fix button inkwells

This commit is contained in:
Salvatore Giordano
2020-11-05 10:42:13 +01:00
parent 70e7a8dc83
commit af836d9711
3 changed files with 129 additions and 173 deletions
-53
View File
@@ -1,53 +0,0 @@
import 'package:flutter/material.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
class AttachmentActions extends StatelessWidget {
final Attachment attachment;
final Message message;
const AttachmentActions({
Key key,
this.attachment,
this.message,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final streamChannel = StreamChannel.of(context);
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.min,
children: attachment.actions?.map((action) {
if (action.style == 'primary') {
return FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
child: Text('${action.text}'),
color: action.style == 'primary'
? StreamChatTheme.of(context).accentColor
: null,
textColor: Colors.white,
onPressed: () {
streamChannel.channel.sendAction(message, {
action.name: action.value,
});
},
);
}
return OutlineButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
child: Text('${action.text}'),
color: StreamChatTheme.of(context).accentColor,
onPressed: () {
streamChannel.channel.sendAction(message, {
action.name: action.value,
});
},
);
})?.toList(),
);
}
}
+31 -23
View File
@@ -1,12 +1,9 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:jiffy/jiffy.dart';
import 'package:stream_chat_flutter/src/attachment_actions.dart';
import '../stream_chat_flutter.dart';
import 'attachment_error.dart';
import 'attachment_title.dart';
import 'full_screen_image.dart';
class GiphyAttachment extends StatelessWidget {
@@ -58,9 +55,9 @@ class GiphyAttachment extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Stack(
children: <Widget>[
GestureDetector(
Padding(
padding: const EdgeInsets.all(8.0),
child: GestureDetector(
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (_) {
return FullScreenImage(
@@ -70,8 +67,6 @@ class GiphyAttachment extends StatelessWidget {
);
}));
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: CachedNetworkImage(
height: size?.height,
width: size?.width,
@@ -106,7 +101,11 @@ class GiphyAttachment extends StatelessWidget {
)),
child: Padding(
padding: const EdgeInsets.only(
left: 4.0, right: 4.0, top: 6.0, bottom: 2.0),
left: 8.0,
right: 8.0,
top: 8.0,
bottom: 4.0,
),
child: Row(
children: [
Icon(
@@ -127,8 +126,6 @@ class GiphyAttachment extends StatelessWidget {
),
),
),
],
),
if (attachment.title != null)
Container(
alignment: Alignment.bottomCenter,
@@ -143,6 +140,7 @@ class GiphyAttachment extends StatelessWidget {
StreamIcons.left,
size: 24.0,
),
splashRadius: 24,
onPressed: () {
streamChannel.channel.sendAction(message, {
'image_action': 'shuffle',
@@ -167,6 +165,7 @@ class GiphyAttachment extends StatelessWidget {
StreamIcons.right,
size: 24.0,
),
splashRadius: 24,
onPressed: () {
streamChannel.channel.sendAction(message, {
'image_action': 'shuffle',
@@ -188,24 +187,23 @@ class GiphyAttachment extends StatelessWidget {
height: 0.5,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
FlatButton(
Expanded(
child: FlatButton(
height: 50,
onPressed: () {
streamChannel.channel.sendAction(message, {
'image_action': 'cancel',
});
},
child: Row(
children: [
Text(
child: Text(
'Cancel',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black.withOpacity(0.5)),
),
],
),
),
Container(
@@ -213,21 +211,20 @@ class GiphyAttachment extends StatelessWidget {
color: Colors.black.withOpacity(0.2),
height: 50.0,
),
FlatButton(
Expanded(
child: FlatButton(
height: 50,
onPressed: () {
streamChannel.channel.sendAction(message, {
'image_action': 'send',
});
},
child: Row(
children: [
Text(
child: Text(
'Send',
style: TextStyle(
color: StreamChatTheme.of(context).accentColor,
fontWeight: FontWeight.bold),
),
],
),
),
],
@@ -282,6 +279,16 @@ class GiphyAttachment extends StatelessWidget {
),
),
clipBehavior: Clip.antiAlias,
child: GestureDetector(
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (_) {
return FullScreenImage(
url: attachment.imageUrl ??
attachment.assetUrl ??
attachment.thumbUrl,
);
}));
},
child: CachedNetworkImage(
height: size?.height,
width: size?.width,
@@ -304,6 +311,7 @@ class GiphyAttachment extends StatelessWidget {
fit: BoxFit.cover,
),
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Row(
+2 -1
View File
@@ -335,7 +335,7 @@ class MessageInputState extends State<MessageInput> {
setState(() {
_commandEnabled = true;
});
_commandsOverlay.remove();
_commandsOverlay?.remove();
_commandsOverlay = null;
} else {
_commandsOverlay = _buildCommandsOverlayEntry();
@@ -344,6 +344,7 @@ class MessageInputState extends State<MessageInput> {
}
if (textEditingController.selection.isCollapsed &&
s.isNotEmpty &&
(s[textEditingController.selection.start - 1] == '@' ||
textEditingController.text
.substring(