Initial commit
This commit is contained in:
47
lib/ui/components/current_status_component.dart
Normal file
47
lib/ui/components/current_status_component.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
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';
|
||||
|
||||
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: [
|
||||
const Icon(Icons.exit_to_app, size: 96),
|
||||
const SizedBox(width: 16),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if(scheduleController.currentSchedule.value != null) ...[
|
||||
Text(scheduleController.currentSchedule.value?['direction'] ?? '', style: Theme.of(context).textTheme.headlineLarge),
|
||||
Text('C ${formatDate(scheduleController.currentSchedule.value?['start'])} До ${formatDate(scheduleController.currentSchedule.value!['end'])}', style: Theme.of(context).textTheme.titleMedium)
|
||||
]
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String formatDate(DateTime date) => DateFormat('hh:mm').format(date);
|
||||
|
||||
}
|
||||
33
lib/ui/components/grid_menu_item.dart
Normal file
33
lib/ui/components/grid_menu_item.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class GridMenuItem extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final void Function()? onTap;
|
||||
|
||||
const GridMenuItem({super.key, required this.icon, required this.label, this.onTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.secondaryContainer,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Icon(icon, size: 64),
|
||||
const SizedBox(height: 6),
|
||||
Text(label, style: Theme.of(context).textTheme.titleMedium, textAlign: TextAlign.center)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
26
lib/ui/layouts/application_layout.dart
Normal file
26
lib/ui/layouts/application_layout.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reverse_nn/application/controllers/application_controller.dart';
|
||||
|
||||
class ApplicationLayout extends StatelessWidget {
|
||||
final Widget body;
|
||||
const ApplicationLayout({super.key, required this.body});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ApplicationController applicationController = Get.put(ApplicationController());
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||
title: const Text('Реверс НН'),
|
||||
actions: [
|
||||
IconButton(icon: Icon(
|
||||
applicationController.getThemeIcon()),
|
||||
onPressed: applicationController.toggleTheme
|
||||
),
|
||||
],
|
||||
),
|
||||
body: body,
|
||||
);
|
||||
}
|
||||
}
|
||||
48
lib/ui/screens/home_screen.dart
Normal file
48
lib/ui/screens/home_screen.dart
Normal file
@@ -0,0 +1,48 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reverse_nn/application/controllers/home_controller.dart';
|
||||
import 'package:reverse_nn/application/services/schedule.dart';
|
||||
import 'package:reverse_nn/ui/components/current_status_component.dart';
|
||||
import 'package:reverse_nn/ui/components/grid_menu_item.dart';
|
||||
import 'package:reverse_nn/ui/layouts/application_layout.dart';
|
||||
|
||||
class HomeScreen extends GetWidget<HomeController> {
|
||||
const HomeScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ApplicationLayout(body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const CurrentStatusComponent(),
|
||||
const SizedBox(height: 16),
|
||||
Expanded(
|
||||
child: GridView(
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 10,
|
||||
crossAxisSpacing: 10,
|
||||
),
|
||||
children: [
|
||||
GridMenuItem(icon: Icons.calendar_month, label: 'Расписание', onTap: () {
|
||||
// log(DateTime(2024, 8, 1, 0, 0, 0).toIso8601String());
|
||||
ScheduleService().getCurrentStatus().then((val) {
|
||||
log(val.toString());
|
||||
});
|
||||
}),
|
||||
const GridMenuItem(icon: Icons.monetization_on, label: 'Поддержать автора'),
|
||||
// GridMenuItem(),
|
||||
// GridMenuItem(),
|
||||
]
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user