Skip to content

Commit

Permalink
show prompt for report send
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-ishita-g committed Jun 7, 2024
1 parent 502748a commit 7bf636f
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 24 deletions.
3 changes: 2 additions & 1 deletion app/assets/locales/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
8 changes: 4 additions & 4 deletions app/lib/ui/components/alert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ Future<void> showConfirmation(

Future<void> showOkayConfirmation(
BuildContext context, {
required String title,
required String message,
String? title,
String? message,
bool isDestructiveAction = true,
VoidCallback? onOkay,
}) {
Expand All @@ -63,8 +63,8 @@ Future<void> 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,
Expand Down
2 changes: 1 addition & 1 deletion app/lib/ui/flow/home/home_screen_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class HomeViewNotifier extends StateNotifier<HomeViewState> {
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,
Expand Down
29 changes: 18 additions & 11 deletions app/lib/ui/flow/setting/contact_support/contact_support_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -33,7 +34,7 @@ class _ContactSupportScreenState extends ConsumerState<ContactSupportScreen> {
Widget build(BuildContext context) {
notifier = ref.watch(contactSupportViewStateProvider.notifier);
final state = ref.watch(contactSupportViewStateProvider);
_observePop();
_showReportSentPrompt();
_observeError();

return AppPage(
Expand Down Expand Up @@ -199,21 +200,27 @@ class _ContactSupportScreenState extends ConsumerState<ContactSupportScreen> {
);
}

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) {
showErrorSnackBar(context, next.toString());
}
});
}

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();
},
);
}
});
}
}
3 changes: 2 additions & 1 deletion app/lib/ui/flow/setting/setting_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class SettingViewNotifier extends StateNotifier<SettingViewState> {
error: error,
stackTrace: stack,
);
state = state.copyWith(error: error, loading: false);
}
}

Expand All @@ -60,7 +61,7 @@ class SettingViewNotifier extends StateNotifier<SettingViewState> {
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,
Expand Down
8 changes: 4 additions & 4 deletions app/lib/ui/flow/setting/space/edit_space_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class EditSpaceViewNotifier extends StateNotifier<EditSpaceViewState> {
error: error,
stackTrace: stack
);
state = state.copyWith(error: error);
state = state.copyWith(error: error, loading: false);
}
}

Expand All @@ -70,7 +70,7 @@ class EditSpaceViewNotifier extends StateNotifier<EditSpaceViewState> {
error: error,
stackTrace: stack
);
state = state.copyWith(error: error);
state = state.copyWith(error: error, saving: false);
}
}

Expand All @@ -85,7 +85,7 @@ class EditSpaceViewNotifier extends StateNotifier<EditSpaceViewState> {
error: error,
stackTrace: stack,
);
state = state.copyWith(error: error);
state = state.copyWith(error: error, deleting: false);
}
}

Expand All @@ -100,7 +100,7 @@ class EditSpaceViewNotifier extends StateNotifier<EditSpaceViewState> {
error: error,
stackTrace: stack,
);
state = state.copyWith(error: error);
state = state.copyWith(error: error, deleted: false);
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/lib/ui/flow/space/create/create_space_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CreateSpaceViewNotifier extends StateNotifier<CreateSpaceViewState> {
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,
Expand Down
2 changes: 1 addition & 1 deletion app/lib/ui/flow/space/join/join_space_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class JoinSpaceViewNotifier extends StateNotifier<JoinSpaceViewState> {
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,
Expand Down

0 comments on commit 7bf636f

Please sign in to comment.