forked from yaso_meth/mih-project
add platform check & block screenshot if Android or IOS
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:patient_manager/env/env.dart';
|
||||
import 'package:patient_manager/router/routeGenerator.dart';
|
||||
import 'package:patient_manager/theme/mihTheme.dart';
|
||||
import 'package:no_screenshot/no_screenshot.dart';
|
||||
|
||||
class MzanziInnovationHub extends StatefulWidget {
|
||||
const MzanziInnovationHub({
|
||||
@@ -19,6 +20,12 @@ class MzanziInnovationHub extends StatefulWidget {
|
||||
class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
|
||||
late ThemeMode _themeMode;
|
||||
late MyTheme theme;
|
||||
final _noScreenshot = NoScreenshot.instance;
|
||||
|
||||
void disableScreenshot() async {
|
||||
bool result = await _noScreenshot.screenshotOff();
|
||||
debugPrint('Screenshot Off: $result');
|
||||
}
|
||||
|
||||
Color getPrimany() {
|
||||
return theme.primaryColor();
|
||||
@@ -47,10 +54,17 @@ class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
|
||||
});
|
||||
}
|
||||
|
||||
void setPlatformSpecificPlugins() {
|
||||
if (theme.getPlateform() == "Android" || theme.getPlateform() == "IOS") {
|
||||
disableScreenshot();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_themeMode = ThemeMode.dark;
|
||||
theme = MyTheme();
|
||||
setPlatformSpecificPlugins();
|
||||
theme.mode = "Dark";
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ class _SignInState extends State<SignIn> {
|
||||
const SizedBox(height: 10),
|
||||
//Heading
|
||||
Text(
|
||||
'Sign In Now',
|
||||
'Sign In (${MzanziInnovationHub.of(context)!.theme.getPlateform()})',
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
class MyTheme {
|
||||
late int _mainColor;
|
||||
@@ -9,7 +10,7 @@ class MyTheme {
|
||||
late String mode;
|
||||
late String screenType;
|
||||
late AssetImage loading;
|
||||
|
||||
bool kIsWeb = const bool.fromEnvironment('dart.library.js_util');
|
||||
// Options:-
|
||||
// f3f9d2 = Cream
|
||||
// f0f0c9 = cream2
|
||||
@@ -28,6 +29,19 @@ class MyTheme {
|
||||
//_mesColor = 0xffc8c8c8d9;
|
||||
}
|
||||
|
||||
String getPlateform() {
|
||||
if (kIsWeb) {
|
||||
return "Web";
|
||||
}
|
||||
if (Platform.isAndroid) {
|
||||
return "Android";
|
||||
} else if (Platform.isIOS) {
|
||||
return "IOS";
|
||||
} else {
|
||||
return "Other";
|
||||
}
|
||||
}
|
||||
|
||||
ThemeData getData() {
|
||||
return ThemeData(
|
||||
fontFamily: 'Segoe UI',
|
||||
|
||||
@@ -8,6 +8,7 @@ import Foundation
|
||||
import app_links
|
||||
import device_info_plus
|
||||
import google_sign_in_ios
|
||||
import no_screenshot
|
||||
import path_provider_foundation
|
||||
import shared_preferences_foundation
|
||||
import sign_in_with_apple
|
||||
@@ -18,6 +19,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin"))
|
||||
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||
FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin"))
|
||||
NoScreenshotPlugin.register(with: registry.registrar(forPlugin: "NoScreenshotPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
SignInWithApplePlugin.register(with: registry.registrar(forPlugin: "SignInWithApplePlugin"))
|
||||
|
||||
@@ -688,6 +688,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.0.27"
|
||||
no_screenshot:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: no_screenshot
|
||||
sha256: ec3d86d7ee89a09c3a3939c1003012536ba4b3fcb4f8cbd23d87ada595c99258
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.1"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -50,6 +50,7 @@ dependencies:
|
||||
gif: ^2.3.0
|
||||
intl: ^0.19.0
|
||||
flutter_native_splash: ^2.4.1
|
||||
no_screenshot: ^0.3.1
|
||||
#google_maps_flutter_web: ^0.5.10
|
||||
url_strategy: ^0.3.0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user