feat: Added error message to new group and info tiles to new chat and merged
This commit is contained in:
@@ -123,10 +123,12 @@ class _GroupChatDetailsScreenState extends State<GroupChatDetailsScreen> {
|
|||||||
onPressed: _isGroupNameEmpty
|
onPressed: _isGroupNameEmpty
|
||||||
? null
|
? null
|
||||||
: () async {
|
: () async {
|
||||||
|
try {
|
||||||
final groupName = _groupNameController.text;
|
final groupName = _groupNameController.text;
|
||||||
final client = StreamChat.of(context).client;
|
final client = StreamChat.of(context).client;
|
||||||
final channel = client
|
final channel = client.channel('messaging',
|
||||||
.channel('messaging', id: Uuid().v4(), extraData: {
|
id: Uuid().v4(),
|
||||||
|
extraData: {
|
||||||
'members': [
|
'members': [
|
||||||
client.state.user.id,
|
client.state.user.id,
|
||||||
..._selectedUsers.map((e) => e.id),
|
..._selectedUsers.map((e) => e.id),
|
||||||
@@ -140,6 +142,9 @@ class _GroupChatDetailsScreenState extends State<GroupChatDetailsScreen> {
|
|||||||
ModalRoute.withName(Routes.HOME),
|
ModalRoute.withName(Routes.HOME),
|
||||||
arguments: ChannelPageArgs(channel: channel),
|
arguments: ChannelPageArgs(channel: channel),
|
||||||
);
|
);
|
||||||
|
} catch (err) {
|
||||||
|
_showErrorAlert();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -227,4 +232,69 @@ class _GroupChatDetailsScreenState extends State<GroupChatDetailsScreen> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _showErrorAlert() {
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
Text('The operation couldn\'t be completed.'),
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,30 @@ class _NewChatScreenState extends State<NewChatScreen> {
|
|||||||
),
|
),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
),
|
),
|
||||||
body: StreamChannel(
|
body: ValueListenableBuilder<ConnectionStatus>(
|
||||||
|
valueListenable: StreamChat.of(context).client.wsConnectionStatus,
|
||||||
|
builder: (context, status, _) {
|
||||||
|
String statusString = '';
|
||||||
|
bool showStatus = true;
|
||||||
|
|
||||||
|
switch (status) {
|
||||||
|
case ConnectionStatus.connected:
|
||||||
|
statusString = 'Connected';
|
||||||
|
showStatus = false;
|
||||||
|
break;
|
||||||
|
case ConnectionStatus.connecting:
|
||||||
|
statusString = 'Reconnecting...';
|
||||||
|
break;
|
||||||
|
case ConnectionStatus.disconnected:
|
||||||
|
statusString = 'Disconnected';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return InfoTile(
|
||||||
|
showMessage: showStatus,
|
||||||
|
tileAnchor: Alignment.topCenter,
|
||||||
|
childAnchor: Alignment.topCenter,
|
||||||
|
message: statusString,
|
||||||
|
child: StreamChannel(
|
||||||
showLoading: false,
|
showLoading: false,
|
||||||
channel: channel,
|
channel: channel,
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -162,20 +185,24 @@ class _NewChatScreenState extends State<NewChatScreen> {
|
|||||||
),
|
),
|
||||||
padding: const EdgeInsets.only(left: 24),
|
padding: const EdgeInsets.only(left: 24),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(8, 4, 12, 4),
|
padding:
|
||||||
|
const EdgeInsets.fromLTRB(8, 4, 12, 4),
|
||||||
child: Text(
|
child: Text(
|
||||||
user.name,
|
user.name,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color: StreamChatTheme.of(context)
|
||||||
StreamChatTheme.of(context).colorTheme.black,
|
.colorTheme
|
||||||
|
.black,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
foregroundDecoration: BoxDecoration(
|
foregroundDecoration: BoxDecoration(
|
||||||
color: StreamChatTheme.of(context).colorTheme.overlay,
|
color: StreamChatTheme.of(context)
|
||||||
|
.colorTheme
|
||||||
|
.overlay,
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
child: UserAvatar(
|
child: UserAvatar(
|
||||||
@@ -225,7 +252,9 @@ class _NewChatScreenState extends State<NewChatScreen> {
|
|||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Text(
|
Text(
|
||||||
'Create a Group',
|
'Create a Group',
|
||||||
style: StreamChatTheme.of(context).textTheme.bodyBold,
|
style: StreamChatTheme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyBold,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -236,7 +265,8 @@ class _NewChatScreenState extends State<NewChatScreen> {
|
|||||||
Container(
|
Container(
|
||||||
width: double.maxFinite,
|
width: double.maxFinite,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: StreamChatTheme.of(context).colorTheme.bgGradient,
|
gradient:
|
||||||
|
StreamChatTheme.of(context).colorTheme.bgGradient,
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
@@ -261,11 +291,13 @@ class _NewChatScreenState extends State<NewChatScreen> {
|
|||||||
child: _showUserList
|
child: _showUserList
|
||||||
? GestureDetector(
|
? GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onPanDown: (_) => FocusScope.of(context).unfocus(),
|
onPanDown: (_) =>
|
||||||
|
FocusScope.of(context).unfocus(),
|
||||||
child: UsersBloc(
|
child: UsersBloc(
|
||||||
child: UserListView(
|
child: UserListView(
|
||||||
selectedUsers: _selectedUsers,
|
selectedUsers: _selectedUsers,
|
||||||
groupAlphabetically: _isSearchActive ? false : true,
|
groupAlphabetically:
|
||||||
|
_isSearchActive ? false : true,
|
||||||
onUserTap: (user, _) {
|
onUserTap: (user, _) {
|
||||||
_controller.clear();
|
_controller.clear();
|
||||||
if (!_selectedUsers.contains(user)) {
|
if (!_selectedUsers.contains(user)) {
|
||||||
@@ -298,16 +330,20 @@ class _NewChatScreenState extends State<NewChatScreen> {
|
|||||||
return LayoutBuilder(
|
return LayoutBuilder(
|
||||||
builder: (context, viewportConstraints) {
|
builder: (context, viewportConstraints) {
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
physics: AlwaysScrollableScrollPhysics(),
|
physics:
|
||||||
|
AlwaysScrollableScrollPhysics(),
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
minHeight: viewportConstraints.maxHeight,
|
minHeight:
|
||||||
|
viewportConstraints.maxHeight,
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(24),
|
padding:
|
||||||
|
const EdgeInsets.all(
|
||||||
|
24),
|
||||||
child: StreamSvgIcon.search(
|
child: StreamSvgIcon.search(
|
||||||
size: 96,
|
size: 96,
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
@@ -315,15 +351,17 @@ class _NewChatScreenState extends State<NewChatScreen> {
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'No user matches these keywords...',
|
'No user matches these keywords...',
|
||||||
style: StreamChatTheme.of(context)
|
style: StreamChatTheme.of(
|
||||||
|
context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.footnote
|
.footnote
|
||||||
.copyWith(
|
.copyWith(
|
||||||
color: StreamChatTheme.of(
|
color: StreamChatTheme
|
||||||
context)
|
.of(context)
|
||||||
.colorTheme
|
.colorTheme
|
||||||
.black
|
.black
|
||||||
.withOpacity(.5)),
|
.withOpacity(
|
||||||
|
.5)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -377,5 +415,7 @@ class _NewChatScreenState extends State<NewChatScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -307,7 +307,33 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
return Stack(
|
return Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
LazyLoadScrollView(
|
ValueListenableBuilder<ConnectionStatus>(
|
||||||
|
valueListenable: _client.wsConnectionStatus,
|
||||||
|
builder: (context, status, _) {
|
||||||
|
String statusString = '';
|
||||||
|
bool showStatus = true;
|
||||||
|
|
||||||
|
switch (status) {
|
||||||
|
case ConnectionStatus.connected:
|
||||||
|
statusString = 'Connected';
|
||||||
|
showStatus = false;
|
||||||
|
break;
|
||||||
|
case ConnectionStatus.connecting:
|
||||||
|
statusString = 'Reconnecting...';
|
||||||
|
break;
|
||||||
|
case ConnectionStatus.disconnected:
|
||||||
|
statusString = 'Disconnected';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return InfoTile(
|
||||||
|
showMessage:
|
||||||
|
widget.showConnectionStateTile ? showStatus : false,
|
||||||
|
tileAnchor: Alignment.topCenter,
|
||||||
|
childAnchor: Alignment.topCenter,
|
||||||
|
message: statusString,
|
||||||
|
child: LazyLoadScrollView(
|
||||||
|
child: LazyLoadScrollView(
|
||||||
onStartOfPage: () async {
|
onStartOfPage: () async {
|
||||||
_inBetweenList = false;
|
_inBetweenList = false;
|
||||||
if (!_upToDate) {
|
if (!_upToDate) {
|
||||||
@@ -340,17 +366,20 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
physics: widget.scrollPhysics,
|
physics: widget.scrollPhysics,
|
||||||
itemScrollController: _scrollController,
|
itemScrollController: _scrollController,
|
||||||
reverse: true,
|
reverse: true,
|
||||||
itemCount:
|
itemCount: messages.length +
|
||||||
messages.length + 2 + (_isThreadConversation ? 1 : 0),
|
2 +
|
||||||
|
(_isThreadConversation ? 1 : 0),
|
||||||
separatorBuilder: (context, i) {
|
separatorBuilder: (context, i) {
|
||||||
if (i == messages.length) return Offstage();
|
if (i == messages.length) return Offstage();
|
||||||
if (i == 0) return SizedBox(height: 30);
|
if (i == 0) return SizedBox(height: 30);
|
||||||
if (i == messages.length + 1) {
|
if (i == messages.length + 1) {
|
||||||
final replyCount = widget.parentMessage.replyCount;
|
final replyCount =
|
||||||
|
widget.parentMessage.replyCount;
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient:
|
gradient: StreamChatTheme.of(context)
|
||||||
StreamChatTheme.of(context).colorTheme.bgGradient,
|
.colorTheme
|
||||||
|
.bgGradient,
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
@@ -372,15 +401,18 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
nextMessage.createdAt.toLocal(),
|
nextMessage.createdAt.toLocal(),
|
||||||
Units.DAY,
|
Units.DAY,
|
||||||
)) {
|
)) {
|
||||||
final divider = widget.dateDividerBuilder != null
|
final divider =
|
||||||
|
widget.dateDividerBuilder != null
|
||||||
? widget.dateDividerBuilder(
|
? widget.dateDividerBuilder(
|
||||||
nextMessage.createdAt.toLocal(),
|
nextMessage.createdAt.toLocal(),
|
||||||
)
|
)
|
||||||
: DateDivider(
|
: DateDivider(
|
||||||
dateTime: nextMessage.createdAt.toLocal(),
|
dateTime:
|
||||||
|
nextMessage.createdAt.toLocal(),
|
||||||
);
|
);
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12.0),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 12.0),
|
||||||
child: divider,
|
child: divider,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -410,7 +442,8 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
widget.parentMessage,
|
widget.parentMessage,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return buildParentMessage(widget.parentMessage);
|
return buildParentMessage(
|
||||||
|
widget.parentMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == messages.length + 1) {
|
if (i == messages.length + 1) {
|
||||||
@@ -446,8 +479,8 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
} else {
|
} else {
|
||||||
if (widget.messageBuilder != null) {
|
if (widget.messageBuilder != null) {
|
||||||
messageWidget = Builder(
|
messageWidget = Builder(
|
||||||
key:
|
key: ValueKey<String>(
|
||||||
ValueKey<String>('MESSAGE-${message.id}'),
|
'MESSAGE-${message.id}'),
|
||||||
builder: (context) => widget.messageBuilder(
|
builder: (context) => widget.messageBuilder(
|
||||||
context,
|
context,
|
||||||
MessageDetails(
|
MessageDetails(
|
||||||
@@ -467,6 +500,7 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
if (widget.showScrollToBottom) _buildScrollToBottom(),
|
if (widget.showScrollToBottom) _buildScrollToBottom(),
|
||||||
|
|||||||
Reference in New Issue
Block a user