Commit f12e317

derdilla <82763757+NobodyForNothing@users.noreply.github.com>
2023-11-05 13:24:01
add InputListTile to restore csv export settings
Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com>
1 parent 80ecab9
Changed files (3)
lib
lib/components/dialoges/input_dialoge.dart
@@ -6,6 +6,8 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
 class InputDialoge extends StatefulWidget {
   final String hintText;
   final String? initialValue;
+
+  /// Gets called when the user submits the text field or presses the submit button.
   final void Function(String text) onSubmit;
   final List<TextInputFormatter>? inputFormatters;
   final TextInputType? keyboardType;
lib/components/settings_widgets.dart
@@ -252,7 +252,49 @@ class NumberInputListTile extends StatelessWidget {
       },
     );
   }
-  
+}
+
+/// A list tile for exposing editable strings.
+class InputListTile extends StatelessWidget {
+  /// Creates a list tile that allows editing a string
+  const InputListTile({super.key,
+    required this.label,
+    required this.initialValue,
+    required this.onSubmit});
+
+  /// Short label describing the required field contents.
+  ///
+  /// This will be both the title of the list tile as well as the hint text in the input dialoge.
+  final String label;
+
+  /// Initial content of the input field.
+  final String initialValue;
+
+  /// Gets called when the user submits a new value
+  final void Function(String text) onSubmit;
+
+  @override
+  Widget build(BuildContext context) {
+    return ListTile(
+      title: Text(label),
+      subtitle: Text(initialValue.toString()),
+      trailing: const Icon(Icons.edit),
+      onTap: () {
+        showDialog(
+          context: context,
+          builder: (context) => InputDialoge(
+            initialValue: initialValue,
+            hintText: label,
+            onSubmit: (value) {
+              Navigator.of(context).pop();
+              onSubmit(value);
+            },
+          ),
+        );
+      },
+    );
+  }
+
 }
 
 /// A ListTile that allows choosing from a dropdown.
lib/screens/subsettings/export_import_screen.dart
@@ -78,27 +78,20 @@ class ExportImportScreen extends StatelessWidget {
                 Consumer<CsvExportSettings>(builder: (context, csvExportSettings, child) =>
                   Column(
                     children: [
-                      /* TODO
-                      NumberInputSettingsTile(
+                      InputListTile(
                         label: localizations.fieldDelimiter,
                         initialValue: csvExportSettings.fieldDelimiter,
-                        onEditingComplete: (value) {
-                          if (value != null) {
-                            csvExportSettings.fieldDelimiter = value;
-                          }
+                        onSubmit: (value) {
+                          csvExportSettings.fieldDelimiter = value;
                         },
                       ),
-                      NumberInputSettingsTile(
-                        label: Text(localizations.textDelimiter),
-                        inputWidth: 40,
+                      InputListTile(
+                        label: localizations.textDelimiter,
                         initialValue: csvExportSettings.textDelimiter,
-                        onEditingComplete: (value) {
-                          if (value != null) {
-                            csvExportSettings.textDelimiter = value;
-                          }
+                        onSubmit: (value) {
+                          csvExportSettings.textDelimiter = value;
                         },
                       ),
-                       */
                       SwitchListTile(
                         title: Text(localizations.exportCsvHeadline),
                         subtitle: Text(localizations.exportCsvHeadlineDesc),