Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
pictures_sections.dart
Go to the documentation of this file.
1import 'dart:io';
2
3import 'package:easy_localization/easy_localization.dart';
4import 'package:fluentui_system_icons/fluentui_system_icons.dart';
5import 'package:flutter/material.dart';
6import 'package:flutter_screenutil/flutter_screenutil.dart';
7
8import '../../../../../../core/ui/theme/color_palette.dart';
9
10class PicturesSections extends StatelessWidget {
13 final Function(String) onDeletePicture;
14 final VoidCallback onAddVoucherPicture;
15 final VoidCallback onAddDrumPicture;
16
18 super.key,
19 this.voucherPicture,
20 this.drumPicture,
21 required this.onDeletePicture,
22 required this.onAddVoucherPicture,
23 required this.onAddDrumPicture,
24 });
25
26 @override
27 Widget build(BuildContext context) {
28 return Container(
29 width: double.infinity,
30 padding: EdgeInsets.all(20.sp),
31 decoration: BoxDecoration(
33 borderRadius: BorderRadius.circular(20),
34 boxShadow: [
35 BoxShadow(
36 color: ColorPalette.black.withValues(alpha: 0.05),
37 blurRadius: 10,
38 offset: const Offset(0, 4),
39 ),
40 ],
41 ),
43 crossAxisAlignment: CrossAxisAlignment.start,
44 children: [
45 Text(
46 'confirmation.flow_meter'.tr(),
47 style: Theme.of(context).textTheme.titleMedium!.copyWith(
48 fontWeight: FontWeight.bold,
49 ),
50 ),
51 SizedBox(height: 16.sp),
52 _buildVoucherSection(context),
53 SizedBox(height: 24.sp),
54 _buildDrumSection(context),
55 ],
56 ),
57 );
58 }
59
61 return Container(
62 decoration: BoxDecoration(
64 borderRadius: BorderRadius.circular(12),
65 border: Border.all(color: ColorPalette.grey.withValues(alpha: 0.2)),
66 ),
68 children: [
69 if (File(picture).existsSync())
70 ClipRRect(
71 borderRadius: BorderRadius.circular(12),
72 child: Image.file(
73 File(picture),
74 height: 120.sp,
75 width: double.infinity,
76 fit: BoxFit.cover,
77 ),
78 ),
79 ListTile(
80 leading: Container(
81 padding: EdgeInsets.all(8.sp),
82 decoration: BoxDecoration(
83 color: ColorPalette.lightGreen.withValues(alpha: 0.2),
84 borderRadius: BorderRadius.circular(8),
85 ),
86 child: const Icon(FluentIcons.image_16_regular, color: ColorPalette.darkGreen),
87 ),
89 trailing: IconButton(
90 icon: const Icon(FluentIcons.delete_12_regular, color: ColorPalette.grey),
91 onPressed: () => onDeletePicture(picture),
92 ),
93 ),
94 ],
95 ),
96 );
97 }
98
99 Widget _buildVoucherSection(BuildContext context) {
100 return Column(
101 crossAxisAlignment: CrossAxisAlignment.start,
102 children: [
103 _buildSectionHeader('confirmation.before_loading'.tr(), voucherPicture != null ? 1 : 0, context),
104 SizedBox(height: 16.sp),
106 picture: voucherPicture,
107 onAdd: onAddVoucherPicture,
108 emptyStateText: 'confirmation.picture_hint'.tr(),
109 title: 'confirmation.before_loading_picture'.tr(),
110 context: context,
111 ),
112 ],
113 );
114 }
115
116 Widget _buildDrumSection(BuildContext context) {
117 return Column(
118 crossAxisAlignment: CrossAxisAlignment.start,
119 children: [
120 _buildSectionHeader('confirmation.after_loading'.tr(), drumPicture != null ? 1 : 0, context),
121 SizedBox(height: 16.sp),
123 picture: drumPicture,
124 onAdd: onAddDrumPicture,
125 emptyStateText: 'confirmation.picture_hint'.tr(),
126 title: 'confirmation.after_loading_picture'.tr(),
127 context: context,
128 ),
129 ],
130 );
131 }
132
134 required String? picture,
135 required VoidCallback onAdd,
136 required String emptyStateText,
137 required String title,
138 required BuildContext context,
139 }) {
140 if (picture == null) {
141 return _buildEmptyState(emptyStateText, onAdd, context);
142 }
143 return _buildPictureItem(picture, title);
144 }
145
146 Widget _buildSectionHeader(String title, int count, BuildContext context) {
147 return Row(
148 mainAxisAlignment: MainAxisAlignment.spaceBetween,
149 children: [
150 Text(
151 title,
152 style: Theme.of(context).textTheme.titleSmall!.copyWith(
154 ),
155 ),
156 ],
157 );
158 }
159
160 Widget _buildEmptyState(String text, VoidCallback onTap, BuildContext context) {
161 return InkWell(
162 onTap: onTap,
163 child: Container(
164 width: double.infinity,
165 height: 110.sp,
166 decoration: BoxDecoration(
167 border: Border.all(color: ColorPalette.grey.withValues(alpha: 0.2)),
169 borderRadius: BorderRadius.circular(12),
170 ),
171 child: Column(
172 mainAxisAlignment: MainAxisAlignment.center,
173 children: [
174 Icon(FluentIcons.camera_16_regular, size: 32.sp, color: ColorPalette.grey),
175 SizedBox(height: 8.sp),
176 Text(
177 text,
178 style: Theme.of(context).textTheme.titleSmall!.copyWith(
180 ),
181 ),
182 ],
183 ),
184 ),
185 );
186 }
187}
static const lightGreen
static const black
static const lightGrey
static const white
static const darkGreen
static const grey
final Function(String) onDeletePicture
final String voucherPicture
Widget _buildPictureItem(String picture, String title)
final VoidCallback onPressed
final VoidCallback onTap
final String title
final String text
final Widget child
override Widget build(BuildContext context)
const PicturesSections({ super.key, this.voucherPicture, this.drumPicture, required this.onDeletePicture, required this.onAddVoucherPicture, required this.onAddDrumPicture, })
Widget _buildPictureContent({ required String? picture, required VoidCallback onAdd, required String emptyStateText, required String title, required BuildContext context, })
Widget _buildSectionHeader(String title, int count, BuildContext context)
Widget _buildEmptyState(String text, VoidCallback onTap, BuildContext context)
Widget _buildDrumSection(BuildContext context)
final EdgeInsets padding
final VoidCallback onAddVoucherPicture
final VoidCallback onAddDrumPicture
Widget _buildVoucherSection(BuildContext context)
class Partner String
final String title
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,),),),],)