forked from yaso_meth/mih-project
check if its PWA
This commit is contained in:
@@ -55,7 +55,8 @@ class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
|
||||
}
|
||||
|
||||
void setPlatformSpecificPlugins() {
|
||||
if (theme.getPlateform() == "Android" || theme.getPlateform() == "IOS") {
|
||||
print("is PWA: ${theme.isPwa()}");
|
||||
if (theme.isPwa()) {
|
||||
disableScreenshot();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ class _SignInState extends State<SignIn> {
|
||||
const SizedBox(height: 10),
|
||||
//Heading
|
||||
Text(
|
||||
'Sign In (${MzanziInnovationHub.of(context)!.theme.getPlateform()})',
|
||||
'Sign In (PWA: ${MzanziInnovationHub.of(context)!.theme.isPwa()})',
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
||||
97
Frontend/patient_manager/lib/test_files/test.dart
Normal file
97
Frontend/patient_manager/lib/test_files/test.dart
Normal file
@@ -0,0 +1,97 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:no_screenshot/no_screenshot.dart';
|
||||
import 'package:no_screenshot/screenshot_snapshot.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
State<MyApp> createState() => _MyAppState();
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> {
|
||||
final _noScreenshot = NoScreenshot.instance;
|
||||
bool _isListeningToScreenshotSnapshot = false;
|
||||
ScreenshotSnapshot _latestValue = ScreenshotSnapshot(
|
||||
isScreenshotProtectionOn: false,
|
||||
wasScreenshotTaken: false,
|
||||
screenshotPath: '',
|
||||
);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_noScreenshot.screenshotStream.listen((value) {
|
||||
setState(() {
|
||||
_latestValue = value;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('No Screenshot Plugin Example'),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
await _noScreenshot.startScreenshotListening();
|
||||
setState(() {
|
||||
_isListeningToScreenshotSnapshot = true;
|
||||
});
|
||||
},
|
||||
child: const Text('Start Listening'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
await _noScreenshot.stopScreenshotListening();
|
||||
setState(() {
|
||||
_isListeningToScreenshotSnapshot = false;
|
||||
});
|
||||
},
|
||||
child: const Text('Stop Listening'),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Text(
|
||||
"Screenshot Streaming is ${_isListeningToScreenshotSnapshot ? 'ON' : 'OFF'}\n\nIsScreenshotProtectionOn: ${_latestValue.isScreenshotProtectionOn}\nwasScreenshotTaken: ${_latestValue.wasScreenshotTaken}\nScreenshot Path: ${_latestValue.screenshotPath}"),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
bool result = await _noScreenshot.screenshotOff();
|
||||
debugPrint('Screenshot Off: $result');
|
||||
},
|
||||
child: const Text('Disable Screenshot'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
bool result = await _noScreenshot.screenshotOn();
|
||||
debugPrint('Enable Screenshot: $result');
|
||||
},
|
||||
child: const Text('Enable Screenshot'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
bool result = await _noScreenshot.toggleScreenshot();
|
||||
debugPrint('Toggle Screenshot: $result');
|
||||
},
|
||||
child: const Text('Toggle Screenshot'),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:io' show Platform;
|
||||
import "package:universal_html/html.dart" as html;
|
||||
|
||||
class MyTheme {
|
||||
late int _mainColor;
|
||||
@@ -29,19 +29,6 @@ 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',
|
||||
@@ -87,6 +74,10 @@ class MyTheme {
|
||||
));
|
||||
}
|
||||
|
||||
bool isPwa() {
|
||||
return html.window.matchMedia('(display-mode: standalone)').matches;
|
||||
}
|
||||
|
||||
void setMode(String m) {
|
||||
mode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user