Skip to content

armgit / ente

Public Imported from GitHub
0

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

Improve comments bottom sheet ux when keyboard is up

ashilkn982a0b9d16f4
diff --git a/mobile/apps/photos/lib/ui/social/comments_screen.dart b/mobile/apps/photos/lib/ui/social/comments_screen.dart
index eadb512659..6d14439800 100644
--- a/mobile/apps/photos/lib/ui/social/comments_screen.dart
+++ b/mobile/apps/photos/lib/ui/social/comments_screen.dart
@@ -26,29 +26,63 @@ Future<void> showFileCommentsBottomSheet(
required int fileID,
String? highlightCommentID,
}) {
- final sheetController = DraggableScrollableController();
-
return showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
- builder: (_) => DraggableScrollableSheet(
+ builder: (_) => _DraggableCommentsSheet(
+ collectionID: collectionID,
+ fileID: fileID,
+ highlightCommentID: highlightCommentID,
+ ),
+ );
+}
+
+class _DraggableCommentsSheet extends StatefulWidget {
+ final int collectionID;
+ final int fileID;
+ final String? highlightCommentID;
+
+ const _DraggableCommentsSheet({
+ required this.collectionID,
+ required this.fileID,
+ this.highlightCommentID,
+ });
+
+ @override
+ State<_DraggableCommentsSheet> createState() =>
+ _DraggableCommentsSheetState();
+}
+
+class _DraggableCommentsSheetState extends State<_DraggableCommentsSheet> {
+ final sheetController = DraggableScrollableController();
+
+ @override
+ void dispose() {
+ sheetController.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final isKeyboardOpen = MediaQuery.of(context).viewInsets.bottom > 60;
+ return DraggableScrollableSheet(
controller: sheetController,
- initialChildSize: 0.6,
- minChildSize: 0.4,
+ initialChildSize: isKeyboardOpen ? 0.95 : 0.6,
+ minChildSize: isKeyboardOpen ? 0.8 : 0.4,
maxChildSize: 0.95,
- snap: true,
- snapSizes: const [0.6],
+ snap: isKeyboardOpen ? false : true,
+ snapSizes: isKeyboardOpen ? null : const [0.6],
expand: false,
builder: (context, scrollController) => FileCommentsBottomSheet(
- collectionID: collectionID,
- fileID: fileID,
- highlightCommentID: highlightCommentID,
+ collectionID: widget.collectionID,
+ fileID: widget.fileID,
+ highlightCommentID: widget.highlightCommentID,
dragController: scrollController,
sheetController: sheetController,
),
- ),
- );
+ );
+ }
}
class FileCommentsBottomSheet extends StatefulWidget {