41 Widget
build(BuildContext context) {
42 final theme = Theme.of(context);
44 return BlocListener<CollectionsInformationBloc, CollectionsInformationState>(
45 listener: (context, state) {
47 widget.onRatingSuccess();
48 Navigator.pop(context);
49 }
else if (state is CollectionRatingError) {
50 ScaffoldMessenger.of(context).showSnackBar(
53 'Error submitting rating: ${state.failure}',
54 style: TextStyle(
color: theme.colorScheme.onError),
56 backgroundColor: theme.colorScheme.error,
57 behavior: SnackBarBehavior.floating,
58 shape: RoundedRectangleBorder(
59 borderRadius: BorderRadius.circular(8.sp),
66 backgroundColor: Colors.transparent,
69 decoration: BoxDecoration(
70 color: theme.colorScheme.surface,
71 borderRadius: BorderRadius.circular(24.sp),
74 color: Colors.black.withValues(alpha: 0.1),
76 offset:
const Offset(0, 10),
80 child: SingleChildScrollView(
84 mainAxisSize: MainAxisSize.min,
88 padding: EdgeInsets.symmetric(vertical: 16.sp),
90 Icons.rate_review_rounded,
92 color: theme.colorScheme.primary,
98 'full_fill_collection.how_was_the_collection'.tr(),
99 style: theme.textTheme.headlineSmall?.copyWith(
100 fontWeight: FontWeight.bold,
101 color: theme.colorScheme.onSurface,
103 textAlign: TextAlign.center,
110 'full_fill_collection.your_feedback'.tr(),
111 style: theme.textTheme.bodyMedium?.copyWith(
112 color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
114 textAlign: TextAlign.center,
121 decoration: BoxDecoration(
122 color: theme.colorScheme.primary.withValues(alpha: 0.05),
123 borderRadius: BorderRadius.circular(16.sp),
125 padding: EdgeInsets.symmetric(vertical: 16.sp),
126 child: RatingBar.builder(
129 direction: Axis.horizontal,
130 allowHalfRating:
false,
132 itemPadding: EdgeInsets.symmetric(horizontal: 4.sp),
133 itemBuilder: (context,
_) => Icon(
135 color: theme.colorScheme.primary,
137 onRatingUpdate: (
rating) {
140 _selectedReasonId = null;
148 BlocBuilder<CollectionsInformationBloc, CollectionsInformationState>(
149 buildWhen: (previous, current) => current is
CollectionLowRatingReasonsLoaded || current is CollectionLowRatingReasonsLoading || current is CollectionLowRatingReasonsError,
150 builder: (context, state) {
151 if (state is CollectionLowRatingReasonsLoading) {
153 child: CircularProgressIndicator(
154 color: theme.colorScheme.primary,
157 }
else if (state is CollectionLowRatingReasonsError) {
159 'Error loading reasons: ${state.failure}',
160 style: TextStyle(
color: theme.colorScheme.error),
163 if (state.reasons.isEmpty) {
165 'full_fill_collection.no_rating_reason'.tr(),
166 style: theme.textTheme.bodyLarge?.copyWith(
167 color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
169 textAlign: TextAlign.center,
173 decoration: BoxDecoration(
174 borderRadius: BorderRadius.circular(12.sp),
176 color: theme.colorScheme.outline.withValues(alpha: 0.2),
179 child: DropdownButtonHideUnderline(
180 child: DropdownButton<String>(
184 padding: EdgeInsets.symmetric(horizontal: 16.sp),
186 'full_fill_collection.what_went_wrong'.tr(),
187 style: theme.textTheme.bodyLarge?.copyWith(
188 color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
193 Icons.keyboard_arrow_down_rounded,
194 color: theme.colorScheme.primary,
196 padding: EdgeInsets.symmetric(horizontal: 16.sp),
197 borderRadius: BorderRadius.circular(12.sp),
198 items: state.reasons.map((reason) {
199 return DropdownMenuItem<String>(
200 value: reason.id?.toString(),
203 style: theme.textTheme.bodyLarge,
207 onChanged: (
String? newValue) {
209 _selectedReasonId = newValue;
225 style: theme.textTheme.bodyLarge,
226 decoration: InputDecoration(
227 hintText:
'full_fill_collection.tell_us_more'.tr(),
228 hintStyle: theme.textTheme.bodyLarge?.copyWith(
229 color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
231 border: OutlineInputBorder(
232 borderRadius: BorderRadius.circular(12.sp),
233 borderSide: BorderSide(
234 color: theme.colorScheme.outline.withValues(alpha: 0.2),
237 enabledBorder: OutlineInputBorder(
238 borderRadius: BorderRadius.circular(12.sp),
239 borderSide: BorderSide(
240 color: theme.colorScheme.outline.withValues(alpha: 0.2),
243 focusedBorder: OutlineInputBorder(
244 borderRadius: BorderRadius.circular(12.sp),
245 borderSide: BorderSide(
246 color: theme.colorScheme.primary,
249 contentPadding: EdgeInsets.all(16.sp),
251 fillColor: theme.colorScheme.surface,
256 BlocBuilder<CollectionsInformationBloc, CollectionsInformationState>(
257 buildWhen: (previous, current) => current is CollectionRatingLoading || current is
CollectionRatingSuccess || current is CollectionRatingError,
258 builder: (context, state) {
259 final isLoading = state is CollectionRatingLoading;
261 return ElevatedButton(
263 final state = context.read<CollectionsInformationBloc>().state;
267 ScaffoldMessenger.of(context).showSnackBar(
270 'full_fill_collection.select_a_reason'.tr(),
271 style: TextStyle(
color: theme.colorScheme.onError),
273 backgroundColor: theme.colorScheme.error,
274 behavior: SnackBarBehavior.floating,
275 shape: RoundedRectangleBorder(
276 borderRadius: BorderRadius.circular(8.sp),
283 context.read<CollectionsInformationBloc>().add(
284 SendCollectionRatingEvent(
285 id: widget.collectionId,
286 rate:
_rating.toInt().toString(),
292 style: ElevatedButton.styleFrom(
293 backgroundColor: theme.colorScheme.primary,
294 foregroundColor: theme.colorScheme.onPrimary,
299 shape: RoundedRectangleBorder(
300 borderRadius: BorderRadius.circular(8.sp),
307 child: CircularProgressIndicator(
309 valueColor: AlwaysStoppedAnimation<Color>(
310 theme.colorScheme.onPrimary,
315 'full_fill_collection.submit'.tr(),
316 style: theme.textTheme.bodyLarge?.copyWith(
317 color: theme.colorScheme.onPrimary,
318 fontWeight: FontWeight.bold,