Skip to content

armgit / ente

Public Imported from GitHub
0

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

[locker] Preselect the file name when renaming a scan

laurenspriem5e9649893d2d
diff --git a/mobile/apps/locker/lib/ui/components/text_input_sheet.dart b/mobile/apps/locker/lib/ui/components/text_input_sheet.dart
index a7b15ba466..3da04ca851 100644
--- a/mobile/apps/locker/lib/ui/components/text_input_sheet.dart
+++ b/mobile/apps/locker/lib/ui/components/text_input_sheet.dart
@@ -12,11 +12,23 @@ Future<dynamic> showTextInputSheet(
TextCapitalization textCapitalization = TextCapitalization.words,
int? maxLength,
bool isPasswordInput = false,
-}) {
+ bool selectInitialValue = false,
+}) async {
var currentText = initialValue ?? '';
var isSubmitting = false;
final canSubmit = ValueNotifier<bool>(currentText.trim().isNotEmpty);
+ final controller = selectInitialValue
+ ? TextEditingController.fromValue(
+ TextEditingValue(
+ text: currentText,
+ selection: TextSelection(
+ baseOffset: 0,
+ extentOffset: currentText.length,
+ ),
+ ),
+ )
+ : null;
Future<void> submit(BuildContext sheetContext, String value) async {
final text = isPasswordInput ? value : value.trim();
@@ -39,13 +51,14 @@ Future<dynamic> showTextInputSheet(
}
}
- return showBottomSheetComponent<dynamic>(
+ final result = await showBottomSheetComponent<dynamic>(
context: context,
builder: (sheetContext) => BottomSheetComponent(
title: title,
isKeyboardAware: true,
content: TextInputComponent(
- initialValue: initialValue,
+ controller: controller,
+ initialValue: controller == null ? initialValue : null,
hintText: hintText,
autofocus: true,
maxLength: maxLength,
@@ -68,4 +81,6 @@ Future<dynamic> showTextInputSheet(
],
),
);
+ controller?.dispose();
+ return result;
}
diff --git a/mobile/apps/locker/lib/ui/pages/scanner/scanner_review_page.dart b/mobile/apps/locker/lib/ui/pages/scanner/scanner_review_page.dart
index 08efe01b45..96ab3a52b1 100644
--- a/mobile/apps/locker/lib/ui/pages/scanner/scanner_review_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/scanner/scanner_review_page.dart
@@ -190,6 +190,7 @@ class _ScannerReviewPageState extends State<ScannerReviewPage>
context,
title: l10n.renameFile,
initialValue: base,
+ selectInitialValue: true,
hintText: l10n.enterFileName,
submitButtonLabel: l10n.save,
onSubmit: (String name) async => widget.session.renameFile(name),