Skip to content

Commit

Permalink
fix: stays on the screen in case of any error
Browse files Browse the repository at this point in the history
  • Loading branch information
am-casper committed Feb 29, 2024
1 parent de306db commit 139347d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/presentation/feedback/bloc/feedback_page_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class FeedbackPageBloc extends Bloc<FeedbackPageEvent, FeedbackPageState> {
rating: state.rating,
description: event.description,
submitted: state.submitted,
error: state.error,
error: false,
mealId: state.mealId,
),
);
Expand Down
24 changes: 22 additions & 2 deletions lib/presentation/feedback/feedback_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:appetizer/presentation/feedback/components/feedback_banner.dart'
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:fluttertoast/fluttertoast.dart';

@RoutePage()
class FeedbackScreen extends StatelessWidget {
Expand All @@ -32,6 +33,27 @@ class FeedbackScreen extends StatelessWidget {
FeedbackPageBloc(repo: context.read<FeedbackRepository>()),
child: BlocBuilder<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 @@ -101,14 +123,12 @@ class FeedbackScreen extends StatelessWidget {
Align(
alignment: Alignment.bottomRight,
child: BlackIconButton(
// onTap: context.router.pop,
onTap: () {
context.read<FeedbackPageBloc>().add(
FeedbackPageSubmitEvent(
mealId: mealId,
rating: state.rating,
description: state.description));
context.router.pop();
},
title: "SUBMIT",
width: 102.toAutoScaledWidth,
Expand Down

0 comments on commit 139347d

Please sign in to comment.