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:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.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 '../stream_chat_flutter.dart';
import 'attachment_error.dart'; import 'attachment_error.dart';
import 'attachment_title.dart';
import 'full_screen_image.dart'; import 'full_screen_image.dart';
class GiphyAttachment extends StatelessWidget { class GiphyAttachment extends StatelessWidget {
@@ -58,9 +55,9 @@ class GiphyAttachment extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[ children: <Widget>[
Stack( Padding(
children: <Widget>[ padding: const EdgeInsets.all(8.0),
GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (_) { Navigator.push(context, MaterialPageRoute(builder: (_) {
return FullScreenImage( return FullScreenImage(
@@ -70,8 +67,6 @@ class GiphyAttachment extends StatelessWidget {
); );
})); }));
}, },
child: Padding(
padding: const EdgeInsets.all(8.0),
child: CachedNetworkImage( child: CachedNetworkImage(
height: size?.height, height: size?.height,
width: size?.width, width: size?.width,
@@ -106,7 +101,11 @@ class GiphyAttachment extends StatelessWidget {
)), )),
child: Padding( child: Padding(
padding: const EdgeInsets.only( 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( child: Row(
children: [ children: [
Icon( Icon(
@@ -127,8 +126,6 @@ class GiphyAttachment extends StatelessWidget {
), ),
), ),
), ),
],
),
if (attachment.title != null) if (attachment.title != null)
Container( Container(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
@@ -143,6 +140,7 @@ class GiphyAttachment extends StatelessWidget {
StreamIcons.left, StreamIcons.left,
size: 24.0, size: 24.0,
), ),
splashRadius: 24,
onPressed: () { onPressed: () {
streamChannel.channel.sendAction(message, { streamChannel.channel.sendAction(message, {
'image_action': 'shuffle', 'image_action': 'shuffle',
@@ -167,6 +165,7 @@ class GiphyAttachment extends StatelessWidget {
StreamIcons.right, StreamIcons.right,
size: 24.0, size: 24.0,
), ),
splashRadius: 24,
onPressed: () { onPressed: () {
streamChannel.channel.sendAction(message, { streamChannel.channel.sendAction(message, {
'image_action': 'shuffle', 'image_action': 'shuffle',
@@ -188,24 +187,23 @@ class GiphyAttachment extends StatelessWidget {
height: 0.5, height: 0.5,
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
FlatButton( Expanded(
child: FlatButton(
height: 50,
onPressed: () { onPressed: () {
streamChannel.channel.sendAction(message, { streamChannel.channel.sendAction(message, {
'image_action': 'cancel', 'image_action': 'cancel',
}); });
}, },
child: Row( child: Text(
children: [
Text(
'Cancel', 'Cancel',
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Colors.black.withOpacity(0.5)), color: Colors.black.withOpacity(0.5)),
), ),
],
), ),
), ),
Container( Container(
@@ -213,21 +211,20 @@ class GiphyAttachment extends StatelessWidget {
color: Colors.black.withOpacity(0.2), color: Colors.black.withOpacity(0.2),
height: 50.0, height: 50.0,
), ),
FlatButton( Expanded(
child: FlatButton(
height: 50,
onPressed: () { onPressed: () {
streamChannel.channel.sendAction(message, { streamChannel.channel.sendAction(message, {
'image_action': 'send', 'image_action': 'send',
}); });
}, },
child: Row( child: Text(
children: [
Text(
'Send', 'Send',
style: TextStyle( style: TextStyle(
color: StreamChatTheme.of(context).accentColor, color: StreamChatTheme.of(context).accentColor,
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
), ),
],
), ),
), ),
], ],
@@ -282,6 +279,16 @@ class GiphyAttachment extends StatelessWidget {
), ),
), ),
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
child: GestureDetector(
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (_) {
return FullScreenImage(
url: attachment.imageUrl ??
attachment.assetUrl ??
attachment.thumbUrl,
);
}));
},
child: CachedNetworkImage( child: CachedNetworkImage(
height: size?.height, height: size?.height,
width: size?.width, width: size?.width,
@@ -304,6 +311,7 @@ class GiphyAttachment extends StatelessWidget {
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
), ),
),
Padding( Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0), padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Row( child: Row(
+2 -1
View File
@@ -335,7 +335,7 @@ class MessageInputState extends State<MessageInput> {
setState(() { setState(() {
_commandEnabled = true; _commandEnabled = true;
}); });
_commandsOverlay.remove(); _commandsOverlay?.remove();
_commandsOverlay = null; _commandsOverlay = null;
} else { } else {
_commandsOverlay = _buildCommandsOverlayEntry(); _commandsOverlay = _buildCommandsOverlayEntry();
@@ -344,6 +344,7 @@ class MessageInputState extends State<MessageInput> {
} }
if (textEditingController.selection.isCollapsed && if (textEditingController.selection.isCollapsed &&
s.isNotEmpty &&
(s[textEditingController.selection.start - 1] == '@' || (s[textEditingController.selection.start - 1] == '@' ||
textEditingController.text textEditingController.text
.substring( .substring(