diff --git a/lib/main.dart b/lib/main.dart index 82d75c5d8..6a1cb0ee8 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -57,6 +57,7 @@ import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/util.dart'; import 'package:window_size/window_size.dart'; final openedFromSWBFileStringStateProvider = @@ -68,7 +69,7 @@ final openedFromSWBFileStringStateProvider = void main() async { WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized(); - if (Platform.isLinux || Platform.isWindows || Platform.isMacOS) { + if (Util.isDesktop) { setWindowTitle('Stack Wallet'); setWindowMinSize(const Size(1200, 900)); setWindowMaxSize(Size.infinite); @@ -605,7 +606,7 @@ class _MaterialAppWithThemeState extends ConsumerState } // TODO proper desktop auth view - if (Platform.isMacOS || Platform.isWindows || Platform.isLinux) { + if (Util.isDesktop) { Future.delayed(Duration.zero).then((value) => Navigator.of(context).pushNamedAndRemoveUntil( DesktopHomeView.routeName, (route) => false)); diff --git a/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/coin_select_item.dart b/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/coin_select_item.dart index 5ff80bbc8..4490984be 100644 --- a/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/coin_select_item.dart +++ b/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/coin_select_item.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; @@ -9,6 +7,7 @@ import 'package:stackwallet/utilities/cfcolors.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/util.dart'; class CoinSelectItem extends ConsumerWidget { const CoinSelectItem({ @@ -23,8 +22,7 @@ class CoinSelectItem extends ConsumerWidget { debugPrint("BUILD: CoinSelectItem for ${coin.name}"); final selectedCoin = ref.watch(addWalletSelectedCoinStateProvider); - final isDesktop = - Platform.isLinux || Platform.isMacOS || Platform.isWindows; + final isDesktop = Util.isDesktop; return Container( decoration: BoxDecoration( diff --git a/lib/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart b/lib/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart index 3d9b7c630..c6e326ec1 100644 --- a/lib/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart +++ b/lib/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -17,6 +16,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/flush_bar_type.dart'; import 'package:stackwallet/utilities/name_generator.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'; @@ -67,7 +67,7 @@ class _NameYourWalletViewState extends ConsumerState { @override void initState() { - isDesktop = Platform.isLinux || Platform.isWindows || Platform.isMacOS; + isDesktop = Util.isDesktop; ref.read(walletsServiceChangeNotifierProvider).walletNames.then( (value) => namesToExclude.addAll( diff --git a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart index 9bef5ce22..7e3a6de7d 100644 --- a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart +++ b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:io'; import 'dart:math'; import 'package:flutter/material.dart'; @@ -20,6 +19,7 @@ import 'package:stackwallet/utilities/clipboard_interface.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/flush_bar_type.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'; @@ -59,7 +59,7 @@ class _NewWalletRecoveryPhraseViewState _manager = widget.manager; _mnemonic = widget.mnemonic; _clipboardInterface = widget.clipboardInterface; - isDesktop = Platform.isMacOS || Platform.isWindows || Platform.isLinux; + isDesktop = Util.isDesktop; super.initState(); } diff --git a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart index 9ef134adf..bf3d95fcb 100644 --- a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart +++ b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -15,6 +14,7 @@ import 'package:stackwallet/utilities/default_nodes.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/logger.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'; @@ -49,7 +49,7 @@ class _NewWalletRecoveryPhraseWarningViewState void initState() { coin = widget.coin; walletName = widget.walletName; - isDesktop = Platform.isMacOS || Platform.isWindows || Platform.isLinux; + isDesktop = Util.isDesktop; super.initState(); } diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view.dart index 69234f9eb..0016efa05 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_rounded_date_picker/flutter_rounded_date_picker.dart'; @@ -14,6 +12,7 @@ import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/format.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'; @@ -51,7 +50,7 @@ class _RestoreOptionsViewState extends ConsumerState { void initState() { walletName = widget.walletName; coin = widget.coin; - isDesktop = Platform.isMacOS || Platform.isWindows || Platform.isLinux; + isDesktop = Util.isDesktop; _dateController = TextEditingController(); textFieldFocusNode = FocusNode(); diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart index d8067668b..7df9a410c 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart @@ -34,6 +34,7 @@ import 'package:stackwallet/utilities/enums/flush_bar_type.dart'; import 'package:stackwallet/utilities/enums/form_input_status_enum.dart'; import 'package:stackwallet/utilities/logger.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/icon_widgets/clipboard_icon.dart'; import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; @@ -117,7 +118,7 @@ class _RestoreWalletViewState extends ConsumerState { @override void initState() { _seedWordCount = widget.seedWordsLength; - isDesktop = Platform.isMacOS || Platform.isWindows || Platform.isLinux; + isDesktop = Util.isDesktop; textSelectionControls = Platform.isIOS ? CustomCupertinoTextSelectionControls(onPaste: onControlsPaste) @@ -199,7 +200,7 @@ class _RestoreWalletViewState extends ConsumerState { context: context, )); } else { - if (!Platform.isLinux) Wakelock.enable(); + if (!Platform.isLinux) await Wakelock.enable(); final walletsService = ref.read(walletsServiceChangeNotifierProvider); final walletId = await walletsService.addNewWallet( diff --git a/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart b/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart index 0aaf3e0f9..b8bba1000 100644 --- a/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart +++ b/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:io'; import 'dart:math'; import 'package:flutter/material.dart'; @@ -17,6 +16,7 @@ import 'package:stackwallet/utilities/cfcolors.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/flush_bar_type.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'; @@ -51,7 +51,7 @@ class _VerifyRecoveryPhraseViewState void initState() { _manager = widget.manager; _mnemonic = widget.mnemonic; - isDesktop = Platform.isLinux || Platform.isWindows || Platform.isMacOS; + isDesktop = Util.isDesktop; // WidgetsBinding.instance?.addObserver(this); super.initState(); } diff --git a/lib/pages/intro_view.dart b/lib/pages/intro_view.dart index 88418b3be..c20a9ef8a 100644 --- a/lib/pages/intro_view.dart +++ b/lib/pages/intro_view.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; @@ -8,6 +6,7 @@ import 'package:stackwallet/pages_desktop_specific/create_password/create_passwo import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/cfcolors.dart'; import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/util.dart'; import 'package:url_launcher/url_launcher.dart'; class IntroView extends StatefulWidget { @@ -22,7 +21,7 @@ class _IntroViewState extends State { @override void initState() { - isDesktop = Platform.isMacOS || Platform.isWindows || Platform.isLinux; + isDesktop = Util.isDesktop; super.initState(); } diff --git a/lib/pages/wallets_view/sub_widgets/empty_wallets.dart b/lib/pages/wallets_view/sub_widgets/empty_wallets.dart index e608b7575..38ae3f914 100644 --- a/lib/pages/wallets_view/sub_widgets/empty_wallets.dart +++ b/lib/pages/wallets_view/sub_widgets/empty_wallets.dart @@ -1,11 +1,10 @@ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/cfcolors.dart'; import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/util.dart'; class EmptyWallets extends StatelessWidget { const EmptyWallets({Key? key}) : super(key: key); @@ -14,8 +13,7 @@ class EmptyWallets extends StatelessWidget { Widget build(BuildContext context) { debugPrint("BUILD: $runtimeType"); - final isDesktop = - Platform.isMacOS || Platform.isWindows || Platform.isLinux; + final isDesktop = Util.isDesktop; return SafeArea( child: Padding( diff --git a/lib/widgets/custom_buttons/app_bar_icon_button.dart b/lib/widgets/custom_buttons/app_bar_icon_button.dart index 021e54b9c..52e0731dd 100644 --- a/lib/widgets/custom_buttons/app_bar_icon_button.dart +++ b/lib/widgets/custom_buttons/app_bar_icon_button.dart @@ -1,9 +1,8 @@ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/cfcolors.dart'; +import 'package:stackwallet/utilities/util.dart'; class AppBarIconButton extends StatelessWidget { const AppBarIconButton({ @@ -54,8 +53,7 @@ class AppBarBackButton extends StatelessWidget { @override Widget build(BuildContext context) { - final isDesktop = - Platform.isMacOS || Platform.isWindows || Platform.isLinux; + final isDesktop = Util.isDesktop; return Padding( padding: isDesktop ? const EdgeInsets.symmetric( diff --git a/lib/widgets/stack_text_field.dart b/lib/widgets/stack_text_field.dart index bddc21a2f..46c59de3a 100644 --- a/lib/widgets/stack_text_field.dart +++ b/lib/widgets/stack_text_field.dart @@ -1,12 +1,11 @@ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:stackwallet/utilities/cfcolors.dart'; import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/util.dart'; InputDecoration standardInputDecoration( String? labelText, FocusNode textFieldFocusNode) { - final isDesktop = Platform.isWindows || Platform.isMacOS || Platform.isLinux; + final isDesktop = Util.isDesktop; return InputDecoration( labelText: labelText,