new UI + new targets.
This commit is contained in:
@@ -5,12 +5,12 @@ import 'settings_screen.dart';
|
||||
import 'target_screen.dart';
|
||||
import '../widgets/bottom_nav.dart';
|
||||
import 'camera_screen.dart';
|
||||
import 'spectator_screen.dart';
|
||||
import '../services/app_settings.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
enum AppTab { book, shooting, camera, calendar, settings }
|
||||
|
||||
/// The five tabs. Every page draws its own large title (see PageHeader);
|
||||
/// the camera opens as its own screen.
|
||||
class HomeScreen extends StatefulWidget {
|
||||
const HomeScreen({super.key});
|
||||
|
||||
@@ -29,12 +29,12 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
AppTab.settings: 'Settings',
|
||||
};
|
||||
|
||||
static const Map<AppTab, IconData> _icons = {
|
||||
AppTab.book: Icons.book,
|
||||
AppTab.shooting: Icons.my_location,
|
||||
AppTab.camera: Icons.camera_alt,
|
||||
AppTab.calendar: Icons.calendar_today,
|
||||
AppTab.settings: Icons.settings,
|
||||
static const Map<AppTab, (IconData, IconData)> _icons = {
|
||||
AppTab.book: (Icons.menu_book_outlined, Icons.menu_book_rounded),
|
||||
AppTab.shooting: (Icons.gps_fixed_rounded, Icons.gps_fixed_rounded),
|
||||
AppTab.camera: (Icons.photo_camera_outlined, Icons.photo_camera_rounded),
|
||||
AppTab.calendar: (Icons.calendar_today_outlined, Icons.calendar_today_rounded),
|
||||
AppTab.settings: (Icons.tune_rounded, Icons.tune_rounded),
|
||||
};
|
||||
|
||||
// Calendar is only shown to club members (see Settings > Club code)
|
||||
@@ -67,10 +67,13 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
|
||||
// When returning from the camera screen, always land on the Shooting tab
|
||||
void _openCameraScan() async {
|
||||
// The photo camera is dark in both themes
|
||||
AppSettings.instance.holdDark();
|
||||
await Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (context) => const CameraScreen()),
|
||||
);
|
||||
setState(() => _selected = AppTab.shooting);
|
||||
AppSettings.instance.releaseDark();
|
||||
if (mounted) setState(() => _selected = AppTab.shooting);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -83,49 +86,12 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
if (!tabs.contains(_selected)) _selected = AppTab.settings; // calendar was just locked
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
settings.t(_titles[_selected]!),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
backgroundColor: AppTheme.bar,
|
||||
iconTheme: const IconThemeData(color: Colors.white),
|
||||
automaticallyImplyLeading: false,
|
||||
scrolledUnderElevation: 0, // For Material 3 (Flutter 3.7+)
|
||||
actions: [
|
||||
if (_selected == AppTab.book)
|
||||
IconButton(
|
||||
tooltip: settings.t('Help'),
|
||||
icon: const Icon(Icons.info_outline_rounded, color: Colors.white),
|
||||
onPressed: () => showBookHelp(context),
|
||||
),
|
||||
if (_selected == AppTab.shooting)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.visibility_rounded, color: Colors.white),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SpectatorScreen(
|
||||
selectedLanguage: settings.language,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
backgroundColor: settings.backgroundColor,
|
||||
body: _page(_selected),
|
||||
body: KeyedSubtree(key: ValueKey(_selected), child: _page(_selected)),
|
||||
bottomNavigationBar: BottomNavBar(
|
||||
selectedIndex: tabs.indexOf(_selected),
|
||||
onItemTapped: (i) => _onTabTapped(tabs[i]),
|
||||
items: [
|
||||
for (final tab in tabs)
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(_icons[tab]),
|
||||
label: settings.t(_titles[tab]!),
|
||||
),
|
||||
for (final tab in tabs) NavItem(_icons[tab]!.$1, _icons[tab]!.$2, settings.t(_titles[tab]!)),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user