Aidra Connect 10.0.2+16
Aidra Connect Mobile Application
Loading...
Searching...
No Matches
settings_screen.dart
Go to the documentation of this file.
1import 'package:connect/core/localization/app_localizations.dart';
2import 'package:connect/core/ui/theme/color_palette.dart';
3
4import '../../../../core/ui/widgets/custom_snackbar.dart';
5import '/core/ui/widgets/custom_card.dart';
6import '/core/ui/widgets/custom_scaffold.dart';
7import '/features/settings/presentation/settings_screen/widgets/faq_dialog.dart';
8import '/features/settings/presentation/settings_screen/widgets/language_selector_dialog.dart';
9import '/features/settings/presentation/settings_screen/widgets/notification_enabler_dialog.dart';
10import '/features/settings/presentation/settings_screen/widgets/report_an_issue_dialog.dart';
11import '/features/settings/presentation/settings_screen/widgets/terms_of_use.dart';
12import '/features/settings/presentation/settings_screen/widgets/theme_switcher_dialog.dart';
13
14import 'package:flutter/material.dart';
15import 'package:flutter_bloc/flutter_bloc.dart';
16import 'package:flutter_screenutil/flutter_screenutil.dart';
17import 'package:hugeicons/hugeicons.dart';
18
19import '../../../authentication/presentation/logic/authentication_bloc/authentication_bloc.dart';
20import 'widgets/privacy_policy.dart';
21
23 const SettingScreen({super.key});
24
25 @override
26 State<SettingScreen> createState() => _SettingScreenState();
27}
28
29class _SettingScreenState extends State<SettingScreen> {
30 @override
31 Widget build(BuildContext context) {
32 return CustomScaffold(
33 title: AppLocalizations.of(context).translate('SETTINGS'),
34 isLeadingVisible: false,
35 body: SingleChildScrollView(
36 padding: EdgeInsets.symmetric(horizontal: 15.sp, vertical: 10.sp),
37 child: Column(
38 crossAxisAlignment: CrossAxisAlignment.start,
39 children: [
41 sectionTitle: AppLocalizations.of(context).translate('General'),
42 context: context,
43 childrens: [
44 // _buildSettingsButton(
45 // label: 'Payment Method',
46 // context: context,
47 // onPressed: () {
48 // CustomSnackBar.display(
49 // context,
50 // Theme.of(context).colorScheme.primary,
51 // 'Hang tight! Soon, you\'ll effortlessly manage multiple payment methods with just a single click.',
52 // );
53 // },
54 // ),
56 label: AppLocalizations.of(context).translate('Appearence'),
57 context: context,
58 suffix: Icon(
59 HugeIcons.strokeRoundedDarkMode,
60 color: Theme.of(context).colorScheme.onSurface,
61 ),
62 onPressed: () {
63 _buildBottomSheet(
64 padding: EdgeInsets.all(5.sp),
65 context: context,
66 body: ThemeSwitcherDialog(),
67 );
68 },
69 ),
71 label: AppLocalizations.of(context).translate('Language'),
72 context: context,
73 suffix: Icon(
74 HugeIcons.strokeRoundedLanguageCircle,
75 color: Theme.of(context).colorScheme.onSurface,
76 ),
77 onPressed: () {
78 _buildBottomSheet(
79 padding: EdgeInsets.zero,
80 context: context,
81 body: LanguageSelectorDialog(),
82 );
83 },
84 ),
86 label:
87 AppLocalizations.of(context).translate('Notifications'),
88 suffix: Icon(
89 HugeIcons.strokeRoundedNotification03,
90 color: Theme.of(context).colorScheme.onSurface,
91 ),
92 context: context,
93 onPressed: () {
94 _buildBottomSheet(
95 padding: EdgeInsets.zero,
96 body: NotificationEnablerDialog(),
97 context: context,
98 );
99 },
100 ),
101 ],
102 ),
103 SizedBox(height: 10.sp),
105 sectionTitle: AppLocalizations.of(context).translate('Support'),
106 context: context,
107 childrens: [
109 label:
110 AppLocalizations.of(context).translate('Report An Issue'),
111 suffix: Icon(
112 HugeIcons.strokeRoundedAlert01,
113 color: Theme.of(context).colorScheme.onSurface,
114 ),
115 onPressed: () {
116 CustomSnackBar.display(
117 context,
118 ColorPalette.lightGreen,
119 AppLocalizations.of(context).translate(
120 'Hang tight! this feature will is coming soon'),
121 );
122 // _buildBottomSheet(
123 // body: ReportAnIsueDialog(),
124 // context: context,
125 // );
126 },
127 context: context,
128 ),
130 label: AppLocalizations.of(context).translate('FAQ'),
131 suffix: Icon(
132 HugeIcons.strokeRoundedMessageQuestion,
133 color: Theme.of(context).colorScheme.onSurface,
134 ),
135 onPressed: () {
136 _buildBottomSheet(
137 padding: EdgeInsets.all(5.sp),
138 body: FaqDialog(),
139 context: context,
140 );
141 },
142 context: context,
143 ),
144 ],
145 ),
146 SizedBox(height: 10.sp),
148 sectionTitle:
149 AppLocalizations.of(context).translate('User Agreements'),
150 context: context,
151 childrens: [
153 label:
154 AppLocalizations.of(context).translate('Privacy Policy'),
155 suffix: Icon(
156 HugeIcons.strokeRoundedShieldUser,
157 color: Theme.of(context).colorScheme.onSurface,
158 ),
159 onPressed: () {
160 _buildBottomSheet(
161 padding: EdgeInsets.all(15.sp),
162 body: PrivacyPolicyDisplayer(),
163 context: context,
164 );
165 },
166 context: context,
167 ),
169 label: AppLocalizations.of(context).translate('Terms of use'),
170 suffix: Icon(
171 HugeIcons.strokeRoundedPolicy,
172 color: Theme.of(context).colorScheme.onSurface,
173 ),
174 onPressed: () {
175 _buildBottomSheet(
176 padding: EdgeInsets.all(15.sp),
177 body: TermsOfUseDisplayer(),
178 context: context,
179 );
180 },
181 context: context,
182 ),
183 ],
184 ),
185 SizedBox(height: 10.sp),
187 sectionTitle: AppLocalizations.of(context).translate('Account'),
188 context: context,
189 childrens: [
191 label: AppLocalizations.of(context).translate('Logout'),
192 suffix: Icon(
193 HugeIcons.strokeRoundedLogout03,
194 color: Theme.of(context).colorScheme.error,
195 ),
196 color: Theme.of(context).colorScheme.error,
197 onPressed: () {
198 context.read<AuthenticationBloc>().add(SignOutEvent());
199 },
200 context: context,
201 ),
202 ],
203 ),
204 ],
205 ),
206 ),
207 );
208 }
209
211 required Widget body,
212 required BuildContext context,
213 EdgeInsets? padding,
214 }) {
215 return showModalBottomSheet(
216 context: context,
217 isScrollControlled: true,
218 backgroundColor: Colors.transparent,
219 builder: (context) => Padding(
220 padding: EdgeInsets.all(10.sp),
223 child: body,
224 ),
225 ),
226 );
227 }
228
230 required String sectionTitle,
231 required List<Widget> childrens,
232 required BuildContext context,
233 }) {
234 return SafeArea(
236 padding: EdgeInsets.zero,
237 child: Column(
238 crossAxisAlignment: CrossAxisAlignment.start,
239 children: [
240 ...childrens,
241 ],
242 ),
243 ),
244 );
245 }
246
248 required String label,
249 Widget? suffix,
250 Color? color,
251 required Function()? onPressed,
252 required BuildContext context,
253 }) {
254 return ElevatedButton(
255 onPressed: onPressed,
256 style: ElevatedButton.styleFrom(
257 backgroundColor: Theme.of(context).colorScheme.surface,
258 overlayColor: color?.withOpacity(0.11) ??
259 Theme.of(context).primaryColor.withOpacity(0.11),
260 padding: EdgeInsets.symmetric(
261 horizontal: 10.sp,
262 vertical: 20.sp,
263 )),
264 child: Row(
265 mainAxisAlignment: MainAxisAlignment.spaceBetween,
266 children: [
267 Text(
268 label,
269 style: Theme.of(context).textTheme.bodySmall?.copyWith(
270 color: color ??
271 Theme.of(context).colorScheme.onSurface.withOpacity(0.7),
272 ),
273 ),
274 suffix ??
275 Icon(
276 HugeIcons.strokeRoundedArrowRight02,
277 size: 17.sp,
278 color: color ??
279 Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
280 ),
281 ],
282 ),
283 );
284 }
285}
String translate(String key)
static AppLocalizations of(BuildContext context)
const SettingScreen({super.key})
override State< SettingScreen > createState()
const CustomCard({ super.key, required this.child, this.padding, this.bgColor, })
final Widget child
final EdgeInsets padding
final Color backgroundColor
final String label
final Color color
Definition failures.dart:1
override Widget build(BuildContext context)
const SettingScreen({super.key})
_buildSettingsButton({ required String label, Widget? suffix, Color? color, required Function()? onPressed, required BuildContext context, })
_buildSettingsSections({ required String sectionTitle, required List< Widget > childrens, required BuildContext context, })
_buildBottomSheet({ required Widget body, required BuildContext context, EdgeInsets? padding, })
final Function(ProposedTimeEntity pickedTimeRange) onPickTimeRange
final String title