Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: finishing touch generosity challenge #769

Merged
merged 3 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/app/injection/injection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ void initRepositories() {
() => GenerosityChallengeVpcRepository(
getIt(),
getIt(),
getIt(),
getIt(),
),
)
..registerLazySingleton<GenerosityChallengeVpcSetupCubit>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,13 @@ class GenerosityChallengeVpcSetupCubit
);
}

//TODO after KIDS-958 is done, deactivate challenge

void _navigateToLogin() {
_vpcRepository.completeChallenge();
emitCustom(const GenerosityChallengeVpcSetupCustom.navigateToLogin());
}


void _navigateToFamilyOverview() {
_vpcRepository.completeChallenge();
emitCustom(
const GenerosityChallengeVpcSetupCustom.navigateToFamilyOverview(),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:givt_app/app/injection/injection.dart';
import 'package:givt_app/app/routes/pages.dart';
import 'package:givt_app/features/children/add_member/widgets/vpc_page.dart';
import 'package:givt_app/features/children/generosity_challenge/cubit/generosity_challenge_cubit.dart';
import 'package:givt_app/features/children/generosity_challenge/cubit/generosity_challenge_vpc_setup_cubit.dart';
import 'package:givt_app/features/children/generosity_challenge/cubit/generosity_challenge_vpc_setup_custom.dart';
import 'package:givt_app/shared/widgets/base/base_state_consumer.dart';
Expand Down Expand Up @@ -47,9 +49,9 @@ class _GenerosityChallengeVpcSetupPageState
BuildContext context, GenerosityChallengeVpcSetupCustom custom) {
switch (custom) {
case NavigateToFamilyOverview():
context.pushNamed(Pages.childrenOverview.name);
context.goNamed(Pages.childrenOverview.name);
case NavigateToLogin():
context.pushNamed(Pages.welcome.name);
context.goNamed(Pages.welcome.name);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@ import 'package:givt_app/features/auth/repositories/auth_repository.dart';
import 'package:givt_app/features/children/add_member/models/member.dart';
import 'package:givt_app/features/children/add_member/repository/add_member_repository.dart';
import 'package:givt_app/features/children/generosity_challenge/domain/exceptions/not_logged_in_exception.dart';
import 'package:givt_app/features/children/generosity_challenge/repositories/generosity_challenge_repository.dart';
import 'package:givt_app/features/children/generosity_challenge/utils/generosity_challenge_helper.dart';
import 'package:givt_app/features/children/generosity_challenge_chat/chat_scripts/models/chat_script_item.dart';
import 'package:givt_app/features/children/generosity_challenge_chat/chat_scripts/repositories/chat_history_repository.dart';

class GenerosityChallengeVpcRepository {
const GenerosityChallengeVpcRepository(
this._addMemberRepository,
this._authRepository,
this._chatHistoryRepository,
this._generosityChallengeRepository,
);

final AddMemberRepository _addMemberRepository;
final AuthRepository _authRepository;
final ChatHistoryRepository _chatHistoryRepository;
final GenerosityChallengeRepository _generosityChallengeRepository;

Future<void> addMembers(List<Member> list) async {
try {
Expand Down Expand Up @@ -44,4 +52,11 @@ class GenerosityChallengeVpcRepository {
throw const NotLoggedInException();
}
}

Future<void> completeChallenge() async {
await _generosityChallengeRepository.clearCache();
await _generosityChallengeRepository.clearUserData();
await _chatHistoryRepository.saveChatHistory(const ChatScriptItem.empty());
await GenerosityChallengeHelper.complete();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class GenerosityChallengeContentHelper {
title: 'Keep the generosity alive',
buttonText: 'Yeah sure!',
description:
"Foster your children's spirit of giving with a recurring giving allowance. It's a simple way to encourage a lifelong habit of kindness. \n\nAre you ready to help them become generous individuals?",
"Let's setup a recurring giving allowance to encourage a lifelong habit of generosity.\n\nAre you ready to help them become generous individuals?",
redirect: Pages.allowanceFlow.path,
onTap: () {},
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,7 @@ class GenerosityDailyCard extends StatelessWidget {
if (description.isNotEmpty)
Text(
description,
// if we are filling in description
// with user selection it is left aligned
// with the default description it is justified
textAlign: dynamicDescription.isNotEmpty
? TextAlign.left
: TextAlign.justify,
textAlign: TextAlign.left,
style: const TextStyle(
color: AppTheme.givtGreen40,
fontSize: 18,
Expand Down