From 7155646f57de48ec9a3462385ef66674e1bcdd42 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 20 Sep 2023 14:52:27 -0600 Subject: [PATCH] desktop tor one time dialog added and hidden dev settings enabled for desktop --- .../global_settings_view/hidden_settings.dart | 26 ++++++- .../my_stack_view/my_stack_view.dart | 74 ++++++++++++++++--- .../tor_has_been_add_dialog.dart | 5 +- 3 files changed, 92 insertions(+), 13 deletions(-) diff --git a/lib/pages/settings_views/global_settings_view/hidden_settings.dart b/lib/pages/settings_views/global_settings_view/hidden_settings.dart index 357c2625b..924524de7 100644 --- a/lib/pages/settings_views/global_settings_view/hidden_settings.dart +++ b/lib/pages/settings_views/global_settings_view/hidden_settings.dart @@ -12,15 +12,19 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_svg/flutter_svg.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:stackwallet/db/hive/db.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/providers/global/debug_service_provider.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/themes/stack_colors.dart'; +import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/background.dart'; +import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/onetime_popups/tor_has_been_add_dialog.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; @@ -35,7 +39,27 @@ class HiddenSettings extends StatelessWidget { child: Scaffold( backgroundColor: Theme.of(context).extension()!.background, appBar: AppBar( - leading: Container(), + leading: Util.isDesktop + ? Padding( + padding: const EdgeInsets.all(8.0), + child: AppBarIconButton( + size: 32, + color: Theme.of(context) + .extension()! + .textFieldDefaultBG, + shadows: const [], + icon: SvgPicture.asset( + Assets.svg.arrowLeft, + width: 18, + height: 18, + color: Theme.of(context) + .extension()! + .topNavIconPrimary, + ), + onPressed: Navigator.of(context).pop, + ), + ) + : Container(), title: Text( "Dev options", style: STextStyles.navBarTitle(context), diff --git a/lib/pages_desktop_specific/my_stack_view/my_stack_view.dart b/lib/pages_desktop_specific/my_stack_view/my_stack_view.dart index 819ec2a90..f510b8289 100644 --- a/lib/pages_desktop_specific/my_stack_view/my_stack_view.dart +++ b/lib/pages_desktop_specific/my_stack_view/my_stack_view.dart @@ -13,11 +13,13 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:stackwallet/pages/settings_views/global_settings_view/hidden_settings.dart'; import 'package:stackwallet/pages/wallets_view/sub_widgets/empty_wallets.dart'; import 'package:stackwallet/pages_desktop_specific/my_stack_view/my_wallets.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart'; import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; @@ -52,27 +54,77 @@ class _MyStackViewState extends ConsumerState { } } -class DesktopMyStackTitle extends ConsumerWidget { - const DesktopMyStackTitle({Key? key}) : super(key: key); +class DesktopMyStackTitle extends ConsumerStatefulWidget { + const DesktopMyStackTitle({super.key}); @override - Widget build(BuildContext context, WidgetRef ref) { + ConsumerState createState() => + _DesktopMyStackTitleState(); +} + +class _DesktopMyStackTitleState extends ConsumerState { + late final RotateIconController _rotateIconController; + + DateTime _hiddenTime = DateTime.now(); + int _hiddenCount = 0; + + void _hiddenOptions() { + _rotateIconController.reset?.call(); + _rotateIconController.forward?.call(); + if (_hiddenCount == 5) { + Navigator.of(context).pushNamed(HiddenSettings.routeName); + } + final now = DateTime.now(); + const timeout = Duration(seconds: 1); + if (now.difference(_hiddenTime) < timeout) { + _hiddenCount++; + } else { + _hiddenCount = 0; + } + _hiddenTime = now; + } + + @override + void initState() { + _rotateIconController = RotateIconController(); + + super.initState(); + } + + @override + dispose() { + _rotateIconController.forward = null; + _rotateIconController.reverse = null; + _rotateIconController.reset = null; + super.dispose(); + } + + @override + Widget build(BuildContext context) { return Row( children: [ const SizedBox( width: 24, ), - SizedBox( - width: 32, - height: 32, - child: SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, + GestureDetector( + onTap: _hiddenOptions, + child: RotateIcon( + icon: SizedBox( + width: 32, + height: 32, + child: SvgPicture.file( + File( + ref.watch( + themeProvider.select( + (value) => value.assets.stackIcon, + ), + ), ), ), ), + curve: Curves.easeInOutCubic, + rotationPercent: 1.0, + controller: _rotateIconController, ), ), const SizedBox( diff --git a/lib/widgets/onetime_popups/tor_has_been_add_dialog.dart b/lib/widgets/onetime_popups/tor_has_been_add_dialog.dart index f96ff098e..8f316c012 100644 --- a/lib/widgets/onetime_popups/tor_has_been_add_dialog.dart +++ b/lib/widgets/onetime_popups/tor_has_been_add_dialog.dart @@ -75,7 +75,10 @@ class _TorHasBeenAddedDialogState extends State<_TorHasBeenAddedDialog> { ), ), DesktopDialogCloseButton( - onPressedOverride: setDoNotShowAgain, + onPressedOverride: () { + setDoNotShowAgain(); + Navigator.of(context).pop(); + }, ), ], ),