Каркас приложения: авторизация, зоны/устройства/правила, управление устройствами

HTTP-клиент к /api/v1 с Sanctum-токеном (хранится в secure storage),
модели зеркалят Laravel API Resources. Экраны: логин, список устройств
с живым статусом, детальная страница устройства (история телеметрии,
turn-on/turn-off/set-level с проверкой capability), списки зон и правил
автоматизации (пока только чтение — формы создания/редактирования впереди).
This commit is contained in:
2026-08-12 01:12:39 +05:00
parent 6a00826194
commit 45b8733d22
25 changed files with 1531 additions and 129 deletions
+47
View File
@@ -0,0 +1,47 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../core/auth_service.dart';
import 'automation_rules_tab.dart';
import 'devices_tab.dart';
import 'zones_tab.dart';
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
int _index = 0;
static const _titles = ['Устройства', 'Зоны', 'Правила'];
static const _tabs = [DevicesTab(), ZonesTab(), AutomationRulesTab()];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(_titles[_index]),
actions: [
IconButton(
icon: const Icon(Icons.logout),
tooltip: 'Выйти',
onPressed: () => context.read<AuthService>().logout(),
),
],
),
body: IndexedStack(index: _index, children: _tabs),
bottomNavigationBar: NavigationBar(
selectedIndex: _index,
onDestinationSelected: (index) => setState(() => _index = index),
destinations: const [
NavigationDestination(icon: Icon(Icons.devices_other), label: 'Устройства'),
NavigationDestination(icon: Icon(Icons.room), label: 'Зоны'),
NavigationDestination(icon: Icon(Icons.rule), label: 'Правила'),
],
),
);
}
}