2023-06-26 23:40:05 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2024-01-27 23:07:06 +01:00
|
|
|
import 'package:shlink_app/views/login_view.dart';
|
|
|
|
import 'package:shlink_app/views/navigationbar_view.dart';
|
2023-06-26 23:40:05 +02:00
|
|
|
import 'globals.dart' as globals;
|
2023-07-09 23:00:00 +02:00
|
|
|
import 'package:dynamic_color/dynamic_color.dart';
|
2023-06-26 23:40:05 +02:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
runApp(const MyApp());
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
2024-01-28 00:32:09 +01:00
|
|
|
static const _defaultLightColorScheme = ColorScheme
|
|
|
|
.light(); //.fromSwatch(primarySwatch: Colors.blue, backgroundColor: Colors.white);
|
2023-07-09 23:00:00 +02:00
|
|
|
|
2024-01-28 00:32:09 +01:00
|
|
|
static final _defaultDarkColorScheme =
|
|
|
|
ColorScheme.fromSwatch(brightness: Brightness.dark);
|
2023-07-09 23:00:00 +02:00
|
|
|
|
2023-06-26 23:40:05 +02:00
|
|
|
// This widget is the root of your application.
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-07-09 23:00:00 +02:00
|
|
|
return DynamicColorBuilder(builder: (lightColorScheme, darkColorScheme) {
|
|
|
|
return MaterialApp(
|
|
|
|
title: 'Shlink',
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
theme: ThemeData(
|
2024-01-28 00:32:09 +01:00
|
|
|
appBarTheme: const AppBarTheme(
|
|
|
|
backgroundColor: Color(0xfffafafa),
|
|
|
|
),
|
2023-07-09 23:00:00 +02:00
|
|
|
colorScheme: lightColorScheme ?? _defaultLightColorScheme,
|
2024-01-28 00:32:09 +01:00
|
|
|
useMaterial3: true),
|
2023-07-09 23:00:00 +02:00
|
|
|
darkTheme: ThemeData(
|
2024-01-27 23:07:06 +01:00
|
|
|
appBarTheme: const AppBarTheme(
|
2023-07-09 23:00:00 +02:00
|
|
|
backgroundColor: Color(0xff0d0d0d),
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
elevation: 0,
|
|
|
|
),
|
2024-01-28 00:32:09 +01:00
|
|
|
colorScheme: darkColorScheme?.copyWith(background: Colors.black) ??
|
|
|
|
_defaultDarkColorScheme,
|
2023-07-09 23:00:00 +02:00
|
|
|
useMaterial3: true,
|
|
|
|
),
|
2024-01-28 00:32:09 +01:00
|
|
|
home: const InitialPage());
|
2023-07-09 23:00:00 +02:00
|
|
|
});
|
2023-06-26 23:40:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class InitialPage extends StatefulWidget {
|
|
|
|
const InitialPage({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<InitialPage> createState() => _InitialPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _InitialPageState extends State<InitialPage> {
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
checkLogin();
|
|
|
|
}
|
|
|
|
|
|
|
|
void checkLogin() async {
|
|
|
|
bool result = await globals.serverManager.checkLogin();
|
|
|
|
if (result) {
|
|
|
|
Navigator.of(context).pushReplacement(
|
2024-01-28 00:32:09 +01:00
|
|
|
MaterialPageRoute(builder: (context) => const NavigationBarView()));
|
|
|
|
} else {
|
2023-06-26 23:40:05 +02:00
|
|
|
Navigator.of(context).pushReplacement(
|
2024-01-28 00:32:09 +01:00
|
|
|
MaterialPageRoute(builder: (context) => const LoginView()));
|
2023-06-26 23:40:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-01-27 23:07:06 +01:00
|
|
|
return const Scaffold(
|
2024-01-28 00:32:09 +01:00
|
|
|
body: Center(child: Text("")),
|
2023-06-26 23:40:05 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|