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 createState() => _HomeScreenState(); } class _HomeScreenState extends State { 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().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: 'Правила'), ], ), ); } }