🎉 Initial Commit
This commit is contained in:
44
lib/main.dart
Normal file
44
lib/main.dart
Normal file
@ -0,0 +1,44 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get_navigation/src/root/get_material_app.dart';
|
||||
import 'package:rhythm_box/router.dart';
|
||||
import 'package:rhythm_box/translations.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetMaterialApp.router(
|
||||
title: 'DietaryGuard',
|
||||
routerDelegate: router.routerDelegate,
|
||||
routeInformationParser: router.routeInformationParser,
|
||||
routeInformationProvider: router.routeInformationProvider,
|
||||
backButtonDispatcher: router.backButtonDispatcher,
|
||||
locale: Get.deviceLocale,
|
||||
theme: ThemeData(
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: Colors.orange,
|
||||
brightness: Brightness.light,
|
||||
),
|
||||
useMaterial3: true,
|
||||
),
|
||||
darkTheme: ThemeData(
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: Colors.orange,
|
||||
brightness: Brightness.dark,
|
||||
),
|
||||
useMaterial3: true,
|
||||
),
|
||||
themeMode: ThemeMode.system,
|
||||
translations: AppTranslations(),
|
||||
onInit: () => _initializeProviders(context),
|
||||
);
|
||||
}
|
||||
|
||||
void _initializeProviders(BuildContext context) async {}
|
||||
}
|
22
lib/router.dart
Normal file
22
lib/router.dart
Normal file
@ -0,0 +1,22 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:rhythm_box/screens/explore.dart';
|
||||
import 'package:rhythm_box/screens/settings.dart';
|
||||
import 'package:rhythm_box/shells/nav_shell.dart';
|
||||
|
||||
final router = GoRouter(routes: [
|
||||
ShellRoute(
|
||||
builder: (context, state, child) => NavShell(child: child),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: "/",
|
||||
name: "explore",
|
||||
builder: (context, state) => const ExploreScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: "/settings",
|
||||
name: "settings",
|
||||
builder: (context, state) => const SettingsScreen(),
|
||||
),
|
||||
],
|
||||
),
|
||||
]);
|
15
lib/screens/explore.dart
Normal file
15
lib/screens/explore.dart
Normal file
@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ExploreScreen extends StatefulWidget {
|
||||
const ExploreScreen({super.key});
|
||||
|
||||
@override
|
||||
State<ExploreScreen> createState() => _ExploreScreenState();
|
||||
}
|
||||
|
||||
class _ExploreScreenState extends State<ExploreScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Placeholder();
|
||||
}
|
||||
}
|
15
lib/screens/settings.dart
Normal file
15
lib/screens/settings.dart
Normal file
@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SettingsScreen extends StatefulWidget {
|
||||
const SettingsScreen({super.key});
|
||||
|
||||
@override
|
||||
State<SettingsScreen> createState() => _SettingsScreenState();
|
||||
}
|
||||
|
||||
class _SettingsScreenState extends State<SettingsScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Placeholder();
|
||||
}
|
||||
}
|
49
lib/shells/nav_shell.dart
Normal file
49
lib/shells/nav_shell.dart
Normal file
@ -0,0 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class Destination {
|
||||
const Destination(this.title, this.page, this.icon);
|
||||
final String title;
|
||||
final String page;
|
||||
final IconData icon;
|
||||
}
|
||||
|
||||
class NavShell extends StatefulWidget {
|
||||
final Widget child;
|
||||
|
||||
const NavShell({super.key, required this.child});
|
||||
|
||||
@override
|
||||
State<NavShell> createState() => _NavShellState();
|
||||
}
|
||||
|
||||
class _NavShellState extends State<NavShell> {
|
||||
int _focusDestination = 0;
|
||||
|
||||
final List<Destination> _allDestinations = <Destination>[
|
||||
Destination('explore'.tr, 'explore', Icons.explore),
|
||||
Destination('settings'.tr, 'settings', Icons.settings)
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: widget.child,
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
showUnselectedLabels: false,
|
||||
currentIndex: _focusDestination,
|
||||
items: _allDestinations
|
||||
.map((x) => BottomNavigationBarItem(
|
||||
icon: Icon(x.icon),
|
||||
label: x.title,
|
||||
))
|
||||
.toList(),
|
||||
onTap: (value) {
|
||||
GoRouter.of(context).goNamed(_allDestinations[value].page);
|
||||
setState(() => _focusDestination = value);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
11
lib/translations.dart
Normal file
11
lib/translations.dart
Normal file
@ -0,0 +1,11 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rhythm_box/translations/en_us.dart';
|
||||
import 'package:rhythm_box/translations/zh_cn.dart';
|
||||
|
||||
class AppTranslations extends Translations {
|
||||
@override
|
||||
Map<String, Map<String, String>> get keys => {
|
||||
'en_US': i18nEnglish,
|
||||
'zh_CN': i18nSimplifiedChinese,
|
||||
};
|
||||
}
|
5
lib/translations/en_us.dart
Normal file
5
lib/translations/en_us.dart
Normal file
@ -0,0 +1,5 @@
|
||||
const i18nEnglish = {
|
||||
'appName': 'RhythmBox',
|
||||
'explore': 'Explore',
|
||||
'settings': 'Settings',
|
||||
};
|
5
lib/translations/zh_cn.dart
Normal file
5
lib/translations/zh_cn.dart
Normal file
@ -0,0 +1,5 @@
|
||||
const i18nSimplifiedChinese = {
|
||||
'appName': '韵律盒',
|
||||
'explore': '探索',
|
||||
'settings': '设置',
|
||||
};
|
Reference in New Issue
Block a user