mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-28 06:28:41 +01:00
fix 2fa UI
This commit is contained in:
@@ -4,12 +4,16 @@ import 'package:qr_flutter/qr_flutter.dart' as qr;
|
||||
class QrImage extends StatelessWidget {
|
||||
QrImage({
|
||||
required this.data,
|
||||
this.foregroundColor = Colors.black,
|
||||
this.backgroundColor = Colors.white,
|
||||
this.size = 100.0,
|
||||
this.version,
|
||||
this.errorCorrectionLevel = qr.QrErrorCorrectLevel.L,
|
||||
});
|
||||
|
||||
final double size;
|
||||
final Color foregroundColor;
|
||||
final Color backgroundColor;
|
||||
final String data;
|
||||
final int? version;
|
||||
final int errorCorrectionLevel;
|
||||
@@ -21,8 +25,8 @@ class QrImage extends StatelessWidget {
|
||||
errorCorrectionLevel: errorCorrectionLevel,
|
||||
version: version ?? 9, // Previous value: 7 something happened after flutter upgrade monero wallets addresses are longer than ver. 7 ???
|
||||
size: size,
|
||||
foregroundColor: Colors.black,
|
||||
backgroundColor: Colors.white,
|
||||
foregroundColor: foregroundColor,
|
||||
backgroundColor: backgroundColor,
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,15 +11,17 @@ import 'package:flutter/material.dart';
|
||||
|
||||
class WarningPage extends BasePage {
|
||||
WarningPage(this.seedPhraseLength)
|
||||
: imageLight = Image.asset('assets/images/pre_seed_light.png'),
|
||||
: isPreSeedPage = seedPhraseLength != null,
|
||||
imageLight = Image.asset('assets/images/pre_seed_light.png'),
|
||||
imageDark = Image.asset('assets/images/pre_seed_dark.png');
|
||||
|
||||
final Image imageDark;
|
||||
final Image imageLight;
|
||||
final int? seedPhraseLength;
|
||||
final bool isPreSeedPage;
|
||||
|
||||
@override
|
||||
Widget? leading(BuildContext context) => null;
|
||||
Widget? leading(BuildContext context) => isPreSeedPage ? null : super.leading(context);
|
||||
|
||||
@override
|
||||
String? get title => S.current.pre_seed_title;
|
||||
@@ -28,37 +30,43 @@ class WarningPage extends BasePage {
|
||||
Widget body(BuildContext context) {
|
||||
final image = currentTheme.type == ThemeType.dark ? imageDark : imageLight;
|
||||
|
||||
final text =
|
||||
"Cake 2FA is a second authentication for certain actions in the wallet. It is NOT as secure as cold storage. If you lose access to your 2FA app or passkeys, you WILL lose access to this wallet. You will need to restore your wallet from the mnemonic seed. Cake support will be unable to assist you if you lose access to your 2FA or mnemonic seeds. Before using Cake 2FA, we recommend reading through the guide here.";
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
padding: EdgeInsets.all(24),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: ResponsiveLayoutUtilBase.kDesktopMaxWidthConstraint),
|
||||
constraints:
|
||||
BoxConstraints(maxWidth: ResponsiveLayoutUtilBase.kDesktopMaxWidthConstraint),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.of(context).size.height * 0.3
|
||||
),
|
||||
constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height * 0.3),
|
||||
child: AspectRatio(aspectRatio: 1, child: image),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Text(
|
||||
S.of(context).pre_seed_description(seedPhraseLength.toString()),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.secondaryTextColor),
|
||||
),
|
||||
isPreSeedPage
|
||||
? S.of(context).pre_seed_description(seedPhraseLength.toString())
|
||||
: text,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: isPreSeedPage
|
||||
? Theme.of(context).extension<CakeTextTheme>()!.secondaryTextColor
|
||||
: Theme.of(context).extension<CakeTextTheme>()!.titleColor)),
|
||||
),
|
||||
PrimaryButton(
|
||||
onPressed: () =>
|
||||
Navigator.of(context).popAndPushNamed(Routes.seed, arguments: true),
|
||||
text: S.of(context).pre_seed_button_text,
|
||||
onPressed: () => isPreSeedPage
|
||||
? Navigator.of(context).popAndPushNamed(Routes.seed, arguments: true)
|
||||
: Navigator.of(context).popAndPushNamed(Routes.setup_2faPage),
|
||||
text: isPreSeedPage ? S.of(context).pre_seed_button_text : 'Neeeeeeee',
|
||||
color: Theme.of(context).primaryColor,
|
||||
textColor: Colors.white)
|
||||
],
|
||||
|
||||
@@ -108,7 +108,7 @@ class SecurityBackupPage extends BasePage {
|
||||
context,
|
||||
route: _securitySettingsViewModel.useTotp2FA
|
||||
? Routes.modify2FAPage
|
||||
: Routes.setup_2faPage,
|
||||
: Routes.warningPage,
|
||||
conditionToDetermineIfToUse2FA: _securitySettingsViewModel
|
||||
.shouldRequireTOTP2FAForAllSecurityAndBackupSettings,
|
||||
),
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/screens/settings/widgets/settings_cell_with_arrow.dart';
|
||||
import 'package:cake_wallet/src/widgets/standard_list.dart';
|
||||
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
|
||||
import 'package:cake_wallet/view_model/set_up_2fa_viewmodel.dart';
|
||||
|
||||
import '../../widgets/standard_list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class Setup2FAPage extends BasePage {
|
||||
Setup2FAPage({required this.setup2FAViewModel});
|
||||
@@ -21,36 +20,27 @@ class Setup2FAPage extends BasePage {
|
||||
Widget body(BuildContext context) {
|
||||
final cake2FAGuideTitle = 'Cake 2FA Guide';
|
||||
final cake2FAGuideUri =
|
||||
Uri.parse('https://guides.cakewallet.com/docs/advanced-features/authentication');
|
||||
Uri.parse('https://guides.cakewallet.com/docs/advanced-features/authentication');
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height * 0.3),
|
||||
child:
|
||||
AspectRatio(aspectRatio: 1, child: Image.asset('assets/images/setup_2fa_img.png')),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
S.current.important_note,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14,
|
||||
height: 1.571,
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
S.current.setup_2fa_text,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14,
|
||||
height: 1.571,
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: Text(
|
||||
S.current.setup_2fa_text,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14,
|
||||
height: 1.571,
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 56),
|
||||
@@ -63,12 +53,16 @@ class Setup2FAPage extends BasePage {
|
||||
),
|
||||
StandardListSeparator(padding: EdgeInsets.symmetric(horizontal: 24)),
|
||||
SettingsCellWithArrow(
|
||||
title: cake2FAGuideTitle,
|
||||
handler: (_) => Navigator.of(context)
|
||||
.pushNamed(Routes.webViewPage, arguments: [cake2FAGuideTitle, cake2FAGuideUri])),
|
||||
title: cake2FAGuideTitle, handler: (_) => _launchUrl(cake2FAGuideUri)),
|
||||
StandardListSeparator(padding: EdgeInsets.symmetric(horizontal: 24)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static void _launchUrl(Uri url) async {
|
||||
try {
|
||||
await launchUrl(url);
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/src/widgets/standard_list.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/routes.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/utils/clipboard_util.dart';
|
||||
import 'package:cake_wallet/utils/show_bar.dart';
|
||||
@@ -13,6 +13,7 @@ import 'package:cake_wallet/view_model/set_up_2fa_viewmodel.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart' as qr;
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class Setup2FAQRPage extends BasePage {
|
||||
Setup2FAQRPage({required this.setup2FAViewModel});
|
||||
@@ -24,12 +25,8 @@ class Setup2FAQRPage extends BasePage {
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
final copyImage = Image.asset(
|
||||
'assets/images/copy_content.png',
|
||||
height: 12,
|
||||
width: 12,
|
||||
color: Color(0xFF355688),
|
||||
);
|
||||
final copyImage = Image.asset('assets/images/copy_content.png',
|
||||
height: 16, width: 16, color: Theme.of(context).extension<CakeTextTheme>()!.titleColor);
|
||||
final cake2FAHowToUseTitle = 'How to use';
|
||||
final cake2FAHowToUseUrl = Uri.parse(
|
||||
'https://guides.cakewallet.com/docs/advanced-features/authentication/#enabling-cake-2fa');
|
||||
@@ -37,41 +34,49 @@ class Setup2FAQRPage extends BasePage {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 58),
|
||||
Spacer(),
|
||||
Text(
|
||||
S.current.add_secret_code,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
height: 1.5714,
|
||||
color: Palette.darkBlueCraiola,
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
AspectRatio(
|
||||
aspectRatio: 1.0,
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 3,
|
||||
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor,
|
||||
),
|
||||
),
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height * 0.4),
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1.0,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 3,
|
||||
color: Colors.white,
|
||||
),
|
||||
padding: EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 3,
|
||||
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor,
|
||||
),
|
||||
child: QrImage(
|
||||
data: setup2FAViewModel.totpVersionOneLink,
|
||||
version: qr.QrVersions.auto,
|
||||
)),
|
||||
),
|
||||
child: Container(
|
||||
child: QrImage(
|
||||
data: setup2FAViewModel.totpVersionOneLink,
|
||||
version: qr.QrVersions.auto,
|
||||
foregroundColor: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
|
||||
backgroundColor: Colors.transparent,
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 26),
|
||||
Text(
|
||||
S.current.add_secret_code,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
height: 1.5714,
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 13),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
@@ -86,7 +91,7 @@ class Setup2FAQRPage extends BasePage {
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Palette.darkGray,
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.secondaryTextColor,
|
||||
height: 1.8333,
|
||||
),
|
||||
),
|
||||
@@ -94,10 +99,8 @@ class Setup2FAQRPage extends BasePage {
|
||||
Text(
|
||||
'${setup2FAViewModel.totpSecretKey}',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
height: 1.375,
|
||||
),
|
||||
fontSize: 18,
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
@@ -115,10 +118,6 @@ class Setup2FAQRPage extends BasePage {
|
||||
showBar<void>(context, S.of(context).copied_to_clipboard);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
color: Color(0xFFF2F0FA),
|
||||
),
|
||||
child: copyImage,
|
||||
),
|
||||
),
|
||||
@@ -142,7 +141,7 @@ class Setup2FAQRPage extends BasePage {
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Palette.darkGray,
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.secondaryTextColor,
|
||||
height: 1.8333,
|
||||
),
|
||||
),
|
||||
@@ -150,10 +149,8 @@ class Setup2FAQRPage extends BasePage {
|
||||
Text(
|
||||
'${setup2FAViewModel.totpVersionOneLink}',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
height: 1.375,
|
||||
),
|
||||
fontSize: 18,
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
@@ -171,10 +168,6 @@ class Setup2FAQRPage extends BasePage {
|
||||
showBar<void>(context, S.of(context).copied_to_clipboard);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
color: Color(0xFFF2F0FA),
|
||||
),
|
||||
child: copyImage,
|
||||
),
|
||||
),
|
||||
@@ -185,22 +178,22 @@ class Setup2FAQRPage extends BasePage {
|
||||
StandardListSeparator(),
|
||||
SizedBox(height: 16),
|
||||
GestureDetector(
|
||||
onTap: () => Navigator.of(context).pushNamed(Routes.webViewPage,
|
||||
arguments: [cake2FAHowToUseTitle, cake2FAHowToUseUrl]),
|
||||
onTap: () => _launchUrl(cake2FAHowToUseUrl),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(cake2FAHowToUseTitle,
|
||||
style: TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
)),
|
||||
Icon(Icons.info_outline,size: 20)
|
||||
decoration: TextDecoration.underline,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor)),
|
||||
Icon(Icons.info_outline,
|
||||
size: 20, color: Theme.of(context).extension<CakeTextTheme>()!.titleColor)
|
||||
],
|
||||
)),
|
||||
Spacer(),
|
||||
Spacer(flex: 5),
|
||||
PrimaryButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushReplacementNamed(Routes.totpAuthCodePage,
|
||||
@@ -217,4 +210,10 @@ class Setup2FAQRPage extends BasePage {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static void _launchUrl(Uri url) async {
|
||||
try {
|
||||
await launchUrl(url);
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user