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/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,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
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
_themeMode = ThemeMode.dark;
|
theme = MihTheme();
|
||||||
theme = MyTheme();
|
var systemTheme =
|
||||||
theme.platform = Theme.of(context).platform;
|
SchedulerBinding.instance.platformDispatcher.platformBrightness;
|
||||||
// var brightness =
|
bool isDarkMode = systemTheme == Brightness.dark;
|
||||||
// SchedulerBinding.instance.platformDispatcher.platformBrightness;
|
if (isDarkMode) {
|
||||||
// bool isDarkMode = brightness == Brightness.dark;
|
theme.mode = "Dark";
|
||||||
// if (isDarkMode) {
|
_themeMode = ThemeMode.dark;
|
||||||
// theme.mode = "Dark";
|
} else {
|
||||||
// } else {
|
theme.mode = "Light";
|
||||||
// theme.mode = "Light";
|
_themeMode = ThemeMode.light;
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
theme.platform = Theme.of(context).platform;
|
||||||
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 +81,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,
|
||||||
|
|||||||
@@ -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_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||||
import 'package:Mzansi_Innovation_Hub/mih_packages/authentication/biometric_check.dart';
|
import 'package:Mzansi_Innovation_Hub/mih_packages/authentication/biometric_check.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
|
||||||
|
|
||||||
import 'package:supertokens_flutter/supertokens.dart';
|
import 'package:supertokens_flutter/supertokens.dart';
|
||||||
import 'package:no_screenshot/no_screenshot.dart';
|
import 'package:no_screenshot/no_screenshot.dart';
|
||||||
@@ -44,14 +42,14 @@ class _AuthCheckState extends State<AuthCheck> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
//signedIn = doesSessionExist();
|
//signedIn = doesSessionExist();
|
||||||
disableScreenshot();
|
disableScreenshot();
|
||||||
var brightness =
|
// var brightness =
|
||||||
SchedulerBinding.instance.platformDispatcher.platformBrightness;
|
// SchedulerBinding.instance.platformDispatcher.platformBrightness;
|
||||||
bool isDarkMode = brightness == Brightness.dark;
|
// bool isDarkMode = brightness == Brightness.dark;
|
||||||
if (isDarkMode) {
|
// if (isDarkMode) {
|
||||||
MzanziInnovationHub.of(context)!.theme.mode = "Dark";
|
// MzanziInnovationHub.of(context)!.theme.mode = "Dark";
|
||||||
} else {
|
// } else {
|
||||||
MzanziInnovationHub.of(context)!.theme.mode = "Light";
|
// MzanziInnovationHub.of(context)!.theme.mode = "Light";
|
||||||
}
|
// }
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import "package:universal_html/html.dart" as html;
|
import "package:universal_html/html.dart" as html;
|
||||||
|
|
||||||
class MyTheme {
|
class MihTheme {
|
||||||
late int _mainColor;
|
late int _mainColor;
|
||||||
late int _secondColor;
|
late int _secondColor;
|
||||||
//late int _errColor;
|
//late int _errColor;
|
||||||
@@ -24,7 +24,7 @@ class MyTheme {
|
|||||||
// a63446 = red
|
// a63446 = red
|
||||||
//747474
|
//747474
|
||||||
|
|
||||||
MyTheme() {
|
MihTheme() {
|
||||||
mode = "Dark";
|
mode = "Dark";
|
||||||
//_errColor = 0xffD87E8B;
|
//_errColor = 0xffD87E8B;
|
||||||
//_succColor = 0xffB0F2B4;
|
//_succColor = 0xffB0F2B4;
|
||||||
@@ -104,6 +104,10 @@ class MyTheme {
|
|||||||
mode;
|
mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ThemeData getThemeData() {
|
||||||
|
return getData();
|
||||||
|
}
|
||||||
|
|
||||||
ThemeData darkMode() {
|
ThemeData darkMode() {
|
||||||
return getData();
|
return getData();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user