121 lines
4.1 KiB
Dart
121 lines
4.1 KiB
Dart
import 'package:flutter/material.dart';
|
||
import 'package:get/get.dart';
|
||
|
||
import 'home_controller.dart';
|
||
import 'widgets/shopping_list_card.dart';
|
||
import 'widgets/soon_expiries_card.dart';
|
||
import 'widgets/stock_products_card.dart';
|
||
|
||
class HomePage extends GetView<HomeController> {
|
||
const HomePage({super.key});
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Scaffold(
|
||
appBar: AppBar(
|
||
title: const Text("Управление продуктами"),
|
||
actions: [
|
||
Row(
|
||
mainAxisSize: MainAxisSize.min,
|
||
children: [
|
||
Obx(
|
||
() => Text("Привет, ${controller.user.value.login}!"),
|
||
),
|
||
const SizedBox(width: 8),
|
||
PopupMenuButton(
|
||
icon: const Icon(Icons.more_vert),
|
||
itemBuilder: (context) => [
|
||
PopupMenuItem(
|
||
onTap: () => controller.openCategoryManagerDialog(),
|
||
child: const ListTile(
|
||
title: Text("Управление категориями"),
|
||
),
|
||
),
|
||
PopupMenuItem(
|
||
onTap: () => controller.openUserManagerDialog(),
|
||
child: const ListTile(
|
||
title: Text("Управление пользователями"),
|
||
),
|
||
),
|
||
const PopupMenuItem(
|
||
padding: EdgeInsets.zero,
|
||
enabled: false,
|
||
child: PopupMenuDivider(),
|
||
),
|
||
PopupMenuItem(
|
||
onTap: () => controller.logout(),
|
||
child: const ListTile(
|
||
title: Text("Выйти"),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
],
|
||
),
|
||
],
|
||
),
|
||
body: Row(
|
||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||
children: [
|
||
Expanded(
|
||
child: Card.filled(
|
||
clipBehavior: Clip.antiAlias,
|
||
child: Column(
|
||
children: [
|
||
ListTile(
|
||
leading: const Icon(Icons.timelapse),
|
||
title: const Text("Скоро испортится!"),
|
||
subtitle: const Text("Надо о них позаботиться"),
|
||
trailing: IconButton(
|
||
onPressed: () => controller.refreshSoonExpiries(),
|
||
icon: const Icon(Icons.refresh_rounded),
|
||
),
|
||
),
|
||
const SoonExpiriesCard(),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
Expanded(
|
||
child: Card.filled(
|
||
clipBehavior: Clip.antiAlias,
|
||
child: Column(
|
||
children: [
|
||
ListTile(
|
||
leading: const Icon(Icons.shelves),
|
||
title: const Text("Продукты в наличии"),
|
||
subtitle: const Text("Эти у нас есть"),
|
||
trailing: IconButton(
|
||
onPressed: () => controller.addNewStorage(),
|
||
icon: const Icon(Icons.add_rounded),
|
||
),
|
||
),
|
||
const StockProductsCard()
|
||
],
|
||
),
|
||
),
|
||
),
|
||
Expanded(
|
||
child: Card.filled(
|
||
clipBehavior: Clip.antiAlias,
|
||
child: Column(
|
||
children: [
|
||
ListTile(
|
||
leading: const Icon(Icons.shopping_bag_outlined),
|
||
title: const Text("Список покупок"),
|
||
subtitle: const Text("Это надо купить"),
|
||
trailing: IconButton(
|
||
onPressed: () => controller.addNewShoppingItem(),
|
||
icon: const Icon(Icons.add_rounded),
|
||
),
|
||
),
|
||
const ShoppingListCard()
|
||
],
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
}
|