Skip to content

Commit

Permalink
Merge pull request #707 from givtnl/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
MaikelStuivenberg authored Apr 29, 2024
2 parents ddf89b2 + c8e4e80 commit 868200d
Show file tree
Hide file tree
Showing 51 changed files with 1,478 additions and 712 deletions.
10 changes: 1 addition & 9 deletions lib/app/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'package:givt_app/app/injection/injection.dart';
import 'package:givt_app/app/routes/app_router.dart';
import 'package:givt_app/core/notification/notification.dart';
import 'package:givt_app/features/auth/cubit/auth_cubit.dart';
import 'package:givt_app/features/children/goal_tracker/cubit/goal_tracker_cubit.dart';
import 'package:givt_app/features/impact_groups/cubit/impact_groups_cubit.dart';
import 'package:givt_app/l10n/l10n.dart';
import 'package:givt_app/shared/bloc/infra/infra_cubit.dart';
Expand Down Expand Up @@ -73,16 +72,9 @@ class _AppState extends State<App> {
),
lazy: false,
),
BlocProvider(
create: (context) => GoalTrackerCubit(
getIt(),
getIt(),
context.read<AuthCubit>(),
),
lazy: false,
),
BlocProvider(
create: (context) => ImpactGroupsCubit(
getIt(),
getIt(),
context.read<AuthCubit>(),
),
Expand Down
6 changes: 0 additions & 6 deletions lib/app/injection/injection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import 'package:givt_app/features/children/details/repositories/child_details_re
import 'package:givt_app/features/children/edit_child/repositories/create_child_repository.dart';
import 'package:givt_app/features/children/edit_profile/repositories/edit_profile_repository.dart';
import 'package:givt_app/features/children/family_goal/repositories/create_family_goal_repository.dart';
import 'package:givt_app/features/children/goal_tracker/repository/goal_tracker_repository.dart';
import 'package:givt_app/features/children/family_history/repository/family_history_repository.dart';
import 'package:givt_app/features/children/generosity_challenge/repositories/generosity_challenge_repository.dart';
import 'package:givt_app/features/children/overview/repositories/family_overview_repository.dart';
Expand Down Expand Up @@ -210,11 +209,6 @@ void initRepositories() {
getIt(),
),
)
..registerLazySingleton<GoalTrackerRepository>(
() => GoalTrackerRepositoryImpl(
getIt(),
),
)
..registerLazySingleton<CreateFamilyGoalRepository>(
() => CreateFamilyGoalRepositoryImpl(
getIt(),
Expand Down
24 changes: 20 additions & 4 deletions lib/app/routes/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import 'package:givt_app/features/children/edit_child/pages/edit_child_page.dart
import 'package:givt_app/features/children/edit_profile/cubit/edit_profile_cubit.dart';
import 'package:givt_app/features/children/family_goal/cubit/create_family_goal_cubit.dart';
import 'package:givt_app/features/children/family_goal/pages/create_family_goal_flow_page.dart';
import 'package:givt_app/features/children/goal_tracker/cubit/goal_tracker_cubit.dart';
import 'package:givt_app/features/children/family_history/family_history_cubit/family_history_cubit.dart';
import 'package:givt_app/features/children/generosity_challenge/cubit/generosity_challenge_cubit.dart';
import 'package:givt_app/features/children/generosity_challenge/pages/generosity_challenge.dart';
Expand All @@ -40,7 +39,10 @@ import 'package:givt_app/features/give/pages/organization_list_page.dart';
import 'package:givt_app/features/give/pages/qr_code_scan_page.dart';
import 'package:givt_app/features/give/pages/select_giving_way_page.dart';
import 'package:givt_app/features/give/pages/success_donation_page.dart';
import 'package:givt_app/features/impact_groups/impact_group_join_success_page.dart';
import 'package:givt_app/features/impact_groups/cubit/impact_groups_cubit.dart';
import 'package:givt_app/features/impact_groups/models/impact_group.dart';
import 'package:givt_app/features/impact_groups/pages/impact_group_details_page.dart';
import 'package:givt_app/features/impact_groups/pages/impact_group_join_success_page.dart';
import 'package:givt_app/features/overview/bloc/givt_bloc.dart';
import 'package:givt_app/features/overview/pages/overview_page.dart';
import 'package:givt_app/features/permit_biometric/cubit/permit_biometric_cubit.dart';
Expand Down Expand Up @@ -214,11 +216,11 @@ class AppRouter {
path: Pages.childrenOverview.path,
name: Pages.childrenOverview.name,
builder: (context, state) {
bool showAllowanceWarning = false;
var showAllowanceWarning = false;
if (state.extra != null) {
showAllowanceWarning = state.extra!.toString().contains('true');
}
context.read<GoalTrackerCubit>().getGoal();
context.read<ImpactGroupsCubit>().fetchImpactGroups();
return MultiBlocProvider(
providers: [
BlocProvider(
Expand Down Expand Up @@ -471,6 +473,20 @@ class AppRouter {
name: Pages.joinImpactGroupSuccess.name,
builder: (context, state) => const ImpactGroupJoinSuccessPage(),
),
GoRoute(
path: Pages.impactGroupDetails.path,
name: Pages.impactGroupDetails.name,
builder: (context, state) => BlocProvider(
create: (_) => GiveBloc(
getIt(),
getIt(),
getIt(),
getIt(),
),
child: ImpactGroupDetailsPage(
impactGroup: state.extra! as ImpactGroup),
),
),
GoRoute(
path: Pages.sepaMandateExplanation.path,
name: Pages.sepaMandateExplanation.name,
Expand Down
5 changes: 5 additions & 0 deletions lib/app/routes/pages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ enum Pages {
name: 'JOIN-IMPACT-GROUP-SUCCESS',
),
permitBiometric(path: 'permit-biometric', name: 'PERMIT-BIOMETRIC'),

impactGroupDetails(
path: 'impact-group-details',
name: 'IMPACT-GROUP-DETAILS',
),
;

const Pages({
Expand Down
4 changes: 3 additions & 1 deletion lib/core/enums/amplitude_events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ enum AmplitudeEvents {
utm('utm'),

giveToFamilyGoalDirectly('give_to_family_goal_directly'),
giveToFamilyGoalViaOptions('give_to_family_goal_via_options'),

skipBiometricWhenRegistered('skip_biometric_when_registered'),
activateBiometricWhenRegistered('activate_biometric_when_registered'),
Expand All @@ -88,6 +87,9 @@ enum AmplitudeEvents {
generosityChallengeDayUndoCompleting(
'generosity_challenge_day_undo_completing',
),

impactGroupDetailsReadMoreClicked('impact_group_details_read_more_clicked'),
impactGroupDetailsGiveClicked('impact_group_details_give_clicked'),
;

const AmplitudeEvents(this.value);
Expand Down
20 changes: 0 additions & 20 deletions lib/core/network/api_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -976,29 +976,9 @@ class APIService {
body: jsonDecode(response.body) as Map<String, dynamic>,
);
}

final decodedBody = jsonDecode(response.body) as Map<String, dynamic>;
final itemMap = decodedBody['items']! as List<dynamic>;
return itemMap;
}

Future<Map<String, dynamic>> fetchFamilyGoal() async {
final url = Uri.https(_apiURL, '/givtservice/v1/goal/family/latest');
final response = await client.get(url);

if (response.statusCode >= 400 && response.statusCode < 500) {
return {};
}

if (response.statusCode >= 500) {
throw GivtServerFailure(
statusCode: response.statusCode,
body: jsonDecode(response.body) as Map<String, dynamic>,
);
}

final decodedBody = jsonDecode(response.body) as Map<String, dynamic>;
final itemMap = decodedBody['item']! as Map<String, dynamic>;
return itemMap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:givt_app/app/routes/routes.dart';
import 'package:givt_app/core/enums/enums.dart';
import 'package:givt_app/features/children/family_goal/cubit/create_family_goal_cubit.dart';
import 'package:givt_app/features/children/family_goal/widgets/family_goal_circle.dart';
import 'package:givt_app/features/children/goal_tracker/cubit/goal_tracker_cubit.dart';
import 'package:givt_app/features/impact_groups/cubit/impact_groups_cubit.dart';
import 'package:givt_app/l10n/l10n.dart';
import 'package:givt_app/utils/utils.dart';
import 'package:go_router/go_router.dart';
Expand All @@ -27,7 +27,7 @@ class CreateFamilyGoalConfirmedPage extends StatelessWidget {
CloseButton(
color: AppTheme.givtBlue,
onPressed: () {
context.read<GoalTrackerCubit>().getGoal();
context.read<ImpactGroupsCubit>().fetchImpactGroups();

context
..pop()
Expand Down
53 changes: 53 additions & 0 deletions lib/features/children/family_goal/pages/family_goal_tracker.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:givt_app/app/routes/pages.dart';
import 'package:givt_app/features/impact_groups/models/goal.dart';
import 'package:givt_app/features/children/family_goal/pages/goal_active_widget.dart';
import 'package:givt_app/features/children/family_goal/pages/goal_completed_widget.dart';
import 'package:givt_app/features/children/family_goal/pages/no_goal_set_widget.dart';
import 'package:givt_app/features/children/overview/cubit/family_overview_cubit.dart';
import 'package:givt_app/features/impact_groups/cubit/impact_groups_cubit.dart';
import 'package:givt_app/utils/app_theme.dart';
import 'package:go_router/go_router.dart';

class FamilyGoalTracker extends StatelessWidget {
const FamilyGoalTracker({super.key});

@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
if (context.read<ImpactGroupsCubit>().state.isFamilyGoalDismissed) {
context.pushNamed(
Pages.createFamilyGoal.name,
extra: context.read<FamilyOverviewCubit>(),
);
}
},
child: Container(
width: double.infinity,
margin: const EdgeInsets.all(24),
decoration: ShapeDecoration(
color: AppTheme.primary98,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: BlocBuilder<ImpactGroupsCubit, ImpactGroupsState>(
builder: (context, state) {
if (state.isFamilyGoalDismissed) {
return const NoGoalSetWidget();
}
if (state.familyGroup.goal.status == FamilyGoalStatus.completed) {
return const GoalCompletedWidget();
}
if (state.familyGroup.goal.status == FamilyGoalStatus.inProgress) {
return const GoalActiveWidget();
}
return const NoGoalSetWidget();
},
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:givt_app/features/children/goal_tracker/cubit/goal_tracker_cubit.dart';
import 'package:givt_app/features/children/goal_tracker/widgets/gradient_progress_bar.dart';
import 'package:givt_app/utils/app_theme.dart';
import 'package:givt_app/features/impact_groups/cubit/impact_groups_cubit.dart';
import 'package:givt_app/l10n/l10n.dart';
import 'package:givt_app/shared/widgets/goal_progress_bar/goal_progress_bar.dart';

class GoalActiveWidget extends StatelessWidget {
const GoalActiveWidget({super.key});

@override
Widget build(BuildContext context) {
return BlocBuilder<GoalTrackerCubit, GoalTrackerState>(
return BlocBuilder<ImpactGroupsCubit, ImpactGroupsState>(
builder: (context, state) {
final currentGoal = state.activeGoal;
final org = state.organisation;
final progress = currentGoal.amount / currentGoal.goalAmount.toDouble();
final totalProgress =
currentGoal.totalAmount / currentGoal.goalAmount.toDouble();
final currentGoal = state.familyGoal;
final org = state.familyGroup.organisation;
return Padding(
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 32),
child: Column(
Expand All @@ -33,7 +30,7 @@ class GoalActiveWidget extends StatelessWidget {
),
const SizedBox(height: 4),
Text(
'Family Goal: \$${currentGoal.goalAmount}',
'${context.l10n.familyGoalPrefix}\$${currentGoal.goalAmount}',
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
fontFamily: 'Mulish',
fontWeight: FontWeight.w400,
Expand All @@ -42,17 +39,7 @@ class GoalActiveWidget extends StatelessWidget {
const SizedBox(height: 4),
Padding(
padding: const EdgeInsets.only(top: 16, bottom: 8),
child: GradientProgressBar(
progress: progress > 1 ? 1 : progress,
totalProgress: totalProgress > 1 ? 1 : totalProgress,
colors: const [
AppTheme.highlight90,
AppTheme.progressGradient1,
AppTheme.progressGradient2,
AppTheme.progressGradient3,
AppTheme.primary70,
],
),
child: GoalProgressBar(goal: currentGoal),
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:givt_app/features/children/goal_tracker/cubit/goal_tracker_cubit.dart';
import 'package:givt_app/features/impact_groups/cubit/impact_groups_cubit.dart';

class GoalCompletedWidget extends StatelessWidget {
const GoalCompletedWidget({super.key});

@override
Widget build(BuildContext context) {
final state = context.read<GoalTrackerCubit>().state;
final org = state.organisation;
final impactGroupsCubit = context.watch<ImpactGroupsCubit>();
final org = impactGroupsCubit.state.familyGroup.organisation;
return Stack(children: [
Positioned(
right: 0,
child: IconButton(
onPressed: () {
context.read<GoalTrackerCubit>().clearGoal();
},
onPressed: () => impactGroupsCubit
.dismissGoal(impactGroupsCubit.state.familyGroup.goal.id),
icon: const Icon(
FontAwesomeIcons.xmark,
size: 20,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:givt_app/core/enums/enums.dart';
import 'package:givt_app/features/children/goal_tracker/cubit/goal_tracker_cubit.dart';
import 'package:givt_app/features/children/family_history/family_history_cubit/family_history_cubit.dart';
import 'package:givt_app/features/children/family_history/models/child_donation.dart';
import 'package:givt_app/features/children/family_history/models/child_donation_helper.dart';
import 'package:givt_app/features/children/overview/cubit/family_overview_cubit.dart';
import 'package:givt_app/features/children/parental_approval/dialogs/parental_approval_dialog.dart';
import 'package:givt_app/features/impact_groups/cubit/impact_groups_cubit.dart';
import 'package:givt_app/l10n/l10n.dart';
import 'package:givt_app/utils/string_datetime_extension.dart';
import 'package:givt_app/utils/utils.dart';
Expand Down Expand Up @@ -46,7 +46,7 @@ class _PendingDonationWidgetState extends State<PendingDonationWidget> {

final familyHystoryCubit = context.read<FamilyHistoryCubit>();
final familyOverviewCubit = context.read<FamilyOverviewCubit>();
final goalTrackercubit = context.read<GoalTrackerCubit>();
final impactGroupsCubit = context.read<ImpactGroupsCubit>();

await showDialog<void>(
barrierDismissible: false,
Expand All @@ -60,7 +60,7 @@ class _PendingDonationWidgetState extends State<PendingDonationWidget> {
value: familyOverviewCubit,
),
BlocProvider.value(
value: goalTrackercubit,
value: impactGroupsCubit,
),
],
child: ParentalApprovalDialog(
Expand Down
Loading

0 comments on commit 868200d

Please sign in to comment.