Skip to content

Commit 98f41eb

Browse files
authored
Added 24 hr format feature
1 parent 13d9a6b commit 98f41eb

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

lib/widgets/add_Task.dart

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
2626
DateTime? due;
2727
String dueString = '';
2828
String priority = 'M';
29+
bool use24hourFormate = false;
2930
final tagcontroller = TextEditingController();
3031
List<String> tags = [];
3132

@@ -75,6 +76,10 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
7576
buildDueDate(context),
7677
const SizedBox(height: 8),
7778
buildPriority(),
79+
const SizedBox(
80+
height: 8,
81+
),
82+
buildformate(),
7883
buildTags(),
7984
],
8085
),
@@ -217,7 +222,12 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
217222
onSurface: Colors.black,
218223
),
219224
),
220-
child: child!,
225+
child: MediaQuery(
226+
data: MediaQuery.of(context).copyWith(
227+
alwaysUse24HourFormat: use24hourFormate,
228+
),
229+
child: child!),
230+
);
221231
);
222232
},
223233
fieldHintText: "Month/Date/Year",
@@ -351,6 +361,40 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
351361
),
352362
],
353363
);
364+
Widget buildformate() {
365+
return Row(mainAxisAlignment: MainAxisAlignment.start, children: [
366+
Text(
367+
'Click to Choose:',
368+
style: GoogleFonts.poppins(
369+
fontWeight: FontWeight.bold,
370+
color: AppSettings.isDarkMode ? Colors.white : Colors.black,
371+
),
372+
),
373+
const SizedBox(
374+
width: 5.0,
375+
),
376+
Wrap(
377+
spacing: 5.0,
378+
children: List<Widget>.generate(
379+
1,
380+
(int index) {
381+
return ChoiceChip(
382+
label: const Text(
383+
'24hour',
384+
),
385+
selected: use24hourFormate,
386+
onSelected: (bool? selected) {
387+
if (selected != use24hourFormate) {
388+
setState(() {
389+
use24hourFormate = selected!;
390+
});
391+
}
392+
});
393+
},
394+
),
395+
)
396+
]);
397+
}
354398

355399
Widget buildCancelButton(BuildContext context) => TextButton(
356400
child: Text(

lib/widgets/taskdetails/dateTimePicker.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ class DateTimeWidget extends StatelessWidget {
7777
var time = await showTimePicker(
7878
context: context,
7979
initialTime: TimeOfDay.now(),
80+
builder: (BuildContext context, Widget? child) {
81+
return MediaQuery(
82+
data: MediaQuery.of(context).copyWith(
83+
alwaysUse24HourFormat: true,
84+
),
85+
child: child!);
86+
},
8087
);
8188
if (time != null) {
8289
var dateTime = date.add(

0 commit comments

Comments
 (0)