Aidra Connect 10.0.2+16
Aidra Connect Mobile Application
Loading...
Searching...
No Matches
report_an_issue_dialog.dart
Go to the documentation of this file.
1import 'dart:io';
2
3import 'package:connect/core/localization/app_localizations.dart';
4
5import '/core/ui/theme/color_palette.dart';
6import '/core/ui/widgets/custom_action_slider.dart';
7import '/core/ui/widgets/custom_scaffold.dart';
8import '/core/ui/widgets/custom_snackbar.dart';
9import '/core/ui/widgets/custom_text_form_field.dart';
10import 'package:flutter/material.dart';
11import 'package:flutter_screenutil/flutter_screenutil.dart';
12import 'package:go_router/go_router.dart';
13import 'package:hugeicons/hugeicons.dart';
14import 'package:image_picker/image_picker.dart';
15
16class ReportAnIsueDialog extends StatefulWidget {
17 const ReportAnIsueDialog({super.key});
18
19 @override
20 State<ReportAnIsueDialog> createState() => _ReportAnIsueDialogState();
21}
22
23class _ReportAnIsueDialogState extends State<ReportAnIsueDialog> {
24 final _formKey = GlobalKey<FormState>();
25 final ImagePicker _picker = ImagePicker();
26 List<File> _selectedImages = [];
27
28 Future<void> _pickImage() async {
29 final XFile? pickedFile = await _picker.pickImage(
30 source: ImageSource.gallery,
31 imageQuality: 80,
32 );
33
34 if (pickedFile != null) {
35 setState(() {
36 _selectedImages.add(File(pickedFile.path));
37 });
38 }
39 }
40
41 void _removeImage(int index) {
42 setState(() {
43 _selectedImages.removeAt(index);
44 });
45 }
46
47 @override
48 Widget build(BuildContext context) {
49 return Padding(
50 padding: EdgeInsets.symmetric(
51 vertical: 5.sp,
52 horizontal: 5.sp,
53 ),
54 child: Form(
55 key: _formKey,
56 child: SingleChildScrollView(
57 child: Column(
58 mainAxisAlignment: MainAxisAlignment.start,
59 crossAxisAlignment: CrossAxisAlignment.stretch,
60 mainAxisSize: MainAxisSize.min,
61 children: [
62 CustomTextFormField(
63 controller: TextEditingController(),
64 hintText: AppLocalizations.of(context).translate('Subject'),
65 validator: (value) {
66 if (value == null || value.isEmpty) {
67 return AppLocalizations.of(context)
68 .translate('Please enter the subject');
69 }
70 return null;
71 },
72 ),
73 SizedBox(height: 15.sp),
74 CustomTextFormField(
75 controller: TextEditingController(),
76 hintText: AppLocalizations.of(context).translate('Description'),
77 maxLines: 5,
78 validator: (value) {
79 if (value == null || value.isEmpty) {
80 return AppLocalizations.of(context)
81 .translate('Please describe the issue');
82 }
83 return null;
84 },
85 ),
86 SizedBox(height: 15.sp),
87 Text(
88 AppLocalizations.of(context).translate('Screenshots'),
89 style: Theme.of(context).textTheme.bodySmall?.copyWith(
90 color: Theme.of(context).hintColor,
91 ),
92 ),
93 SizedBox(height: 10.sp),
94 SizedBox(
95 height: 80.sp,
96 child: ListView.separated(
97 scrollDirection: Axis.horizontal,
98 itemCount: _selectedImages.length + 1,
99 separatorBuilder: (context, index) => SizedBox(width: 10.sp),
100 itemBuilder: (context, index) {
101 if (index == _selectedImages.length) {
102 return GestureDetector(
104 child: Container(
105 width: 80.sp,
106 height: 80.sp,
107 decoration: BoxDecoration(
108 border: Border.all(
109 color: Theme.of(context).hintColor,
110 width: 0.4,
111 ),
112 borderRadius: BorderRadius.circular(10),
113 ),
114 child: const Icon(
115 HugeIcons.strokeRoundedCamera01,
116 ),
117 ),
118 );
119 }
120
121 // Display selected image
122 return Stack(
123 children: [
124 ClipRRect(
125 borderRadius: BorderRadius.circular(10),
126 child: Image.file(
127 _selectedImages[index],
128 width: 80.sp,
129 height: 80.sp,
130 fit: BoxFit.cover,
131 ),
132 ),
133 Positioned(
134 top: 5,
135 right: 5,
136 child: GestureDetector(
137 onTap: () => _removeImage(index),
138 child: CircleAvatar(
140 Theme.of(context).colorScheme.error,
141 radius: 12,
142 child: Icon(
143 HugeIcons.strokeRoundedCancel01,
144 size: 16.sp,
145 color: Theme.of(context).colorScheme.onPrimary,
146 ),
147 ),
148 ),
149 ),
150 ],
151 );
152 },
153 ),
154 ),
155 SizedBox(height: 20.sp),
156 CustomSliderV2(
157 action: (action) {
158 if (_formKey.currentState!.validate()) {
159 if (_selectedImages.isEmpty) {
161 context,
164 'Please upload at least one screenshot of the issue'),
165 );
166 return;
167 } else {
168 context.pop();
170 context,
173 'Your report has been successfully submitted. Our team will review it and get back to you shortly'),
174 );
175 }
176 }
177 },
178 text: AppLocalizations.of(context).translate('SUBMIT'),
179 ),
180 ],
181 ),
182 ),
183 ),
184 );
185 }
186}
String translate(String key)
AppLocalizations(this.locale)
String translate(String key)
static AppLocalizations of(BuildContext context)
static const red
static const darkGreen
static display(final BuildContext context, final Color color, final String message,)
override State< ReportAnIsueDialog > createState()
const ReportAnIsueDialog({super.key})
final Widget child
final EdgeInsets padding
final Color backgroundColor
final VoidCallback onTap
final Color color
Definition failures.dart:1
override Widget build(BuildContext context)
List< File > _selectedImages
final ImagePicker _picker
void _removeImage(int index)
Future< void > _pickImage() async
final double value