add theme link pn main init

This commit is contained in:
2025-01-31 09:50:05 +02:00
parent ef1d86ef24
commit 3f325fda66

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import '../mih_env/env.dart'; import '../mih_env/env.dart';
import '../mih_router/routeGenerator.dart'; import '../mih_router/routeGenerator.dart';
import '../mih_theme/mih_theme.dart'; import '../mih_theme/mih_theme.dart';
@@ -18,7 +19,7 @@ class MzanziInnovationHub extends StatefulWidget {
class _MzanziInnovationHubState extends State<MzanziInnovationHub> { class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
late ThemeMode _themeMode; late ThemeMode _themeMode;
late MyTheme theme; late MihTheme theme;
Color getPrimany() { Color getPrimany() {
return theme.primaryColor(); return theme.primaryColor();
@@ -51,58 +52,26 @@ class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
}); });
} }
// void doInit() async {
// print(
// "FpjsProPlugin.initFpjs Token: ${AppEnviroment.fingerPrintPluginKey}");
// await FpjsProPlugin.initFpjs(
// AppEnviroment.fingerPrintPluginKey, // insert your actual API key here
// endpoint: "https://mzansi-innovation-hub.co.za",
// scriptUrlPattern:
// 'https://mzansi-innovation-hub.co.za/web/v<version>/<apiKey>/loader_v<loaderVersion>.js',
// );
// identify();
// }
// void identify() async {
// try {
// var visitorId = await FpjsProPlugin.getVisitorId() ?? 'Unknown';
// print(visitorId);
// // use the visitor id
// } on FingerprintProError catch (e) {
// print("Error on Init: $e");
// // process an error somehow
// // check lib/error.dart to get more info about error types
// }
// }
@override @override
void initState() { void initState() {
_themeMode = ThemeMode.dark; var systemTheme =
theme = MyTheme(); SchedulerBinding.instance.platformDispatcher.platformBrightness;
bool isDarkMode = systemTheme == Brightness.dark;
if (isDarkMode) {
theme.mode = "Dark";
_themeMode = ThemeMode.dark;
} else {
theme.mode = "Light";
_themeMode = ThemeMode.light;
}
theme = MihTheme();
theme.platform = Theme.of(context).platform; theme.platform = Theme.of(context).platform;
// var brightness =
// SchedulerBinding.instance.platformDispatcher.platformBrightness;
// bool isDarkMode = brightness == Brightness.dark;
// if (isDarkMode) {
// theme.mode = "Dark";
// } else {
// theme.mode = "Light";
// }
super.initState(); super.initState();
//doInit(); //doInit();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// var brightness =
// SchedulerBinding.instance.platformDispatcher.platformBrightness;
// bool isDarkMode = brightness == Brightness.dark;
// if (isDarkMode) {
// theme.mode = "Dark";
// } else {
// theme.mode = "Light";
// }
double width = MediaQuery.sizeOf(context).width; double width = MediaQuery.sizeOf(context).width;
theme.setScreenType(width); theme.setScreenType(width);
precacheImage(theme.loadingImage(), context); precacheImage(theme.loadingImage(), context);
@@ -111,8 +80,8 @@ class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
return MaterialApp( return MaterialApp(
title: getTitle(), title: getTitle(),
themeMode: _themeMode, themeMode: _themeMode,
theme: theme.darkMode(), theme: theme.getThemeData(),
darkTheme: theme.lightMode(), darkTheme: theme.getThemeData(),
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
initialRoute: '/', initialRoute: '/',
onGenerateRoute: RouteGenerator.generateRoute, onGenerateRoute: RouteGenerator.generateRoute,