Merge pull request #220 from GetStream/doc-fixes-2

Doc fixes 2
This commit is contained in:
Salvatore Giordano
2021-01-19 10:40:01 +01:00
committed by GitHub
6 changed files with 173 additions and 100 deletions
@@ -70,6 +70,10 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
); );
} }
var userMember = snapshot.data
.firstWhere((e) => e.user.id == StreamChat.of(context).user.id);
var isOwner = userMember.role == 'owner';
return Scaffold( return Scaffold(
backgroundColor: StreamChatTheme.of(context).colorTheme.whiteSnow, backgroundColor: StreamChatTheme.of(context).colorTheme.whiteSnow,
appBar: AppBar( appBar: AppBar(
@@ -161,7 +165,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
height: 8.0, height: 8.0,
color: StreamChatTheme.of(context).colorTheme.greyGainsboro, color: StreamChatTheme.of(context).colorTheme.greyGainsboro,
), ),
_buildNameTile(), if (isOwner) _buildNameTile(),
_buildOptionListTiles(), _buildOptionListTiles(),
], ],
), ),
@@ -156,6 +156,9 @@ class _HomePageState extends State<HomePage> {
onNewChatButtonTap: () { onNewChatButtonTap: () {
Navigator.pushNamed(context, Routes.NEW_CHAT); Navigator.pushNamed(context, Routes.NEW_CHAT);
}, },
preNavigationCallback: () {
FocusScope.of(context).requestFocus(FocusNode());
},
), ),
drawer: _buildDrawer(context, user), drawer: _buildDrawer(context, user),
drawerEdgeDragWidth: 50, drawerEdgeDragWidth: 50,
@@ -519,6 +522,7 @@ class _ChannelListPageState extends State<ChannelListPage> {
); );
}, },
onItemTap: (messageResponse) async { onItemTap: (messageResponse) async {
FocusScope.of(context).requestFocus(FocusNode());
final client = StreamChat.of(context).client; final client = StreamChat.of(context).client;
final message = messageResponse.message; final message = messageResponse.message;
final channel = client.channel( final channel = client.channel(
@@ -55,6 +55,7 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
this.onUserAvatarTap, this.onUserAvatarTap,
this.onNewChatButtonTap, this.onNewChatButtonTap,
this.showConnectionStateTile = false, this.showConnectionStateTile = false,
this.preNavigationCallback,
}) : super(key: key); }) : super(key: key);
/// Pass this if you don't have a [Client] in your widget tree. /// Pass this if you don't have a [Client] in your widget tree.
@@ -72,6 +73,8 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
final bool showConnectionStateTile; final bool showConnectionStateTile;
final VoidCallback preNavigationCallback;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final _client = client ?? StreamChat.of(context).client; final _client = client ?? StreamChat.of(context).client;
@@ -110,8 +113,13 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
child: UserAvatar( child: UserAvatar(
user: user, user: user,
showOnlineStatus: false, showOnlineStatus: false,
onTap: onTap: onUserAvatarTap ??
onUserAvatarTap ?? (_) => Scaffold.of(context).openDrawer(), (_) {
if (preNavigationCallback != null) {
preNavigationCallback();
}
Scaffold.of(context).openDrawer();
},
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
constraints: BoxConstraints.tightFor( constraints: BoxConstraints.tightFor(
height: 40, height: 40,
@@ -433,8 +433,6 @@ class MessageInputState extends State<MessageInput> {
_buildAttachments(), _buildAttachments(),
LimitedBox( LimitedBox(
maxHeight: widget.maxHeight, maxHeight: widget.maxHeight,
child: SizedBox(
height: 40,
child: TextField( child: TextField(
key: Key('messageInputText'), key: Key('messageInputText'),
enabled: _inputEnabled, enabled: _inputEnabled,
@@ -510,7 +508,6 @@ class MessageInputState extends State<MessageInput> {
), ),
textCapitalization: TextCapitalization.sentences, textCapitalization: TextCapitalization.sentences,
), ),
),
) )
], ],
), ),
@@ -1042,15 +1039,9 @@ class MessageInputState extends State<MessageInput> {
final mediaInfo = await CompressVideoService.compressVideo(file.path); final mediaInfo = await CompressVideoService.compressVideo(file.path);
if (mediaInfo.filesize / (1024 * 1024) > _kMaxAttachmentSize) { if (mediaInfo.filesize / (1024 * 1024) > _kMaxAttachmentSize) {
// ignore: deprecated_member_use _showErrorAlert(
Scaffold.of(context).showSnackBar(
SnackBar(
content: Text(
'The file is too large to upload. The file size limit is 20MB. We tried compressing it, but it was not enough.', 'The file is too large to upload. The file size limit is 20MB. We tried compressing it, but it was not enough.',
),
),
); );
setState(() { setState(() {
_attachments.remove(attachment); _attachments.remove(attachment);
}); });
@@ -1063,13 +1054,8 @@ class MessageInputState extends State<MessageInput> {
path: mediaInfo.path, path: mediaInfo.path,
); );
} else { } else {
// ignore: deprecated_member_use _showErrorAlert(
Scaffold.of(context).showSnackBar( 'The file is too large to upload. The file size limit is 20MB.',
SnackBar(
content: Text(
'The file is too large to upload. The file size limit is 20MB',
),
),
); );
} }
} }
@@ -2021,12 +2007,8 @@ class MessageInputState extends State<MessageInput> {
}); });
} else { } else {
// ignore: deprecated_member_use // ignore: deprecated_member_use
Scaffold.of(context).showSnackBar( _showErrorAlert(
SnackBar( 'The file is too large to upload. The file size limit is 20MB.',
content: Text(
'The file is too large to upload. The file size limit is 20MB',
),
),
); );
setState(() { setState(() {
_attachments.remove(attachment); _attachments.remove(attachment);
@@ -2279,6 +2261,77 @@ class MessageInputState extends State<MessageInput> {
}); });
} }
void _showErrorAlert(String description) {
showModalBottomSheet(
backgroundColor: StreamChatTheme.of(context).colorTheme.white,
context: context,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16.0),
topRight: Radius.circular(16.0),
)),
builder: (context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
height: 26.0,
),
StreamSvgIcon.error(
color: StreamChatTheme.of(context).colorTheme.accentRed,
size: 24.0,
),
SizedBox(
height: 26.0,
),
Text(
'Something went wrong',
style: StreamChatTheme.of(context).textTheme.headlineBold,
),
SizedBox(
height: 7.0,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
description,
textAlign: TextAlign.center,
),
),
SizedBox(
height: 36.0,
),
Container(
color:
StreamChatTheme.of(context).colorTheme.black.withOpacity(.08),
height: 1.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FlatButton(
child: Text(
'OK',
style: StreamChatTheme.of(context)
.textTheme
.bodyBold
.copyWith(
color: StreamChatTheme.of(context)
.colorTheme
.accentBlue),
),
onPressed: () {
Navigator.of(context).pop();
},
),
],
),
],
);
},
);
}
void _parseExistingMessage(Message message) { void _parseExistingMessage(Message message) {
textEditingController.text = message.text; textEditingController.text = message.text;
@@ -956,7 +956,10 @@ class _MessageListViewState extends State<MessageListView> {
end: colorTheme.white.withOpacity(0), end: colorTheme.white.withOpacity(0),
), ),
duration: const Duration(seconds: 3), duration: const Duration(seconds: 3),
child: Padding(
padding: const EdgeInsets.only(top: 4.0),
child: child, child: child,
),
onEnd: () => initialMessageHighlightComplete = true, onEnd: () => initialMessageHighlightComplete = true,
builder: (_, color, child) { builder: (_, color, child) {
return Container( return Container(
@@ -79,6 +79,7 @@ class ThreadHeader extends StatelessWidget implements PreferredSizeWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AppBar( return AppBar(
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
brightness: Theme.of(context).brightness,
elevation: 1, elevation: 1,
leading: showBackButton leading: showBackButton
? StreamBackButton( ? StreamBackButton(