shlink-manager/lib/main.dart

107 lines
2.8 KiB
Dart
Raw Permalink Normal View History

2023-06-26 23:40:05 +02:00
import 'package:flutter/material.dart';
import 'package:shlink_app/LoginView.dart';
import 'package:shlink_app/NavigationBarView.dart';
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});
2023-07-09 23:00:00 +02:00
static final _defaultLightColorScheme =
ColorScheme.fromSwatch(primarySwatch: Colors.blue);
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(
appBarTheme: AppBarTheme(
backgroundColor: Color(0xfffafafa),
),
colorScheme: lightColorScheme ?? _defaultLightColorScheme,
useMaterial3: true
),
darkTheme: ThemeData(
appBarTheme: AppBarTheme(
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,
),
/*theme: ThemeData(
2023-06-26 23:40:05 +02:00
primarySwatch: Colors.blue,
brightness: Brightness.light,
2023-07-09 23:00:00 +02:00
useMaterial3: true,
colorScheme: ColorScheme.fromSwatch().copyWith(
secondary: Colors.orange
)
),*/
/*darkTheme: ThemeData(
2023-06-26 23:40:05 +02:00
primarySwatch: Colors.blue,
brightness: Brightness.dark,
useMaterial3: true,
colorScheme: ColorScheme.dark(
background: Colors.black,
surface: Color(0xff0d0d0d),
secondaryContainer: Colors.grey[300]
)
2023-07-09 23:00:00 +02:00
),*/
themeMode: ThemeMode.system,
home: InitialPage()
);
});
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) {
return Scaffold(
body: Center(
child: Text("")
),
);
}
}