From 25a218e1fb0a9e7b87a3177c6aaefaf24d7400c1 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sat, 26 Nov 2022 13:26:54 +0530 Subject: [PATCH 01/10] remove sharing button for fav collection --- lib/ui/viewer/gallery/gallery_app_bar_widget.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/lib/ui/viewer/gallery/gallery_app_bar_widget.dart index 8a5c520c9..4fe1c6cc4 100644 --- a/lib/ui/viewer/gallery/gallery_app_bar_widget.dart +++ b/lib/ui/viewer/gallery/gallery_app_bar_widget.dart @@ -255,7 +255,8 @@ class _GalleryAppBarWidgetState extends State { final List actions = []; if (Configuration.instance.hasConfiguredAccount() && widget.selectedFiles.files.isEmpty && - widget.type == GalleryType.ownedCollection) { + widget.type == GalleryType.ownedCollection && + widget.collection?.type != CollectionType.favorites) { actions.add( Tooltip( message: "Share", From d969eb5581c4645f565444b4326265f0deb1e249 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sat, 26 Nov 2022 13:28:10 +0530 Subject: [PATCH 02/10] increase caption length from 280 -> 5000 --- lib/ui/viewer/file/file_caption_widget.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ui/viewer/file/file_caption_widget.dart b/lib/ui/viewer/file/file_caption_widget.dart index b625ffa17..0f2931d57 100644 --- a/lib/ui/viewer/file/file_caption_widget.dart +++ b/lib/ui/viewer/file/file_caption_widget.dart @@ -13,7 +13,7 @@ class FileCaptionWidget extends StatefulWidget { } class _FileCaptionWidgetState extends State { - int maxLength = 280; + static const int maxLength = 5000; int currentLength = 0; final _textController = TextEditingController(); final _focusNode = FocusNode(); From 02f976167d114daa6c1ff54f3831aa1277b4bd17 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sat, 26 Nov 2022 13:29:56 +0530 Subject: [PATCH 03/10] Show max 10 files in caption edit field --- lib/ui/viewer/file/file_caption_widget.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ui/viewer/file/file_caption_widget.dart b/lib/ui/viewer/file/file_caption_widget.dart index 0f2931d57..cc3b36673 100644 --- a/lib/ui/viewer/file/file_caption_widget.dart +++ b/lib/ui/viewer/file/file_caption_widget.dart @@ -89,7 +89,7 @@ class _FileCaptionWidgetState extends State { cursorWidth: 1.5, maxLength: maxLength, minLines: 1, - maxLines: 6, + maxLines: 10, textCapitalization: TextCapitalization.sentences, keyboardType: TextInputType.text, onChanged: (value) { From 1a8a48567bac01f2c59757093783a47d13ce9cf4 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sat, 26 Nov 2022 14:32:27 +0530 Subject: [PATCH 04/10] Caption: increase counter threshold --- lib/ui/viewer/file/file_caption_widget.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ui/viewer/file/file_caption_widget.dart b/lib/ui/viewer/file/file_caption_widget.dart index cc3b36673..8022317df 100644 --- a/lib/ui/viewer/file/file_caption_widget.dart +++ b/lib/ui/viewer/file/file_caption_widget.dart @@ -14,6 +14,9 @@ class FileCaptionWidget extends StatefulWidget { class _FileCaptionWidgetState extends State { static const int maxLength = 5000; + // counterThreshold represents the nun of char after which + // currentLength/maxLength will show up + static const int counterThreshold = 1000; int currentLength = 0; final _textController = TextEditingController(); final _focusNode = FocusNode(); @@ -60,7 +63,7 @@ class _FileCaptionWidgetState extends State { focusNode: _focusNode, decoration: InputDecoration( counterStyle: textTheme.mini.copyWith(color: colorScheme.textMuted), - counterText: currentLength > 99 + counterText: currentLength >= counterThreshold ? currentLength.toString() + " / " + maxLength.toString() : "", contentPadding: const EdgeInsets.all(16), From eed7fa934964c189b51f06345ce7ce277863bcfc Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sat, 26 Nov 2022 14:39:24 +0530 Subject: [PATCH 05/10] PhotoView:Limit maxlines for photo description --- lib/ui/viewer/file/fading_bottom_bar.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ui/viewer/file/fading_bottom_bar.dart b/lib/ui/viewer/file/fading_bottom_bar.dart index ae7013337..7352ac038 100644 --- a/lib/ui/viewer/file/fading_bottom_bar.dart +++ b/lib/ui/viewer/file/fading_bottom_bar.dart @@ -204,6 +204,8 @@ class FadingBottomBarState extends State { ), child: Text( widget.file.caption, + overflow: TextOverflow.ellipsis, + maxLines: 4, style: getEnteTextTheme(context) .small .copyWith(color: textBaseDark), From 65f842897b0931774db6fae5d12362cc0debff16 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sat, 26 Nov 2022 15:02:53 +0530 Subject: [PATCH 06/10] Add dependency on keyboard_visiblity --- lib/ui/common/keyboard_top_buttons.dart | 0 pubspec.lock | 7 +++++++ pubspec.yaml | 1 + 3 files changed, 8 insertions(+) create mode 100644 lib/ui/common/keyboard_top_buttons.dart diff --git a/lib/ui/common/keyboard_top_buttons.dart b/lib/ui/common/keyboard_top_buttons.dart new file mode 100644 index 000000000..e69de29bb diff --git a/pubspec.lock b/pubspec.lock index 5bee9ad4d..f6a3e6679 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -707,6 +707,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.7.0" + keyboard_visibility: + dependency: "direct main" + description: + name: keyboard_visibility + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.6" like_button: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index add1421e0..7864ef723 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -72,6 +72,7 @@ dependencies: implicitly_animated_reorderable_list: ^0.4.0 in_app_purchase: ^3.0.7 intl: ^0.17.0 + keyboard_visibility: ^0.5.6 like_button: ^2.0.2 loading_animations: ^2.1.0 local_auth: ^1.1.5 From b918039c7c5c5e7ca81b924bc798844d5e7816bd Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sun, 27 Nov 2022 07:14:12 +0530 Subject: [PATCH 07/10] Add basic widgets for buttons on top of keyboard --- .../components/keyboard/keybiard_oveylay.dart | 32 +++++++++++ .../keyboard/keyboard_top_button.dart | 56 +++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 lib/ui/components/keyboard/keybiard_oveylay.dart create mode 100644 lib/ui/components/keyboard/keyboard_top_button.dart diff --git a/lib/ui/components/keyboard/keybiard_oveylay.dart b/lib/ui/components/keyboard/keybiard_oveylay.dart new file mode 100644 index 000000000..d14a1e4bc --- /dev/null +++ b/lib/ui/components/keyboard/keybiard_oveylay.dart @@ -0,0 +1,32 @@ +import 'package:flutter/widgets.dart'; + +class KeyboardOverlay { + static OverlayEntry? _overlayEntry; + + static showOverlay(BuildContext context, Widget child) { + if (_overlayEntry != null) { + return; + } + + final OverlayState? overlayState = Overlay.of(context); + _overlayEntry = OverlayEntry( + builder: (context) { + return Positioned( + bottom: MediaQuery.of(context).viewInsets.bottom, + right: 0.0, + left: 0.0, + child: child, + ); + }, + ); + + overlayState!.insert(_overlayEntry!); + } + + static removeOverlay() { + if (_overlayEntry != null) { + _overlayEntry!.remove(); + _overlayEntry = null; + } + } +} diff --git a/lib/ui/components/keyboard/keyboard_top_button.dart b/lib/ui/components/keyboard/keyboard_top_button.dart new file mode 100644 index 000000000..8e93a432a --- /dev/null +++ b/lib/ui/components/keyboard/keyboard_top_button.dart @@ -0,0 +1,56 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:photos/theme/ente_theme.dart'; + +class KeyboardTopButton extends StatelessWidget { + final Function? onDoneTap; + final Function? onCancelTap; + final String doneText; + final String cancelText; + + const KeyboardTopButton({ + super.key, + this.doneText = "Done", + this.cancelText = "Cancel", + this.onDoneTap, + this.onCancelTap, + }); + + @override + Widget build(BuildContext context) { + final enteTheme = getEnteTextTheme(context); + final colorScheme = getEnteColorScheme(context); + return Container( + width: double.infinity, + decoration: BoxDecoration( + border: Border( + top: BorderSide(width: 1.0, color: colorScheme.strokeFaint), + bottom: BorderSide(width: 1.0, color: colorScheme.strokeFaint), + ), + color: colorScheme.backgroundElevated2, + ), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + CupertinoButton( + padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 14), + onPressed: () { + onCancelTap?.call(); + }, + child: Text(cancelText, style: enteTheme.bodyBold), + ), + CupertinoButton( + padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 14), + onPressed: () { + onDoneTap?.call(); + }, + child: Text(doneText, style: enteTheme.bodyBold), + ), + ], + ), + ), + ); + } +} From e8c571d877f100e9137354328e36ce6d34ee724f Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sun, 27 Nov 2022 07:15:54 +0530 Subject: [PATCH 08/10] iOS: Podfile update changes --- ios/Podfile.lock | 7 +++++++ ios/Runner.xcodeproj/project.pbxproj | 2 ++ lib/ui/common/keyboard_top_buttons.dart | 0 3 files changed, 9 insertions(+) delete mode 100644 lib/ui/common/keyboard_top_buttons.dart diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 735f8cfa6..a75bf352f 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -102,6 +102,9 @@ PODS: - Flutter - in_app_purchase_storekit (0.0.1): - Flutter + - keyboard_visibility (0.5.0): + - Flutter + - Reachability - libwebp (1.2.3): - libwebp/demux (= 1.2.3) - libwebp/mux (= 1.2.3) @@ -193,6 +196,7 @@ DEPENDENCIES: - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) - image_editor (from `.symlinks/plugins/image_editor/ios`) - in_app_purchase_storekit (from `.symlinks/plugins/in_app_purchase_storekit/ios`) + - keyboard_visibility (from `.symlinks/plugins/keyboard_visibility/ios`) - local_auth (from `.symlinks/plugins/local_auth/ios`) - media_extension (from `.symlinks/plugins/media_extension/ios`) - motionphoto (from `.symlinks/plugins/motionphoto/ios`) @@ -271,6 +275,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/image_editor/ios" in_app_purchase_storekit: :path: ".symlinks/plugins/in_app_purchase_storekit/ios" + keyboard_visibility: + :path: ".symlinks/plugins/keyboard_visibility/ios" local_auth: :path: ".symlinks/plugins/local_auth/ios" media_extension: @@ -336,6 +342,7 @@ SPEC CHECKSUMS: GoogleUtilities: 1d20a6ad97ef46f67bbdec158ce00563a671ebb7 image_editor: eab82a302a6623a866da5145b7c4c0ee8a4ffbb4 in_app_purchase_storekit: d7fcf4646136ec258e237872755da8ea6c1b6096 + keyboard_visibility: 96a24de806fe6823c3ad956c01ba2ec6d056616f libwebp: 60305b2e989864154bd9be3d772730f08fc6a59c local_auth: 1740f55d7af0a2e2a8684ce225fe79d8931e808c Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 41eb25fc0..91fb51834 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -287,6 +287,7 @@ "${BUILT_PRODUCTS_DIR}/fluttertoast/fluttertoast.framework", "${BUILT_PRODUCTS_DIR}/image_editor/image_editor.framework", "${BUILT_PRODUCTS_DIR}/in_app_purchase_storekit/in_app_purchase_storekit.framework", + "${BUILT_PRODUCTS_DIR}/keyboard_visibility/keyboard_visibility.framework", "${BUILT_PRODUCTS_DIR}/libwebp/libwebp.framework", "${BUILT_PRODUCTS_DIR}/local_auth/local_auth.framework", "${BUILT_PRODUCTS_DIR}/media_extension/media_extension.framework", @@ -341,6 +342,7 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/fluttertoast.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_editor.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/in_app_purchase_storekit.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/keyboard_visibility.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/local_auth.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/media_extension.framework", diff --git a/lib/ui/common/keyboard_top_buttons.dart b/lib/ui/common/keyboard_top_buttons.dart deleted file mode 100644 index e69de29bb..000000000 From e421841f553ef8c191e3fb0d7050fec539a4669b Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sun, 27 Nov 2022 09:55:10 +0530 Subject: [PATCH 09/10] Handle done and cancel button --- .../keyboard/keyboard_top_button.dart | 12 ++--- lib/ui/viewer/file/file_caption_widget.dart | 53 +++++++++++++++---- 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/lib/ui/components/keyboard/keyboard_top_button.dart b/lib/ui/components/keyboard/keyboard_top_button.dart index 8e93a432a..cd913eb61 100644 --- a/lib/ui/components/keyboard/keyboard_top_button.dart +++ b/lib/ui/components/keyboard/keyboard_top_button.dart @@ -3,8 +3,8 @@ import 'package:flutter/material.dart'; import 'package:photos/theme/ente_theme.dart'; class KeyboardTopButton extends StatelessWidget { - final Function? onDoneTap; - final Function? onCancelTap; + final VoidCallback? onDoneTap; + final VoidCallback? onCancelTap; final String doneText; final String cancelText; @@ -36,16 +36,12 @@ class KeyboardTopButton extends StatelessWidget { children: [ CupertinoButton( padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 14), - onPressed: () { - onCancelTap?.call(); - }, + onPressed: onCancelTap, child: Text(cancelText, style: enteTheme.bodyBold), ), CupertinoButton( padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 14), - onPressed: () { - onDoneTap?.call(); - }, + onPressed: onDoneTap, child: Text(doneText, style: enteTheme.bodyBold), ), ], diff --git a/lib/ui/viewer/file/file_caption_widget.dart b/lib/ui/viewer/file/file_caption_widget.dart index 8022317df..47f7e4468 100644 --- a/lib/ui/viewer/file/file_caption_widget.dart +++ b/lib/ui/viewer/file/file_caption_widget.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:photos/core/constants.dart'; import 'package:photos/models/file.dart'; import 'package:photos/theme/ente_theme.dart'; +import 'package:photos/ui/components/keyboard/keybiard_oveylay.dart'; +import 'package:photos/ui/components/keyboard/keyboard_top_button.dart'; import 'package:photos/utils/magic_util.dart'; class FileCaptionWidget extends StatefulWidget { @@ -18,10 +20,12 @@ class _FileCaptionWidgetState extends State { // currentLength/maxLength will show up static const int counterThreshold = 1000; int currentLength = 0; + final _textController = TextEditingController(); final _focusNode = FocusNode(); String? editedCaption; String hintText = fileCaptionDefaultHint; + Widget? keyboardTopButtoms; @override void initState() { @@ -49,15 +53,7 @@ class _FileCaptionWidgetState extends State { final textTheme = getEnteTextTheme(context); return TextField( onSubmitted: (value) async { - if (editedCaption != null) { - final isSuccesful = - await editFileCaption(context, widget.file, editedCaption); - if (isSuccesful) { - if (mounted) { - Navigator.pop(context); - } - } - } + await _onDoneClick(context); }, controller: _textController, focusNode: _focusNode, @@ -94,7 +90,7 @@ class _FileCaptionWidgetState extends State { minLines: 1, maxLines: 10, textCapitalization: TextCapitalization.sentences, - keyboardType: TextInputType.text, + keyboardType: TextInputType.multiline, onChanged: (value) { setState(() { hintText = fileCaptionDefaultHint; @@ -105,11 +101,48 @@ class _FileCaptionWidgetState extends State { ); } + Future _onDoneClick(BuildContext context) async { + if (editedCaption != null) { + final isSuccesful = + await editFileCaption(context, widget.file, editedCaption); + if (isSuccesful) { + if (mounted) { + Navigator.pop(context); + } + } + } + } + + void onCancelTap() { + _focusNode.unfocus(); + if (widget.file.caption != null) { + _textController.text = widget.file.caption!; + } + editedCaption = null; + } + + void onDoneTap() { + _focusNode.unfocus(); + _onDoneClick(context); + } + void _focusNodeListener() { final caption = widget.file.caption; if (_focusNode.hasFocus && caption != null) { _textController.text = caption; editedCaption = caption; } + final bool hasFocus = _focusNode.hasFocus; + keyboardTopButtoms ??= KeyboardTopButton( + onDoneTap: onDoneTap, + onCancelTap: onCancelTap, + ); + if (hasFocus) { + KeyboardOverlay.showOverlay(context, keyboardTopButtoms!); + } else { + debugPrint("Removing listener"); + + KeyboardOverlay.removeOverlay(); + } } } From 606bd8155573b791658303f950f25392f14bbe09 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sun, 27 Nov 2022 10:02:00 +0530 Subject: [PATCH 10/10] minor fix --- lib/ui/viewer/file/file_caption_widget.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/ui/viewer/file/file_caption_widget.dart b/lib/ui/viewer/file/file_caption_widget.dart index 47f7e4468..915fff6fe 100644 --- a/lib/ui/viewer/file/file_caption_widget.dart +++ b/lib/ui/viewer/file/file_caption_widget.dart @@ -114,10 +114,8 @@ class _FileCaptionWidgetState extends State { } void onCancelTap() { + _textController.text = widget.file.caption ?? ''; _focusNode.unfocus(); - if (widget.file.caption != null) { - _textController.text = widget.file.caption!; - } editedCaption = null; }