-
Notifications
You must be signed in to change notification settings - Fork 310
Expand file tree
/
Copy pathcalendar_configs.dart
More file actions
179 lines (171 loc) · 6.38 KB
/
calendar_configs.dart
File metadata and controls
179 lines (171 loc) · 6.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import 'package:calendar_view/calendar_view.dart';
import 'package:flutter/material.dart';
import '../enumerations.dart';
import '../extension.dart';
import '../localization/locale_controller.dart';
import '../theme/app_colors.dart';
import 'add_event_form.dart';
class CalendarConfig extends StatefulWidget {
final void Function(CalendarView view) onViewChange;
final void Function(bool)? onThemeChange;
final CalendarView currentView;
const CalendarConfig({
super.key,
required this.onViewChange,
this.onThemeChange,
this.currentView = CalendarView.month,
});
@override
State<CalendarConfig> createState() => _CalendarConfigState();
}
class _CalendarConfigState extends State<CalendarConfig> {
bool isDarkMode = false;
// Map of supported locales with their display names
final Map<String, String> supportedLocales = {
'en': 'English',
'es': 'Spanish',
'ar': 'Arabic',
};
@override
Widget build(BuildContext context) {
final color = Theme.of(context).colorScheme;
final translate = context.translate;
final localeController = LocaleController.of(context);
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(left: 20, top: 20),
child: Text(
translate.flutterCalendarPage,
style: TextStyle(color: color.onSurface, fontSize: 30),
),
),
Divider(color: AppColors.lightNavyBlue),
Expanded(
child: SingleChildScrollView(
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 20),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// Language selector dropdown
DropdownButton<String>(
value: localeController.currentLocale,
icon: const Icon(Icons.language),
elevation: 16,
style: TextStyle(color: color.onSurface, fontSize: 20),
onChanged: (String? value) {
if (value != null) {
localeController.setLocale(value);
}
},
items: supportedLocales.entries
.map<DropdownMenuItem<String>>((entry) {
return DropdownMenuItem<String>(
value: entry.key,
child: Text(entry.value),
);
})
.toList(),
),
Row(
children: [
Text(
translate.darkMode,
style: TextStyle(
fontSize: 20.0,
color: color.onSurface,
),
),
Switch(
value: isDarkMode,
onChanged: (value) {
setState(() => isDarkMode = value);
if (widget.onThemeChange != null) {
widget.onThemeChange!(isDarkMode);
}
},
),
],
),
],
),
SizedBox(height: 20),
Text(
translate.activeView,
style: TextStyle(
fontSize: 20.0,
color: Theme.of(context).colorScheme.onSurface,
),
),
Wrap(
children: List.generate(CalendarView.values.length, (index) {
final view = CalendarView.values[index];
// Get translated name based on the view
String viewName = '';
switch (view) {
case CalendarView.month:
viewName = translate.monthView;
break;
case CalendarView.day:
viewName = translate.dayView;
break;
case CalendarView.week:
viewName = translate.weekView;
case CalendarView.multiDay:
viewName = translate.multidayView;
break;
}
return GestureDetector(
onTap: () => widget.onViewChange(view),
child: Container(
padding: EdgeInsets.symmetric(
vertical: 10,
horizontal: 40,
),
margin: EdgeInsets.only(right: 20, top: 20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(7),
color: view == widget.currentView
? AppColors.navyBlue
: AppColors.bluishGrey,
),
child: Text(
viewName,
style: TextStyle(
color: view == widget.currentView
? AppColors.white
: AppColors.black,
fontSize: 17,
),
),
),
);
}),
),
SizedBox(height: 40),
Text(
"${translate.addEvent}: ",
style: TextStyle(fontSize: 20.0, color: color.onSurface),
),
SizedBox(height: 20),
AddOrEditEventForm(
onEventAdd: (event) {
CalendarControllerProvider.of(
context,
).controller.add(event);
},
),
],
),
),
),
],
);
}
}