Skip to content

armgit / ente

Public Imported from GitHub
0

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

Change bottom padding of scrollbar if file selection sheet is up/down

ashilknb053b0082fd0
diff --git a/mobile/apps/photos/lib/ui/home/home_gallery_widget.dart b/mobile/apps/photos/lib/ui/home/home_gallery_widget.dart
index b398d41323..0c9887fa39 100644
--- a/mobile/apps/photos/lib/ui/home/home_gallery_widget.dart
+++ b/mobile/apps/photos/lib/ui/home/home_gallery_widget.dart
@@ -73,7 +73,6 @@ class _HomeGalleryWidgetState extends State<HomeGalleryWidget> {
@override
Widget build(BuildContext context) {
- final double bottomSafeArea = MediaQuery.paddingOf(context).bottom;
final gallery = Gallery(
key: ValueKey(_shouldHideSharedItems),
asyncLoader: (creationStartTime, creationEndTime, {limit, asc}) async {
@@ -129,6 +128,7 @@ class _HomeGalleryWidgetState extends State<HomeGalleryWidget> {
footer: widget.footer,
reloadDebounceTime: const Duration(seconds: 2),
reloadDebounceExecutionInterval: const Duration(seconds: 5),
+ galleryType: GalleryType.homepage,
);
return GalleryFilesState(
child: SelectionState(
diff --git a/mobile/apps/photos/lib/ui/viewer/actions/file_selection_overlay_bar.dart b/mobile/apps/photos/lib/ui/viewer/actions/file_selection_overlay_bar.dart
index e21c161888..7a400604de 100644
--- a/mobile/apps/photos/lib/ui/viewer/actions/file_selection_overlay_bar.dart
+++ b/mobile/apps/photos/lib/ui/viewer/actions/file_selection_overlay_bar.dart
@@ -1,3 +1,5 @@
+import "dart:io";
+
import 'package:flutter/material.dart';
import "package:photos/generated/l10n.dart";
import 'package:photos/models/collection/collection.dart';
@@ -16,6 +18,7 @@ import "package:photos/ui/viewer/gallery/state/search_filter_data_provider.dart"
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
class FileSelectionOverlayBar extends StatefulWidget {
+ static double roughHeight = Platform.isIOS ? 240.0 : 232.0;
final GalleryType galleryType;
final SelectedFiles selectedFiles;
final Collection? collection;
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
index 750d555b00..28a0a3b8e0 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
@@ -13,10 +13,12 @@ import 'package:photos/events/tab_changed_event.dart';
import 'package:photos/models/file/file.dart';
import 'package:photos/models/file_load_result.dart';
import "package:photos/models/gallery/gallery_sections.dart";
+import "package:photos/models/gallery_type.dart";
import 'package:photos/models/selected_files.dart';
import "package:photos/service_locator.dart";
import "package:photos/theme/ente_theme.dart";
import 'package:photos/ui/common/loading_widget.dart';
+import "package:photos/ui/viewer/actions/file_selection_overlay_bar.dart";
import "package:photos/ui/viewer/gallery/component/gallery_file_widget.dart";
import "package:photos/ui/viewer/gallery/component/group/group_header_widget.dart";
import "package:photos/ui/viewer/gallery/component/group/type.dart";
@@ -58,6 +60,7 @@ class Gallery extends StatefulWidget {
final bool disableScroll;
final Duration reloadDebounceTime;
final Duration reloadDebounceExecutionInterval;
+ final GalleryType? galleryType;
/// When true, selection will be limited to one item. Tapping on any item
/// will select even when no other item is selected.
@@ -100,6 +103,7 @@ class Gallery extends StatefulWidget {
this.reloadDebounceTime = const Duration(milliseconds: 500),
this.reloadDebounceExecutionInterval = const Duration(seconds: 2),
this.disablePinnedGroupHeader = false,
+ this.galleryType,
super.key,
});
@@ -131,6 +135,7 @@ class GalleryState extends State<Gallery> {
final miscUtil = MiscUtil();
final scrollBarInUseNotifier = ValueNotifier<bool>(false);
late GroupType _groupType;
+ final scrollbarBottomPaddingNotifier = ValueNotifier<double>(0);
@override
void initState() {
@@ -243,6 +248,8 @@ class GalleryState extends State<Gallery> {
}
WidgetsBinding.instance.addPostFrameCallback((_) async {
+ // To set the initial value of scrollbar bottom padding
+ _selectedFilesListener();
try {
final headerRenderBox = await miscUtil
.getNonNullValueWithRetry(
@@ -258,6 +265,9 @@ class GalleryState extends State<Gallery> {
}
setState(() {});
});
+
+ widget.selectedFiles?.addListener(_selectedFilesListener);
+ // To set the initial value of scrollbar bottom padding
}
@override
@@ -271,6 +281,15 @@ class GalleryState extends State<Gallery> {
}
}
+ void _selectedFilesListener() {
+ final bottomInset = MediaQuery.paddingOf(context).bottom;
+ final extra = widget.galleryType == GalleryType.homepage ? 76.0 : 0.0;
+ widget.selectedFiles?.files.isEmpty ?? true
+ ? scrollbarBottomPaddingNotifier.value = bottomInset + extra
+ : scrollbarBottomPaddingNotifier.value =
+ FileSelectionOverlayBar.roughHeight + bottomInset;
+ }
+
void _setGroupType() {
_groupType = widget.enableFileGrouping ? widget.groupType : GroupType.none;
}
@@ -442,6 +461,8 @@ class GalleryState extends State<Gallery> {
_scrollController.dispose();
scrollBarInUseNotifier.dispose();
_headerHeightNotifier.dispose();
+ widget.selectedFiles?.removeListener(_selectedFilesListener);
+ scrollbarBottomPaddingNotifier.dispose();
super.dispose();
}
@@ -487,8 +508,6 @@ class GalleryState extends State<Gallery> {
: const SizedBox.shrink();
}
- final double bottomPadding = MediaQuery.paddingOf(context).bottom + 180;
-
final galleryGroups = GalleryGroups(
allFiles: _allGalleryFiles,
groupType: _groupType,
@@ -544,7 +563,7 @@ class GalleryState extends State<Gallery> {
inUseNotifier: scrollBarInUseNotifier,
heighOfViewport: MediaQuery.sizeOf(context).height,
topPadding: groupHeaderExtent!,
- bottomPadding: bottomPadding,
+ bottomPadding: scrollbarBottomPaddingNotifier,
child: NotificationListener<SizeChangedLayoutNotification>(
onNotification: (notification) {
final renderBox = _headerKey.currentContext
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/custom_scroll_bar.dart b/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/custom_scroll_bar.dart
index cd85c5cdb2..8bd90b103a 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/custom_scroll_bar.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/custom_scroll_bar.dart
@@ -20,7 +20,7 @@ class ScrollbarDivision {
class CustomScrollBar extends StatefulWidget {
final Widget child;
- final double bottomPadding;
+ final ValueNotifier<double> bottomPadding;
final double topPadding;
final ScrollController scrollController;
final GalleryGroups galleryGroups;
@@ -74,6 +74,7 @@ class _CustomScrollBarState extends State<CustomScrollBar> {
void initState() {
super.initState();
_init();
+ widget.bottomPadding.addListener(_computePositionToTitleMap);
}
@override
@@ -82,6 +83,12 @@ class _CustomScrollBarState extends State<CustomScrollBar> {
_init();
}
+ @override
+ void dispose() {
+ widget.bottomPadding.removeListener(_computePositionToTitleMap);
+ super.dispose();
+ }
+
void _init() {
_logger.info("Initializing CustomScrollBar2");
if (widget.galleryGroups.groupType.showScrollbarDivisions() &&
@@ -116,6 +123,7 @@ class _CustomScrollBarState extends State<CustomScrollBar> {
// if the scrollable is long enough, where the header and footer extents
// are negligible compared to max extent of the scrollable.
Future<void> _computePositionToTitleMap() async {
+ _logger.info("Computing position to title map");
final result = <({double position, String title})>[];
heightOfScrollTrack = await _getHeightOfScrollTrack();
final maxScrollExtent = widget.scrollController.position.maxScrollExtent;
@@ -201,7 +209,9 @@ class _CustomScrollBarState extends State<CustomScrollBar> {
() => renderBox!.size.height,
id: "getHeightOfScrollTrack",
)
- .then((value) => value - widget.bottomPadding - widget.topPadding);
+ .then(
+ (value) => value - widget.bottomPadding.value - widget.topPadding,
+ );
}
@override
@@ -214,7 +224,7 @@ class _CustomScrollBarState extends State<CustomScrollBar> {
MediaQuery(
data: MediaQuery.of(context).copyWith(
padding: EdgeInsets.only(
- bottom: widget.bottomPadding,
+ bottom: widget.bottomPadding.value,
top: widget.topPadding,
),
),
@@ -232,7 +242,7 @@ class _CustomScrollBarState extends State<CustomScrollBar> {
: Padding(
padding: EdgeInsets.only(
top: widget.topPadding,
- bottom: widget.bottomPadding,
+ bottom: widget.bottomPadding.value,
),
child: ValueListenableBuilder<bool>(
valueListenable: widget.inUseNotifier,