shlink-manager/lib/main.dart

84 lines
2.4 KiB
Dart
Raw Normal View History

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-07-25 17:37:17 +02:00
static final ColorScheme _defaultLightColorScheme =
ColorScheme.fromSeed(seedColor: Colors.blue);
2023-07-09 23:00:00 +02:00
2024-03-31 22:21:07 +02:00
static final _defaultDarkColorScheme = ColorScheme.fromSeed(
2024-07-25 17:37:17 +02:00
brightness: Brightness.dark,
seedColor: Colors.blue,
background: Colors.black);
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-07-25 19:23:21 +02:00
colorScheme: darkColorScheme?.copyWith(surface: Colors.black) ??
2024-01-28 00:32:09 +01:00
_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) {
2024-07-25 19:11:24 +02:00
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const NavigationBarView()),
2024-07-25 19:23:21 +02:00
(Route<dynamic> route) => false);
2024-01-28 00:32:09 +01:00
} else {
2024-07-25 19:11:24 +02:00
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const LoginView()),
2024-07-25 19:23:21 +02:00
(Route<dynamic> route) => false);
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
);
}
}