53 lines
1.6 KiB
Dart
Executable File
53 lines
1.6 KiB
Dart
Executable File
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'values/strings.dart';
|
|
|
|
class MainScaffold extends StatelessWidget {
|
|
final Widget child;
|
|
|
|
const MainScaffold({super.key, required this.child});
|
|
|
|
int _locationToIndex(String location) {
|
|
switch (location) {
|
|
case '/': return 0;
|
|
case '/add': return 1;
|
|
case '/flashcards': return 2;
|
|
case '/leaderboard': return 3;
|
|
//case '/settings': return 4;
|
|
default: return 0;
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final location = GoRouterState.of(context).uri.toString();
|
|
final currentIndex = _locationToIndex(location);
|
|
|
|
return Scaffold(
|
|
body: child,
|
|
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
type: BottomNavigationBarType.fixed,
|
|
currentIndex: currentIndex,
|
|
|
|
onTap: (index) {
|
|
switch (index) {
|
|
case 0: context.go('/'); break;
|
|
case 1: context.go('/add'); break;
|
|
case 2: context.go('/flashcards'); break;
|
|
case 3: context.go('/leaderboard'); break;
|
|
//case 4: context.go('/settings'); break;
|
|
}
|
|
},
|
|
|
|
items: [
|
|
BottomNavigationBarItem(icon: Icon(Icons.list), label: Strings.list),
|
|
BottomNavigationBarItem(icon: Icon(Icons.add), label: Strings.add),
|
|
BottomNavigationBarItem(icon: Icon(Icons.repeat), label: Strings.flashcards),
|
|
BottomNavigationBarItem(icon: Icon(Icons.leaderboard), label: Strings.leaderboard),
|
|
//BottomNavigationBarItem(icon: Icon(Icons.settings), label: Strings.settings),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} |