diff --git a/lib/pages/intro_view.dart b/lib/pages/intro_view.dart index 1c78efb77..3552cc0a1 100644 --- a/lib/pages/intro_view.dart +++ b/lib/pages/intro_view.dart @@ -16,6 +16,8 @@ import 'package:stackwallet/hive/db.dart'; class IntroView extends StatefulWidget { const IntroView({Key? key}) : super(key: key); + static const String routeName = "/introView"; + @override State createState() => _IntroViewState(); } diff --git a/lib/pages/settings_views/global_settings_view/delete_account_view.dart b/lib/pages/settings_views/global_settings_view/delete_account_view.dart new file mode 100644 index 000000000..5fdabf6ad --- /dev/null +++ b/lib/pages/settings_views/global_settings_view/delete_account_view.dart @@ -0,0 +1,75 @@ +import 'package:flutter/material.dart'; +import 'package:stackwallet/pages/intro_view.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; +import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; +import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; +import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import 'package:stackwallet/widgets/rounded_white_container.dart'; + +class DeleteAccountView extends StatefulWidget { + const DeleteAccountView({Key? key}) : super(key: key); + + static const String routeName = "/deleteAccountView"; + + @override + State createState() => _DeleteAccountViewState(); +} + +class _DeleteAccountViewState extends State { + final isDesktop = Util.isDesktop; + + Future onConfirmDeleteAccount() async { + // TODO delete everything then pop to intro view + await Navigator.of(context).pushNamedAndRemoveUntil( + IntroView.routeName, + (route) => false, + ); + } + + @override + Widget build(BuildContext context) { + return MasterScaffold( + isDesktop: isDesktop, + appBar: isDesktop + ? DesktopAppBar(isCompactHeight: true) + : AppBar( + leading: AppBarBackButton( + onPressed: () async { + if (FocusScope.of(context).hasFocus) { + FocusScope.of(context).unfocus(); + await Future.delayed( + const Duration(milliseconds: 75)); + } + if (mounted) { + Navigator.of(context).pop(); + } + }, + ), + title: Text( + "Delete account", + style: STextStyles.navBarTitle(context), + ), + ), + body: Padding( + padding: const EdgeInsets.all(14), + child: Column( + children: [ + RoundedWhiteContainer( + child: Text( + "There is no account to delete, but Apple requires that we have a way to 'delete accounts' in the app and will reject our app updates if we don't, so here it is. Clicking this will delete all app data (not from our servers, because we never had it in the first place).\n\nWhen you click confirm, all app data will be deleted, including wallets and preferences, and you will be taken back to the very first onboarding screen. BE SURE TO BACKUP ALL SEEDS!!\n\nAre you sure you want to delete your \"account\"?", + style: STextStyles.smallMed12(context), + ), + ), + const Spacer(), + PrimaryButton( + label: "Confirm", + onPressed: onConfirmDeleteAccount, + ) + ], + ), + ), + ); + } +} diff --git a/lib/pages/settings_views/global_settings_view/global_settings_view.dart b/lib/pages/settings_views/global_settings_view/global_settings_view.dart index 1b334cf18..85e71f44f 100644 --- a/lib/pages/settings_views/global_settings_view/global_settings_view.dart +++ b/lib/pages/settings_views/global_settings_view/global_settings_view.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:stackwallet/pages/address_book_views/address_book_view.dart'; import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart'; @@ -5,6 +7,7 @@ import 'package:stackwallet/pages/settings_views/global_settings_view/about_view import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/advanced_settings_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/currency_view.dart'; +import 'package:stackwallet/pages/settings_views/global_settings_view/delete_account_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/language_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/security_views/security_view.dart'; @@ -224,6 +227,20 @@ class GlobalSettingsView extends StatelessWidget { .pushNamed(SupportView.routeName); }, ), + if (Platform.isIOS) + const SizedBox( + height: 8, + ), + if (Platform.isIOS) + SettingsListButton( + iconAssetName: Assets.svg.circleAlert, + iconSize: 16, + title: "Delete account", + onPressed: () async { + await Navigator.of(context) + .pushNamed(DeleteAccountView.routeName); + }, + ), // TextButton( // style: Theme.of(context) // .textButtonTheme diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 8db03e8d0..5764e22a0 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -33,6 +33,7 @@ import 'package:stackwallet/pages/exchange_view/send_from_view.dart'; import 'package:stackwallet/pages/exchange_view/trade_details_view.dart'; import 'package:stackwallet/pages/exchange_view/wallet_initiated_exchange_view.dart'; import 'package:stackwallet/pages/home_view/home_view.dart'; +import 'package:stackwallet/pages/intro_view.dart'; import 'package:stackwallet/pages/manage_favorites_view/manage_favorites_view.dart'; import 'package:stackwallet/pages/notification_views/notifications_view.dart'; import 'package:stackwallet/pages/pinpad_views/create_pin_view.dart'; @@ -43,6 +44,7 @@ import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_v import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/debug_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/currency_view.dart'; +import 'package:stackwallet/pages/settings_views/global_settings_view/delete_account_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/global_settings_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/hidden_settings.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/language_view.dart'; @@ -98,6 +100,18 @@ class RouteGenerator { final args = settings.arguments; switch (settings.name) { + case IntroView.routeName: + return getRoute( + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const IntroView(), + settings: RouteSettings(name: settings.name)); + + case DeleteAccountView.routeName: + return getRoute( + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const DeleteAccountView(), + settings: RouteSettings(name: settings.name)); + case HomeView.routeName: return getRoute( shouldUseMaterialRoute: useMaterialPageRoute,