Files
reverse_nn/lib/ui/components/current_status_component.dart
2024-12-16 02:35:30 +03:00

49 lines
2.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart' show DateFormat;
import 'package:reverse_nn/application/controllers/schedule_controller.dart';
import 'package:reverse_nn/application/services/schedule.dart';
class CurrentStatusComponent extends StatelessWidget {
const CurrentStatusComponent({super.key});
@override
Widget build(BuildContext context) {
final ScheduleController controller = Get.put(ScheduleController());
return Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primaryContainer,
borderRadius: BorderRadius.circular(10),
),
child: Padding(
padding: const EdgeInsets.all(10),
child: GetBuilder<ScheduleController>(
builder: (scheduleController) {
return Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(ScheduleService.getIconByDirection(scheduleController.currentSchedule.value?['direction']), size: 96),
const SizedBox(width: 16),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if(scheduleController.currentSchedule.value != null) ...[
Text(ScheduleService.formatDirection(scheduleController.currentSchedule.value?['direction'] ?? ''), style: Theme.of(context).textTheme.headlineLarge),
Text('C\t\t\t\t${formatDate(scheduleController.currentSchedule.value?['start'], showDate: scheduleController.currentSchedule.value!['need_show_end_date'])}', style: Theme.of(context).textTheme.titleMedium),
Text('До\t${formatDate(scheduleController.currentSchedule.value!['end'], showDate: scheduleController.currentSchedule.value!['need_show_end_date'])}', style: Theme.of(context).textTheme.titleMedium),
]
],
)
],
);
}
),
),
);
}
String formatDate(DateTime date, {bool showDate = false}) => DateFormat(showDate ? 'hh:mm (dd.MM.yyyy)' : 'hh:mm').format(date);
}