Merge pull request #224 from GetStream/doc-fixes-2.3

Doc fixes 2.3
This commit is contained in:
Salvatore Giordano
2021-01-20 13:00:24 +01:00
committed by GitHub
11 changed files with 114 additions and 71 deletions
@@ -382,7 +382,7 @@ class _ChatInfoScreenState extends State<ChatInfoScreen> {
child: Container( child: Container(
padding: const EdgeInsets.symmetric(horizontal: 8.0), padding: const EdgeInsets.symmetric(horizontal: 8.0),
constraints: BoxConstraints.tightFor( constraints: BoxConstraints.tightFor(
width: 28, width: 24,
height: 12, height: 12,
), ),
child: Material( child: Material(
@@ -393,6 +393,10 @@ class _ChatInfoScreenState extends State<ChatInfoScreen> {
color: StreamChatTheme.of(context).colorTheme.white, color: StreamChatTheme.of(context).colorTheme.white,
), ),
alternativeWidget, alternativeWidget,
if (widget.user.online)
SizedBox(
width: 24.0,
),
], ],
); );
} }
@@ -939,28 +939,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
} }
} }
return Row( return alternativeWidget;
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (user.online)
Material(
type: MaterialType.circle,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
constraints: BoxConstraints.tightFor(
width: 28,
height: 12,
),
child: Material(
shape: CircleBorder(),
color: Color(0xff20E070),
),
),
color: StreamChatTheme.of(context).colorTheme.white,
),
alternativeWidget,
],
);
} }
Widget _buildModalListTile( Widget _buildModalListTile(
@@ -10,6 +10,8 @@ import 'stream_channel.dart';
import '../stream_chat_flutter.dart'; import '../stream_chat_flutter.dart';
enum ReturnActionType { none, reply }
typedef ShowMessageCallback = void Function(Message message, Channel channel); typedef ShowMessageCallback = void Function(Message message, Channel channel);
/// A full screen image widget /// A full screen image widget
@@ -13,6 +13,7 @@ class GiphyAttachment extends StatelessWidget {
final Message message; final Message message;
final Size size; final Size size;
final ShowMessageCallback onShowMessage; final ShowMessageCallback onShowMessage;
final ValueChanged<ReturnActionType> onReturnAction;
const GiphyAttachment({ const GiphyAttachment({
Key key, Key key,
@@ -21,6 +22,7 @@ class GiphyAttachment extends StatelessWidget {
this.message, this.message,
this.size, this.size,
this.onShowMessage, this.onShowMessage,
this.onReturnAction,
}) : super(key: key); }) : super(key: key);
@override @override
@@ -65,23 +67,8 @@ class GiphyAttachment extends StatelessWidget {
Padding( Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () async {
Navigator.push(context, MaterialPageRoute(builder: (_) { _onImageTap(context);
final channel = StreamChannel.of(context).channel;
return StreamChannel(
channel: channel,
child: FullScreenMedia(
mediaAttachments: [
attachment,
],
userName: message.user.name,
sentAt: message.createdAt,
message: message,
onShowMessage: onShowMessage,
),
);
}));
}, },
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
@@ -317,11 +304,37 @@ class GiphyAttachment extends StatelessWidget {
); );
} }
void _onImageTap(BuildContext context) async {
var res = await Navigator.push(context, MaterialPageRoute(
builder: (_) {
final channel = StreamChannel.of(context).channel;
return StreamChannel(
channel: channel,
child: FullScreenMedia(
mediaAttachments: [
attachment,
],
userName: message.user.name,
sentAt: message.createdAt,
message: message,
onShowMessage: onShowMessage,
),
);
},
));
if (res != null) {
onReturnAction(res);
}
}
Widget _buildSentAttachment(context) { Widget _buildSentAttachment(context) {
return Container( return Container(
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () async {
Navigator.push(context, MaterialPageRoute(builder: (_) { var res =
await Navigator.push(context, MaterialPageRoute(builder: (_) {
var channel = StreamChannel.of(context).channel; var channel = StreamChannel.of(context).channel;
return StreamChannel( return StreamChannel(
@@ -337,6 +350,10 @@ class GiphyAttachment extends StatelessWidget {
), ),
); );
})); }));
if (res != null) {
onReturnAction(res);
}
}, },
child: Stack( child: Stack(
children: [ children: [
@@ -60,7 +60,9 @@ class ImageActionsModal extends StatelessWidget {
size: 24.0, size: 24.0,
color: StreamChatTheme.of(context).colorTheme.grey, color: StreamChatTheme.of(context).colorTheme.grey,
), ),
() {}, () {
Navigator.pop(context, ReturnActionType.reply);
},
), ),
_buildButton( _buildButton(
context, context,
@@ -83,12 +85,12 @@ class ImageActionsModal extends StatelessWidget {
urls[currentIndex].assetUrl ?? urls[currentIndex].assetUrl ??
urls[currentIndex].thumbUrl; urls[currentIndex].thumbUrl;
Navigator.pop(context);
if (urls[currentIndex].type == 'video') { if (urls[currentIndex].type == 'video') {
await _saveVideo(url); await _saveVideo(url);
Navigator.pop(context);
} else { } else {
await _saveImage(url); await _saveImage(url);
Navigator.pop(context);
} }
}, },
), ),
@@ -14,6 +14,7 @@ class ImageAttachment extends StatelessWidget {
final Size size; final Size size;
final bool showTitle; final bool showTitle;
final ShowMessageCallback onShowMessage; final ShowMessageCallback onShowMessage;
final ValueChanged<ReturnActionType> onReturnAction;
const ImageAttachment({ const ImageAttachment({
Key key, Key key,
@@ -23,6 +24,7 @@ class ImageAttachment extends StatelessWidget {
this.messageTheme, this.messageTheme,
this.showTitle = true, this.showTitle = true,
this.onShowMessage, this.onShowMessage,
this.onReturnAction,
}) : super(key: key); }) : super(key: key);
@override @override
@@ -42,8 +44,8 @@ class ImageAttachment extends StatelessWidget {
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () async {
Navigator.push( var result = await Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (_) { builder: (_) {
@@ -64,6 +66,10 @@ class ImageAttachment extends StatelessWidget {
}, },
), ),
); );
if (result != null) {
onReturnAction(result);
}
}, },
child: CachedNetworkImage( child: CachedNetworkImage(
height: size?.height, height: size?.height,
@@ -272,10 +272,7 @@ class _ImageFooterState extends State<ImageFooter> {
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
color: StreamChatTheme.of(context) color: Colors.white.withOpacity(0.6),
.colorTheme
.white
.withOpacity(0.6),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
blurRadius: 8.0, blurRadius: 8.0,
@@ -286,7 +283,7 @@ class _ImageFooterState extends State<ImageFooter> {
), ),
], ],
), ),
padding: const EdgeInsets.all(1), padding: const EdgeInsets.all(2),
child: UserAvatar( child: UserAvatar(
user: widget.message.user, user: widget.message.user,
constraints: constraints:
@@ -101,24 +101,29 @@ class ImageHeader extends StatelessWidget implements PreferredSizeWidget {
@override @override
final Size preferredSize; final Size preferredSize;
void _showMessageActionModalBottomSheet(BuildContext context) { void _showMessageActionModalBottomSheet(BuildContext context) async {
final channel = StreamChannel.of(context).channel; final channel = StreamChannel.of(context).channel;
showDialog( var result = await showDialog(
context: context, context: context,
barrierColor: StreamChatTheme.of(context).colorTheme.overlay, barrierColor: StreamChatTheme.of(context).colorTheme.overlay,
builder: (context) { builder: (context) {
return StreamChannel( return StreamChannel(
channel: channel, channel: channel,
child: ImageActionsModal( child: ImageActionsModal(
userName: userName, userName: userName,
sentAt: sentAt, sentAt: sentAt,
message: message, message: message,
urls: urls, urls: urls,
currentIndex: currentIndex, currentIndex: currentIndex,
onShowMessage: onShowMessage, onShowMessage: onShowMessage,
), ),
); );
}); },
);
if (result != null) {
Navigator.pop(context, result);
}
} }
} }
@@ -780,6 +780,16 @@ class _MessageListViewState extends State<MessageListView> {
? StreamChatTheme.of(context).ownMessageTheme ? StreamChatTheme.of(context).ownMessageTheme
: StreamChatTheme.of(context).otherMessageTheme, : StreamChatTheme.of(context).otherMessageTheme,
onShowMessage: widget.onShowMessage, onShowMessage: widget.onShowMessage,
onReturnAction: (action) {
switch (action) {
case ReturnActionType.none:
break;
case ReturnActionType.reply:
FocusScope.of(context).unfocus();
widget.onMessageSwiped(message);
break;
}
},
); );
} }
@@ -930,6 +940,16 @@ class _MessageListViewState extends State<MessageListView> {
readList: readList, readList: readList,
allRead: allRead, allRead: allRead,
onShowMessage: widget.onShowMessage, onShowMessage: widget.onShowMessage,
onReturnAction: (action) {
switch (action) {
case ReturnActionType.none:
break;
case ReturnActionType.reply:
FocusScope.of(context).unfocus();
widget.onMessageSwiped(message);
break;
}
},
); );
if (!message.isDeleted && !message.isSystem && !message.isEphemeral) { if (!message.isDeleted && !message.isSystem && !message.isEphemeral) {
@@ -120,6 +120,7 @@ class MessageWidget extends StatefulWidget {
final List<Read> readList; final List<Read> readList;
final ShowMessageCallback onShowMessage; final ShowMessageCallback onShowMessage;
final ValueChanged<ReturnActionType> onReturnAction;
/// If true show the users username next to the timestamp of the message /// If true show the users username next to the timestamp of the message
final bool showUsername; final bool showUsername;
@@ -178,6 +179,7 @@ class MessageWidget extends StatefulWidget {
this.onShowMessage, this.onShowMessage,
this.editMessageInputBuilder, this.editMessageInputBuilder,
this.textBuilder, this.textBuilder,
this.onReturnAction,
Map<String, AttachmentBuilder> customAttachmentBuilders, Map<String, AttachmentBuilder> customAttachmentBuilders,
this.readList, this.readList,
this.padding, this.padding,
@@ -199,6 +201,7 @@ class MessageWidget extends StatefulWidget {
MediaQuery.of(context).size.height * 0.3, MediaQuery.of(context).size.height * 0.3,
), ),
onShowMessage: onShowMessage, onShowMessage: onShowMessage,
onReturnAction: onReturnAction,
); );
}, },
'video': (context, message, attachment) { 'video': (context, message, attachment) {
@@ -211,6 +214,7 @@ class MessageWidget extends StatefulWidget {
), ),
message: message, message: message,
onShowMessage: onShowMessage, onShowMessage: onShowMessage,
onReturnAction: onReturnAction,
); );
}, },
'giphy': (context, message, attachment) { 'giphy': (context, message, attachment) {
@@ -223,6 +227,7 @@ class MessageWidget extends StatefulWidget {
MediaQuery.of(context).size.height * 0.3, MediaQuery.of(context).size.height * 0.3,
), ),
onShowMessage: onShowMessage, onShowMessage: onShowMessage,
onReturnAction: onReturnAction,
); );
}, },
'file': (context, message, attachment) { 'file': (context, message, attachment) {
@@ -15,6 +15,7 @@ class VideoAttachment extends StatefulWidget {
final Size size; final Size size;
final Message message; final Message message;
final ShowMessageCallback onShowMessage; final ShowMessageCallback onShowMessage;
final ValueChanged<ReturnActionType> onReturnAction;
VideoAttachment({ VideoAttachment({
Key key, Key key,
@@ -23,6 +24,7 @@ class VideoAttachment extends StatefulWidget {
this.message, this.message,
this.size, this.size,
this.onShowMessage, this.onShowMessage,
this.onReturnAction,
}) : super(key: key); }) : super(key: key);
@override @override
@@ -84,10 +86,10 @@ class _VideoAttachmentState extends State<VideoAttachment> {
}); });
return GestureDetector( return GestureDetector(
onTap: () { onTap: () async {
final channel = StreamChannel.of(context).channel; final channel = StreamChannel.of(context).channel;
Navigator.push( var res = await Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (_) => StreamChannel( builder: (_) => StreamChannel(
@@ -102,6 +104,10 @@ class _VideoAttachmentState extends State<VideoAttachment> {
), ),
), ),
); );
if (res != null) {
widget.onReturnAction(res);
}
}, },
child: Container( child: Container(
height: widget.size?.height, height: widget.size?.height,