Преглед изворни кода

Add basic widgets for buttons on top of keyboard

Neeraj Gupta пре 2 година
родитељ
комит
b918039c7c

+ 32 - 0
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;
+    }
+  }
+}

+ 56 - 0
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),
+            ),
+          ],
+        ),
+      ),
+    );
+  }
+}