Move copy message snackbar to top of view
On Android 13 or newer there is an operating system integrated message bubble that pops up and shows you any automated clipboard changes at the bottom left of the screen. This bubble obscures the message text of the snackbar so I've moved it to the top of the screen when on Android. It might make sense to do more accurate version checking in the future to only show the snackbar if on Android < 13 or iOS but we'd need to pull in the device_info_plus package or similar for that.
This commit is contained in:
parent
44e94555f2
commit
e97e0a52af
1 changed files with 20 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:recon/models/message.dart';
|
||||
|
@ -17,7 +19,24 @@ class MessageText extends StatelessWidget {
|
|||
onLongPress: () async {
|
||||
await Clipboard.setData(ClipboardData(text: message.content));
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text("Copied to clipboard")));
|
||||
const content = Text("Copied to clipboard");
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
Platform.isIOS
|
||||
? const SnackBar(content: content)
|
||||
: SnackBar(
|
||||
content: content,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
dismissDirection: DismissDirection.none,
|
||||
margin: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).size.height - 170,
|
||||
right: 20,
|
||||
left: 20,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Column(
|
||||
|
|
Loading…
Reference in a new issue