Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
cancellation_bottom_sheet.dart
Go to the documentation of this file.
1import 'package:fluentui_system_icons/fluentui_system_icons.dart';
2import 'package:flutter/material.dart';
3import 'package:flutter_bloc/flutter_bloc.dart';
4import 'package:flutter_screenutil/flutter_screenutil.dart';
5
6import '../../../../../../core/ui/theme/color_palette.dart';
7import '../../../bloc/collections_bloc/collections_bloc.dart';
8
10 final int collectionId;
11 final Function(int) onReasonSelected;
12
14 super.key,
15 required this.collectionId,
16 required this.onReasonSelected,
17 });
18
19 @override
20 State<CancellationBottomSheet> createState() => _CancellationBottomSheetState();
21}
22
23class _CancellationBottomSheetState extends State<CancellationBottomSheet> {
24 @override
25 void initState() {
26 context.read<CollectionsBloc>().add(LoadCancellationReasonsEvent());
27 super.initState();
28 }
30 @override
31 Widget build(BuildContext context) {
32 return BlocBuilder<CollectionsBloc, CollectionsState>(
33 buildWhen: (previous, current) => current is CancellationReasonsLoading || current is CancellationReasonsLoaded || current is CancellationReasonsError,
34 builder: (context, state) {
35 if (state is CancellationReasonsLoading) {
36 return Container(
37 height: MediaQuery.sizeOf(context).height * 0.4,
38 decoration: const BoxDecoration(
39 color: Colors.white,
40 borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
41 ),
42 child: const Center(child: CircularProgressIndicator(color: ColorPalette.lightGreen)),
43 );
44 }
45 if (state is CancellationReasonsLoaded) {
46 return Container(
47 constraints: BoxConstraints(
48 maxHeight: MediaQuery.sizeOf(context).height * 0.7,
49 ),
50 decoration: const BoxDecoration(
51 color: Colors.white,
52 borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
53 ),
55 mainAxisSize: MainAxisSize.min,
56 children: [
57 Container(
58 margin: EdgeInsets.only(top: 12.sp),
59 width: 40.sp,
60 height: 4.sp,
61 decoration: BoxDecoration(
62 color: Colors.grey[300],
63 borderRadius: BorderRadius.circular(2),
64 ),
65 ),
66 Padding(
67 padding: EdgeInsets.all(16.sp),
69 children: [
70 Text(
71 'Select Cancellation Reason',
72 style: Theme.of(context).textTheme.titleMedium?.copyWith(
73 fontWeight: FontWeight.bold,
74 ),
75 ),
76 const SizedBox(height: 8),
77 Divider(color: Colors.grey[300]),
78 ],
79 ),
80 ),
81 Flexible(
82 child: ListView.builder(
83 shrinkWrap: true,
84 physics: const BouncingScrollPhysics(),
85 itemCount: state.reasons.length,
86 itemBuilder: (context, index) {
87 final reason = state.reasons[index];
88 return Material(
89 color: Colors.transparent,
90 child: InkWell(
91 onTap: () => widget.onReasonSelected(reason.id ?? 0),
92 child: Padding(
93 padding: const EdgeInsets.symmetric(
94 horizontal: 16,
95 vertical: 12,
96 ),
97 child: Row(
98 children: [
99 Container(
100 padding: const EdgeInsets.all(8),
101 decoration: BoxDecoration(
102 color: Colors.red[50],
103 borderRadius: BorderRadius.circular(8),
104 ),
105 child: const Icon(
106 FluentIcons.shield_error_16_regular,
107 color: ColorPalette.red
108 ),
109 ),
110 const SizedBox(width: 16),
111 Expanded(
112 child: Text(
113 reason.name ?? '',
114 style: Theme.of(context).textTheme.displaySmall,
115 ),
116 ),
117 Icon(
118 Icons.chevron_right,
119 color: Colors.grey[400],
120 ),
121 ],
122 ),
123 ),
124 ),
125 );
126 },
127 ),
128 ),
129 const SizedBox(height: 16),
130 ],
131 ),
132 );
133 }
134 return Container(
135 height: MediaQuery.sizeOf(context).height * 0.4,
136 decoration: const BoxDecoration(
137 color: Colors.white,
138 borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
139 ),
140 child: const Center(
141 child: Text('Error loading reasons'),
142 ),
143 );
144 },
145 );
146 }
147}
override void initState()
class App extends StatefulWidget build(BuildContext context)
Definition app.dart:31
const CancellationBottomSheet({ super.key, required this.collectionId, required this.onReasonSelected, })
static const lightGreen
final Function(int) onReasonSelected
override State< CancellationBottomSheet > createState()
const CancellationBottomSheet({ super.key, required this.collectionId, required this.onReasonSelected, })
const CancellationReasonsLoaded({required this.reasons})
final Widget child
final EdgeInsets padding
final Color color
Definition failures.dart:1
style Text( '${ 'scheduling.reference'.tr()}:${collection.internalCode}', style:Theme.of(context).textTheme.bodySmall,)
style SizedBox(height:2.h)
style Column(crossAxisAlignment:CrossAxisAlignment.end, children:[Container(padding:EdgeInsets.symmetric(horizontal:8.w, vertical:4.h), decoration:BoxDecoration(color:ColorPalette.tiffanyBlue.withValues(alpha:0.1), borderRadius:BorderRadius.circular(12),), child:Text(collection.type ?? '', style:Theme.of(context).textTheme.bodySmall?.copyWith(color:ColorPalette.tiffanyBlue, fontWeight:FontWeight.bold,),),),],)