shlink-manager/lib/main.dart

89 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-01-27 23:07:06 +01:00
static const _defaultLightColorScheme =
ColorScheme.light();//.fromSwatch(primarySwatch: Colors.blue, backgroundColor: Colors.white);
2023-07-09 23:00:00 +02:00
static final _defaultDarkColorScheme = ColorScheme.fromSwatch(
primarySwatch: Colors.blue, brightness: Brightness.dark);
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-27 23:07:06 +01:00
appBarTheme: const AppBarTheme(
2023-07-09 23:00:00 +02:00
backgroundColor: Color(0xfffafafa),
),
colorScheme: lightColorScheme ?? _defaultLightColorScheme,
useMaterial3: true
),
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,
),
2023-07-09 23:15:15 +02:00
colorScheme: darkColorScheme?.copyWith(background: Colors.black) ?? _defaultDarkColorScheme,
2023-07-09 23:00:00 +02:00
useMaterial3: true,
),
themeMode: ThemeMode.system,
2024-01-27 23:07:06 +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(
MaterialPageRoute(builder: (context) => const NavigationBarView())
);
}
else {
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (context) => const LoginView())
);
}
}
@override
Widget build(BuildContext context) {
2024-01-27 23:07:06 +01:00
return const Scaffold(
2023-06-26 23:40:05 +02:00
body: Center(
child: Text("")
),
);
}
}