Cw 865 create new seed UI for show seed keys page to match onboarding seed verification UI (#1961)

* update wallet keys page UI

* localisation

* hide keys tab for electrum wallets

* Fix padding for tab view

* Fix more padding

* add height box for isLegacySeedOnly

* revert adding tar.gz files [skip ci]

---------

Co-authored-by: tuxpizza <tuxsudo@tux.pizza>
This commit is contained in:
Serhii
2025-01-24 20:08:33 +02:00
committed by GitHub
co-authored by tuxpizza
parent 4fe2be3c92
commit 9673b7c026
34 changed files with 654 additions and 318 deletions
+13 -101
View File
@@ -1,13 +1,13 @@
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/widgets/seedphrase_grid_widget.dart';
import 'package:cake_wallet/src/widgets/warning_box_widget.dart';
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart';
import 'package:cake_wallet/themes/theme_base.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/utils/clipboard_util.dart';
import 'package:cake_wallet/utils/share_util.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
@@ -16,14 +16,9 @@ import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/view_model/wallet_seed_view_model.dart';
import '../../../themes/extensions/send_page_theme.dart';
class WalletSeedPage extends BasePage {
WalletSeedPage(this.walletSeedViewModel, {required this.isNewWalletCreated});
final imageLight = Image.asset('assets/images/crypto_lock_light.png');
final imageDark = Image.asset('assets/images/crypto_lock.png');
@override
String get title => S.current.seed_title;
@@ -68,7 +63,6 @@ class WalletSeedPage extends BasePage {
return WillPopScope(
onWillPop: () async => false,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 14, vertical: 8),
alignment: Alignment.center,
child: ConstrainedBox(
constraints:
@@ -79,46 +73,14 @@ class WalletSeedPage extends BasePage {
Observer(
builder: (_) {
return Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 22, right: 22),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
decoration: BoxDecoration(
color: currentTheme.type == ThemeType.dark
? Color.fromRGBO(132, 110, 64, 1)
: Color.fromRGBO(194, 165, 94, 1),
borderRadius: BorderRadius.all(Radius.circular(12)),
border: Border.all(
color: currentTheme.type == ThemeType.dark
? Color.fromRGBO(177, 147, 41, 1)
: Color.fromRGBO(125, 122, 15, 1),
width: 2.0,
)),
child: Row(
children: [
Icon(
Icons.warning_amber_rounded,
size: 64,
color: Colors.white.withOpacity(0.75),
),
SizedBox(width: 6),
Expanded(
child: Text(
S.current.cake_seeds_save_disclaimer,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w800,
color: currentTheme.type == ThemeType.dark
? Colors.white.withOpacity(0.75)
: Colors.white.withOpacity(0.85),
),
),
),
],
),
),
WarningBox(
content: S.current.cake_seeds_save_disclaimer,
currentTheme: currentTheme),
SizedBox(height: 20),
Text(
key: ValueKey('wallet_seed_page_wallet_name_text_key'),
@@ -131,70 +93,19 @@ class WalletSeedPage extends BasePage {
),
SizedBox(height: 20),
Expanded(
child: GridView.builder(
itemCount: walletSeedViewModel.seedSplit.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: 2.8,
mainAxisSpacing: 8.0,
crossAxisSpacing: 8.0,
),
itemBuilder: (context, index) {
final item = walletSeedViewModel.seedSplit[index];
final numberCount = index + 1;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Theme.of(context).cardColor,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
child: Text(
//maxLines: 1,
numberCount.toString(),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
height: 1,
fontWeight: FontWeight.w800,
color: Theme.of(context)
.extension<CakeTextTheme>()!
.buttonTextColor
.withOpacity(0.5)),
),
),
const SizedBox(width: 6),
Expanded(
child: Text(
'${item[0].toLowerCase()}${item.substring(1)}',
style: TextStyle(
fontSize: 14,
height: 0.8,
fontWeight: FontWeight.w700,
color: Theme.of(context)
.extension<CakeTextTheme>()!
.buttonTextColor),
),
),
],
),
);
},
),
child: SeedPhraseGridWidget(list: walletSeedViewModel.seedSplit),
),
],
),
),
);
},
),
Column(
children: <Widget>[
Row(
Padding(
padding: EdgeInsets.symmetric(horizontal: 14, vertical: 8),
child: Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Flexible(
@@ -233,6 +144,7 @@ class WalletSeedPage extends BasePage {
)
],
),
),
SizedBox(height: 12),
],
)
+282 -85
View File
@@ -1,19 +1,21 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:cake_wallet/entities/qr_view_data.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/list_row.dart';
import 'package:cake_wallet/src/widgets/section_divider.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/widgets/seedphrase_grid_widget.dart';
import 'package:cake_wallet/src/widgets/text_info_box.dart';
import 'package:cake_wallet/src/widgets/warning_box_widget.dart';
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart';
import 'package:cake_wallet/themes/theme_base.dart';
import 'package:cake_wallet/utils/brightness_util.dart';
import 'package:cake_wallet/utils/clipboard_util.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/view_model/wallet_keys_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:cake_wallet/themes/extensions/picker_theme.dart';
class WalletKeysPage extends BasePage {
WalletKeysPage(this.walletKeysViewModel);
@@ -24,95 +26,290 @@ class WalletKeysPage extends BasePage {
final WalletKeysViewModel walletKeysViewModel;
@override
Widget trailing(BuildContext context) => IconButton(
key: ValueKey('wallet_keys_page_fullscreen_qr_button_key'),
onPressed: () async {
final url = await walletKeysViewModel.url;
Widget body(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0),
child: Column(
children: [
Padding(
padding: EdgeInsets.only(left: 14, right: 14, bottom: 8),
child: WarningBox(
key: const ValueKey('wallet_keys_page_share_warning_text_key'),
content: S.of(context).do_not_share_warning_text.toUpperCase(),
currentTheme: currentTheme,
),
),
Expanded(
child: WalletKeysPageBody(
walletKeysViewModel: walletKeysViewModel,
currentTheme: currentTheme,
),
),
],
),
);
}
}
BrightnessUtil.changeBrightnessForFunction(() async {
await Navigator.pushNamed(
context,
Routes.fullscreenQR,
arguments: QrViewData(data: url.toString(), version: QrVersions.auto),
);
});
},
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
hoverColor: Colors.transparent,
icon: Image.asset(
'assets/images/qr_code_icon.png',
),
);
class WalletKeysPageBody extends StatefulWidget {
WalletKeysPageBody({
required this.walletKeysViewModel,
required this.currentTheme,
});
final WalletKeysViewModel walletKeysViewModel;
final ThemeBase currentTheme;
@override
Widget body(BuildContext context) {
State<StatefulWidget> createState() => _WalletKeysPageBodyState();
}
class _WalletKeysPageBodyState extends State<WalletKeysPageBody>
with SingleTickerProviderStateMixin {
late TabController _tabController;
late bool showKeyTab;
late bool showLegacySeedTab;
late bool isLegacySeedOnly;
@override
void initState() {
super.initState();
showKeyTab = widget.walletKeysViewModel.items.isNotEmpty;
showLegacySeedTab = widget.walletKeysViewModel.legacySeedSplit.isNotEmpty;
isLegacySeedOnly = widget.walletKeysViewModel.isLegacySeedOnly;
final totalTabs = 1 + (showKeyTab ? 1 : 0) + (showLegacySeedTab ? 1 : 0);
_tabController = TabController(length: totalTabs, vsync: this);
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0),
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(left: 22, right: 22, top: 0),
child: TabBar(
controller: _tabController,
splashFactory: NoSplash.splashFactory,
indicatorSize: TabBarIndicatorSize.label,
isScrollable: true,
labelStyle: TextStyle(
fontSize: 18,
fontFamily: 'Lato',
fontWeight: FontWeight.w600,
color: Theme.of(context).appBarTheme.titleTextStyle!.color,
),
unselectedLabelStyle: TextStyle(
fontSize: 18,
fontFamily: 'Lato',
fontWeight: FontWeight.w600,
color: Theme.of(context).appBarTheme.titleTextStyle!.color?.withOpacity(0.5),
),
labelColor: Theme.of(context).appBarTheme.titleTextStyle!.color,
indicatorColor: Theme.of(context).appBarTheme.titleTextStyle!.color,
indicatorPadding: EdgeInsets.zero,
labelPadding: const EdgeInsets.only(right: 24),
tabAlignment: TabAlignment.start,
dividerColor: Colors.transparent,
padding: EdgeInsets.zero,
tabs: [
Tab(text: S.of(context).widgets_seed),
if (showKeyTab) Tab(text: S.of(context).keys),
if (showLegacySeedTab) Tab(text: S.of(context).legacy),
],
),
),
const SizedBox(height: 20),
Expanded(
child: TabBarView(
controller: _tabController,
children: [
Padding(
padding: const EdgeInsets.only(left: 22, right: 22,),
child: _buildSeedTab(context, false),
),
if (showKeyTab)
Padding(
padding: const EdgeInsets.only(left: 22, right: 22),
child: _buildKeysTab(context),
),
if (showLegacySeedTab)
Padding(
padding: const EdgeInsets.only(left: 22, right: 22),
child: _buildSeedTab(context, showLegacySeedTab),
),
],
),
),
],
),
);
}
Widget _buildSeedTab(BuildContext context, bool isLegacySeed) {
return Column(
children: [
if (isLegacySeedOnly || isLegacySeed) _buildHeightBox(),
const SizedBox(height: 20),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
color: Theme.of(context).cardColor,
),
child: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: AutoSizeText(
key: ValueKey('wallet_keys_page_share_warning_text_key'),
S.of(context).do_not_share_warning_text.toUpperCase(),
textAlign: TextAlign.center,
maxLines: 4,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.red,
),
),
),
),
),
child: SeedPhraseGridWidget(
list: isLegacySeed
? widget.walletKeysViewModel.legacySeedSplit
: widget.walletKeysViewModel.seedSplit,
),
),
Expanded(
flex: 7,
child: Container(
padding: EdgeInsets.only(top: 20.0, bottom: 20.0),
child: Observer(
builder: (_) {
return ListView.separated(
key: ValueKey('wallet_keys_page_credentials_list_view_key'),
separatorBuilder: (context, index) => Container(
height: 1,
padding: EdgeInsets.only(left: 24),
color: Theme.of(context).extension<PickerTheme>()!.dividerColor,
child: const HorizontalSectionDivider(),
),
itemCount: walletKeysViewModel.items.length,
itemBuilder: (BuildContext context, int index) {
final item = walletKeysViewModel.items[index];
return GestureDetector(
key: item.key,
onTap: () {
ClipboardUtil.setSensitiveDataToClipboard(ClipboardData(text: item.value));
showBar<void>(context, S.of(context).copied_key_to_clipboard(item.title));
},
child: ListRow(
title: item.title + ':',
value: item.value,
),
);
},
);
},
),
),
const SizedBox(height: 10),
_buildBottomActionPanel(
titleForClipboard: S.of(context).wallet_seed.toLowerCase(),
dataToCopy: isLegacySeed
? widget.walletKeysViewModel.legacySeed
: widget.walletKeysViewModel.seed,
onShowQR: () async => _showQR(context, false),
),
],
);
}
Widget _buildKeysTab(BuildContext context) {
return Column(
children: [
Expanded(
child: ListView.separated(
shrinkWrap: true,
itemCount: widget.walletKeysViewModel.items.length,
itemBuilder: (context, index) {
final item = widget.walletKeysViewModel.items[index];
return TextInfoBox(
key: item.key,
title: item.title,
value: item.value,
onCopy: (context) => _onCopy(item.title, item.value, context),
);
},
separatorBuilder: (context, index) => const SizedBox(height: 20),
),
),
SizedBox(height: 20),
],
);
}
Widget _buildHeightBox() {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 14),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Theme.of(context).cardColor,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
S.of(context).block_height,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Theme.of(context).extension<CakeTextTheme>()!.buttonTextColor.withOpacity(0.5),
),
),
const SizedBox(width: 6),
Expanded(
child: FutureBuilder<String?>(
future: widget.walletKeysViewModel.restoreHeight,
builder: (context, snapshot) {
final textToDisplay = snapshot.connectionState == ConnectionState.waiting
? 'Fetching...'
: (snapshot.data ?? '---');
return Text(
textToDisplay,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Theme.of(context).extension<CakeTextTheme>()!.buttonTextColor,
),
);
},
),
),
],
),
);
}
Widget _buildBottomActionPanel({
required String titleForClipboard,
required String dataToCopy,
required VoidCallback onShowQR,
}) {
return Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Flexible(
child: Container(
padding: const EdgeInsets.only(right: 8.0, top: 8.0),
child: PrimaryButton(
key: const ValueKey('wallet_keys_page_copy_seeds_button_key'),
onPressed: () => _onCopy(titleForClipboard, dataToCopy, context),
text: S.of(context).copy,
color: Theme.of(context).cardColor,
textColor: widget.currentTheme.type == ThemeType.dark
? Theme.of(context).extension<DashboardPageTheme>()!.textColor
: Theme.of(context).extension<CakeTextTheme>()!.buttonTextColor,
),
),
),
Flexible(
child: Container(
padding: const EdgeInsets.only(left: 8.0, top: 8.0),
child: PrimaryButton(
key: const ValueKey('wallet_keys_page_show_qr_seeds_button_key'),
onPressed: onShowQR,
text: S.current.show + ' QR',
color: Theme.of(context).primaryColor,
textColor: Colors.white,
),
),
),
],
),
),
const SizedBox(height: 12),
],
);
}
Future<void> _onCopy(String title, String text, BuildContext context) async {
await ClipboardUtil.setSensitiveDataToClipboard(ClipboardData(text: text));
showBar<void>(context, S.of(context).copied_key_to_clipboard(title));
}
Future<void> _showQR(BuildContext context, bool isLegacySeed) async {
final url = await widget.walletKeysViewModel.getUrl(isLegacySeed);
BrightnessUtil.changeBrightnessForFunction(() async {
await Navigator.pushNamed(
context,
Routes.fullscreenQR,
arguments: QrViewData(data: url.toString(), version: QrVersions.auto),
);
});
}
}
@@ -0,0 +1,68 @@
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:flutter/material.dart';
class SeedPhraseGridWidget extends StatelessWidget {
const SeedPhraseGridWidget({
super.key,
required this.list,
});
final List<String> list;
@override
Widget build(BuildContext context) {
return GridView.builder(
itemCount: list.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: 2.8,
mainAxisSpacing: 8.0,
crossAxisSpacing: 8.0,
),
itemBuilder: (context, index) {
final item = list[index];
final numberCount = index + 1;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Theme.of(context).cardColor,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
child: Text(
//maxLines: 1,
numberCount.toString(),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
height: 1,
fontWeight: FontWeight.w800,
color: Theme.of(context)
.extension<CakeTextTheme>()!
.buttonTextColor
.withOpacity(0.5)),
),
),
const SizedBox(width: 6),
Expanded(
child: Text(
'${item[0].toLowerCase()}${item.substring(1)}',
style: TextStyle(
fontSize: 14,
height: 0.8,
fontWeight: FontWeight.w700,
color: Theme.of(context).extension<CakeTextTheme>()!.buttonTextColor),
),
),
],
),
);
},
);
}
}
+51
View File
@@ -0,0 +1,51 @@
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:flutter/material.dart';
class TextInfoBox extends StatelessWidget {
const TextInfoBox({Key? key, required this.title, required this.value, this.onCopy})
: super(key: key);
final String title;
final String value;
final void Function(BuildContext context)? onCopy;
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Theme.of(context).cardColor,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(title,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Theme.of(context)
.extension<CakeTextTheme>()!
.buttonTextColor
.withOpacity(0.5))),
GestureDetector(
onTap: onCopy != null ? () => onCopy!(context) : null,
child: Icon(Icons.copy,
size: 13,
color: Theme.of(context).textTheme.bodyLarge?.color?.withOpacity(0.7))),
],
),
const SizedBox(height: 4),
Text(value,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Theme.of(context).extension<CakeTextTheme>()!.buttonTextColor)),
],
),
);
}
}
+51
View File
@@ -0,0 +1,51 @@
import 'package:cake_wallet/themes/theme_base.dart';
import 'package:flutter/material.dart';
class WarningBox extends StatelessWidget {
const WarningBox({required this.content, required this.currentTheme, Key? key})
: super(key: key);
final String content;
final ThemeBase currentTheme;
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
decoration: BoxDecoration(
color: currentTheme.type == ThemeType.dark
? Color.fromRGBO(132, 110, 64, 1)
: Color.fromRGBO(194, 165, 94, 1),
borderRadius: BorderRadius.all(Radius.circular(12)),
border: Border.all(
color: currentTheme.type == ThemeType.dark
? Color.fromRGBO(177, 147, 41, 1)
: Color.fromRGBO(125, 122, 15, 1),
width: 2.0,
)),
child: Row(
children: [
Icon(
Icons.warning_amber_rounded,
size: 64,
color: Colors.white.withOpacity(0.75),
),
SizedBox(width: 6),
Expanded(
child: Text(
content,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w800,
color: currentTheme.type == ThemeType.dark
? Colors.white.withOpacity(0.75)
: Colors.white.withOpacity(0.85),
),
),
),
],
),
);
}
}