2022-04-23 09:20:15 +02:00
|
|
|
import 'package:animated_splash_screen/animated_splash_screen.dart';
|
2023-11-10 05:04:17 +01:00
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
import 'package:page_transition/page_transition.dart';
|
|
|
|
import 'package:path_provider/path_provider.dart';
|
2022-05-16 02:51:47 +02:00
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2022-04-18 15:57:03 +02:00
|
|
|
|
2023-09-22 09:29:07 +02:00
|
|
|
import 'package:nekoya_app/screens/login.dart';
|
|
|
|
import 'package:nekoya_app/screens/register.dart';
|
|
|
|
import 'package:nekoya_app/screens/payment.dart';
|
2023-11-10 05:04:17 +01:00
|
|
|
import 'package:nekoya_app/screens/forgotpassword.dart';
|
|
|
|
import 'package:nekoya_app/screens/onboarding.dart';
|
2023-09-22 09:29:07 +02:00
|
|
|
import 'package:nekoya_app/components/menu.dart';
|
|
|
|
import 'package:nekoya_app/utils/navigation_auth.dart';
|
2022-04-22 22:08:59 +02:00
|
|
|
|
2023-11-10 05:04:17 +01:00
|
|
|
void main() async {
|
2022-04-22 22:08:59 +02:00
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
2023-11-10 05:04:17 +01:00
|
|
|
|
|
|
|
// Init Storage
|
|
|
|
final dir = await getApplicationDocumentsDirectory();
|
|
|
|
Hive.defaultDirectory = dir.path;
|
|
|
|
|
2022-05-22 11:53:47 +02:00
|
|
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
|
|
|
|
.then((_) {
|
2022-05-12 17:10:36 +02:00
|
|
|
runApp(const Nekoya());
|
2022-04-22 22:08:59 +02:00
|
|
|
});
|
2022-04-18 15:57:03 +02:00
|
|
|
}
|
|
|
|
|
2022-05-12 17:10:36 +02:00
|
|
|
class Nekoya extends StatefulWidget {
|
|
|
|
const Nekoya({Key? key}) : super(key: key);
|
2022-04-18 15:57:03 +02:00
|
|
|
|
2022-05-12 17:10:36 +02:00
|
|
|
@override
|
|
|
|
State<Nekoya> createState() => _NekoyaState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _NekoyaState extends State<Nekoya> {
|
2022-04-18 15:57:03 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-11-10 05:04:17 +01:00
|
|
|
final box = Hive.box();
|
|
|
|
final onBoardingStatus = box.get('onboarding', defaultValue: 'true');
|
|
|
|
|
2022-04-23 09:20:15 +02:00
|
|
|
return MaterialApp(
|
2022-04-25 16:03:54 +02:00
|
|
|
theme: ThemeData(
|
2022-04-26 11:15:38 +02:00
|
|
|
colorScheme:
|
|
|
|
ColorScheme.fromSwatch(accentColor: const Color(0xff8B0000))),
|
2022-04-23 09:20:15 +02:00
|
|
|
debugShowCheckedModeBanner: false,
|
2022-05-21 12:08:45 +02:00
|
|
|
initialRoute: '',
|
2022-05-14 18:29:00 +02:00
|
|
|
routes: {
|
2022-05-22 11:53:47 +02:00
|
|
|
'': (context) => AnimatedSplashScreen(
|
|
|
|
splash: 'assets/images/logo_transparent.webp',
|
|
|
|
pageTransitionType: PageTransitionType.fade,
|
|
|
|
backgroundColor: const Color(0xff1b1c1e),
|
|
|
|
splashIconSize: 150,
|
2023-11-10 05:04:17 +01:00
|
|
|
nextScreen: onBoardingStatus == 'true'
|
|
|
|
? const Onboarding()
|
|
|
|
: const Menu(
|
|
|
|
initialScreen: 2,
|
|
|
|
),
|
2022-05-22 11:53:47 +02:00
|
|
|
),
|
2022-05-14 18:29:00 +02:00
|
|
|
'/login': (context) => const Login(),
|
|
|
|
'/register': (context) => const Register(),
|
2022-05-22 11:53:47 +02:00
|
|
|
'/products': (context) => const Menu(
|
|
|
|
initialScreen: 1,
|
|
|
|
),
|
|
|
|
'/cart': (context) => const Menu(
|
|
|
|
initialScreen: 3,
|
|
|
|
),
|
|
|
|
'/sessions': (context) => const NavigationAuth(
|
|
|
|
route: Menu(
|
|
|
|
initialScreen: 0,
|
|
|
|
)),
|
|
|
|
'/transactions': (context) => const NavigationAuth(
|
|
|
|
route: Menu(
|
|
|
|
initialScreen: 4,
|
|
|
|
)),
|
2022-05-16 06:42:02 +02:00
|
|
|
'/payment': (context) => const NavigationAuth(route: Payment()),
|
2022-05-22 11:53:47 +02:00
|
|
|
'/forgotpassword': (context) => const ForgotPassword(),
|
2022-05-14 18:29:00 +02:00
|
|
|
},
|
2022-04-18 15:57:03 +02:00
|
|
|
);
|
|
|
|
}
|
2022-05-22 11:53:47 +02:00
|
|
|
}
|