v1.1.0+3
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
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';
|
||||
import 'package:reverse_nn/ui/components/schedule_item_component.dart';
|
||||
|
||||
class CurrentStatusComponent extends StatelessWidget {
|
||||
const CurrentStatusComponent({super.key});
|
||||
@@ -10,40 +9,13 @@ class CurrentStatusComponent extends StatelessWidget {
|
||||
@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),
|
||||
]
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
),
|
||||
),
|
||||
|
||||
return GetBuilder<ScheduleController>(
|
||||
builder: (controller) {
|
||||
if(controller.currentSchedule.value == null) { return Container(); }
|
||||
|
||||
return ScheduleItemComponent(item: controller.currentSchedule.value!);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
String formatDate(DateTime date, {bool showDate = false}) => DateFormat(showDate ? 'hh:mm (dd.MM.yyyy)' : 'hh:mm').format(date);
|
||||
|
||||
}
|
||||
57
lib/ui/components/schedule_item_component.dart
Normal file
57
lib/ui/components/schedule_item_component.dart
Normal file
@@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart' show DateFormat;
|
||||
import 'package:reverse_nn/application/services/schedule.dart';
|
||||
|
||||
class ScheduleItemComponent extends StatelessWidget {
|
||||
final Map<String, dynamic> item;
|
||||
const ScheduleItemComponent({super.key, required this.item});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(top: 10),
|
||||
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.secondaryContainer,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Icon(ScheduleService.getIconByDirection(item['direction'] as String), size: 56),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_directionText(context),
|
||||
_startText(context),
|
||||
_endText(context),
|
||||
],
|
||||
))
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String formatDate(DateTime date, {bool showDate = false}) {
|
||||
return DateFormat(showDate ? 'HH:mm dd.MM.yyyy' : 'HH:mm').format(date);
|
||||
}
|
||||
|
||||
Widget _directionText(BuildContext context) => Text(
|
||||
ScheduleService.formatDirection(item['direction'] ?? ''),
|
||||
style: Theme.of(context).textTheme.headlineLarge
|
||||
);
|
||||
|
||||
Widget _startText(BuildContext context) => Text(
|
||||
'C\t\t\t\t${formatDate(item['start'], showDate: item['show_start_date'] ?? false)}',
|
||||
style: Theme.of(context).textTheme.titleLarge
|
||||
);
|
||||
|
||||
Widget _endText(BuildContext context) => Text(
|
||||
'До\t${formatDate(item['end'], showDate: item['show_end_date'] ?? false)}',
|
||||
style: Theme.of(context).textTheme.titleLarge
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user