From d97ecfeb704fe6ebe14020c64e689d8792dfb042 Mon Sep 17 00:00:00 2001 From: cp-ishita-g Date: Thu, 6 Jun 2024 16:07:43 +0530 Subject: [PATCH] fix snakebar with toast in iOS --- app/ios/Podfile.lock | 10 ++++++++ app/lib/ui/components/error_snakebar.dart | 25 +++++++++++++------ .../contact_support_screen.dart | 1 + app/pubspec.lock | 8 ++++++ app/pubspec.yaml | 1 + 5 files changed, 38 insertions(+), 7 deletions(-) diff --git a/app/ios/Podfile.lock b/app/ios/Podfile.lock index 978824ac..d09fc2ba 100644 --- a/app/ios/Podfile.lock +++ b/app/ios/Podfile.lock @@ -1050,6 +1050,9 @@ PODS: - Flutter (1.0.0) - flutter_timezone (0.0.1): - Flutter + - fluttertoast (0.0.2): + - Flutter + - Toast - google_sign_in_ios (0.0.1): - AppAuth (>= 1.7.4) - Flutter @@ -1194,6 +1197,7 @@ PODS: - sqflite (0.0.3): - Flutter - FlutterMacOS + - Toast (4.1.1) - TOCropViewController (2.7.4) DEPENDENCIES: @@ -1205,6 +1209,7 @@ DEPENDENCIES: - firebase_storage (from `.symlinks/plugins/firebase_storage/ios`) - Flutter (from `Flutter`) - flutter_timezone (from `.symlinks/plugins/flutter_timezone/ios`) + - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) - google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/darwin`) - image_cropper (from `.symlinks/plugins/image_cropper/ios`) - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) @@ -1242,6 +1247,7 @@ SPEC REPOS: - nanopb - PromisesObjC - RecaptchaInterop + - Toast - TOCropViewController EXTERNAL SOURCES: @@ -1261,6 +1267,8 @@ EXTERNAL SOURCES: :path: Flutter flutter_timezone: :path: ".symlinks/plugins/flutter_timezone/ios" + fluttertoast: + :path: ".symlinks/plugins/fluttertoast/ios" google_sign_in_ios: :path: ".symlinks/plugins/google_sign_in_ios/darwin" image_cropper: @@ -1303,6 +1311,7 @@ SPEC CHECKSUMS: FirebaseStorage: 44f4e25073f6fa0d4d8c09f5bec299ee9e4eb985 Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 flutter_timezone: ffb07bdad3c6276af8dada0f11978d8a1f8a20bb + fluttertoast: e9a18c7be5413da53898f660530c56f35edfba9c google_sign_in_ios: 07375bfbf2620bc93a602c0e27160d6afc6ead38 GoogleSignIn: d4281ab6cf21542b1cfaff85c191f230b399d2db GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15 @@ -1321,6 +1330,7 @@ SPEC CHECKSUMS: share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec + Toast: 1f5ea13423a1e6674c4abdac5be53587ae481c4e TOCropViewController: 80b8985ad794298fb69d3341de183f33d1853654 PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796 diff --git a/app/lib/ui/components/error_snakebar.dart b/app/lib/ui/components/error_snakebar.dart index 1b579a5a..935fa5b1 100644 --- a/app/lib/ui/components/error_snakebar.dart +++ b/app/lib/ui/components/error_snakebar.dart @@ -1,5 +1,8 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:fluttertoast/fluttertoast.dart'; void showErrorSnackBar(BuildContext context, Object error) { HapticFeedback.mediumImpact(); @@ -11,13 +14,21 @@ void showSnackBar( String text, { SnackBarLength length = SnackBarLength.short, }) { - final snackBar = SnackBar( - content: Text(text), - behavior: SnackBarBehavior.floating, - duration: Duration(seconds: length.seconds), - ); - ScaffoldMessenger.of(context).removeCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar(snackBar); + if (Platform.isIOS) { + Fluttertoast.showToast( + msg: text, + timeInSecForIosWeb: length.seconds, + gravity: ToastGravity.BOTTOM, + ); + } else { + final snackBar = SnackBar( + content: Text(text), + behavior: SnackBarBehavior.floating, + duration: Duration(seconds: length.seconds), + ); + ScaffoldMessenger.of(context).removeCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar(snackBar); + } } enum SnackBarLength { diff --git a/app/lib/ui/flow/setting/contact_support/contact_support_screen.dart b/app/lib/ui/flow/setting/contact_support/contact_support_screen.dart index ee33ef6b..2c8f2896 100644 --- a/app/lib/ui/flow/setting/contact_support/contact_support_screen.dart +++ b/app/lib/ui/flow/setting/contact_support/contact_support_screen.dart @@ -194,6 +194,7 @@ class _ContactSupportScreenState extends ConsumerState { context.l10n.contact_support_submit_title, onPressed: () { notifier.submitSupportRequest(); + showErrorSnackBar(context, state.error.toString()); }, ), ); diff --git a/app/pubspec.lock b/app/pubspec.lock index b04b3fc7..b4f14d5c 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -588,6 +588,14 @@ packages: description: flutter source: sdk version: "0.0.0" + fluttertoast: + dependency: "direct main" + description: + name: fluttertoast + sha256: "7eae679e596a44fdf761853a706f74979f8dd3cd92cf4e23cae161fda091b847" + url: "https://pub.dev" + source: hosted + version: "8.2.6" freezed: dependency: "direct dev" description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index f782c40c..daf36ed5 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -53,6 +53,7 @@ dependencies: cached_network_image: ^3.3.1 image_picker: ^1.1.1 image_cropper: ^6.0.0 + fluttertoast: ^8.2.6 # auth firebase_auth: ^4.20.0