standardize isDesktop check

This commit is contained in:
julian 2022-09-19 14:18:31 -06:00
parent 6af788a25e
commit b0c179666c
12 changed files with 26 additions and 33 deletions

View file

@ -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<MaterialAppWithTheme>
}
// TODO proper desktop auth view
if (Platform.isMacOS || Platform.isWindows || Platform.isLinux) {
if (Util.isDesktop) {
Future<void>.delayed(Duration.zero).then((value) =>
Navigator.of(context).pushNamedAndRemoveUntil(
DesktopHomeView.routeName, (route) => false));

View file

@ -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(

View file

@ -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<NameYourWalletView> {
@override
void initState() {
isDesktop = Platform.isLinux || Platform.isWindows || Platform.isMacOS;
isDesktop = Util.isDesktop;
ref.read(walletsServiceChangeNotifierProvider).walletNames.then(
(value) => namesToExclude.addAll(

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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<RestoreOptionsView> {
void initState() {
walletName = widget.walletName;
coin = widget.coin;
isDesktop = Platform.isMacOS || Platform.isWindows || Platform.isLinux;
isDesktop = Util.isDesktop;
_dateController = TextEditingController();
textFieldFocusNode = FocusNode();

View file

@ -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<RestoreWalletView> {
@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<RestoreWalletView> {
context: context,
));
} else {
if (!Platform.isLinux) Wakelock.enable();
if (!Platform.isLinux) await Wakelock.enable();
final walletsService = ref.read(walletsServiceChangeNotifierProvider);
final walletId = await walletsService.addNewWallet(

View file

@ -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();
}

View file

@ -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<IntroView> {
@override
void initState() {
isDesktop = Platform.isMacOS || Platform.isWindows || Platform.isLinux;
isDesktop = Util.isDesktop;
super.initState();
}

View file

@ -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(

View file

@ -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(

View file

@ -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,