Skip to content

Commit

Permalink
feat: makes all form fields required for submission
Browse files Browse the repository at this point in the history
  • Loading branch information
am-casper committed Feb 29, 2024
1 parent 139347d commit b8e5ed9
Showing 1 changed file with 48 additions and 22 deletions.
70 changes: 48 additions & 22 deletions lib/presentation/feedback/feedback_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,8 @@ class FeedbackScreen extends StatelessWidget {
body: BlocProvider(
create: (context) =>
FeedbackPageBloc(repo: context.read<FeedbackRepository>()),
child: BlocBuilder<FeedbackPageBloc, FeedbackPageState>(
child: BlocConsumer<FeedbackPageBloc, FeedbackPageState>(
builder: (context, state) {
if (state.error) {
Fluttertoast.showToast(
msg: "Unable to submit feedback!",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
textColor: Colors.white,
backgroundColor: AppTheme.red,
fontSize: 16.0);
}
if (state.submitted) {
Fluttertoast.showToast(
msg: "Feedback submitted successfully!",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
textColor: Colors.white,
backgroundColor: AppTheme.green,
fontSize: 12.toAutoScaledFont);
context.router.pop();
}
return Column(
children: [
const FeedbackBanner(),
Expand Down Expand Up @@ -124,6 +103,30 @@ class FeedbackScreen extends StatelessWidget {
alignment: Alignment.bottomRight,
child: BlackIconButton(
onTap: () {
for (var rating in state.rating) {
if (rating == 0) {
Fluttertoast.showToast(
msg: "Please rate all the categories!",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
textColor: Colors.white,
backgroundColor: AppTheme.red,
fontSize: 12.toAutoScaledFont);
return;
}
}
if (state.description.trim().isEmpty) {
Fluttertoast.showToast(
msg: "Please describe your Feedback!",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
textColor: Colors.white,
backgroundColor: AppTheme.red,
fontSize: 12.toAutoScaledFont);
return;
}
context.read<FeedbackPageBloc>().add(
FeedbackPageSubmitEvent(
mealId: mealId,
Expand All @@ -143,6 +146,29 @@ class FeedbackScreen extends StatelessWidget {
],
);
},
listener: (BuildContext context, FeedbackPageState state) {
if (state.submitted) {
Fluttertoast.showToast(
msg: "Feedback submitted successfully!",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
textColor: Colors.white,
backgroundColor: AppTheme.green,
fontSize: 12.toAutoScaledFont);
context.router.pop();
}
if (state.error) {
Fluttertoast.showToast(
msg: "Unable to submit feedback!",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
textColor: Colors.white,
backgroundColor: AppTheme.red,
fontSize: 16.0);
}
},
),
),
);
Expand Down

0 comments on commit b8e5ed9

Please sign in to comment.