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

New Summary Screen Reflect & Share (KIDS-1395) #1061

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
1 change: 1 addition & 0 deletions lib/core/enums/amplitude_events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ enum AmplitudeEvents {
reflectAndShareResultNextRoundClicked(
'reflect_and_share_result_next_round_clicked',
),
familyReflectSummaryBackToHome('family_reflect_summary_back_to_home'),

// DEBUG ONLY
debugButtonClicked('debug_button_clicked'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class _ProfileSelectionScreenState extends State<ProfileSelectionScreen> {
onTap: () => context.goNamed(
FamilyPages.reflectIntro.name,
),
text: 'Reflect & Share',
text: 'Graditude game',
analyticsEvent: AnalyticsEvent(
AmplitudeEvents.reflectAndShareClicked,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class InterviewCubit extends CommonCubit<RecordAnswerUIModel, GameProfile> {

// Advance to the next reporter/question
void advanceToNext() {
_reflectAndShareRepository.totalQuestionsAsked++;
_nrOfQuestionsAsked++;
if (_isLastQuestion()) {
interviewFinished();
Expand Down Expand Up @@ -100,4 +101,8 @@ class InterviewCubit extends CommonCubit<RecordAnswerUIModel, GameProfile> {
),
);
}

void increaseTimeSpent() {
_reflectAndShareRepository.totalTimeSpent++;
}
}
25 changes: 25 additions & 0 deletions lib/features/family/features/reflect/bloc/summary_cubit.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:givt_app/features/family/features/reflect/domain/models/summary_details.dart';
import 'package:givt_app/features/family/features/reflect/domain/reflect_and_share_repository.dart';
import 'package:givt_app/shared/bloc/base_state.dart';
import 'package:givt_app/shared/bloc/common_cubit.dart';

class SummaryCubit extends CommonCubit<SummaryDetails, dynamic> {
SummaryCubit(this._reflectAndShareRepository)
: super(const BaseState.loading());

final ReflectAndShareRepository _reflectAndShareRepository;

void init() {
final totalMinutesPlayed =
(_reflectAndShareRepository.totalTimeSpent / 60).round();
final amountOfQuestionsAsked =
_reflectAndShareRepository.totalQuestionsAsked;

emitData(
SummaryDetails(
minutesPlayed: totalMinutesPlayed,
questionsAsked: amountOfQuestionsAsked,
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class SummaryDetails {
SummaryDetails({required this.minutesPlayed, required this.questionsAsked});

int minutesPlayed;
int questionsAsked;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class ReflectAndShareRepository {
final ProfilesRepository _profilesRepository;

int completedLoops = 0;
int totalQuestionsAsked = 0;
int totalTimeSpent = 0;

List<GameProfile>? _allProfiles;
List<GameProfile> _selectedProfiles = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class _RecordAnswerScreenState extends State<RecordAnswerScreen> {

if (!mounted) return;
setState(() {
cubit.increaseTimeSpent();
_remainingSeconds--;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class _ReflectIntroScreenState extends State<ReflectIntroScreen> {
create: (_) => _cubit,
child: FunScaffold(
appBar: const FunTopAppBar(
title: 'Reflect and share',
title: 'Graditude game',
leading: GivtBackButtonFlat(),
),
body: BlocConsumer<FamilyOverviewCubit, FamilyOverviewState>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:givt_app/features/family/app/injection.dart';
import 'package:givt_app/features/family/extensions/extensions.dart';
import 'package:givt_app/features/family/features/reflect/bloc/result_cubit.dart';
import 'package:givt_app/features/family/features/reflect/presentation/pages/family_roles_screen.dart';
import 'package:givt_app/features/family/features/reflect/presentation/pages/summary_screen.dart';
import 'package:givt_app/features/family/shared/design/components/components.dart';
import 'package:givt_app/features/family/shared/design/illustrations/fun_icon.dart';
import 'package:givt_app/features/family/shared/widgets/texts/shared_texts.dart';
Expand Down Expand Up @@ -94,11 +95,8 @@ class _ResultScreenState extends State<ResultScreen> {
],
FunButton.secondary(
onTap: () {
Navigator.of(context).popUntil(
ModalRoute.withName(
FamilyPages.profileSelection.name,
),
);
Navigator.of(context)
.push(const SummaryScreen().toRoute(context));
},
text: 'Finish reflecting',
analyticsEvent: AnalyticsEvent(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:givt_app/core/enums/amplitude_events.dart';
import 'package:givt_app/features/family/app/family_pages.dart';
import 'package:givt_app/features/family/app/injection.dart';
import 'package:givt_app/features/family/features/reflect/bloc/summary_cubit.dart';
import 'package:givt_app/features/family/shared/design/components/components.dart';
import 'package:givt_app/features/family/shared/widgets/buttons/givt_back_button_flat.dart';
import 'package:givt_app/features/family/shared/widgets/texts/shared_texts.dart';
import 'package:givt_app/shared/models/analytics_event.dart';
import 'package:givt_app/shared/widgets/base/base_state_consumer.dart';
import 'package:givt_app/shared/widgets/fun_scaffold.dart';

class SummaryScreen extends StatefulWidget {
const SummaryScreen({super.key});

@override
State<SummaryScreen> createState() => _SummaryScreenState();
}

class _SummaryScreenState extends State<SummaryScreen> {
final _cubit = SummaryCubit(getIt());

@override
void didChangeDependencies() {
super.didChangeDependencies();
_cubit.init();
}

@override
Widget build(BuildContext context) {
return FunScaffold(
appBar: const FunTopAppBar(
title: 'Awesome work heroes!',
leading: GivtBackButtonFlat(),
),
body: BaseStateConsumer(
cubit: _cubit,
onData: (context, secretWord) {
return Column(
children: [
const Spacer(),
const TitleMediumText(
'Your mission to connect through conversation was a success!',
textAlign: TextAlign.center,
),
const SizedBox(height: 16),
SvgPicture.asset('assets/family/images/family_superheroes.svg'),
const SizedBox(height: 32),
Row(
children: [
Expanded(
child: FunTile.gold(
titleBig:
'${secretWord.minutesPlayed} minutes family time',
iconData: FontAwesomeIcons.solidClock,
assetSize: 32,
),
),
const SizedBox(width: 16),
Expanded(
child: FunTile.blue(
titleBig: '${secretWord.questionsAsked} questions asked',
iconData: FontAwesomeIcons.solidCircleQuestion,
assetSize: 32,
),
),
],
),
const Spacer(),
FunButton(
onTap: () {
Navigator.of(context).popUntil(
ModalRoute.withName(
FamilyPages.profileSelection.name,
),
);
},
text: 'Back to home',
analyticsEvent: AnalyticsEvent(
AmplitudeEvents.familyReflectSummaryBackToHome,
),
),
],
);
},
),
);
}
}
Loading