mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
[mob][photos] Swipe lock for multiple files
This commit is contained in:
parent
5f7b411b67
commit
b7bd8c83ba
@ -1,7 +1,7 @@
|
||||
import "package:photos/events/event.dart";
|
||||
|
||||
class FileSwipeLockEvent extends Event {
|
||||
final bool shouldSwipeLock;
|
||||
|
||||
FileSwipeLockEvent(this.shouldSwipeLock);
|
||||
final bool isGuestView;
|
||||
final bool swipeLocked;
|
||||
FileSwipeLockEvent(this.isGuestView, this.swipeLocked);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import "package:logging/logging.dart";
|
||||
import "package:modal_bottom_sheet/modal_bottom_sheet.dart";
|
||||
import 'package:photos/core/configuration.dart';
|
||||
import "package:photos/core/event_bus.dart";
|
||||
import "package:photos/events/file_swipe_lock_event.dart";
|
||||
import "package:photos/events/people_changed_event.dart";
|
||||
import "package:photos/face/model/person.dart";
|
||||
import "package:photos/generated/l10n.dart";
|
||||
@ -32,9 +33,9 @@ import 'package:photos/ui/components/action_sheet_widget.dart';
|
||||
import "package:photos/ui/components/bottom_action_bar/selection_action_button_widget.dart";
|
||||
import 'package:photos/ui/components/buttons/button_widget.dart';
|
||||
import 'package:photos/ui/components/models/button_type.dart';
|
||||
// import 'package:photos/ui/sharing/manage_links_widget.dart';
|
||||
import "package:photos/ui/sharing/show_images_prevew.dart";
|
||||
import "package:photos/ui/tools/collage/collage_creator_page.dart";
|
||||
import "package:photos/ui/viewer/file/detail_page.dart";
|
||||
import "package:photos/ui/viewer/location/update_location_data_widget.dart";
|
||||
import 'package:photos/utils/delete_file_util.dart';
|
||||
import "package:photos/utils/dialog_util.dart";
|
||||
@ -271,7 +272,13 @@ class _FileSelectionActionsWidgetState
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
items.add(
|
||||
SelectionActionButton(
|
||||
icon: Icons.lock,
|
||||
labelText: "Guest view",
|
||||
onTap: _onGuestViewClick,
|
||||
),
|
||||
);
|
||||
items.add(
|
||||
SelectionActionButton(
|
||||
icon: Icons.grid_view_outlined,
|
||||
@ -559,6 +566,23 @@ class _FileSelectionActionsWidgetState
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onGuestViewClick() async {
|
||||
final List<EnteFile> selectedFiles = widget.selectedFiles.files.toList();
|
||||
final page = DetailPage(
|
||||
DetailPageConfiguration(
|
||||
selectedFiles,
|
||||
null,
|
||||
0,
|
||||
"guest_view",
|
||||
),
|
||||
);
|
||||
routeToPage(context, page, forceCustomPageRoute: true).ignore();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
Bus.instance.fire(FileSwipeLockEvent(true, false));
|
||||
});
|
||||
widget.selectedFiles.clearAll();
|
||||
}
|
||||
|
||||
Future<void> _onArchiveClick() async {
|
||||
await changeVisibility(
|
||||
context,
|
||||
|
@ -86,7 +86,8 @@ class _DetailPageState extends State<DetailPage> {
|
||||
bool _hasLoadedTillEnd = false;
|
||||
final _enableFullScreenNotifier = ValueNotifier(false);
|
||||
bool _isFirstOpened = true;
|
||||
bool isFileSwipeLocked = false;
|
||||
bool isGuestView = false;
|
||||
bool swipeLocked = false;
|
||||
late final StreamSubscription<FileSwipeLockEvent>
|
||||
_fileSwipeLockEventSubscription;
|
||||
|
||||
@ -102,7 +103,8 @@ class _DetailPageState extends State<DetailPage> {
|
||||
_fileSwipeLockEventSubscription =
|
||||
Bus.instance.on<FileSwipeLockEvent>().listen((event) {
|
||||
setState(() {
|
||||
isFileSwipeLocked = event.shouldSwipeLock;
|
||||
isGuestView = event.isGuestView;
|
||||
swipeLocked = event.swipeLocked;
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -138,12 +140,12 @@ class _DetailPageState extends State<DetailPage> {
|
||||
" files .",
|
||||
);
|
||||
return PopScope(
|
||||
canPop: !isFileSwipeLocked,
|
||||
canPop: !isGuestView,
|
||||
onPopInvoked: (didPop) async {
|
||||
if (isFileSwipeLocked) {
|
||||
if (isGuestView) {
|
||||
final authenticated = await _requestAuthentication();
|
||||
if (authenticated) {
|
||||
Bus.instance.fire(FileSwipeLockEvent(false));
|
||||
Bus.instance.fire(FileSwipeLockEvent(false, false));
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -176,7 +178,7 @@ class _DetailPageState extends State<DetailPage> {
|
||||
_files![selectedIndex],
|
||||
_onEditFileRequested,
|
||||
widget.config.mode == DetailPageMode.minimalistic &&
|
||||
!isFileSwipeLocked,
|
||||
!isGuestView,
|
||||
onFileRemoved: _onFileRemoved,
|
||||
userID: Configuration.instance.getUserID(),
|
||||
enableFullScreenNotifier: _enableFullScreenNotifier,
|
||||
@ -235,10 +237,13 @@ class _DetailPageState extends State<DetailPage> {
|
||||
} else {
|
||||
_selectedIndexNotifier.value = index;
|
||||
}
|
||||
Bus.instance.fire(FileSwipeLockEvent(isGuestView, swipeLocked));
|
||||
_preloadEntries();
|
||||
},
|
||||
physics: _shouldDisableScroll || isFileSwipeLocked
|
||||
physics: _shouldDisableScroll || isGuestView
|
||||
? swipeLocked
|
||||
? const NeverScrollableScrollPhysics()
|
||||
: const FastScrollPhysics(speedFactor: 4.0)
|
||||
: const FastScrollPhysics(speedFactor: 4.0),
|
||||
controller: _pageController,
|
||||
itemCount: _files!.length,
|
||||
|
@ -53,7 +53,7 @@ class FileAppBarState extends State<FileAppBar> {
|
||||
final List<Widget> _actions = [];
|
||||
late final StreamSubscription<FileSwipeLockEvent>
|
||||
_fileSwipeLockEventSubscription;
|
||||
bool _isFileSwipeLocked = false;
|
||||
bool isGuestView = false;
|
||||
|
||||
@override
|
||||
void didUpdateWidget(FileAppBar oldWidget) {
|
||||
@ -69,7 +69,7 @@ class FileAppBarState extends State<FileAppBar> {
|
||||
_fileSwipeLockEventSubscription =
|
||||
Bus.instance.on<FileSwipeLockEvent>().listen((event) {
|
||||
setState(() {
|
||||
_isFileSwipeLocked = event.shouldSwipeLock;
|
||||
isGuestView = event.isGuestView;
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -124,19 +124,19 @@ class FileAppBarState extends State<FileAppBar> {
|
||||
switchOutCurve: Curves.easeInOut,
|
||||
child: AppBar(
|
||||
clipBehavior: Clip.none,
|
||||
key: ValueKey(_isFileSwipeLocked),
|
||||
key: ValueKey(isGuestView),
|
||||
iconTheme: const IconThemeData(
|
||||
color: Colors.white,
|
||||
), //same for both themes
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
_isFileSwipeLocked
|
||||
isGuestView
|
||||
? _requestAuthentication()
|
||||
: Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
actions: shouldShowActions && !_isFileSwipeLocked ? _actions : [],
|
||||
actions: shouldShowActions && !isGuestView ? _actions : [],
|
||||
elevation: 0,
|
||||
backgroundColor: const Color(0x00000000),
|
||||
),
|
||||
@ -306,7 +306,7 @@ class FileAppBarState extends State<FileAppBar> {
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
),
|
||||
const Text("Swipe lock"),
|
||||
const Text("Guest view"),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -329,7 +329,7 @@ class FileAppBarState extends State<FileAppBar> {
|
||||
} else if (value == 5) {
|
||||
await _handleUnHideRequest(context);
|
||||
} else if (value == 6) {
|
||||
await _onSwipeLock();
|
||||
await _onTapGuestView();
|
||||
}
|
||||
},
|
||||
),
|
||||
@ -413,9 +413,9 @@ class FileAppBarState extends State<FileAppBar> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onSwipeLock() async {
|
||||
Future<void> _onTapGuestView() async {
|
||||
if (await LocalAuthentication().isDeviceSupported()) {
|
||||
Bus.instance.fire(FileSwipeLockEvent(!_isFileSwipeLocked));
|
||||
Bus.instance.fire(FileSwipeLockEvent(!isGuestView, true));
|
||||
} else {
|
||||
await showErrorDialog(
|
||||
context,
|
||||
@ -432,7 +432,7 @@ class FileAppBarState extends State<FileAppBar> {
|
||||
"Please authenticate to view more photos and videos.",
|
||||
);
|
||||
if (hasAuthenticated) {
|
||||
Bus.instance.fire(FileSwipeLockEvent(false));
|
||||
Bus.instance.fire(FileSwipeLockEvent(false, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class FileBottomBar extends StatefulWidget {
|
||||
|
||||
class FileBottomBarState extends State<FileBottomBar> {
|
||||
final GlobalKey shareButtonKey = GlobalKey();
|
||||
bool _isFileSwipeLocked = false;
|
||||
bool isGuestView = false;
|
||||
late final StreamSubscription<FileSwipeLockEvent>
|
||||
_fileSwipeLockEventSubscription;
|
||||
bool isPanorama = false;
|
||||
@ -59,7 +59,7 @@ class FileBottomBarState extends State<FileBottomBar> {
|
||||
_fileSwipeLockEventSubscription =
|
||||
Bus.instance.on<FileSwipeLockEvent>().listen((event) {
|
||||
setState(() {
|
||||
_isFileSwipeLocked = event.shouldSwipeLock;
|
||||
isGuestView = event.isGuestView;
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -220,9 +220,9 @@ class FileBottomBarState extends State<FileBottomBar> {
|
||||
valueListenable: widget.enableFullScreenNotifier,
|
||||
builder: (BuildContext context, bool isFullScreen, _) {
|
||||
return IgnorePointer(
|
||||
ignoring: isFullScreen || _isFileSwipeLocked,
|
||||
ignoring: isFullScreen || isGuestView,
|
||||
child: AnimatedOpacity(
|
||||
opacity: isFullScreen || _isFileSwipeLocked ? 0 : 1,
|
||||
opacity: isFullScreen || isGuestView ? 0 : 1,
|
||||
duration: const Duration(milliseconds: 250),
|
||||
curve: Curves.easeInOut,
|
||||
child: Align(
|
||||
|
@ -48,7 +48,7 @@ class _VideoWidgetState extends State<VideoWidget> {
|
||||
final _progressNotifier = ValueNotifier<double?>(null);
|
||||
bool _isPlaying = false;
|
||||
final EnteWakeLock _wakeLock = EnteWakeLock();
|
||||
bool _isFileSwipeLocked = false;
|
||||
bool isGuestView = false;
|
||||
late final StreamSubscription<FileSwipeLockEvent>
|
||||
_fileSwipeLockEventSubscription;
|
||||
|
||||
@ -83,7 +83,7 @@ class _VideoWidgetState extends State<VideoWidget> {
|
||||
_fileSwipeLockEventSubscription =
|
||||
Bus.instance.on<FileSwipeLockEvent>().listen((event) {
|
||||
setState(() {
|
||||
_isFileSwipeLocked = event.shouldSwipeLock;
|
||||
isGuestView = event.isGuestView;
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -188,7 +188,7 @@ class _VideoWidgetState extends State<VideoWidget> {
|
||||
? _getVideoPlayer()
|
||||
: _getLoadingWidget();
|
||||
final contentWithDetector = GestureDetector(
|
||||
onVerticalDragUpdate: _isFileSwipeLocked
|
||||
onVerticalDragUpdate: isGuestView
|
||||
? null
|
||||
: (d) => {
|
||||
if (d.delta.dy > dragSensitivity)
|
||||
|
@ -47,7 +47,7 @@ class _VideoWidgetNewState extends State<VideoWidgetNew>
|
||||
late StreamSubscription<bool> playingStreamSubscription;
|
||||
bool _isAppInFG = true;
|
||||
late StreamSubscription<PauseVideoEvent> pauseVideoSubscription;
|
||||
bool _isFileSwipeLocked = false;
|
||||
bool isGuestView = false;
|
||||
late final StreamSubscription<FileSwipeLockEvent>
|
||||
_fileSwipeLockEventSubscription;
|
||||
|
||||
@ -97,7 +97,7 @@ class _VideoWidgetNewState extends State<VideoWidgetNew>
|
||||
_fileSwipeLockEventSubscription =
|
||||
Bus.instance.on<FileSwipeLockEvent>().listen((event) {
|
||||
setState(() {
|
||||
_isFileSwipeLocked = event.shouldSwipeLock;
|
||||
isGuestView = event.isGuestView;
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -159,7 +159,7 @@ class _VideoWidgetNewState extends State<VideoWidgetNew>
|
||||
),
|
||||
fullscreen: const MaterialVideoControlsThemeData(),
|
||||
child: GestureDetector(
|
||||
onVerticalDragUpdate: _isFileSwipeLocked
|
||||
onVerticalDragUpdate: isGuestView
|
||||
? null
|
||||
: (d) => {
|
||||
if (d.delta.dy > dragSensitivity)
|
||||
|
@ -54,7 +54,7 @@ class _ZoomableImageState extends State<ZoomableImage> {
|
||||
bool _isZooming = false;
|
||||
PhotoViewController _photoViewController = PhotoViewController();
|
||||
final _scaleStateController = PhotoViewScaleStateController();
|
||||
bool _isFileSwipeLocked = false;
|
||||
bool isGuestView = false;
|
||||
late final StreamSubscription<FileSwipeLockEvent>
|
||||
_fileSwipeLockEventSubscription;
|
||||
|
||||
@ -75,7 +75,7 @@ class _ZoomableImageState extends State<ZoomableImage> {
|
||||
_fileSwipeLockEventSubscription =
|
||||
Bus.instance.on<FileSwipeLockEvent>().listen((event) {
|
||||
setState(() {
|
||||
_isFileSwipeLocked = event.shouldSwipeLock;
|
||||
isGuestView = event.isGuestView;
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -159,7 +159,7 @@ class _ZoomableImageState extends State<ZoomableImage> {
|
||||
}
|
||||
|
||||
final GestureDragUpdateCallback? verticalDragCallback =
|
||||
_isZooming || _isFileSwipeLocked
|
||||
_isZooming || isGuestView
|
||||
? null
|
||||
: (d) => {
|
||||
if (!_isZooming)
|
||||
|
Loading…
x
Reference in New Issue
Block a user