Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Quick fixes and fallback when no system lock found

Aman Raj Singh Mourya972b7b82dd71
diff --git a/mobile/lib/ui/viewer/file/detail_page.dart b/mobile/lib/ui/viewer/file/detail_page.dart
index a7c1de5073..521a12ea69 100644
--- a/mobile/lib/ui/viewer/file/detail_page.dart
+++ b/mobile/lib/ui/viewer/file/detail_page.dart
@@ -141,8 +141,8 @@ class _DetailPageState extends State<DetailPage> {
canPop: !isFileSwipeLocked,
onPopInvoked: (didPop) async {
if (isFileSwipeLocked) {
- final auth = await _requestAuthentication();
- if (auth) {
+ final authenticated = await _requestAuthentication();
+ if (authenticated) {
Bus.instance.fire(FileSwipeLockEvent(false));
}
}
diff --git a/mobile/lib/ui/viewer/file/file_app_bar.dart b/mobile/lib/ui/viewer/file/file_app_bar.dart
index a815d9c482..b0327b5a7e 100644
--- a/mobile/lib/ui/viewer/file/file_app_bar.dart
+++ b/mobile/lib/ui/viewer/file/file_app_bar.dart
@@ -2,6 +2,7 @@ import "dart:async";
import 'dart:io';
import 'package:flutter/material.dart';
+import "package:local_auth/local_auth.dart";
import 'package:logging/logging.dart';
import 'package:media_extension/media_extension.dart';
import "package:photos/core/event_bus.dart";
@@ -406,7 +407,15 @@ class FileAppBarState extends State<FileAppBar> {
}
Future<void> _onSwipeLock() async {
- Bus.instance.fire(FileSwipeLockEvent(!_isFileSwipeLocked));
+ if (await LocalAuthentication().isDeviceSupported()) {
+ Bus.instance.fire(FileSwipeLockEvent(!_isFileSwipeLocked));
+ } else {
+ await showErrorDialog(
+ context,
+ S.of(context).noSystemLockFound,
+ "To enable swipe lock, please setup device passcode or screen lock in your system settings.",
+ );
+ }
}
Future<void> _requestAuthentication() async {
diff --git a/mobile/lib/ui/viewer/file/file_bottom_bar.dart b/mobile/lib/ui/viewer/file/file_bottom_bar.dart
index 80f4e71499..e3fa46ff6c 100644
--- a/mobile/lib/ui/viewer/file/file_bottom_bar.dart
+++ b/mobile/lib/ui/viewer/file/file_bottom_bar.dart
@@ -43,11 +43,14 @@ class FileBottomBar extends StatefulWidget {
class FileBottomBarState extends State<FileBottomBar> {
final GlobalKey shareButtonKey = GlobalKey();
bool _isFileSwipeLocked = false;
+ late final StreamSubscription<FileSwipeLockEvent>
+ _fileSwipeLockEventSubscription;
@override
void initState() {
super.initState();
- Bus.instance.on<FileSwipeLockEvent>().listen((event) {
+ _fileSwipeLockEventSubscription =
+ Bus.instance.on<FileSwipeLockEvent>().listen((event) {
setState(() {
_isFileSwipeLocked = event.shouldSwipeLock;
});
@@ -56,14 +59,13 @@ class FileBottomBarState extends State<FileBottomBar> {
@override
void dispose() {
+ _fileSwipeLockEventSubscription.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
- return _isFileSwipeLocked
- ? const IgnorePointer(child: SizedBox.shrink())
- : _getBottomBar();
+ return _isFileSwipeLocked ? Container() : _getBottomBar();
}
void safeRefresh() {