feat: Add post-save navigation to staff profile for emergency contact and experience, remove a placeholder page, and refine bloc usage and UI rendering.
This commit is contained in:
@@ -39,7 +39,6 @@ class EmergencyContactScreen extends StatelessWidget {
|
||||
body: BlocProvider(
|
||||
create: (context) => Modular.get<EmergencyContactBloc>(),
|
||||
child: BlocConsumer<EmergencyContactBloc, EmergencyContactState>(
|
||||
|
||||
listener: (context, state) {
|
||||
if (state.status == EmergencyContactStatus.failure) {
|
||||
UiSnackbar.show(
|
||||
@@ -66,12 +65,12 @@ class EmergencyContactScreen extends StatelessWidget {
|
||||
const EmergencyContactInfoBanner(),
|
||||
const SizedBox(height: UiConstants.space6),
|
||||
...state.contacts.asMap().entries.map(
|
||||
(entry) => EmergencyContactFormItem(
|
||||
index: entry.key,
|
||||
contact: entry.value,
|
||||
totalContacts: state.contacts.length,
|
||||
),
|
||||
),
|
||||
(entry) => EmergencyContactFormItem(
|
||||
index: entry.key,
|
||||
contact: entry.value,
|
||||
totalContacts: state.contacts.length,
|
||||
),
|
||||
),
|
||||
const EmergencyContactAddButton(),
|
||||
const SizedBox(height: UiConstants.space16),
|
||||
],
|
||||
|
||||
@@ -2,13 +2,17 @@ import 'package:core_localization/core_localization.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import '../blocs/emergency_contact_bloc.dart';
|
||||
|
||||
class EmergencyContactSaveButton extends StatelessWidget {
|
||||
const EmergencyContactSaveButton({super.key});
|
||||
|
||||
void _onSave(BuildContext context) {
|
||||
context.read<EmergencyContactBloc>().add(EmergencyContactsSaved());
|
||||
BlocProvider.of<EmergencyContactBloc>(
|
||||
context,
|
||||
).add(EmergencyContactsSaved());
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -19,10 +23,13 @@ class EmergencyContactSaveButton extends StatelessWidget {
|
||||
if (state.status == EmergencyContactStatus.saved) {
|
||||
UiSnackbar.show(
|
||||
context,
|
||||
message: t.staff.profile.menu_items.emergency_contact_page.save_success,
|
||||
message:
|
||||
t.staff.profile.menu_items.emergency_contact_page.save_success,
|
||||
type: UiSnackbarType.success,
|
||||
margin: const EdgeInsets.only(bottom: 150, left: 16, right: 16),
|
||||
);
|
||||
|
||||
Modular.to.toProfile();
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
@@ -36,8 +43,9 @@ class EmergencyContactSaveButton extends StatelessWidget {
|
||||
child: SafeArea(
|
||||
child: UiButton.primary(
|
||||
fullWidth: true,
|
||||
onPressed:
|
||||
state.isValid && !isLoading ? () => _onSave(context) : null,
|
||||
onPressed: state.isValid && !isLoading
|
||||
? () => _onSave(context)
|
||||
: null,
|
||||
child: isLoading
|
||||
? const SizedBox(
|
||||
height: 20.0,
|
||||
@@ -49,7 +57,14 @@ class EmergencyContactSaveButton extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
)
|
||||
: Text(t.staff.profile.menu_items.emergency_contact_page.save_continue),
|
||||
: Text(
|
||||
t
|
||||
.staff
|
||||
.profile
|
||||
.menu_items
|
||||
.emergency_contact_page
|
||||
.save_continue,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import 'package:krow_domain/krow_domain.dart';
|
||||
|
||||
import '../blocs/experience_bloc.dart';
|
||||
@@ -13,34 +14,57 @@ class ExperiencePage extends StatelessWidget {
|
||||
|
||||
String _getIndustryLabel(dynamic node, Industry industry) {
|
||||
switch (industry) {
|
||||
case Industry.hospitality: return node.hospitality;
|
||||
case Industry.foodService: return node.food_service;
|
||||
case Industry.warehouse: return node.warehouse;
|
||||
case Industry.events: return node.events;
|
||||
case Industry.retail: return node.retail;
|
||||
case Industry.healthcare: return node.healthcare;
|
||||
case Industry.other: return node.other;
|
||||
case Industry.hospitality:
|
||||
return node.hospitality;
|
||||
case Industry.foodService:
|
||||
return node.food_service;
|
||||
case Industry.warehouse:
|
||||
return node.warehouse;
|
||||
case Industry.events:
|
||||
return node.events;
|
||||
case Industry.retail:
|
||||
return node.retail;
|
||||
case Industry.healthcare:
|
||||
return node.healthcare;
|
||||
case Industry.other:
|
||||
return node.other;
|
||||
}
|
||||
}
|
||||
|
||||
String _getSkillLabel(dynamic node, ExperienceSkill skill) {
|
||||
switch (skill) {
|
||||
case ExperienceSkill.foodService: return node.food_service;
|
||||
case ExperienceSkill.bartending: return node.bartending;
|
||||
case ExperienceSkill.eventSetup: return node.event_setup;
|
||||
case ExperienceSkill.hospitality: return node.hospitality;
|
||||
case ExperienceSkill.warehouse: return node.warehouse;
|
||||
case ExperienceSkill.customerService: return node.customer_service;
|
||||
case ExperienceSkill.cleaning: return node.cleaning;
|
||||
case ExperienceSkill.security: return node.security;
|
||||
case ExperienceSkill.retail: return node.retail;
|
||||
case ExperienceSkill.driving: return node.driving;
|
||||
case ExperienceSkill.cooking: return node.cooking;
|
||||
case ExperienceSkill.cashier: return node.cashier;
|
||||
case ExperienceSkill.server: return node.server;
|
||||
case ExperienceSkill.barista: return node.barista;
|
||||
case ExperienceSkill.hostHostess: return node.host_hostess;
|
||||
case ExperienceSkill.busser: return node.busser;
|
||||
case ExperienceSkill.foodService:
|
||||
return node.food_service;
|
||||
case ExperienceSkill.bartending:
|
||||
return node.bartending;
|
||||
case ExperienceSkill.eventSetup:
|
||||
return node.event_setup;
|
||||
case ExperienceSkill.hospitality:
|
||||
return node.hospitality;
|
||||
case ExperienceSkill.warehouse:
|
||||
return node.warehouse;
|
||||
case ExperienceSkill.customerService:
|
||||
return node.customer_service;
|
||||
case ExperienceSkill.cleaning:
|
||||
return node.cleaning;
|
||||
case ExperienceSkill.security:
|
||||
return node.security;
|
||||
case ExperienceSkill.retail:
|
||||
return node.retail;
|
||||
case ExperienceSkill.driving:
|
||||
return node.driving;
|
||||
case ExperienceSkill.cooking:
|
||||
return node.cooking;
|
||||
case ExperienceSkill.cashier:
|
||||
return node.cashier;
|
||||
case ExperienceSkill.server:
|
||||
return node.server;
|
||||
case ExperienceSkill.barista:
|
||||
return node.barista;
|
||||
case ExperienceSkill.hostHostess:
|
||||
return node.host_hostess;
|
||||
case ExperienceSkill.busser:
|
||||
return node.busser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,39 +75,38 @@ class ExperiencePage extends StatelessWidget {
|
||||
return Scaffold(
|
||||
appBar: UiAppBar(
|
||||
title: i18n.title,
|
||||
onLeadingPressed: () => Modular.to.pop(),
|
||||
onLeadingPressed: () => Modular.to.toProfile(),
|
||||
),
|
||||
body: BlocProvider<ExperienceBloc>(
|
||||
create: (context) => Modular.get<ExperienceBloc>(),
|
||||
child: BlocConsumer<ExperienceBloc, ExperienceState>(
|
||||
listener: (context, state) {
|
||||
if (state.status == ExperienceStatus.success) {
|
||||
UiSnackbar.show(
|
||||
context,
|
||||
message: 'Experience saved successfully',
|
||||
type: UiSnackbarType.success,
|
||||
margin: const EdgeInsets.only(
|
||||
bottom: 120,
|
||||
left: UiConstants.space4,
|
||||
right: UiConstants.space4,
|
||||
),
|
||||
);
|
||||
Modular.to.pop();
|
||||
} else if (state.status == ExperienceStatus.failure) {
|
||||
UiSnackbar.show(
|
||||
context,
|
||||
message: state.errorMessage != null
|
||||
? translateErrorKey(state.errorMessage!)
|
||||
: 'An error occurred',
|
||||
type: UiSnackbarType.error,
|
||||
margin: const EdgeInsets.only(
|
||||
bottom: 120,
|
||||
left: UiConstants.space4,
|
||||
right: UiConstants.space4,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
if (state.status == ExperienceStatus.success) {
|
||||
UiSnackbar.show(
|
||||
context,
|
||||
message: 'Experience saved successfully',
|
||||
type: UiSnackbarType.success,
|
||||
margin: const EdgeInsets.only(
|
||||
bottom: 120,
|
||||
left: UiConstants.space4,
|
||||
right: UiConstants.space4,
|
||||
),
|
||||
);
|
||||
} else if (state.status == ExperienceStatus.failure) {
|
||||
UiSnackbar.show(
|
||||
context,
|
||||
message: state.errorMessage != null
|
||||
? translateErrorKey(state.errorMessage!)
|
||||
: 'An error occurred',
|
||||
type: UiSnackbarType.error,
|
||||
margin: const EdgeInsets.only(
|
||||
bottom: 120,
|
||||
left: UiConstants.space4,
|
||||
right: UiConstants.space4,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return Column(
|
||||
children: [
|
||||
@@ -106,15 +129,15 @@ class ExperiencePage extends StatelessWidget {
|
||||
.map(
|
||||
(i) => UiChip(
|
||||
label: _getIndustryLabel(i18n.industries, i),
|
||||
isSelected:
|
||||
state.selectedIndustries.contains(i),
|
||||
onTap: () =>
|
||||
BlocProvider.of<ExperienceBloc>(context)
|
||||
.add(ExperienceIndustryToggled(i)),
|
||||
variant:
|
||||
state.selectedIndustries.contains(i)
|
||||
? UiChipVariant.primary
|
||||
: UiChipVariant.secondary,
|
||||
isSelected: state.selectedIndustries.contains(
|
||||
i,
|
||||
),
|
||||
onTap: () => BlocProvider.of<ExperienceBloc>(
|
||||
context,
|
||||
).add(ExperienceIndustryToggled(i)),
|
||||
variant: state.selectedIndustries.contains(i)
|
||||
? UiChipVariant.primary
|
||||
: UiChipVariant.secondary,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
@@ -133,15 +156,16 @@ class ExperiencePage extends StatelessWidget {
|
||||
.map(
|
||||
(s) => UiChip(
|
||||
label: _getSkillLabel(i18n.skills, s),
|
||||
isSelected:
|
||||
state.selectedSkills.contains(s.value),
|
||||
onTap: () =>
|
||||
BlocProvider.of<ExperienceBloc>(context)
|
||||
.add(ExperienceSkillToggled(s.value)),
|
||||
isSelected: state.selectedSkills.contains(
|
||||
s.value,
|
||||
),
|
||||
onTap: () => BlocProvider.of<ExperienceBloc>(
|
||||
context,
|
||||
).add(ExperienceSkillToggled(s.value)),
|
||||
variant:
|
||||
state.selectedSkills.contains(s.value)
|
||||
? UiChipVariant.primary
|
||||
: UiChipVariant.secondary,
|
||||
? UiChipVariant.primary
|
||||
: UiChipVariant.secondary,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
@@ -177,10 +201,7 @@ class ExperiencePage extends StatelessWidget {
|
||||
spacing: UiConstants.space2,
|
||||
runSpacing: UiConstants.space2,
|
||||
children: customSkills.map((skill) {
|
||||
return UiChip(
|
||||
label: skill,
|
||||
variant: UiChipVariant.accent,
|
||||
);
|
||||
return UiChip(label: skill, variant: UiChipVariant.accent);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
@@ -202,8 +223,9 @@ class ExperiencePage extends StatelessWidget {
|
||||
child: UiButton.primary(
|
||||
onPressed: state.status == ExperienceStatus.loading
|
||||
? null
|
||||
: () => BlocProvider.of<ExperienceBloc>(context)
|
||||
.add(ExperienceSubmitted()),
|
||||
: () => BlocProvider.of<ExperienceBloc>(
|
||||
context,
|
||||
).add(ExperienceSubmitted()),
|
||||
fullWidth: true,
|
||||
text: state.status == ExperienceStatus.loading
|
||||
? null
|
||||
|
||||
Reference in New Issue
Block a user