From 7bf636fdd30430ad1d52c329c85458c627d2e845 Mon Sep 17 00:00:00 2001 From: cp-ishita-g Date: Fri, 7 Jun 2024 11:11:52 +0530 Subject: [PATCH] show prompt for report send --- app/assets/locales/app_en.arb | 3 +- app/lib/ui/components/alert.dart | 8 ++--- .../ui/flow/home/home_screen_viewmodel.dart | 2 +- .../contact_support_screen.dart | 29 ++++++++++++------- .../ui/flow/setting/setting_view_model.dart | 3 +- .../setting/space/edit_space_view_model.dart | 8 ++--- .../space/create/create_space_view_model.dart | 2 +- .../space/join/join_space_view_model.dart | 2 +- 8 files changed, 33 insertions(+), 24 deletions(-) diff --git a/app/assets/locales/app_en.arb b/app/assets/locales/app_en.arb index 49483c59..826ec600 100644 --- a/app/assets/locales/app_en.arb +++ b/app/assets/locales/app_en.arb @@ -142,5 +142,6 @@ "contact_support_title_field": "Title", "contact_support_description_title": "Description", "contact_support_attachment": "Attachment (if any)", - "contact_support_submit_title": "Submit" + "contact_support_submit_title": "Submit", + "contact_support_feedback_alert_message": "Thanks! Your feedback has been recorded." } \ No newline at end of file diff --git a/app/lib/ui/components/alert.dart b/app/lib/ui/components/alert.dart index 6a16975a..c2facf24 100644 --- a/app/lib/ui/components/alert.dart +++ b/app/lib/ui/components/alert.dart @@ -52,8 +52,8 @@ Future showConfirmation( Future showOkayConfirmation( BuildContext context, { - required String title, - required String message, + String? title, + String? message, bool isDestructiveAction = true, VoidCallback? onOkay, }) { @@ -63,8 +63,8 @@ Future showOkayConfirmation( builder: (context) { return AlertDialog.adaptive( surfaceTintColor: context.colorScheme.containerNormalOnSurface, - title: Text(title), - content: Text(message), + title: (title != null) ? Text(title) : null, + content: (message != null) ? Text(message) : null, actions: [ adaptiveAction( context: context, diff --git a/app/lib/ui/flow/home/home_screen_viewmodel.dart b/app/lib/ui/flow/home/home_screen_viewmodel.dart index 39d2c517..b0a9b77e 100644 --- a/app/lib/ui/flow/home/home_screen_viewmodel.dart +++ b/app/lib/ui/flow/home/home_screen_viewmodel.dart @@ -63,7 +63,7 @@ class HomeViewNotifier extends StateNotifier { final code = await spaceService.getInviteCode(state.selectedSpace?.space.id ?? ''); state = state.copyWith(spaceInvitationCode: code ?? '', fetchingInviteCode: false); } catch (error, stack) { - state = state.copyWith(error: error); + state = state.copyWith(error: error, fetchingInviteCode: false); logger.e( 'HomeViewNotifier: Error while getting invitation code', error: error, 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..72500156 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 @@ -16,6 +16,7 @@ import 'package:yourspace_flutter/domain/extenstions/context_extenstions.dart'; import 'package:yourspace_flutter/ui/components/error_snakebar.dart'; import 'package:yourspace_flutter/ui/flow/setting/contact_support/contact_support_view_model.dart'; +import '../../../components/alert.dart'; import '../../../components/app_page.dart'; class ContactSupportScreen extends ConsumerStatefulWidget { @@ -33,7 +34,7 @@ class _ContactSupportScreenState extends ConsumerState { Widget build(BuildContext context) { notifier = ref.watch(contactSupportViewStateProvider.notifier); final state = ref.watch(contactSupportViewStateProvider); - _observePop(); + _showReportSentPrompt(); _observeError(); return AppPage( @@ -199,16 +200,6 @@ class _ContactSupportScreenState extends ConsumerState { ); } - void _observePop() { - ref.listen( - contactSupportViewStateProvider.select((state) => state.requestSent), - (previous, next) { - if (next) { - context.pop(); - } - }); - } - void _observeError() { ref.listen(contactSupportViewStateProvider.select((state) => state.error), (previous, next) { if (next != null) { @@ -216,4 +207,20 @@ class _ContactSupportScreenState extends ConsumerState { } }); } + + void _showReportSentPrompt() { + ref.listen( + contactSupportViewStateProvider.select((state) => state.requestSent), + (previous, next) { + if (next) { + showOkayConfirmation( + context, + message: context.l10n.contact_support_feedback_alert_message, + onOkay: () { + context.pop(); + }, + ); + } + }); + } } diff --git a/app/lib/ui/flow/setting/setting_view_model.dart b/app/lib/ui/flow/setting/setting_view_model.dart index d223597b..027cad3a 100644 --- a/app/lib/ui/flow/setting/setting_view_model.dart +++ b/app/lib/ui/flow/setting/setting_view_model.dart @@ -51,6 +51,7 @@ class SettingViewNotifier extends StateNotifier { error: error, stackTrace: stack, ); + state = state.copyWith(error: error, loading: false); } } @@ -60,7 +61,7 @@ class SettingViewNotifier extends StateNotifier { await userService.signOut(); state = state.copyWith(signingOut: false, logOut: true); } catch (error, stack) { - state = state.copyWith(error: error); + state = state.copyWith(error: error, signingOut: false); logger.e( 'SettingViewNotifier: error while sign out', error: error, diff --git a/app/lib/ui/flow/setting/space/edit_space_view_model.dart b/app/lib/ui/flow/setting/space/edit_space_view_model.dart index dbfba259..727e37c0 100644 --- a/app/lib/ui/flow/setting/space/edit_space_view_model.dart +++ b/app/lib/ui/flow/setting/space/edit_space_view_model.dart @@ -50,7 +50,7 @@ class EditSpaceViewNotifier extends StateNotifier { error: error, stackTrace: stack ); - state = state.copyWith(error: error); + state = state.copyWith(error: error, loading: false); } } @@ -70,7 +70,7 @@ class EditSpaceViewNotifier extends StateNotifier { error: error, stackTrace: stack ); - state = state.copyWith(error: error); + state = state.copyWith(error: error, saving: false); } } @@ -85,7 +85,7 @@ class EditSpaceViewNotifier extends StateNotifier { error: error, stackTrace: stack, ); - state = state.copyWith(error: error); + state = state.copyWith(error: error, deleting: false); } } @@ -100,7 +100,7 @@ class EditSpaceViewNotifier extends StateNotifier { error: error, stackTrace: stack, ); - state = state.copyWith(error: error); + state = state.copyWith(error: error, deleted: false); } } diff --git a/app/lib/ui/flow/space/create/create_space_view_model.dart b/app/lib/ui/flow/space/create/create_space_view_model.dart index a89b74e2..306190c7 100644 --- a/app/lib/ui/flow/space/create/create_space_view_model.dart +++ b/app/lib/ui/flow/space/create/create_space_view_model.dart @@ -27,7 +27,7 @@ class CreateSpaceViewNotifier extends StateNotifier { final invitationCode = await spaceService.createSpaceAndGetInviteCode(state.spaceName.text); state = state.copyWith(isCreating: false, invitationCode: invitationCode); } catch (error, stack) { - state = state.copyWith(error: error); + state = state.copyWith(error: error, isCreating: false); logger.e( 'CreateSpaceViewNotifier: $error - error while creating new space', error: error, diff --git a/app/lib/ui/flow/space/join/join_space_view_model.dart b/app/lib/ui/flow/space/join/join_space_view_model.dart index fc8f0e9d..5e8bfc7d 100644 --- a/app/lib/ui/flow/space/join/join_space_view_model.dart +++ b/app/lib/ui/flow/space/join/join_space_view_model.dart @@ -49,7 +49,7 @@ class JoinSpaceViewNotifier extends StateNotifier { final space = await spaceService.getSpace(spaceId); state = state.copyWith(verifying: false, space: space, spaceJoined: true); } catch (error, stack) { - state = state.copyWith(error: error); + state = state.copyWith(error: error, verifying: false); logger.e( 'JoinSpaceViewNotifier: Error while join space with invitation code', error: error,