Skip to content

armgit / ente

Public Imported from GitHub
0

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

[auth] fix Copied to Clipboard text behind clipboard

eYdr1en92a03ce58555
diff --git a/mobile/apps/auth/lib/utils/toast_util.dart b/mobile/apps/auth/lib/utils/toast_util.dart
index 942274bc85..8d53d42723 100644
--- a/mobile/apps/auth/lib/utils/toast_util.dart
+++ b/mobile/apps/auth/lib/utils/toast_util.dart
@@ -1,4 +1,5 @@
import 'package:ente_auth/ente_theme_data.dart';
+import 'package:ente_auth/utils/platform_util.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';
@@ -9,6 +10,58 @@ void showToast(
toastLength = Toast.LENGTH_LONG,
iOSDismissOnTap = true,
}) async {
+ // If on mobile and keyboard is visible, render toast above the keyboard using FToast.
+ final bool isMobile = PlatformUtil.isMobile();
+
+ if (isMobile) {
+ final baseToast = Container(
+ padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(25.0),
+ color: Theme.of(context).colorScheme.toastBackgroundColor,
+ ),
+ child: Text(
+ message,
+ textAlign: TextAlign.center,
+ style: TextStyle(
+ color: Theme.of(context).colorScheme.toastTextColor,
+ fontSize: 16.0,
+ ),
+ ),
+ );
+
+ final fToast = FToast()..init(context);
+
+ Widget toastChild = baseToast;
+ if (iOSDismissOnTap == true) {
+ toastChild = GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () {
+ fToast.removeCustomToast();
+ fToast.removeQueuedCustomToasts();
+ },
+ child: baseToast,
+ );
+ }
+
+ fToast.showToast(
+ child: toastChild,
+ gravity: ToastGravity.BOTTOM,
+ toastDuration: const Duration(seconds: 2),
+ positionedToastBuilder: (context, child) {
+ final double currentInset = MediaQuery.of(context).viewInsets.bottom;
+ return Positioned(
+ left: 16,
+ right: 16,
+ bottom: currentInset + 16,
+ child: child,
+ );
+ },
+ );
+ return;
+ }
+
+ // Default path (Android, desktop, or when keyboard isn't visible)
try {
await Fluttertoast.cancel();
await Fluttertoast.showToast(
@@ -21,7 +74,8 @@ void showToast(
fontSize: 16.0,
);
} on MissingPluginException catch (_) {
- Widget toast = Container(
+ final fToast = FToast()..init(context);
+ final Widget baseToast = Container(
padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25.0),
@@ -36,11 +90,8 @@ void showToast(
),
);
- final fToast = FToast();
- fToast.init(context);
-
fToast.showToast(
- child: toast,
+ child: baseToast,
gravity: ToastGravity.BOTTOM,
toastDuration: const Duration(seconds: 2),
);