88 lines
2.5 KiB
Dart
88 lines
2.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:kettlebell_tracker/screens/home_screen.dart';
|
|
import 'package:kettlebell_tracker/screens/settings_screen.dart';
|
|
import 'package:kettlebell_tracker/screens/training_screen.dart';
|
|
import 'package:kettlebell_tracker/screens/history_screen.dart';
|
|
import 'package:kettlebell_tracker/theme/app_theme.dart';
|
|
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
|
import 'dart:io';
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
|
|
sqfliteFfiInit();
|
|
databaseFactory = databaseFactoryFfi;
|
|
}
|
|
|
|
runApp(
|
|
const ProviderScope(child: MyApp()),
|
|
);
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Giant Programm Tracker',
|
|
theme: AppTheme.darkTheme,
|
|
home: const MainScreen(),
|
|
debugShowCheckedModeBanner: false,
|
|
);
|
|
}
|
|
}
|
|
|
|
class MainScreen extends ConsumerStatefulWidget {
|
|
const MainScreen({super.key});
|
|
|
|
@override
|
|
ConsumerState<MainScreen> createState() => _MainScreenState();
|
|
}
|
|
|
|
class _MainScreenState extends ConsumerState<MainScreen> {
|
|
int _selectedIndex = 0;
|
|
|
|
static const List<Widget> _widgetOptions = <Widget>[
|
|
HomeScreen(),
|
|
SettingsScreen(),
|
|
TrainingScreen(),
|
|
HistoryScreen(),
|
|
];
|
|
|
|
void _onItemTapped(int index) {
|
|
setState(() {
|
|
_selectedIndex = index;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
return Scaffold(
|
|
body: Center(child: _widgetOptions.elementAt(_selectedIndex)),
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
items: const <BottomNavigationBarItem>[
|
|
BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(Icons.settings),
|
|
label: 'Einstellungen',
|
|
),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(Icons.sports_gymnastics),
|
|
label: 'Training',
|
|
),
|
|
BottomNavigationBarItem(icon: Icon(Icons.history), label: 'Historie'),
|
|
],
|
|
currentIndex: _selectedIndex,
|
|
onTap: _onItemTapped,
|
|
type: BottomNavigationBarType.fixed, // Important for more than 3 items
|
|
backgroundColor: theme.colorScheme.surface,
|
|
selectedItemColor: theme.colorScheme.primary,
|
|
unselectedItemColor: AppTheme.oneDarkTextWeak,
|
|
),
|
|
);
|
|
}
|
|
}
|