Skip to content

Commit

Permalink
Merge pull request #779 from givtnl/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
MaikelStuivenberg authored May 31, 2024
2 parents 834cb9b + dbb4183 commit a782934
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 109 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
LOGIT_API_KEY: ${{ secrets.LOGIT_API_KEY }}
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
with:
flutter-version: '3.22.x'
flutter-version: '3.19.x'

ios:
needs: linter
Expand All @@ -52,7 +52,7 @@ jobs:
LOGIT_API_KEY: ${{ secrets.LOGIT_API_KEY }}
GOOGLE_SERVICES_PLIST: ${{ secrets.GOOGLE_SERVICES_PLIST }}
with:
flutter-version: '3.22.x'
flutter-version: '3.19.x'


semantic-pr:
Expand Down
26 changes: 26 additions & 0 deletions lib/features/children/add_member/cubit/add_member_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class AddMemberCubit extends Cubit<AddMemberState> {
emit(state.copyWith(nrOfForms: state.nrOfForms + 1));

void validateForms() {
LoggingInfo.instance.info(
'Validate forms',
methodName: 'validateForms',
);
emit(
state.copyWith(
members: state.members,
Expand All @@ -40,6 +44,10 @@ class AddMemberCubit extends Cubit<AddMemberState> {
}

void resetFormStatus() {
LoggingInfo.instance.info(
'Reset form status',
methodName: 'resetFormStatus',
);
emit(
state.copyWith(
members: state.members,
Expand All @@ -50,6 +58,10 @@ class AddMemberCubit extends Cubit<AddMemberState> {
}

void allFormsFilled() {
LoggingInfo.instance.info(
'All forms filled (hasChildren: ${state.hasChildren})',
methodName: 'allFormsFilled',
);
if (state.hasChildren) {
emit(
state.copyWith(
Expand All @@ -70,6 +82,10 @@ class AddMemberCubit extends Cubit<AddMemberState> {
}

void dismissedVPC() {
LoggingInfo.instance.info(
'Dismissed VPC',
methodName: 'dismissedVPC',
);
emit(
state.copyWith(
members: state.members,
Expand All @@ -82,6 +98,10 @@ class AddMemberCubit extends Cubit<AddMemberState> {
required Member member,
required String invisibleSecondKey,
}) {
LoggingInfo.instance.info(
'Remember profile: ${member.firstName}',
methodName: 'rememberProfile',
);
final invisibleSecondMemberIndex =
state.members.indexWhere((p) => p.key == invisibleSecondKey);
final existingChildIndex =
Expand Down Expand Up @@ -131,6 +151,12 @@ class AddMemberCubit extends Cubit<AddMemberState> {
}

Future<void> createMember() async {
unawaited(
LoggingInfo.instance.info(
'Create member',
methodName: 'createMember',
),
);
final members = state.members;
final memberNames = members.map((member) => member.firstName).toList();

Expand Down
19 changes: 18 additions & 1 deletion lib/features/children/add_member/pages/add_member_form_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:givt_app/app/routes/pages.dart';
import 'package:givt_app/core/logging/logging_service.dart';
import 'package:givt_app/features/children/add_member/cubit/add_member_cubit.dart';
import 'package:givt_app/features/children/add_member/widgets/add_member_form.dart';
import 'package:givt_app/features/children/add_member/widgets/success_add_member_page.dart';
Expand Down Expand Up @@ -100,6 +101,10 @@ class _CreateMemberPageState extends State<CreateMemberPage> {
Widget build(BuildContext context) {
return BlocConsumer<AddMemberCubit, AddMemberState>(
listener: (context, state) {
LoggingInfo.instance.info(
'State: ${state.status}, formStatus: ${state.formStatus}',
methodName: 'listener',
);
if (state.status == AddMemberStateStatus.error) {
SnackBarHelper.showMessage(
context,
Expand All @@ -109,6 +114,10 @@ class _CreateMemberPageState extends State<CreateMemberPage> {
context.goNamed(Pages.childrenOverview.name);
}
if (state.status == AddMemberStateStatus.vpc) {
LoggingInfo.instance.info(
'Show VPC bottom sheet',
methodName: 'listener',
);
showModalBottomSheet<void>(
context: context,
showDragHandle: true,
Expand All @@ -127,10 +136,18 @@ class _CreateMemberPageState extends State<CreateMemberPage> {
});
}
if (state.status == AddMemberStateStatus.continueWithoutVPC) {
LoggingInfo.instance.info(
'Continue without VPC',
methodName: 'listener',
);
context.read<AddMemberCubit>().createMember();
}
if (state.nrOfForms == state.members.length &&
state.formStatus == AddMemberFormStatus.initial) {
LoggingInfo.instance.info(
'All forms filled',
methodName: 'listener',
);
context.read<AddMemberCubit>().allFormsFilled();
return;
}
Expand Down Expand Up @@ -245,4 +262,4 @@ class _CreateMemberPageState extends State<CreateMemberPage> {
);
});
}
}
}
6 changes: 6 additions & 0 deletions lib/features/children/add_member/widgets/add_member_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:givt_app/core/enums/amplitude_events.dart';
import 'package:givt_app/core/enums/country.dart';
import 'package:givt_app/core/logging/logging_service.dart';
import 'package:givt_app/features/auth/cubit/auth_cubit.dart';
import 'package:givt_app/features/children/add_member/cubit/add_member_cubit.dart';
import 'package:givt_app/features/children/add_member/models/member.dart';
Expand Down Expand Up @@ -72,6 +73,11 @@ class _AddMemberFormState extends State<AddMemberForm> {
if (state.formStatus == AddMemberFormStatus.validate) {
final cubit = context.read<AddMemberCubit>();
if (isChildSelected) {
final validation = formKeyChild.currentState!.validate();
LoggingInfo.instance.info(
'Form is valid: $validation',
methodName: 'listenerToValidation',
);
if (!formKeyChild.currentState!.validate()) {
cubit.resetFormStatus();
return;
Expand Down
Loading

0 comments on commit a782934

Please sign in to comment.