Semi Final 7th Aug 2024

This commit is contained in:
2024-08-07 14:24:05 +09:00
parent 66ade1fe09
commit 347861e5a1
23 changed files with 342 additions and 160 deletions

View File

@ -8,6 +8,9 @@ import 'package:rogapp/model/category.dart';
import 'package:rogapp/model/team.dart';
import 'package:intl/intl.dart';
import 'package:timezone/timezone.dart' as tz;
import 'package:timezone/data/latest.dart' as tz;
class EntryDetailPage extends GetView<EntryController> {
@override
Widget build(BuildContext context) {
@ -70,7 +73,7 @@ class EntryDetailPage extends GetView<EntryController> {
title: Text('日付'),
subtitle: Text(
controller.selectedDate.value != null
? DateFormat('yyyy-MM-dd').format(controller.selectedDate.value!)
? DateFormat('yyyy-MM-dd').format(tz.TZDateTime.from(controller.selectedDate.value!, tz.getLocation('Asia/Tokyo')))
: '日付を選択してください',
),
onTap: () async {
@ -78,14 +81,22 @@ class EntryDetailPage extends GetView<EntryController> {
Get.snackbar('Error', 'Please select an event first');
return;
}
final tz.TZDateTime now = tz.TZDateTime.now(tz.getLocation('Asia/Tokyo'));
final tz.TZDateTime eventStart = tz.TZDateTime.from(controller.selectedEvent.value!.startDatetime, tz.getLocation('Asia/Tokyo'));
final tz.TZDateTime eventEnd = tz.TZDateTime.from(controller.selectedEvent.value!.endDatetime, tz.getLocation('Asia/Tokyo'));
final tz.TZDateTime initialDate = controller.selectedDate.value != null
? tz.TZDateTime.from(controller.selectedDate.value!, tz.getLocation('Asia/Tokyo'))
: (now.isAfter(eventStart) ? now : eventStart);
final DateTime? picked = await showDatePicker(
context: context,
initialDate: controller.selectedDate.value ?? controller.selectedEvent.value!.startDatetime,
firstDate: controller.selectedEvent.value!.startDatetime,
lastDate: controller.selectedEvent.value!.endDatetime,
initialDate: initialDate,
firstDate: eventStart,
lastDate: eventEnd,
);
if (picked != null) {
controller.updateDate(picked);
controller.updateDate(tz.TZDateTime.from(picked, tz.getLocation('Asia/Tokyo')));
}
},
),
@ -96,6 +107,7 @@ class EntryDetailPage extends GetView<EntryController> {
onPressed: () => controller.createEntry(),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
minimumSize: Size(double.infinity, 50),
),
)
@ -108,6 +120,7 @@ class EntryDetailPage extends GetView<EntryController> {
onPressed: () => controller.deleteEntry(),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
foregroundColor: Colors.white,
minimumSize: Size(0, 50),
),
),
@ -119,6 +132,7 @@ class EntryDetailPage extends GetView<EntryController> {
onPressed: () => controller.updateEntry(),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.lightBlue,
foregroundColor: Colors.white,
minimumSize: Size(0, 50),
),
),