forked from yaso_meth/mih-project
Merge pull request #65 from yaso-meth/BUG-Theme-switcher
BUG-Theme-switcher
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import '../mih_env/env.dart';
|
||||
import '../mih_router/routeGenerator.dart';
|
||||
import '../mih_theme/mih_theme.dart';
|
||||
@@ -18,7 +19,7 @@ class MzanziInnovationHub extends StatefulWidget {
|
||||
|
||||
class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
|
||||
late ThemeMode _themeMode;
|
||||
late MyTheme theme;
|
||||
late MihTheme theme;
|
||||
|
||||
Color getPrimany() {
|
||||
return theme.primaryColor();
|
||||
@@ -51,58 +52,27 @@ 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
|
||||
void initState() {
|
||||
_themeMode = ThemeMode.dark;
|
||||
theme = MyTheme();
|
||||
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";
|
||||
// }
|
||||
theme = MihTheme();
|
||||
var systemTheme =
|
||||
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.platform = Theme.of(context).platform;
|
||||
super.initState();
|
||||
//doInit();
|
||||
}
|
||||
|
||||
@override
|
||||
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;
|
||||
theme.setScreenType(width);
|
||||
precacheImage(theme.loadingImage(), context);
|
||||
@@ -111,8 +81,8 @@ class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
|
||||
return MaterialApp(
|
||||
title: getTitle(),
|
||||
themeMode: _themeMode,
|
||||
theme: theme.darkMode(),
|
||||
darkTheme: theme.lightMode(),
|
||||
theme: theme.getThemeData(),
|
||||
darkTheme: theme.getThemeData(),
|
||||
debugShowCheckedModeBanner: false,
|
||||
initialRoute: '/',
|
||||
onGenerateRoute: RouteGenerator.generateRoute,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:Mzansi_Innovation_Hub/main.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_packages/authentication/biometric_check.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
|
||||
import 'package:supertokens_flutter/supertokens.dart';
|
||||
import 'package:no_screenshot/no_screenshot.dart';
|
||||
@@ -44,14 +42,14 @@ class _AuthCheckState extends State<AuthCheck> {
|
||||
void initState() {
|
||||
//signedIn = doesSessionExist();
|
||||
disableScreenshot();
|
||||
var brightness =
|
||||
SchedulerBinding.instance.platformDispatcher.platformBrightness;
|
||||
bool isDarkMode = brightness == Brightness.dark;
|
||||
if (isDarkMode) {
|
||||
MzanziInnovationHub.of(context)!.theme.mode = "Dark";
|
||||
} else {
|
||||
MzanziInnovationHub.of(context)!.theme.mode = "Light";
|
||||
}
|
||||
// var brightness =
|
||||
// SchedulerBinding.instance.platformDispatcher.platformBrightness;
|
||||
// bool isDarkMode = brightness == Brightness.dark;
|
||||
// if (isDarkMode) {
|
||||
// MzanziInnovationHub.of(context)!.theme.mode = "Dark";
|
||||
// } else {
|
||||
// MzanziInnovationHub.of(context)!.theme.mode = "Light";
|
||||
// }
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import "package:universal_html/html.dart" as html;
|
||||
|
||||
class MyTheme {
|
||||
class MihTheme {
|
||||
late int _mainColor;
|
||||
late int _secondColor;
|
||||
//late int _errColor;
|
||||
@@ -24,7 +24,7 @@ class MyTheme {
|
||||
// a63446 = red
|
||||
//747474
|
||||
|
||||
MyTheme() {
|
||||
MihTheme() {
|
||||
mode = "Dark";
|
||||
//_errColor = 0xffD87E8B;
|
||||
//_succColor = 0xffB0F2B4;
|
||||
@@ -104,6 +104,10 @@ class MyTheme {
|
||||
mode;
|
||||
}
|
||||
|
||||
ThemeData getThemeData() {
|
||||
return getData();
|
||||
}
|
||||
|
||||
ThemeData darkMode() {
|
||||
return getData();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user