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(),
);
}
}
+127 -119
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,76 +55,76 @@ 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(
url: attachment.imageUrl ?? url: attachment.imageUrl ??
attachment.assetUrl ?? attachment.assetUrl ??
attachment.thumbUrl, attachment.thumbUrl,
); );
})); }));
}, },
child: Padding( child: CachedNetworkImage(
padding: const EdgeInsets.all(8.0), height: size?.height,
child: CachedNetworkImage( width: size?.width,
height: size?.height, placeholder: (_, __) {
return Container(
width: size?.width, width: size?.width,
placeholder: (_, __) { height: size?.height,
return Container( child: Center(
width: size?.width, child: CircularProgressIndicator(),
height: size?.height,
child: Center(
child: CircularProgressIndicator(),
),
);
},
imageUrl: attachment.thumbUrl ??
attachment.imageUrl ??
attachment.assetUrl,
errorWidget: (context, url, error) => AttachmentError(
attachment: attachment,
size: size,
), ),
fit: BoxFit.cover, );
), },
imageUrl: attachment.thumbUrl ??
attachment.imageUrl ??
attachment.assetUrl,
errorWidget: (context, url, error) => AttachmentError(
attachment: attachment,
size: size,
),
fit: BoxFit.cover,
),
),
),
Positioned(
left: 0,
top: 0,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(16.0),
)),
child: Padding(
padding: const EdgeInsets.only(
left: 8.0,
right: 8.0,
top: 8.0,
bottom: 4.0,
),
child: Row(
children: [
Icon(
StreamIcons.lightning,
color: StreamChatTheme.of(context).accentColor,
size: 16.0,
),
Text(
'GIPHY',
style: TextStyle(
color: StreamChatTheme.of(context).accentColor,
fontWeight: FontWeight.bold,
fontSize: 11.0,
),
),
],
), ),
), ),
Positioned( ),
left: 0,
top: 0,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(16.0),
)),
child: Padding(
padding: const EdgeInsets.only(
left: 4.0, right: 4.0, top: 6.0, bottom: 2.0),
child: Row(
children: [
Icon(
StreamIcons.lightning,
color: StreamChatTheme.of(context).accentColor,
size: 16.0,
),
Text(
'GIPHY',
style: TextStyle(
color: StreamChatTheme.of(context).accentColor,
fontWeight: FontWeight.bold,
fontSize: 11.0,
),
),
],
),
),
),
),
],
), ),
if (attachment.title != null) if (attachment.title != null)
Container( Container(
@@ -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(
onPressed: () { child: FlatButton(
streamChannel.channel.sendAction(message, { height: 50,
'image_action': 'cancel', onPressed: () {
}); streamChannel.channel.sendAction(message, {
}, 'image_action': 'cancel',
child: Row( });
children: [ },
Text( child: 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(
onPressed: () { child: FlatButton(
streamChannel.channel.sendAction(message, { height: 50,
'image_action': 'send', onPressed: () {
}); streamChannel.channel.sendAction(message, {
}, 'image_action': 'send',
child: Row( });
children: [ },
Text( child: Text(
'Send', 'Send',
style: TextStyle( style: TextStyle(
color: StreamChatTheme.of(context).accentColor, color: StreamChatTheme.of(context).accentColor,
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
), ),
],
), ),
), ),
], ],
@@ -282,26 +279,37 @@ class GiphyAttachment extends StatelessWidget {
), ),
), ),
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
child: CachedNetworkImage( child: GestureDetector(
height: size?.height, onTap: () {
width: size?.width, Navigator.push(context, MaterialPageRoute(builder: (_) {
placeholder: (_, __) { return FullScreenImage(
return Container( url: attachment.imageUrl ??
width: size?.width, attachment.assetUrl ??
height: size?.height, attachment.thumbUrl,
child: Center( );
child: CircularProgressIndicator(), }));
),
);
}, },
imageUrl: attachment.thumbUrl ?? child: CachedNetworkImage(
attachment.imageUrl ?? height: size?.height,
attachment.assetUrl, width: size?.width,
errorWidget: (context, url, error) => AttachmentError( placeholder: (_, __) {
attachment: attachment, return Container(
size: size, width: size?.width,
height: size?.height,
child: Center(
child: CircularProgressIndicator(),
),
);
},
imageUrl: attachment.thumbUrl ??
attachment.imageUrl ??
attachment.assetUrl,
errorWidget: (context, url, error) => AttachmentError(
attachment: attachment,
size: size,
),
fit: BoxFit.cover,
), ),
fit: BoxFit.cover,
), ),
), ),
Padding( Padding(
+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(