Quellcode durchsuchen

Fix caption hint

Neeraj Gupta vor 2 Jahren
Ursprung
Commit
803d0829d8
1 geänderte Dateien mit 6 neuen und 4 gelöschten Zeilen
  1. 6 4
      lib/ui/viewer/file/file_caption_widget.dart

+ 6 - 4
lib/ui/viewer/file/file_caption_widget.dart

@@ -17,6 +17,7 @@ class _FileCaptionWidgetState extends State<FileCaptionWidget> {
   final _textController = TextEditingController();
   final _textController = TextEditingController();
   final _focusNode = FocusNode();
   final _focusNode = FocusNode();
   String? editedCaption;
   String? editedCaption;
+  String? hintText = "Add a description...";
 
 
   @override
   @override
   void initState() {
   void initState() {
@@ -28,6 +29,9 @@ class _FileCaptionWidgetState extends State<FileCaptionWidget> {
       }
       }
     });
     });
     editedCaption = widget.file.caption;
     editedCaption = widget.file.caption;
+    if (editedCaption != null && editedCaption!.isNotEmpty) {
+      hintText = editedCaption;
+    }
     super.initState();
     super.initState();
   }
   }
 
 
@@ -45,7 +49,6 @@ class _FileCaptionWidgetState extends State<FileCaptionWidget> {
   Widget build(BuildContext context) {
   Widget build(BuildContext context) {
     final colorScheme = getEnteColorScheme(context);
     final colorScheme = getEnteColorScheme(context);
     final textTheme = getEnteTextTheme(context);
     final textTheme = getEnteTextTheme(context);
-    final caption = widget.file.caption;
     return TextField(
     return TextField(
       onEditingComplete: () async {
       onEditingComplete: () async {
         if (editedCaption != null) {
         if (editedCaption != null) {
@@ -68,9 +71,7 @@ class _FileCaptionWidgetState extends State<FileCaptionWidget> {
         focusedBorder: InputBorder.none,
         focusedBorder: InputBorder.none,
         filled: true,
         filled: true,
         fillColor: colorScheme.fillFaint,
         fillColor: colorScheme.fillFaint,
-        hintText: caption == null || caption.isEmpty
-            ? "Add a description..."
-            : caption,
+        hintText: hintText,
         hintStyle: getEnteTextTheme(context)
         hintStyle: getEnteTextTheme(context)
             .small
             .small
             .copyWith(color: colorScheme.textMuted),
             .copyWith(color: colorScheme.textMuted),
@@ -83,6 +84,7 @@ class _FileCaptionWidgetState extends State<FileCaptionWidget> {
       keyboardType: TextInputType.text,
       keyboardType: TextInputType.text,
       onChanged: (value) {
       onChanged: (value) {
         setState(() {
         setState(() {
+          hintText = "Add a description...";
           currentLength = value.length;
           currentLength = value.length;
           editedCaption = value;
           editedCaption = value;
         });
         });