diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 62074faed..7640d53d3 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -4,9 +4,9 @@ PODS: - MTBBarcodeScanner - SwiftProtobuf - BigInt (5.2.0) - - connectivity (0.0.1): + - connectivity_plus (0.0.1): - Flutter - - Reachability + - ReachabilitySwift - CryptoSwift (1.6.0) - cw_haven (0.0.1): - cw_haven/Boost (= 0.0.1) @@ -126,11 +126,11 @@ PODS: - path_provider_foundation (0.0.1): - Flutter - FlutterMacOS - - permission_handler_apple (9.0.4): + - permission_handler_apple (9.1.0): - Flutter - platform_device_id (0.0.1): - Flutter - - Reachability (3.2) + - ReachabilitySwift (5.0.0) - SDWebImage (5.15.5): - SDWebImage/Core (= 5.15.5) - SDWebImage/Core (5.15.5) @@ -153,7 +153,7 @@ PODS: DEPENDENCIES: - barcode_scan2 (from `.symlinks/plugins/barcode_scan2/ios`) - - connectivity (from `.symlinks/plugins/connectivity/ios`) + - connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`) - CryptoSwift - cw_haven (from `.symlinks/plugins/cw_haven/ios`) - cw_monero (from `.symlinks/plugins/cw_monero/ios`) @@ -188,7 +188,7 @@ SPEC REPOS: - DKPhotoGallery - MTBBarcodeScanner - OrderedSet - - Reachability + - ReachabilitySwift - SDWebImage - SwiftProtobuf - SwiftyGif @@ -197,8 +197,8 @@ SPEC REPOS: EXTERNAL SOURCES: barcode_scan2: :path: ".symlinks/plugins/barcode_scan2/ios" - connectivity: - :path: ".symlinks/plugins/connectivity/ios" + connectivity_plus: + :path: ".symlinks/plugins/connectivity_plus/ios" cw_haven: :path: ".symlinks/plugins/cw_haven/ios" cw_monero: @@ -249,7 +249,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: barcode_scan2: 0af2bb63c81b4565aab6cd78278e4c0fa136dbb0 BigInt: f668a80089607f521586bbe29513d708491ef2f7 - connectivity: c4130b2985d4ef6fd26f9702e886bd5260681467 + connectivity_plus: 413a8857dd5d9f1c399a39130850d02fe0feaf7e CryptoSwift: 562f8eceb40e80796fffc668b0cad9313284cfa6 cw_haven: b3e54e1fbe7b8e6fda57a93206bc38f8e89b898a cw_monero: 4cf3b96f2da8e95e2ef7d6703dd4d2c509127b7d @@ -271,9 +271,9 @@ SPEC CHECKSUMS: OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8 - permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce + permission_handler_apple: 8f116445eff3c0e7c65ad60f5fef5490aa94b4e4 platform_device_id: 81b3e2993881f87d0c82ef151dc274df4869aef5 - Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 + ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825 SDWebImage: fd7e1a22f00303e058058278639bf6196ee431fe share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68 shared_preferences_foundation: e2dae3258e06f44cc55f49d42024fd8dd03c590c diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 50b9da031..dc6c28225 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -390,7 +390,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = 1; + TARGETED_DEVICE_FAMILY = "1,2"; VALID_ARCHS = arm64; VERSIONING_SYSTEM = "apple-generic"; }; @@ -537,7 +537,7 @@ SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = 1; + TARGETED_DEVICE_FAMILY = "1,2"; VALID_ARCHS = arm64; VERSIONING_SYSTEM = "apple-generic"; }; @@ -574,7 +574,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = 1; + TARGETED_DEVICE_FAMILY = "1,2"; VALID_ARCHS = arm64; VERSIONING_SYSTEM = "apple-generic"; }; diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json index 6d834d4ee..df5cf1cc5 100644 --- a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,21 +1,25 @@ { "images" : [ { + "filename" : "Icon-App-40x40@1x.png", "idiom" : "iphone", "scale" : "2x", "size" : "20x20" }, { + "filename" : "Icon-App-20x20@3x.png", "idiom" : "iphone", "scale" : "3x", "size" : "20x20" }, { + "filename" : "Icon-App-29x29@2x 1.png", "idiom" : "iphone", "scale" : "2x", "size" : "29x29" }, { + "filename" : "Icon-App-29x29@3x.png", "idiom" : "iphone", "scale" : "3x", "size" : "29x29" @@ -26,6 +30,7 @@ "size" : "40x40" }, { + "filename" : "Icon-App-40x40@3x.png", "idiom" : "iphone", "scale" : "3x", "size" : "40x40" @@ -43,26 +48,31 @@ "size" : "60x60" }, { + "filename" : "Icon-App-20x20@1x.png", "idiom" : "ipad", "scale" : "1x", "size" : "20x20" }, { + "filename" : "Icon-App-20x20@2x.png", "idiom" : "ipad", "scale" : "2x", "size" : "20x20" }, { + "filename" : "Icon-App-29x29@1x.png", "idiom" : "ipad", "scale" : "1x", "size" : "29x29" }, { + "filename" : "Icon-App-29x29@2x.png", "idiom" : "ipad", "scale" : "2x", "size" : "29x29" }, { + "filename" : "Icon-App-40x40@1x 1.png", "idiom" : "ipad", "scale" : "1x", "size" : "40x40" @@ -73,16 +83,19 @@ "size" : "40x40" }, { + "filename" : "Icon-App-76x76@1x.png", "idiom" : "ipad", "scale" : "1x", "size" : "76x76" }, { + "filename" : "Icon-App-76x76@2x.png", "idiom" : "ipad", "scale" : "2x", "size" : "76x76" }, { + "filename" : "Icon-App-83.5x83.5@2x.png", "idiom" : "ipad", "scale" : "2x", "size" : "83.5x83.5" diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 000000000..369d8d9a4 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 000000000..65ed7f3db Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 000000000..fb14bfc55 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 000000000..d24d594a3 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x 1.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x 1.png new file mode 100644 index 000000000..07acd0a82 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x 1.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 000000000..07acd0a82 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 000000000..bdc20091d Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x 1.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x 1.png new file mode 100644 index 000000000..65ed7f3db Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x 1.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 000000000..65ed7f3db Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 000000000..80e78be41 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 000000000..e06998b67 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 000000000..78a2ccfb1 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 000000000..0ba8d647c Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/lib/di.dart b/lib/di.dart index 85dd7154b..f6fb693a4 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -36,6 +36,7 @@ import 'package:cake_wallet/themes/theme_list.dart'; import 'package:cake_wallet/utils/device_info.dart'; import 'package:cake_wallet/store/anonpay/anonpay_transactions_store.dart'; import 'package:cake_wallet/utils/payment_request.dart'; +import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cake_wallet/view_model/dashboard/desktop_sidebar_view_model.dart'; import 'package:cake_wallet/view_model/anon_invoice_page_view_model.dart'; import 'package:cake_wallet/view_model/anonpay_details_view_model.dart'; @@ -244,7 +245,7 @@ Future setup({ nodeSource: _nodeSource, isBitcoinBuyEnabled: isBitcoinBuyEnabled, // Enforce darkTheme on platforms other than mobile till the design for other themes is completed - initialTheme: DeviceInfo.instance.isMobile ? null : ThemeList.darkTheme, + initialTheme: ResponsiveLayoutUtil.instance.isMobile && DeviceInfo.instance.isMobile ? null : ThemeList.darkTheme, ); if (_isSetupFinished) { diff --git a/lib/entities/main_actions.dart b/lib/entities/main_actions.dart index f7a322096..d42c15dc8 100644 --- a/lib/entities/main_actions.dart +++ b/lib/entities/main_actions.dart @@ -6,6 +6,7 @@ import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/utils/device_info.dart'; +import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:cw_core/wallet_type.dart'; diff --git a/lib/main.dart b/lib/main.dart index 3bfcc8617..1896f531c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -6,6 +6,7 @@ import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/locales/locale.dart'; import 'package:cake_wallet/store/yat/yat_store.dart'; import 'package:cake_wallet/utils/exception_handler.dart'; +import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -194,7 +195,9 @@ class App extends StatefulWidget { class AppState extends State with SingleTickerProviderStateMixin { AppState() : yatStore = getIt.get() { SystemChrome.setPreferredOrientations( - [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]); + ResponsiveLayoutUtil.instance.isIpad ? + [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight] : + [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]); } YatStore yatStore; diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index 47a62f53a..94717f93f 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -43,7 +43,7 @@ class DashboardPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - body: ResponsiveLayoutUtil.instance.isMobile(context) + body: ResponsiveLayoutUtil.instance.isMobile ? _DashboardPageView( balancePage: balancePage, dashboardViewModel: dashboardViewModel, diff --git a/lib/src/screens/dashboard/widgets/address_page.dart b/lib/src/screens/dashboard/widgets/address_page.dart index 82a867058..a047e9f29 100644 --- a/lib/src/screens/dashboard/widgets/address_page.dart +++ b/lib/src/screens/dashboard/widgets/address_page.dart @@ -73,7 +73,7 @@ class AddressPage extends BasePage { ? closeButtonImageDarkTheme : closeButtonImage; - bool isMobileView = ResponsiveLayoutUtil.instance.isMobile(context); + bool isMobileView = ResponsiveLayoutUtil.instance.isMobile; return MergeSemantics( child: SizedBox( diff --git a/lib/src/screens/dashboard/widgets/balance_page.dart b/lib/src/screens/dashboard/widgets/balance_page.dart index 6e2893429..85d0fb0a1 100644 --- a/lib/src/screens/dashboard/widgets/balance_page.dart +++ b/lib/src/screens/dashboard/widgets/balance_page.dart @@ -120,19 +120,22 @@ class BalancePage extends StatelessWidget { .backgroundColor!, height: 1)), SizedBox(height: 5), - Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - AutoSizeText(availableBalance, - style: TextStyle( - fontSize: 24, - fontFamily: 'Lato', - fontWeight: FontWeight.w900, - color: Theme.of(context) - .accentTextTheme! - .displayMedium! - .backgroundColor!, - height: 1), - maxLines: 1, - textAlign: TextAlign.center), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Expanded( + child: AutoSizeText(availableBalance, + style: TextStyle( + fontSize: 24, + fontFamily: 'Lato', + fontWeight: FontWeight.w900, + color: Theme.of(context) + .accentTextTheme! + .displayMedium! + .backgroundColor!, + height: 1), + maxLines: 1, + textAlign: TextAlign.start), + ), Text(currency, style: TextStyle( fontSize: 28, diff --git a/lib/src/screens/dashboard/widgets/transactions_page.dart b/lib/src/screens/dashboard/widgets/transactions_page.dart index 61ab84265..e92e97f04 100644 --- a/lib/src/screens/dashboard/widgets/transactions_page.dart +++ b/lib/src/screens/dashboard/widgets/transactions_page.dart @@ -31,7 +31,7 @@ class TransactionsPage extends StatelessWidget { onLongPressUp: () => dashboardViewModel.balanceViewModel.isReversing = !dashboardViewModel.balanceViewModel.isReversing, child: Container( - color: ResponsiveLayoutUtil.instance.isMobile(context) + color: ResponsiveLayoutUtil.instance.isMobile ? null : Theme.of(context).colorScheme.background, padding: EdgeInsets.only(top: 24, bottom: 24), diff --git a/lib/src/screens/exchange/exchange_page.dart b/lib/src/screens/exchange/exchange_page.dart index 6eea29b42..91097ead3 100644 --- a/lib/src/screens/exchange/exchange_page.dart +++ b/lib/src/screens/exchange/exchange_page.dart @@ -117,7 +117,7 @@ class ExchangePage extends BasePage { final _closeButton = currentTheme.type == ThemeType.dark ? closeButtonImageDarkTheme : closeButtonImage; - bool isMobileView = ResponsiveLayoutUtil.instance.isMobile(context); + bool isMobileView = ResponsiveLayoutUtil.instance.isMobile; return MergeSemantics( child: SizedBox( @@ -731,7 +731,7 @@ class ExchangePage extends BasePage { }, )); - if (ResponsiveLayoutUtil.instance.isMobile(context)) { + if (ResponsiveLayoutUtil.instance.isMobile) { return MobileExchangeCardsSection( firstExchangeCard: firstExchangeCard, secondExchangeCard: secondExchangeCard, diff --git a/lib/src/screens/receive/anonpay_invoice_page.dart b/lib/src/screens/receive/anonpay_invoice_page.dart index 41bd5f6fd..f8df3eeb3 100644 --- a/lib/src/screens/receive/anonpay_invoice_page.dart +++ b/lib/src/screens/receive/anonpay_invoice_page.dart @@ -9,6 +9,7 @@ import 'package:cake_wallet/src/screens/receive/widgets/anonpay_input_form.dart' import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/src/widgets/keyboard_done_button.dart'; import 'package:cake_wallet/utils/device_info.dart'; +import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cake_wallet/view_model/anon_invoice_page_view_model.dart'; import 'package:cake_wallet/view_model/dashboard/receive_option_view_model.dart'; import 'package:flutter/material.dart'; @@ -88,32 +89,30 @@ class AnonPayInvoicePage extends BasePage { .accentTextTheme! .bodyLarge! .backgroundColor!, - nextFocus: false, - actions: [ - KeyboardActionsItem( - focusNode: _amountFocusNode, - toolbarButtons: [(_) => KeyboardDoneButton()], + nextFocus: false, + actions: [ + KeyboardActionsItem( + focusNode: _amountFocusNode, + toolbarButtons: [(_) => KeyboardDoneButton()], + ), + ]), + child: Container( + color: Theme.of(context).colorScheme.background, + child: ScrollableWithBottomSection( + contentPadding: EdgeInsets.only(bottom: 24), + content: Container( + decoration: ResponsiveLayoutUtil.instance.isMobile ? BoxDecoration( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(24), bottomRight: Radius.circular(24)), + gradient: LinearGradient( + colors: [ + Theme.of(context).primaryTextTheme!.titleSmall!.color!, + Theme.of(context).primaryTextTheme!.titleSmall!.decorationColor!, + ], + begin: Alignment.topLeft, + end: Alignment.bottomRight, ), - ]), - child: Container( - color: Theme.of(context).colorScheme.background, - child: ScrollableWithBottomSection( - contentPadding: EdgeInsets.only(bottom: 24), - content: Container( - decoration: DeviceInfo.instance.isMobile - ? BoxDecoration( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(24), bottomRight: Radius.circular(24)), - gradient: LinearGradient( - colors: [ - Theme.of(context).primaryTextTheme!.titleSmall!.color!, - Theme.of(context).primaryTextTheme!.titleSmall!.decorationColor!, - ], - begin: Alignment.topLeft, - end: Alignment.bottomRight, - ), - ) - : null, + ) : null, child: Observer(builder: (_) { return Padding( padding: EdgeInsets.fromLTRB(24, 120, 24, 0), diff --git a/lib/src/screens/receive/widgets/currency_input_field.dart b/lib/src/screens/receive/widgets/currency_input_field.dart index f1ce170f7..85e2cdbe2 100644 --- a/lib/src/screens/receive/widgets/currency_input_field.dart +++ b/lib/src/screens/receive/widgets/currency_input_field.dart @@ -1,4 +1,5 @@ import 'package:cake_wallet/src/widgets/base_text_form_field.dart'; +import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cw_core/currency.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -9,7 +10,8 @@ class CurrencyInputField extends StatelessWidget { required this.onTapPicker, required this.selectedCurrency, this.focusNode, - required this.controller, required this.isLight, + required this.controller, + required this.isLight, }); final Function() onTapPicker; @@ -22,13 +24,12 @@ class CurrencyInputField extends StatelessWidget { Widget build(BuildContext context) { final arrowBottomPurple = Image.asset( 'assets/images/arrow_bottom_purple_icon.png', - color: Theme.of(context) - .accentTextTheme! - .displayMedium! - .backgroundColor!, + color: Theme.of(context).accentTextTheme!.displayMedium!.backgroundColor!, height: 8, ); - final _width = MediaQuery.of(context).size.width; + // This magic number for wider screen sets the text input focus at center of the inputfield + final _width = + ResponsiveLayoutUtil.instance.isMobile ? MediaQuery.of(context).size.width : 500; return Column( children: [ @@ -42,10 +43,12 @@ class CurrencyInputField extends StatelessWidget { keyboardType: TextInputType.numberWithOptions(signed: false, decimal: true), inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r'^\d+(\.|\,)?\d{0,8}'))], hintText: '0.000', - placeholderTextStyle: isLight ? null : TextStyle( - color: Theme.of(context).primaryTextTheme!.headlineSmall!.color!, - fontWeight: FontWeight.w600, - ), + placeholderTextStyle: isLight + ? null + : TextStyle( + color: Theme.of(context).primaryTextTheme!.headlineSmall!.color!, + fontWeight: FontWeight.w600, + ), borderColor: Theme.of(context).accentTextTheme!.titleLarge!.backgroundColor!, textColor: Theme.of(context).accentTextTheme!.displayMedium!.backgroundColor!, textStyle: TextStyle( @@ -72,7 +75,10 @@ class CurrencyInputField extends StatelessWidget { style: TextStyle( fontWeight: FontWeight.w600, fontSize: 16, - color: Theme.of(context).accentTextTheme!.displayMedium!.backgroundColor!, + color: Theme.of(context) + .accentTextTheme! + .displayMedium! + .backgroundColor!, ), ), if (selectedCurrency.tag != null) @@ -107,8 +113,10 @@ class CurrencyInputField extends StatelessWidget { style: TextStyle( fontWeight: FontWeight.w600, fontSize: 20, - color: - Theme.of(context).accentTextTheme!.displayMedium!.backgroundColor!, + color: Theme.of(context) + .accentTextTheme! + .displayMedium! + .backgroundColor!, ), ), ), diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 6fffffa42..4ad1ad8ca 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -62,7 +62,7 @@ class SendPage extends BasePage { final _closeButton = currentTheme.type == ThemeType.dark ? closeButtonImageDarkTheme : closeButtonImage; - bool isMobileView = ResponsiveLayoutUtil.instance.isMobile(context); + bool isMobileView = ResponsiveLayoutUtil.instance.isMobile; return MergeSemantics( child: SizedBox( @@ -92,7 +92,7 @@ class SendPage extends BasePage { double _sendCardHeight(BuildContext context) { final double initialHeight = sendViewModel.isElectrumWallet ? 490 : 465; - if (!ResponsiveLayoutUtil.instance.isMobile(context)) { + if (!ResponsiveLayoutUtil.instance.isMobile) { return initialHeight - 66; } return initialHeight; diff --git a/lib/src/screens/send/widgets/send_card.dart b/lib/src/screens/send/widgets/send_card.dart index 96045b1bd..2b4b40fa3 100644 --- a/lib/src/screens/send/widgets/send_card.dart +++ b/lib/src/screens/send/widgets/send_card.dart @@ -122,7 +122,7 @@ class SendCardState extends State color: Colors.transparent, )), Container( - decoration: ResponsiveLayoutUtil.instance.isMobile(context) ? BoxDecoration( + decoration: ResponsiveLayoutUtil.instance.isMobile ? BoxDecoration( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(24), bottomRight: Radius.circular(24)), @@ -137,9 +137,9 @@ class SendCardState extends State child: Padding( padding: EdgeInsets.fromLTRB( 24, - ResponsiveLayoutUtil.instance.isMobile(context) ? 100 : 55, + ResponsiveLayoutUtil.instance.isMobile ? 100 : 55, 24, - ResponsiveLayoutUtil.instance.isMobile(context) ? 32 : 0, + ResponsiveLayoutUtil.instance.isMobile ? 32 : 0, ), child: SingleChildScrollView( child: Observer(builder: (_) => Column( diff --git a/lib/src/screens/settings/display_settings_page.dart b/lib/src/screens/settings/display_settings_page.dart index c7baa9b6a..04fd134e6 100644 --- a/lib/src/screens/settings/display_settings_page.dart +++ b/lib/src/screens/settings/display_settings_page.dart @@ -8,6 +8,7 @@ import 'package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell. import 'package:cake_wallet/themes/theme_base.dart'; import 'package:cake_wallet/themes/theme_list.dart'; import 'package:cake_wallet/utils/device_info.dart'; +import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cake_wallet/view_model/settings/choices_list_item.dart'; import 'package:cake_wallet/view_model/settings/display_settings_view_model.dart'; import 'package:flutter/material.dart'; @@ -29,11 +30,11 @@ class DisplaySettingsPage extends BasePage { child: Column( children: [ SettingsSwitcherCell( - title: S.current.settings_display_balance, - value: _displaySettingsViewModel.shouldDisplayBalance, - onValueChange: (_, bool value) { - _displaySettingsViewModel.setShouldDisplayBalance(value); - }), + title: S.current.settings_display_balance, + value: _displaySettingsViewModel.shouldDisplayBalance, + onValueChange: (_, bool value) { + _displaySettingsViewModel.setShouldDisplayBalance(value); + }), SettingsSwitcherCell( title: S.current.show_market_place, value: _displaySettingsViewModel.shouldShowMarketPlaceInDashboard, @@ -42,14 +43,17 @@ class DisplaySettingsPage extends BasePage { }, ), //if (!isHaven) it does not work correctly - if(!_displaySettingsViewModel.disabledFiatApiMode) + if (!_displaySettingsViewModel.disabledFiatApiMode) SettingsPickerCell( title: S.current.settings_currency, searchHintText: S.current.search_currency, items: FiatCurrency.all, selectedItem: _displaySettingsViewModel.fiatCurrency, - onItemSelected: (FiatCurrency currency) => _displaySettingsViewModel.setFiatCurrency(currency), - images: FiatCurrency.all.map((e) => Image.asset("assets/images/flags/${e.countryCode}.png")).toList(), + onItemSelected: (FiatCurrency currency) => + _displaySettingsViewModel.setFiatCurrency(currency), + images: FiatCurrency.all + .map((e) => Image.asset("assets/images/flags/${e.countryCode}.png")) + .toList(), isGridView: true, matchingCriteria: (FiatCurrency currency, String searchText) { return currency.title.toLowerCase().contains(searchText) || @@ -66,13 +70,14 @@ class DisplaySettingsPage extends BasePage { selectedItem: _displaySettingsViewModel.languageCode, onItemSelected: _displaySettingsViewModel.onLanguageSelected, images: LanguageService.list.keys - .map((e) => Image.asset("assets/images/flags/${LanguageService.localeCountryCode[e]}.png")) + .map((e) => Image.asset( + "assets/images/flags/${LanguageService.localeCountryCode[e]}.png")) .toList(), matchingCriteria: (String code, String searchText) { return LanguageService.list[code]?.toLowerCase().contains(searchText) ?? false; }, ), - if (DeviceInfo.instance.isMobile) + if (ResponsiveLayoutUtil.instance.isMobile && DeviceInfo.instance.isMobile) SettingsChoicesCell( ChoicesListItem( title: S.current.color_theme, diff --git a/lib/src/screens/wallet_list/wallet_list_page.dart b/lib/src/screens/wallet_list/wallet_list_page.dart index 3f33ebc7a..a9a4b894f 100644 --- a/lib/src/screens/wallet_list/wallet_list_page.dart +++ b/lib/src/screens/wallet_list/wallet_list_page.dart @@ -1,6 +1,6 @@ import 'package:cake_wallet/core/auth_service.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; -import 'package:cake_wallet/utils/device_info.dart'; +import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cake_wallet/utils/show_bar.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/view_model/wallet_list/wallet_list_item.dart'; @@ -229,7 +229,7 @@ class WalletListBodyState extends State { await hideProgressText(); // only pop the wallets route in mobile as it will go back to dashboard page // in desktop platforms the navigation tree is different - if (DeviceInfo.instance.isMobile) { + if (ResponsiveLayoutUtil.instance.isMobile) { WidgetsBinding.instance.addPostFrameCallback((_) { Navigator.of(context).pop(); }); diff --git a/lib/src/widgets/add_template_button.dart b/lib/src/widgets/add_template_button.dart index 87951e044..c88b72e7f 100644 --- a/lib/src/widgets/add_template_button.dart +++ b/lib/src/widgets/add_template_button.dart @@ -26,7 +26,7 @@ class AddTemplateButton extends StatelessWidget { child: Container( height: 34, padding: EdgeInsets.symmetric( - horizontal: ResponsiveLayoutUtil.instance.isMobile(context) ? 10 : 30), + horizontal: ResponsiveLayoutUtil.instance.isMobile ? 10 : 30), alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(20)), diff --git a/lib/src/widgets/address_text_field.dart b/lib/src/widgets/address_text_field.dart index 415d40c6d..daa2e0a60 100644 --- a/lib/src/widgets/address_text_field.dart +++ b/lib/src/widgets/address_text_field.dart @@ -1,6 +1,6 @@ -import 'dart:io'; import 'package:cake_wallet/utils/device_info.dart'; +import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:cake_wallet/routes.dart'; @@ -105,7 +105,7 @@ class AddressTextField extends StatelessWidget { width: prefixIconWidth * options.length + (spaceBetweenPrefixIcons * options.length), child: Row( - mainAxisAlignment: DeviceInfo.instance.isMobile + mainAxisAlignment: ResponsiveLayoutUtil.instance.isMobile ? MainAxisAlignment.spaceBetween : MainAxisAlignment.end, children: [ SizedBox(width: 5), diff --git a/lib/utils/exception_handler.dart b/lib/utils/exception_handler.dart index 4b156ade1..aeb81fb66 100644 --- a/lib/utils/exception_handler.dart +++ b/lib/utils/exception_handler.dart @@ -130,17 +130,16 @@ class ExceptionHandler { _ignoredErrors.any((element) => error.contains(element)); static const List _ignoredErrors = const [ - "errno = 9", // SocketException: Bad file descriptor - "errno = 28", // OS Error: No space left on device - "errno = 32", // SocketException: Write failed (OS Error: Broken pipe) - "errno = 49", // SocketException: Can't assign requested address - "errno = 54", // SocketException: Connection reset by peer - "errno = 57", // SocketException: Read failed (OS Error: Socket is not connected) - "errno = 60", // SocketException: Operation timed out - "errno = 65", // SocketException: No route to host - "errno = 103", // SocketException: Software caused connection abort - "errno = 104", // SocketException: Connection reset by peer - "errno = 110", // SocketException: Connection timed out + "Bad file descriptor", + "No space left on device", + "Write failed (OS Error: Broken pipe)", + "Can't assign requested address", + "Read failed (OS Error: Socket is not connected)", + "Operation timed out", + "No route to host", + "Software caused connection abort", + "Connection reset by peer", + "Connection timed out", "Connection reset by peer", "Connection closed before full header was received", "Connection terminated during handshake", diff --git a/lib/utils/responsive_layout_util.dart b/lib/utils/responsive_layout_util.dart index 8ae76ca21..d0f029a54 100644 --- a/lib/utils/responsive_layout_util.dart +++ b/lib/utils/responsive_layout_util.dart @@ -1,33 +1,35 @@ import 'package:flutter/material.dart'; class ResponsiveLayoutUtil { - static const double _kMobileThreshold = 900; + static const double _kMobileThreshold = 768; static const double kDesktopMaxWidthConstraint = 400; static const double kPopupWidth = 400; static const double kPopupSpaceHeight = 100; - + static const _kIpadMaxWidth = 2560.0; const ResponsiveLayoutUtil._(); static final instance = ResponsiveLayoutUtil._(); - bool isMobile(BuildContext context) { - final MediaQueryData mediaQueryData = MediaQuery.of(context); - return mediaQueryData.size.width < _kMobileThreshold; + bool get isMobile => + WidgetsBinding.instance.platformDispatcher.views.first.physicalSize.width < _kMobileThreshold; + + bool get isIpad { + final width = WidgetsBinding.instance.platformDispatcher.views.first.physicalSize.width; + return width >= _kMobileThreshold && !(width > _kIpadMaxWidth); } /// Returns dynamic size. /// /// If screen size is mobile, it returns 66% ([scale]) of the [originalValue]. double getDynamicSize( - BuildContext context, double originalValue, { double? mobileSize, double? scale, }) { scale ??= 2 / 3; mobileSize ??= originalValue * scale; - final value = isMobile(context) ? mobileSize : originalValue; + final value = isMobile ? mobileSize : originalValue; return value.roundToDouble(); }