Bladeren bron

Made a non functional version of TextInputWidget

ashilkn 2 jaren geleden
bovenliggende
commit
ba1d7bf2b0
3 gewijzigde bestanden met toevoegingen van 190 en 24 verwijderingen
  1. 123 0
      lib/ui/components/dialog_widget.dart
  2. 41 24
      lib/ui/viewer/gallery/gallery_app_bar_widget.dart
  3. 26 0
      lib/utils/dialog_util.dart

+ 123 - 0
lib/ui/components/dialog_widget.dart

@@ -151,3 +151,126 @@ class Actions extends StatelessWidget {
     );
     );
   }
   }
 }
 }
+
+class TextInputDialog extends StatelessWidget {
+  final String title;
+  final String? body;
+  final List<ButtonWidget> buttons;
+  final IconData? icon;
+  final String? label;
+  final String? message;
+  const TextInputDialog({
+    required this.title,
+    this.body,
+    required this.buttons,
+    this.icon,
+    this.label,
+    this.message,
+    super.key,
+  });
+
+  @override
+  Widget build(BuildContext context) {
+    final widthOfScreen = MediaQuery.of(context).size.width;
+    final isMobileSmall = widthOfScreen <= mobileSmallThreshold;
+    final colorScheme = getEnteColorScheme(context);
+    final textTheme = getEnteTextTheme(context);
+    var textInputChildren = <Widget>[];
+    if (label != null) textInputChildren.add(Text(label!));
+    textInputChildren.add(
+      ClipRRect(
+        borderRadius: const BorderRadius.all(Radius.circular(8)),
+        child: Material(
+          child: TextFormField(
+            decoration: InputDecoration(
+              hintText: "Placeholder",
+              hintStyle: textTheme.body.copyWith(color: colorScheme.textMuted),
+              filled: true,
+              contentPadding: const EdgeInsets.symmetric(
+                vertical: 11,
+                horizontal: 11,
+              ),
+              border: const UnderlineInputBorder(
+                borderSide: BorderSide.none,
+              ),
+              focusedBorder: OutlineInputBorder(
+                borderSide: BorderSide(color: colorScheme.strokeMuted),
+                borderRadius: BorderRadius.circular(8),
+              ),
+              prefixIconConstraints: const BoxConstraints(
+                maxHeight: 44,
+                maxWidth: 44,
+                minHeight: 44,
+                minWidth: 44,
+              ),
+              suffixIconConstraints: const BoxConstraints(
+                maxHeight: 44,
+                maxWidth: 44,
+                minHeight: 44,
+                minWidth: 44,
+              ),
+              prefixIcon: Icon(
+                Icons.search_outlined,
+                color: colorScheme.strokeMuted,
+              ),
+            ),
+          ),
+        ),
+      ),
+    );
+    if (message != null) {
+      textInputChildren.add(
+        Padding(
+          padding: const EdgeInsets.symmetric(horizontal: 8),
+          child: Text(
+            message!,
+            style: textTheme.small.copyWith(color: colorScheme.textMuted),
+          ),
+        ),
+      );
+    }
+    textInputChildren =
+        addSeparators(textInputChildren, const SizedBox(height: 4));
+    return Container(
+      width: min(widthOfScreen, 320),
+      padding: isMobileSmall
+          ? const EdgeInsets.all(0)
+          : const EdgeInsets.fromLTRB(6, 8, 6, 6),
+      decoration: BoxDecoration(
+        color: colorScheme.backgroundElevated,
+        boxShadow: shadowFloatLight,
+        borderRadius: const BorderRadius.all(Radius.circular(8)),
+      ),
+      child: Padding(
+        padding: const EdgeInsets.all(16),
+        child: Column(
+          mainAxisSize: MainAxisSize.min,
+          children: [
+            ContentContainer(
+              title: title,
+              body: body,
+              icon: icon,
+            ),
+            Padding(
+              padding: const EdgeInsets.only(top: 19),
+              child: Column(
+                mainAxisSize: MainAxisSize.min,
+                crossAxisAlignment: CrossAxisAlignment.start,
+                children: textInputChildren,
+              ),
+            ),
+            const SizedBox(height: 36),
+            Row(
+              mainAxisSize: MainAxisSize.min,
+              children: [
+                Expanded(child: buttons.first),
+                const SizedBox(width: 8),
+                Expanded(child: buttons.last),
+              ],
+            )
+          ],
+        ),
+      ),
+    );
+  }
+}

+ 41 - 24
lib/ui/viewer/gallery/gallery_app_bar_widget.dart

@@ -17,7 +17,7 @@ import 'package:photos/services/collections_service.dart';
 import 'package:photos/services/sync_service.dart';
 import 'package:photos/services/sync_service.dart';
 import 'package:photos/services/update_service.dart';
 import 'package:photos/services/update_service.dart';
 import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
 import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
-import 'package:photos/ui/common/rename_dialog.dart';
+// import 'package:photos/ui/common/rename_dialog.dart';
 import 'package:photos/ui/components/action_sheet_widget.dart';
 import 'package:photos/ui/components/action_sheet_widget.dart';
 import 'package:photos/ui/components/button_widget.dart';
 import 'package:photos/ui/components/button_widget.dart';
 import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/components/dialog_widget.dart';
@@ -111,31 +111,48 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
     if (widget.type != GalleryType.ownedCollection) {
     if (widget.type != GalleryType.ownedCollection) {
       return;
       return;
     }
     }
-    final result = await showDialog<String>(
-      context: context,
-      builder: (BuildContext context) {
-        return RenameDialog(_appBarTitle, 'Album');
-      },
-      barrierColor: Colors.black.withOpacity(0.85),
+    showTextInputDialog(
+      context,
+      title: "Title",
+      message: "Message",
+      buttons: const [
+        ButtonWidget(
+          buttonType: ButtonType.secondary,
+          buttonSize: ButtonSize.small,
+          labelText: "Cancel",
+        ),
+        ButtonWidget(
+          buttonSize: ButtonSize.small,
+          buttonType: ButtonType.neutral,
+          labelText: "Rename",
+        ),
+      ],
     );
     );
-    // indicates user cancelled the rename request
-    if (result == null || result.trim() == _appBarTitle!.trim()) {
-      return;
-    }
+    // final result = await showDialog<String>(
+    //   context: context,
+    //   builder: (BuildContext context) {
+    //     return RenameDialog(_appBarTitle, 'Album');
+    //   },
+    //   barrierColor: Colors.black.withOpacity(0.85),
+    // );
+    // // indicates user cancelled the rename request
+    // if (result == null || result.trim() == _appBarTitle!.trim()) {
+    //   return;
+    // }
 
 
-    final dialog = createProgressDialog(context, "Changing name...");
-    await dialog.show();
-    try {
-      await CollectionsService.instance.rename(widget.collection!, result);
-      await dialog.hide();
-      if (mounted) {
-        _appBarTitle = result;
-        setState(() {});
-      }
-    } catch (e) {
-      await dialog.hide();
-      showGenericErrorDialog(context: context);
-    }
+    // final dialog = createProgressDialog(context, "Changing name...");
+    // await dialog.show();
+    // try {
+    //   await CollectionsService.instance.rename(widget.collection!, result);
+    //   await dialog.hide();
+    //   if (mounted) {
+    //     _appBarTitle = result;
+    //     setState(() {});
+    //   }
+    // } catch (e) {
+    //   await dialog.hide();
+    //   showGenericErrorDialog(context: context);
+    // }
   }
   }
 
 
   Future<dynamic> _leaveAlbum(BuildContext context) async {
   Future<dynamic> _leaveAlbum(BuildContext context) async {

+ 26 - 0
lib/utils/dialog_util.dart

@@ -250,3 +250,29 @@ Future<ButtonAction?> showConfettiDialog<T>({
     routeSettings: routeSettings,
     routeSettings: routeSettings,
   );
   );
 }
 }
+
+showTextInputDialog(
+  BuildContext context, {
+  required String title,
+  String? body,
+  required List<ButtonWidget> buttons,
+  IconData? icon,
+  String? label,
+  String? message,
+}) {
+  return showDialog(
+    context: context,
+    builder: (context) {
+      return Center(
+        child: TextInputDialog(
+          title: title,
+          message: message,
+          label: label,
+          body: body,
+          icon: icon,
+          buttons: buttons,
+        ),
+      );
+    },
+  );
+}