Files
mih-project/Frontend/patient_manager/lib/main.dart
2024-09-17 16:14:54 +02:00

81 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:patient_manager/mih_env/env.dart';
import 'package:patient_manager/mih_router/routeGenerator.dart';
import 'package:patient_manager/mih_theme/mih_theme.dart';
import 'package:no_screenshot/no_screenshot.dart';
class MzanziInnovationHub extends StatefulWidget {
const MzanziInnovationHub({
super.key,
});
@override
State<MzanziInnovationHub> createState() => _MzanziInnovationHubState();
// ignore: library_private_types_in_public_api
static _MzanziInnovationHubState? of(BuildContext context) =>
context.findAncestorStateOfType<_MzanziInnovationHubState>();
}
class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
late ThemeMode _themeMode;
late MyTheme theme;
final noscreenshot = NoScreenshot.instance;
Color getPrimany() {
return theme.primaryColor();
}
String getTitle() {
if (AppEnviroment.getEnv() == "Dev") {
return "Mzansi Innovation Hub - Dev";
} else {
return "Mzansi Innovation Hub";
}
}
void changeTheme(ThemeMode themeMode) {
setState(() {
_themeMode = themeMode;
if (_themeMode == ThemeMode.light) {
setState(() {
theme.mode = "Light";
});
} else {
setState(() {
theme.mode = "Dark";
});
}
});
}
@override
void initState() {
_themeMode = ThemeMode.dark;
theme = MyTheme();
theme.platform = Theme.of(context).platform;
if (theme.getPlatform() == "Android") {
noscreenshot.screenshotOff();
}
theme.mode = "Dark";
super.initState();
}
@override
Widget build(BuildContext context) {
double width = MediaQuery.sizeOf(context).width;
theme.setScreenType(width);
precacheImage(theme.loadingImage(), context);
precacheImage(theme.logoImage(), context);
precacheImage(theme.logoFrame(), context);
return MaterialApp(
title: getTitle(),
themeMode: _themeMode,
theme: theme.darkMode(),
darkTheme: theme.lightMode(),
debugShowCheckedModeBanner: false,
initialRoute: '/',
onGenerateRoute: RouteGenerator.generateRoute,
);
}
}