Explorar el Código

Added: When the app is in the background, hided te contents of the app (#387)

<!--
  Thanks for contributing!

Provide a description of your changes below and a general summary in the
title

Please look at the following checklist to ensure that your PR can be
accepted quickly:
-->

## Description

Added: Hide the contents of the app, when is it in the background - Both
android and ios

In android, it shows a blank white/black background, when in background

In iOS, it shows the launch icon, when in background


![photo_2023-12-06_12-53-02](https://github.com/ente-io/auth/assets/54765537/4f787e6a-984c-4eae-9028-303a32009838)

Android Physical Device


![photo_2023-12-06_12-52-55](https://github.com/ente-io/auth/assets/54765537/b8802cf5-0db0-473e-8be8-8cf3bf7b29a5)

Android stimulator

Also, compared the bitwarden apps in android, the flow is same

iOS Device: Need to verify 
@ua741 @vishnukvmd Could you run on iOS devices and verify it?

Closes #47 

## Type of Change

<!--- Put an `x` in all the boxes that apply: -->

- [ ] 🖼️ New icon
- [x] ✨ New feature (non-breaking change which adds functionality)
- [ ] 🛠️ Bug fix (non-breaking change which fixes an issue)
- [ ] ❌ Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] 🧹 Code refactor
- [ ] ✅ Build configuration change
- [ ] 📝 Documentation
- [ ] 🗑️ Chore
Muhammed Ayimen Abdul Latheef hace 1 año
padre
commit
1a654fe748
Se han modificado 3 ficheros con 26 adiciones y 0 borrados
  1. 17 0
      lib/main.dart
  2. 8 0
      pubspec.lock
  3. 1 0
      pubspec.yaml

+ 17 - 0
lib/main.dart

@@ -24,6 +24,7 @@ import "package:flutter/material.dart";
 import 'package:flutter_displaymode/flutter_displaymode.dart';
 import 'package:logging/logging.dart';
 import 'package:path_provider/path_provider.dart';
+import 'package:privacy_screen/privacy_screen.dart';
 
 final _logger = Logger("main");
 
@@ -31,6 +32,22 @@ void main() async {
   WidgetsFlutterBinding.ensureInitialized();
   final savedThemeMode = await AdaptiveTheme.getThemeMode();
   await _runInForeground(savedThemeMode);
+  await PrivacyScreen.instance.enable(
+    iosOptions: const PrivacyIosOptions(
+      enablePrivacy: true,
+      privacyImageName: "LaunchImage",
+      lockTrigger: IosLockTrigger.didEnterBackground,
+    ),
+    androidOptions: const PrivacyAndroidOptions(
+      enableSecure: true,
+    ),
+    backgroundColor: savedThemeMode == AdaptiveThemeMode.dark
+        ? Colors.black
+        : Colors.white,
+    blurEffect: savedThemeMode == AdaptiveThemeMode.dark
+        ? PrivacyBlurEffect.dark
+        : PrivacyBlurEffect.extraLight,
+  );
   FlutterDisplayMode.setHighRefreshRate();
 }
 

+ 8 - 0
pubspec.lock

@@ -1047,6 +1047,14 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "1.5.1"
+  privacy_screen:
+    dependency: "direct main"
+    description:
+      name: privacy_screen
+      sha256: b80297d2726d96e8a8341149e81a415302755f02d3af7c05c820d9e191bbfbee
+      url: "https://pub.dev"
+    source: hosted
+    version: "0.0.6"
   process:
     dependency: transitive
     description:

+ 1 - 0
pubspec.yaml

@@ -67,6 +67,7 @@ dependencies:
   path_provider: ^2.0.11
   pinput: ^1.2.2
   pointycastle: ^3.7.3
+  privacy_screen: ^0.0.6
   protobuf: ^3.0.0
   qr_code_scanner: ^1.0.1
   qr_flutter: 4.0.0