Skip to content

Commit

Permalink
Merge pull request #1600 from get10101/chore/move-backup-button-to-se…
Browse files Browse the repository at this point in the history
…ttings

chore: Move backup button to settings
  • Loading branch information
holzeis authored Nov 18, 2023
2 parents dc95115 + 516c02f commit 4d4a9a3
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 197 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Move backup button to settings

## [1.5.1] - 2023-11-16

- Add on-boarding wizard
Expand Down
18 changes: 9 additions & 9 deletions mobile/lib/common/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import 'package:get_10101/features/wallet/onboarding/onboarding_screen.dart';
import 'package:get_10101/features/wallet/receive_screen.dart';
import 'package:get_10101/features/wallet/scanner_screen.dart';
import 'package:get_10101/features/welcome/seed_import_screen.dart';
import 'package:get_10101/features/wallet/seed_screen.dart';
import 'package:get_10101/common/settings/seed_screen.dart';
import 'package:get_10101/features/wallet/send/send_screen.dart';
import 'package:get_10101/features/wallet/wallet_screen.dart';
import 'package:get_10101/features/welcome/welcome_screen.dart';
Expand Down Expand Up @@ -92,6 +92,14 @@ GoRouter createRoutes() {
return const ShareLogsScreen();
},
),
GoRoute(
path: SeedScreen.subRouteName,
// Use root navigator so the screen overlays the application shell
parentNavigatorKey: rootNavigatorKey,
builder: (BuildContext context, GoRouterState state) {
return const SeedScreen();
},
),
GoRoute(
path: ChannelScreen.subRouteName,
// Use root navigator so the screen overlays the application shell
Expand Down Expand Up @@ -150,14 +158,6 @@ GoRouter createRoutes() {
return const SendScreen();
},
),
GoRoute(
path: SeedScreen.subRouteName,
// Use root navigator so the screen overlays the application shell
parentNavigatorKey: rootNavigatorKey,
builder: (BuildContext context, GoRouterState state) {
return const SeedScreen();
},
),
GoRoute(
path: OnboardingScreen.subRouteName,
parentNavigatorKey: rootNavigatorKey,
Expand Down
134 changes: 134 additions & 0 deletions mobile/lib/common/settings/seed_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import 'package:flutter/material.dart';
import 'package:get_10101/common/settings/seed_words.dart';
import 'package:get_10101/common/settings/settings_screen.dart';
import 'package:go_router/go_router.dart';
import 'package:get_10101/ffi.dart';

class SeedScreen extends StatefulWidget {
static const route = "${SettingsScreen.route}/$subRouteName";
static const subRouteName = "seed";

const SeedScreen({super.key});

@override
State<SeedScreen> createState() => _SeedScreenState();
}

class _SeedScreenState extends State<SeedScreen> {
bool checked = false;
bool visibility = false;

List<String>? phrase;

@override
void initState() {
phrase = api.getSeedPhrase();
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Padding(
padding: const EdgeInsets.only(top: 20, left: 10, right: 10),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Stack(
children: [
GestureDetector(
child: Container(
alignment: AlignmentDirectional.topStart,
decoration: BoxDecoration(
color: Colors.transparent, borderRadius: BorderRadius.circular(10)),
width: 70,
child: const Icon(
Icons.arrow_back_ios_new_rounded,
size: 22,
)),
onTap: () {
GoRouter.of(context).pop();
},
),
const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Backup",
style: TextStyle(fontWeight: FontWeight.w500, fontSize: 20),
),
],
),
],
),
),
],
),
const SizedBox(
height: 20,
),
Container(
margin: const EdgeInsets.all(10),
child: Center(
child: RichText(
text: const TextSpan(
style: TextStyle(color: Colors.black, fontSize: 18),
children: [
TextSpan(
text:
"The recovery phrase (sometimes called a seed), is a list of 12 English words. It allows you to recover full access to your funds if needed\n\n"),
TextSpan(
text: "Do not share this seed with anyone. ",
style: TextStyle(fontWeight: FontWeight.bold)),
TextSpan(
text:
"Beware of phising. The developers of 10101 will never ask for your seed.\n\n"),
TextSpan(
text: "Do not lose this seed. ",
style: TextStyle(fontWeight: FontWeight.bold)),
TextSpan(
text:
"Save it somewhere safe (not on this phone). If you lose your seed and your phone, you've lost your funds."),
])),
),
),
const SizedBox(height: 10),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
buildSeedWordsWidget(phrase!, visibility),
const SizedBox(height: 10),
Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
IconButton(
icon: visibility
? const Icon(Icons.visibility)
: const Icon(Icons.visibility_off),
onPressed: () {
setState(() {
visibility = !visibility;
});
},
tooltip: visibility ? 'Hide Seed' : 'Show Seed'),
Text(visibility ? 'Hide Seed' : 'Show Seed')
],
),
),
],
),
),
],
),
)),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Row buildSeedWordsWidget(List<String> phrase, bool visible) {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Column(crossAxisAlignment: CrossAxisAlignment.start, children: firstColumn),
const SizedBox(width: 10),
const SizedBox(width: 30),
Column(crossAxisAlignment: CrossAxisAlignment.start, children: secondColumn)
],
);
Expand All @@ -37,7 +37,7 @@ class SeedWord extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.fromLTRB(0, 10, 0, 0),
padding: const EdgeInsets.fromLTRB(0, 5, 0, 5),
child: Row(
crossAxisAlignment: visibility ? CrossAxisAlignment.baseline : CrossAxisAlignment.end,
textBaseline: TextBaseline.alphabetic,
Expand All @@ -46,17 +46,19 @@ class SeedWord extends StatelessWidget {
width: 25.0,
child: Text(
'#$index',
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
style: TextStyle(fontSize: 14, color: Colors.grey[600]),
),
),
const SizedBox(width: 5),
visibility
? Text(
word!,
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
? SizedBox(
width: 100,
child: Text(
word!,
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
)
: Container(
color: Colors.grey[300], child: const SizedBox(width: 100, height: 24))
: Container(width: 100, height: 24, color: Colors.grey[300]),
]));
}
}
5 changes: 5 additions & 0 deletions mobile/lib/common/settings/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:get_10101/common/settings/force_close_screen.dart';
import 'package:get_10101/common/settings/share_logs_screen.dart';
import 'package:get_10101/common/snack_bar.dart';
import 'package:get_10101/common/status_screen.dart';
import 'package:get_10101/common/settings/seed_screen.dart';

import 'package:get_10101/util/custom_icon_icons.dart';
import 'package:go_router/go_router.dart';
Expand Down Expand Up @@ -116,6 +117,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
title: "Channel",
isAlarm: channelStatusNotifier.isClosing(),
callBackFunc: () => GoRouter.of(context).push(ChannelScreen.route)),
SettingsClickable(
icon: Icons.backup_outlined,
title: "Backup",
callBackFunc: () => GoRouter.of(context).push(SeedScreen.route))
],
),
)
Expand Down
122 changes: 0 additions & 122 deletions mobile/lib/features/wallet/seed_screen.dart

This file was deleted.

Loading

0 comments on commit 4d4a9a3

Please sign in to comment.