feat: add success and error feedback for experience submission in ExperiencePage
This commit is contained in:
@@ -57,10 +57,17 @@ class ExperiencePage extends StatelessWidget {
|
|||||||
create: (context) => Modular.get<ExperienceBloc>(),
|
create: (context) => Modular.get<ExperienceBloc>(),
|
||||||
child: BlocConsumer<ExperienceBloc, ExperienceState>(
|
child: BlocConsumer<ExperienceBloc, ExperienceState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state.status == ExperienceStatus.success) {
|
if (state.status == ExperienceStatus.success) {
|
||||||
Modular.to.pop();
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
}
|
const SnackBar(content: Text('Experience saved successfully')),
|
||||||
},
|
);
|
||||||
|
Modular.to.pop();
|
||||||
|
} else if (state.status == ExperienceStatus.failure) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text(state.errorMessage ?? 'An error occurred')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
@@ -166,25 +173,22 @@ class ExperiencePage extends StatelessWidget {
|
|||||||
border: Border(top: BorderSide(color: UiColors.border)),
|
border: Border(top: BorderSide(color: UiColors.border)),
|
||||||
),
|
),
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: SizedBox(
|
child: UiButton.primary(
|
||||||
width: double.infinity,
|
onPressed: state.status == ExperienceStatus.loading
|
||||||
child: UiButton.primary(
|
? null
|
||||||
onPressed: state.status == ExperienceStatus.loading
|
: () => BlocProvider.of<ExperienceBloc>(context).add(ExperienceSubmitted()),
|
||||||
? null
|
fullWidth: true,
|
||||||
: () => BlocProvider.of<ExperienceBloc>(context).add(ExperienceSubmitted()),
|
text: state.status == ExperienceStatus.loading ? null : i18n.save_button,
|
||||||
fullWidth: true,
|
child: state.status == ExperienceStatus.loading
|
||||||
text: state.status == ExperienceStatus.loading ? null : i18n.save_button,
|
? SizedBox(
|
||||||
child: state.status == ExperienceStatus.loading
|
height: 20.0,
|
||||||
? SizedBox(
|
width: 20.0,
|
||||||
height: 20.0,
|
child: CircularProgressIndicator(
|
||||||
width: 20.0,
|
strokeWidth: 2,
|
||||||
child: CircularProgressIndicator(
|
valueColor: AlwaysStoppedAnimation<Color>(UiColors.white), // UiColors.primaryForeground is white mostly
|
||||||
strokeWidth: 2,
|
),
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(UiColors.white), // UiColors.primaryForeground is white mostly
|
)
|
||||||
),
|
: null,
|
||||||
)
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user