fix
This commit is contained in:
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:patient_manager/env/env.dart';
|
import 'package:patient_manager/env/env.dart';
|
||||||
import 'package:patient_manager/router/routeGenerator.dart';
|
import 'package:patient_manager/router/routeGenerator.dart';
|
||||||
import 'package:patient_manager/theme/mihTheme.dart';
|
import 'package:patient_manager/theme/mihTheme.dart';
|
||||||
import 'package:flutter_windowmanager/flutter_windowmanager.dart';
|
import 'package:no_screenshot/no_screenshot.dart';
|
||||||
|
|
||||||
class MzanziInnovationHub extends StatefulWidget {
|
class MzanziInnovationHub extends StatefulWidget {
|
||||||
const MzanziInnovationHub({
|
const MzanziInnovationHub({
|
||||||
@@ -20,7 +20,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 MyTheme theme;
|
||||||
|
final noscreenshot = NoScreenshot.instance;
|
||||||
Color getPrimany() {
|
Color getPrimany() {
|
||||||
return theme.primaryColor();
|
return theme.primaryColor();
|
||||||
}
|
}
|
||||||
@@ -53,18 +53,15 @@ class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
|
|||||||
_themeMode = ThemeMode.dark;
|
_themeMode = ThemeMode.dark;
|
||||||
theme = MyTheme();
|
theme = MyTheme();
|
||||||
theme.platform = Theme.of(context).platform;
|
theme.platform = Theme.of(context).platform;
|
||||||
|
if (theme.getPlatform() == "Android") {
|
||||||
|
noscreenshot.screenshotOff();
|
||||||
|
}
|
||||||
theme.mode = "Dark";
|
theme.mode = "Dark";
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
|
||||||
if (theme.getPlatform() == "Android") {
|
|
||||||
await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
@@ -1,193 +1 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:secure_application/secure_application.dart';
|
|
||||||
|
|
||||||
void main() => runApp(MaterialApp(home: MyApp()));
|
|
||||||
|
|
||||||
class MyApp extends StatefulWidget {
|
|
||||||
@override
|
|
||||||
_MyAppState createState() => _MyAppState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MyAppState extends State<MyApp> {
|
|
||||||
bool failedAuth = false;
|
|
||||||
double blurr = 20;
|
|
||||||
double opacity = 0.6;
|
|
||||||
StreamSubscription<bool>? subLock;
|
|
||||||
List<String> history = [];
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
subLock?.cancel();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
var width = MediaQuery.of(context).size.width * 0.8;
|
|
||||||
return MaterialApp(
|
|
||||||
home: SecureApplication(
|
|
||||||
nativeRemoveDelay: 1000,
|
|
||||||
onNeedUnlock: (secure) async {
|
|
||||||
print(
|
|
||||||
'need unlock maybe use biometric to confirm and then sercure.unlock() or you can use the lockedBuilder');
|
|
||||||
// var authResult = authMyUser();
|
|
||||||
// if (authResul) {
|
|
||||||
// secure.unlock();
|
|
||||||
// return SecureApplicationAuthenticationStatus.SUCCESS;
|
|
||||||
//}
|
|
||||||
// else {
|
|
||||||
// return SecureApplicationAuthenticationStatus.FAILED;
|
|
||||||
//}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
onAuthenticationFailed: () async {
|
|
||||||
// clean you data
|
|
||||||
setState(() {
|
|
||||||
failedAuth = true;
|
|
||||||
});
|
|
||||||
print('auth failed');
|
|
||||||
},
|
|
||||||
onAuthenticationSucceed: () async {
|
|
||||||
// clean you data
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
failedAuth = false;
|
|
||||||
});
|
|
||||||
print('auth success');
|
|
||||||
},
|
|
||||||
child: Builder(builder: (context) {
|
|
||||||
if (subLock == null)
|
|
||||||
subLock = SecureApplicationProvider.of(context, listen: false)
|
|
||||||
?.lockEvents
|
|
||||||
.listen((s) => history.add(
|
|
||||||
'${DateTime.now().toIso8601String()} - ${s ? 'locked' : 'unlocked'}'));
|
|
||||||
return SecureGate(
|
|
||||||
blurr: blurr,
|
|
||||||
opacity: opacity,
|
|
||||||
lockedBuilder: (context, secureNotifier) => Center(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
ElevatedButton(
|
|
||||||
child: Text('UNLOCK'),
|
|
||||||
onPressed: () => secureNotifier?.authSuccess(unlock: true),
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
|
||||||
child: Text('FAIL AUTHENTICATION'),
|
|
||||||
onPressed: () => secureNotifier?.authFailed(unlock: true),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
child: Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Secure Window Example'),
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
child: Builder(builder: (context) {
|
|
||||||
var valueNotifier = SecureApplicationProvider.of(context);
|
|
||||||
if (valueNotifier == null)
|
|
||||||
throw new Exception(
|
|
||||||
'Unable to find secure application context');
|
|
||||||
return ListView(
|
|
||||||
children: <Widget>[
|
|
||||||
Text('This is secure content'),
|
|
||||||
ValueListenableBuilder<SecureApplicationState>(
|
|
||||||
valueListenable: valueNotifier,
|
|
||||||
builder: (context, state, _) => state.secured
|
|
||||||
? Column(
|
|
||||||
children: <Widget>[
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () => valueNotifier.open(),
|
|
||||||
child: Text('Open app'),
|
|
||||||
),
|
|
||||||
state.paused
|
|
||||||
? ElevatedButton(
|
|
||||||
onPressed: () =>
|
|
||||||
valueNotifier.unpause(),
|
|
||||||
child: Text('resume security'),
|
|
||||||
)
|
|
||||||
: ElevatedButton(
|
|
||||||
onPressed: () =>
|
|
||||||
valueNotifier.pause(),
|
|
||||||
child: Text('pause security'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: ElevatedButton(
|
|
||||||
onPressed: () => valueNotifier.secure(),
|
|
||||||
child: Text('Secure app'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
failedAuth
|
|
||||||
? Text(
|
|
||||||
'Auth failed we cleaned sensitive data',
|
|
||||||
style: TextStyle(color: Colors.red),
|
|
||||||
)
|
|
||||||
: Text(
|
|
||||||
'Auth success',
|
|
||||||
style: TextStyle(color: Colors.green),
|
|
||||||
),
|
|
||||||
FlutterLogo(
|
|
||||||
size: width,
|
|
||||||
),
|
|
||||||
StreamBuilder(
|
|
||||||
stream: valueNotifier.authenticationEvents,
|
|
||||||
builder: (context, snapshot) =>
|
|
||||||
Text('Last auth status is: ${snapshot.data}'),
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () => valueNotifier.lock(),
|
|
||||||
child: Text('manually lock'),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Text('Blurr:'),
|
|
||||||
Expanded(
|
|
||||||
child: Slider(
|
|
||||||
value: blurr,
|
|
||||||
min: 0,
|
|
||||||
max: 100,
|
|
||||||
onChanged: (v) => setState(() => blurr = v)),
|
|
||||||
),
|
|
||||||
Text(blurr.floor().toString()),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Text('opacity:'),
|
|
||||||
Expanded(
|
|
||||||
child: Slider(
|
|
||||||
value: opacity,
|
|
||||||
min: 0,
|
|
||||||
max: 1,
|
|
||||||
onChanged: (v) =>
|
|
||||||
setState(() => opacity = v)),
|
|
||||||
),
|
|
||||||
Text((opacity * 100).floor().toString() + "%"),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
...history.map<Widget>((h) => Text(h)).toList(),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -84,6 +84,12 @@ class MyTheme {
|
|||||||
}
|
}
|
||||||
} else if (kIsWeb) {
|
} else if (kIsWeb) {
|
||||||
return "Web";
|
return "Web";
|
||||||
|
} else if (!kIsWeb) {
|
||||||
|
if (platform == TargetPlatform.android) {
|
||||||
|
return "Android";
|
||||||
|
} else if (platform == TargetPlatform.iOS) {
|
||||||
|
return "iOS";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return "Other";
|
return "Other";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -400,14 +400,6 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
flutter_windowmanager:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: flutter_windowmanager
|
|
||||||
sha256: b4d0bc06f6777952b729c0cdb7ce9ad1ecabd8b8b1cb0acb57a36621457dab1b
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.2.0"
|
|
||||||
font_awesome_flutter:
|
font_awesome_flutter:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -696,6 +688,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.0.27"
|
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:
|
package_config:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -856,14 +856,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.2"
|
version: "1.0.2"
|
||||||
secure_application:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: secure_application
|
|
||||||
sha256: b8e34b4bc2467a3a3c0a649e46ae6a442df7ca27aeaddebb8a53c40656da0385
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "4.0.1"
|
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -52,8 +52,7 @@ dependencies:
|
|||||||
flutter_native_splash: ^2.4.1
|
flutter_native_splash: ^2.4.1
|
||||||
#google_maps_flutter_web: ^0.5.10
|
#google_maps_flutter_web: ^0.5.10
|
||||||
url_strategy: ^0.3.0
|
url_strategy: ^0.3.0
|
||||||
secure_application: ^4.0.1
|
no_screenshot: ^0.3.1
|
||||||
flutter_windowmanager: ^0.2.0
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user