From c71bf423adeeae48658ef3a246cbdc193f354653 Mon Sep 17 00:00:00 2001 From: Maikel Stuivenberg Date: Tue, 25 Jun 2024 17:06:34 +0200 Subject: [PATCH 1/2] Add logout functionality on empty-state page --- .../screens/profile_selection_screen.dart | 2 +- .../widgets/profiles_empty_state_widget.dart | 58 ++++++++++++++----- 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/lib/features/family/features/profiles/screens/profile_selection_screen.dart b/lib/features/family/features/profiles/screens/profile_selection_screen.dart index c63927e05..88a576c15 100644 --- a/lib/features/family/features/profiles/screens/profile_selection_screen.dart +++ b/lib/features/family/features/profiles/screens/profile_selection_screen.dart @@ -128,7 +128,7 @@ class _ProfileSelectionScreenState extends State { ), body: state is ProfilesLoadingState ? const CustomCircularProgressIndicator() - : state.children.isEmpty && state.parents.isEmpty + : state.children.isEmpty ? ProfilesEmptyStateWidget( onRetry: () => context .read() diff --git a/lib/features/family/features/profiles/widgets/profiles_empty_state_widget.dart b/lib/features/family/features/profiles/widgets/profiles_empty_state_widget.dart index 40999849b..e14c77921 100644 --- a/lib/features/family/features/profiles/widgets/profiles_empty_state_widget.dart +++ b/lib/features/family/features/profiles/widgets/profiles_empty_state_widget.dart @@ -1,5 +1,13 @@ import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:givt_app/app/routes/pages.dart'; +import 'package:givt_app/core/enums/amplitude_events.dart'; +import 'package:givt_app/features/auth/cubit/auth_cubit.dart'; +import 'package:givt_app/features/family/shared/widgets/givt_elevated_button.dart'; +import 'package:givt_app/features/family/shared/widgets/givt_elevated_secondary_button.dart'; import 'package:givt_app/utils/utils.dart'; +import 'package:go_router/go_router.dart'; class ProfilesEmptyStateWidget extends StatelessWidget { const ProfilesEmptyStateWidget({ @@ -13,26 +21,46 @@ class ProfilesEmptyStateWidget extends StatelessWidget { Widget build(BuildContext context) { return Center( child: Padding( - padding: const EdgeInsets.all(50), + padding: const EdgeInsets.all(24), child: Column( mainAxisSize: MainAxisSize.min, children: [ - const Text( - 'There are no profiles attached to the current user.', - textAlign: TextAlign.center, - style: TextStyle( - color: AppTheme.givt4KidsBlue, - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), + Text('There are no profiles attached to the current user.', + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.bodyMedium), const SizedBox( - height: 25, + height: 24, ), - ElevatedButton.icon( - onPressed: onRetry, - icon: const Icon(Icons.refresh_rounded), - label: const Text("Retry"), + Row( + children: [ + Expanded( + child: GivtElevatedSecondaryButton( + onTap: () { + AnalyticsHelper.logEvent( + eventName: AmplitudeEvents.logOutPressed, + ); + + context.read().logout(); + context.goNamed(Pages.welcome.name); + }, + text: 'Logout', + leftIcon: SvgPicture.asset( + 'assets/family/images/logout.svg', + width: 36, + ), + ), + ), + const SizedBox( + width: 16, + ), + Expanded( + child: GivtElevatedButton( + onTap: onRetry, + text: 'Retry', + leftIcon: Icons.refresh_rounded, + ), + ), + ], ), ], ), From 234ab0bc2b99bfb2e7d08cd8689996b03c543ab8 Mon Sep 17 00:00:00 2001 From: Maikel Stuivenberg Date: Tue, 25 Jun 2024 17:18:44 +0200 Subject: [PATCH 2/2] use existing functionality --- .../widgets/profiles_empty_state_widget.dart | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/features/family/features/profiles/widgets/profiles_empty_state_widget.dart b/lib/features/family/features/profiles/widgets/profiles_empty_state_widget.dart index e14c77921..2af2dd090 100644 --- a/lib/features/family/features/profiles/widgets/profiles_empty_state_widget.dart +++ b/lib/features/family/features/profiles/widgets/profiles_empty_state_widget.dart @@ -4,6 +4,7 @@ import 'package:flutter_svg/svg.dart'; import 'package:givt_app/app/routes/pages.dart'; import 'package:givt_app/core/enums/amplitude_events.dart'; import 'package:givt_app/features/auth/cubit/auth_cubit.dart'; +import 'package:givt_app/features/family/features/auth/helpers/logout_helper.dart'; import 'package:givt_app/features/family/shared/widgets/givt_elevated_button.dart'; import 'package:givt_app/features/family/shared/widgets/givt_elevated_secondary_button.dart'; import 'package:givt_app/utils/utils.dart'; @@ -25,9 +26,11 @@ class ProfilesEmptyStateWidget extends StatelessWidget { child: Column( mainAxisSize: MainAxisSize.min, children: [ - Text('There are no profiles attached to the current user.', - textAlign: TextAlign.center, - style: Theme.of(context).textTheme.bodyMedium), + Text( + 'There are no profiles attached to the current user.', + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.bodyMedium, + ), const SizedBox( height: 24, ), @@ -35,14 +38,7 @@ class ProfilesEmptyStateWidget extends StatelessWidget { children: [ Expanded( child: GivtElevatedSecondaryButton( - onTap: () { - AnalyticsHelper.logEvent( - eventName: AmplitudeEvents.logOutPressed, - ); - - context.read().logout(); - context.goNamed(Pages.welcome.name); - }, + onTap: () => logout(context, fromLogoutBtn: true), text: 'Logout', leftIcon: SvgPicture.asset( 'assets/family/images/logout.svg',