feat: Added sharing and added actions for buttons
This commit is contained in:
@@ -11,6 +11,7 @@ import '../stream_chat_flutter.dart';
|
|||||||
class FullScreenImage extends StatefulWidget {
|
class FullScreenImage extends StatefulWidget {
|
||||||
/// The url of the image
|
/// The url of the image
|
||||||
final List<String> urls;
|
final List<String> urls;
|
||||||
|
final Message message;
|
||||||
|
|
||||||
final int startIndex;
|
final int startIndex;
|
||||||
final String userName;
|
final String userName;
|
||||||
@@ -20,6 +21,7 @@ class FullScreenImage extends StatefulWidget {
|
|||||||
const FullScreenImage({
|
const FullScreenImage({
|
||||||
Key key,
|
Key key,
|
||||||
@required this.urls,
|
@required this.urls,
|
||||||
|
this.message,
|
||||||
this.startIndex = 0,
|
this.startIndex = 0,
|
||||||
this.userName = '',
|
this.userName = '',
|
||||||
this.sentAt,
|
this.sentAt,
|
||||||
@@ -109,11 +111,13 @@ class _FullScreenImageState extends State<FullScreenImage>
|
|||||||
onBackPressed: () {
|
onBackPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
|
message: widget.message,
|
||||||
),
|
),
|
||||||
ImageFooter(
|
ImageFooter(
|
||||||
currentPage: _currentPage,
|
currentPage: _currentPage,
|
||||||
totalPages: widget.urls.length,
|
totalPages: widget.urls.length,
|
||||||
urls: widget.urls,
|
urls: widget.urls,
|
||||||
|
message: widget.message,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -64,14 +64,20 @@ class GiphyAttachment extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
final channel = StreamChannel.of(context).channel;
|
||||||
|
|
||||||
Navigator.push(context,
|
Navigator.push(context,
|
||||||
MaterialPageRoute(builder: (_) {
|
MaterialPageRoute(builder: (_) {
|
||||||
return FullScreenImage(
|
return StreamChannel(
|
||||||
urls: [attachment.imageUrl ??
|
channel: channel,
|
||||||
attachment.assetUrl ??
|
child: FullScreenImage(
|
||||||
attachment.thumbUrl],
|
urls: [attachment.imageUrl ??
|
||||||
userName: message.user.name,
|
attachment.assetUrl ??
|
||||||
sentAt: message.createdAt,
|
attachment.thumbUrl],
|
||||||
|
userName: message.user.name,
|
||||||
|
sentAt: message.createdAt,
|
||||||
|
message: message,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
@@ -299,13 +305,19 @@ class GiphyAttachment extends StatelessWidget {
|
|||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
final channel = StreamChannel.of(context).channel;
|
||||||
|
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (_) {
|
Navigator.push(context, MaterialPageRoute(builder: (_) {
|
||||||
return FullScreenImage(
|
return StreamChannel(
|
||||||
urls: [attachment.imageUrl ??
|
channel: channel,
|
||||||
attachment.assetUrl ??
|
child: FullScreenImage(
|
||||||
attachment.thumbUrl],
|
urls: [attachment.imageUrl ??
|
||||||
userName: message.user.name,
|
attachment.assetUrl ??
|
||||||
sentAt: message.createdAt,
|
attachment.thumbUrl],
|
||||||
|
userName: message.user.name,
|
||||||
|
sentAt: message.createdAt,
|
||||||
|
message: message,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ import '../stream_chat_flutter.dart';
|
|||||||
import 'stream_icons.dart';
|
import 'stream_icons.dart';
|
||||||
|
|
||||||
class ImageActionsModal extends StatelessWidget {
|
class ImageActionsModal extends StatelessWidget {
|
||||||
|
final Message message;
|
||||||
final String userName;
|
final String userName;
|
||||||
final String sentAt;
|
final String sentAt;
|
||||||
|
|
||||||
ImageActionsModal({this.userName, this.sentAt});
|
ImageActionsModal({this.message, this.userName, this.sentAt});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -21,20 +22,18 @@ class ImageActionsModal extends StatelessWidget {
|
|||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
begin: Alignment.topCenter,
|
begin: Alignment.topCenter,
|
||||||
end: Alignment.bottomCenter,
|
end: Alignment.bottomCenter,
|
||||||
colors: [
|
colors: [
|
||||||
Colors.black.withOpacity(0.8),
|
Colors.black.withOpacity(0.8),
|
||||||
Colors.transparent,
|
Colors.transparent,
|
||||||
],
|
],
|
||||||
stops: [0.0, 0.4],
|
stops: [0.0, 0.4],
|
||||||
)
|
)),
|
||||||
),
|
)),
|
||||||
)
|
|
||||||
),
|
|
||||||
_buildPage(context),
|
_buildPage(context),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -70,8 +69,10 @@ class ImageActionsModal extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
sentAt,
|
sentAt,
|
||||||
style:
|
style: StreamChatTheme.of(context)
|
||||||
StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith(color: Colors.white.withOpacity(0.5)),
|
.channelPreviewTheme
|
||||||
|
.subtitle
|
||||||
|
.copyWith(color: Colors.white.withOpacity(0.5)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -104,11 +105,26 @@ class ImageActionsModal extends StatelessWidget {
|
|||||||
children: ListTile.divideTiles(
|
children: ListTile.divideTiles(
|
||||||
context: context,
|
context: context,
|
||||||
tiles: [
|
tiles: [
|
||||||
_buildButton(context, 'Reply', StreamIcons.curve_line_down_left, () {}),
|
_buildButton(context, 'Reply',
|
||||||
_buildButton(context, 'Show in Chat', StreamIcons.eye, () {}),
|
StreamIcons.curve_line_down_left, () {}),
|
||||||
_buildButton(context, 'Save Image', StreamIcons.save_1, () {}),
|
_buildButton(context, 'Show in Chat', StreamIcons.eye,
|
||||||
|
() {
|
||||||
|
Navigator.pop(context);
|
||||||
|
Navigator.pop(context);
|
||||||
|
}),
|
||||||
|
_buildButton(
|
||||||
|
context, 'Save Image', StreamIcons.save_1, () {}),
|
||||||
_buildButton(context, 'Copy', StreamIcons.copy, () {}),
|
_buildButton(context, 'Copy', StreamIcons.copy, () {}),
|
||||||
_buildButton(context, 'Delete', StreamIcons.delete, () {}, color: Colors.red),
|
if (StreamChat.of(context).user.id == message.user.id)
|
||||||
|
_buildButton(context, 'Delete', StreamIcons.delete,
|
||||||
|
() {
|
||||||
|
Navigator.pop(context);
|
||||||
|
Navigator.pop(context);
|
||||||
|
StreamChat.of(context).client.deleteMessage(
|
||||||
|
message,
|
||||||
|
StreamChannel.of(context).channel.cid,
|
||||||
|
);
|
||||||
|
}, color: Colors.red),
|
||||||
],
|
],
|
||||||
).toList(),
|
).toList(),
|
||||||
),
|
),
|
||||||
@@ -121,7 +137,9 @@ class ImageActionsModal extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildButton(context, String title, IconData iconData, VoidCallback onTap, {Color color}) {
|
Widget _buildButton(
|
||||||
|
context, String title, IconData iconData, VoidCallback onTap,
|
||||||
|
{Color color}) {
|
||||||
var titleStyle = TextStyle(
|
var titleStyle = TextStyle(
|
||||||
fontSize: 14.5,
|
fontSize: 14.5,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
|
|||||||
@@ -43,12 +43,18 @@ class ImageAttachment extends StatelessWidget {
|
|||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (_) {
|
builder: (_) {
|
||||||
return FullScreenImage(
|
final channel = StreamChannel.of(context).channel;
|
||||||
urls: [attachment.imageUrl ??
|
|
||||||
attachment.assetUrl ??
|
return StreamChannel(
|
||||||
attachment.thumbUrl],
|
channel: channel,
|
||||||
userName: message.user.name,
|
child: FullScreenImage(
|
||||||
sentAt: message.createdAt,
|
urls: [attachment.imageUrl ??
|
||||||
|
attachment.assetUrl ??
|
||||||
|
attachment.thumbUrl],
|
||||||
|
userName: message.user.name,
|
||||||
|
sentAt: message.createdAt,
|
||||||
|
message: message,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
+295
-238
@@ -11,6 +11,7 @@ import 'package:stream_chat_flutter/src/stream_chat.dart';
|
|||||||
import 'package:stream_chat_flutter/src/stream_chat_theme.dart';
|
import 'package:stream_chat_flutter/src/stream_chat_theme.dart';
|
||||||
import 'package:stream_chat_flutter/src/stream_icons.dart';
|
import 'package:stream_chat_flutter/src/stream_icons.dart';
|
||||||
import 'package:stream_chat_flutter/src/user_avatar.dart';
|
import 'package:stream_chat_flutter/src/user_avatar.dart';
|
||||||
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
|
|
||||||
import './channel_name.dart';
|
import './channel_name.dart';
|
||||||
import 'channel_image.dart';
|
import 'channel_image.dart';
|
||||||
@@ -31,6 +32,7 @@ class ImageFooter extends StatefulWidget {
|
|||||||
final int totalPages;
|
final int totalPages;
|
||||||
|
|
||||||
final List<String> urls;
|
final List<String> urls;
|
||||||
|
final Message message;
|
||||||
|
|
||||||
/// Creates a channel header
|
/// Creates a channel header
|
||||||
ImageFooter({
|
ImageFooter({
|
||||||
@@ -41,6 +43,7 @@ class ImageFooter extends StatefulWidget {
|
|||||||
this.currentPage = 0,
|
this.currentPage = 0,
|
||||||
this.totalPages = 0,
|
this.totalPages = 0,
|
||||||
this.urls,
|
this.urls,
|
||||||
|
this.message,
|
||||||
}) : preferredSize = Size.fromHeight(kToolbarHeight),
|
}) : preferredSize = Size.fromHeight(kToolbarHeight),
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
@@ -57,7 +60,7 @@ class _ImageFooterState extends State<ImageFooter> {
|
|||||||
TextEditingController _searchController = TextEditingController();
|
TextEditingController _searchController = TextEditingController();
|
||||||
TextEditingController _messageController = TextEditingController();
|
TextEditingController _messageController = TextEditingController();
|
||||||
|
|
||||||
List<User> selectedUsers = [];
|
List<User> _selectedUsers = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -134,8 +137,8 @@ class _ImageFooterState extends State<ImageFooter> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.only(
|
borderRadius: BorderRadius.only(
|
||||||
topRight: Radius.circular(8.0),
|
topRight: Radius.circular(16.0),
|
||||||
topLeft: Radius.circular(8.0),
|
topLeft: Radius.circular(16.0),
|
||||||
)),
|
)),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
@@ -196,184 +199,197 @@ class _ImageFooterState extends State<ImageFooter> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildShareModal(context) {
|
Widget _buildShareModal(context) {
|
||||||
|
final channel = StreamChannel.of(context).channel;
|
||||||
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
print('KEY ${MediaQuery.of(context).viewInsets.bottom}');
|
return StreamChannel(
|
||||||
print(MediaQuery.of(context).viewInsets.bottom == 0.0);
|
channel: channel,
|
||||||
return Scaffold(
|
child: Scaffold(
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
body: StatefulBuilder(builder: (modalContext, modalSetState) {
|
body: StatefulBuilder(builder: (modalContext, modalSetState) {
|
||||||
return Align(
|
return Align(
|
||||||
alignment:
|
alignment: _userSearchMode
|
||||||
_userSearchMode ? Alignment.topCenter : Alignment.bottomCenter,
|
? Alignment.topCenter
|
||||||
child: Material(
|
: Alignment.bottomCenter,
|
||||||
color: Colors.transparent,
|
child: Material(
|
||||||
shape: RoundedRectangleBorder(
|
color: Colors.transparent,
|
||||||
borderRadius: BorderRadius.circular(16.0),
|
shape: RoundedRectangleBorder(
|
||||||
),
|
borderRadius: BorderRadius.circular(16.0),
|
||||||
child: Stack(
|
),
|
||||||
children: [
|
child: Stack(
|
||||||
ListView(
|
children: [
|
||||||
children: [
|
ListView(
|
||||||
if (!_userSearchMode && MediaQuery.of(context).viewInsets.bottom == 0.0)
|
children: [
|
||||||
GestureDetector(
|
if (!_userSearchMode &&
|
||||||
child: Container(
|
MediaQuery.of(context).viewInsets.bottom == 0.0)
|
||||||
height: MediaQuery.of(modalContext).size.height / 2,
|
GestureDetector(
|
||||||
color: Colors.transparent,
|
child: Container(
|
||||||
|
height:
|
||||||
|
MediaQuery.of(modalContext).size.height / 2,
|
||||||
|
color: Colors.transparent,
|
||||||
|
),
|
||||||
|
onTapUp: (val) {
|
||||||
|
Navigator.pop(modalContext);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
onTapUp: (val) {
|
Container(
|
||||||
Navigator.pop(modalContext);
|
margin: EdgeInsets.symmetric(
|
||||||
},
|
horizontal: 8.0,
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
vertical: 4.0,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topRight: Radius.circular(16.0),
|
||||||
|
topLeft: Radius.circular(16.0),
|
||||||
|
)),
|
||||||
|
child: _buildTextInputSection(modalSetState),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
margin: EdgeInsets.symmetric(
|
margin: EdgeInsets.symmetric(
|
||||||
horizontal: 8.0,
|
horizontal: 8.0,
|
||||||
),
|
),
|
||||||
padding: EdgeInsets.symmetric(
|
decoration: BoxDecoration(
|
||||||
vertical: 4.0,
|
|
||||||
),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.only(
|
borderRadius: BorderRadius.only(
|
||||||
topRight: Radius.circular(16.0),
|
bottomRight: Radius.circular(
|
||||||
topLeft: Radius.circular(16.0),
|
_userSearchMode ? 16.0 : 0.0),
|
||||||
)),
|
bottomLeft: Radius.circular(
|
||||||
child: _buildTextInputSection(modalSetState),
|
_userSearchMode ? 16.0 : 0.0),
|
||||||
),
|
),
|
||||||
Container(
|
|
||||||
margin: EdgeInsets.symmetric(
|
|
||||||
horizontal: 8.0,
|
|
||||||
),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.only(
|
|
||||||
bottomRight:
|
|
||||||
Radius.circular(_userSearchMode ? 16.0 : 0.0),
|
|
||||||
bottomLeft:
|
|
||||||
Radius.circular(_userSearchMode ? 16.0 : 0.0),
|
|
||||||
),
|
),
|
||||||
),
|
child: FutureBuilder<QueryUsersResponse>(
|
||||||
child: FutureBuilder<QueryUsersResponse>(
|
future: _userQuery,
|
||||||
future: _userQuery,
|
builder: (context, snapshot) {
|
||||||
builder: (context, snapshot) {
|
if (!snapshot.hasData) {
|
||||||
if (!snapshot.hasData) {
|
return Center(
|
||||||
return Center(
|
child: CircularProgressIndicator(),
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
var filteredData = snapshot.data.users.toList();
|
|
||||||
|
|
||||||
if (_userSearchMode &&
|
|
||||||
_searchController.text.length > 0) {
|
|
||||||
filteredData = snapshot.data.users
|
|
||||||
.where((element) => element.name
|
|
||||||
.toLowerCase()
|
|
||||||
.contains(_searchController.text
|
|
||||||
.toLowerCase()))
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
return GridView.builder(
|
|
||||||
shrinkWrap: true,
|
|
||||||
physics: NeverScrollableScrollPhysics(),
|
|
||||||
itemBuilder: (context, position) {
|
|
||||||
var user = filteredData[position];
|
|
||||||
var isUserSelected =
|
|
||||||
selectedUsers.contains(user);
|
|
||||||
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment:
|
|
||||||
CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Stack(
|
|
||||||
children: [
|
|
||||||
CircleAvatar(
|
|
||||||
maxRadius: 32.0,
|
|
||||||
child: UserAvatar(
|
|
||||||
onTap: (user) {
|
|
||||||
if (isUserSelected) {
|
|
||||||
selectedUsers.remove(user);
|
|
||||||
} else {
|
|
||||||
selectedUsers.add(user);
|
|
||||||
}
|
|
||||||
modalSetState(() {});
|
|
||||||
},
|
|
||||||
user: user,
|
|
||||||
constraints:
|
|
||||||
BoxConstraints.tightFor(
|
|
||||||
height:
|
|
||||||
isUserSelected ? 56 : 64,
|
|
||||||
width:
|
|
||||||
isUserSelected ? 56 : 64,
|
|
||||||
),
|
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(32),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Text(
|
|
||||||
user.name,
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.subtitle2,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
maxLines: 2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
itemCount: filteredData.length,
|
|
||||||
gridDelegate:
|
var filteredData =
|
||||||
SliverGridDelegateWithFixedCrossAxisCount(
|
snapshot.data.users.toList();
|
||||||
crossAxisCount: 4,
|
|
||||||
childAspectRatio: 0.75,
|
if (_userSearchMode &&
|
||||||
),
|
_searchController.text.length > 0) {
|
||||||
);
|
filteredData = snapshot.data.users
|
||||||
}),
|
.where((element) => element.name
|
||||||
),
|
.toLowerCase()
|
||||||
],
|
.contains(_searchController.text
|
||||||
),
|
.toLowerCase()))
|
||||||
if (!_userSearchMode && selectedUsers.isEmpty)
|
.toList();
|
||||||
Align(
|
}
|
||||||
alignment: Alignment.bottomCenter,
|
|
||||||
child: Container(
|
return GridView.builder(
|
||||||
color: Colors.white,
|
shrinkWrap: true,
|
||||||
height: 48.0,
|
physics: NeverScrollableScrollPhysics(),
|
||||||
margin: EdgeInsets.symmetric(
|
itemBuilder: (context, position) {
|
||||||
horizontal: 8.0,
|
var user = filteredData[position];
|
||||||
|
var isUserSelected =
|
||||||
|
_selectedUsers.contains(user);
|
||||||
|
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Stack(
|
||||||
|
children: [
|
||||||
|
CircleAvatar(
|
||||||
|
maxRadius: 32.0,
|
||||||
|
child: UserAvatar(
|
||||||
|
onTap: (user) {
|
||||||
|
if (isUserSelected) {
|
||||||
|
_selectedUsers
|
||||||
|
.remove(user);
|
||||||
|
} else {
|
||||||
|
_selectedUsers.add(user);
|
||||||
|
}
|
||||||
|
modalSetState(() {});
|
||||||
|
},
|
||||||
|
user: user,
|
||||||
|
constraints:
|
||||||
|
BoxConstraints.tightFor(
|
||||||
|
height: isUserSelected
|
||||||
|
? 56
|
||||||
|
: 64,
|
||||||
|
width: isUserSelected
|
||||||
|
? 56
|
||||||
|
: 64,
|
||||||
|
),
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius.circular(
|
||||||
|
32),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.all(8.0),
|
||||||
|
child: Text(
|
||||||
|
user.name,
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.subtitle2,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
maxLines: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
itemCount: filteredData.length,
|
||||||
|
gridDelegate:
|
||||||
|
SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
|
crossAxisCount: 4,
|
||||||
|
childAspectRatio: 0.75,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
child: SizedBox.expand(
|
],
|
||||||
child: Center(
|
),
|
||||||
child: Text(
|
if (!_userSearchMode && _selectedUsers.isEmpty)
|
||||||
'Save to Photos',
|
Align(
|
||||||
style: TextStyle(
|
alignment: Alignment.bottomCenter,
|
||||||
color: StreamChatTheme.of(modalContext).accentColor,
|
child: Container(
|
||||||
fontWeight: FontWeight.bold,
|
color: Colors.white,
|
||||||
|
height: 48.0,
|
||||||
|
margin: EdgeInsets.symmetric(
|
||||||
|
horizontal: 8.0,
|
||||||
|
),
|
||||||
|
child: SizedBox.expand(
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
'Save to Photos',
|
||||||
|
style: TextStyle(
|
||||||
|
color: StreamChatTheme.of(modalContext)
|
||||||
|
.accentColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
if (!_userSearchMode && _selectedUsers.isNotEmpty)
|
||||||
if (!_userSearchMode && selectedUsers.isNotEmpty)
|
_buildShareTextInputSection(modalSetState),
|
||||||
_buildShareTextInputSection(modalSetState),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
}),
|
||||||
}),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -487,91 +503,93 @@ class _ImageFooterState extends State<ImageFooter> {
|
|||||||
|
|
||||||
Widget _buildShareTextInputSection(modalSetState) {
|
Widget _buildShareTextInputSection(modalSetState) {
|
||||||
return Align(
|
return Align(
|
||||||
alignment: Alignment.bottomCenter,
|
alignment: Alignment.bottomCenter,
|
||||||
child: Container(
|
child: Container(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
height: 56.0,
|
height: 56.0,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _messageController,
|
controller: _messageController,
|
||||||
onChanged: (val) {
|
onChanged: (val) {
|
||||||
modalSetState(() {});
|
modalSetState(() {});
|
||||||
},
|
},
|
||||||
onTap: () {
|
onTap: () {
|
||||||
modalSetState(() {});
|
modalSetState(() {});
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
isDense: true,
|
isDense: true,
|
||||||
prefixText: ' ',
|
prefixText: ' ',
|
||||||
hintText: 'Add a comment',
|
hintText: 'Add a comment',
|
||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(32.0),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.black.withOpacity(0.16),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(32.0),
|
borderRadius: BorderRadius.circular(32.0),
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
color: Colors.black.withOpacity(0.16),
|
color: Colors.black.withOpacity(0.16),
|
||||||
),
|
)),
|
||||||
),
|
contentPadding: EdgeInsets.symmetric(vertical: 12.0),
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(32.0),
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Colors.black.withOpacity(0.16),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
contentPadding: EdgeInsets.symmetric(vertical: 12.0),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
AnimatedCrossFade(
|
),
|
||||||
crossFadeState: _messageController.text.isNotEmpty
|
AnimatedCrossFade(
|
||||||
? CrossFadeState.showFirst
|
crossFadeState: _messageController.text.isNotEmpty
|
||||||
: CrossFadeState.showSecond,
|
? CrossFadeState.showFirst
|
||||||
firstChild: IconTheme(
|
: CrossFadeState.showSecond,
|
||||||
data:
|
firstChild: IconTheme(
|
||||||
StreamChatTheme.of(context).channelTheme.messageInputButtonIconTheme,
|
data: StreamChatTheme.of(context)
|
||||||
child: Center(
|
.channelTheme
|
||||||
child: Padding(
|
.messageInputButtonIconTheme,
|
||||||
padding: const EdgeInsets.all(8.0),
|
child: Center(
|
||||||
child: InkWell(
|
|
||||||
onTap: () {
|
|
||||||
// sendMessage();
|
|
||||||
},
|
|
||||||
child: Transform.rotate(
|
|
||||||
angle: -pi / 2,
|
|
||||||
child: Icon(
|
|
||||||
StreamIcons.send_message,
|
|
||||||
color: StreamChatTheme.of(context).accentColor,
|
|
||||||
),),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
secondChild: IconTheme(
|
|
||||||
data:
|
|
||||||
StreamChatTheme.of(context).channelTheme.messageInputButtonIconTheme,
|
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Center(
|
child: InkWell(
|
||||||
child: InkWell(
|
onTap: () {
|
||||||
onTap: () {},
|
sendMessage();
|
||||||
child: Icon(
|
},
|
||||||
StreamIcons.send_message,
|
child: Transform.rotate(
|
||||||
color: Colors.grey,
|
angle: -pi / 2,
|
||||||
),
|
child: Icon(
|
||||||
)),
|
StreamIcons.send_message,
|
||||||
|
color: StreamChatTheme.of(context).accentColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
duration: Duration(milliseconds: 300),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
),
|
),
|
||||||
],
|
secondChild: IconTheme(
|
||||||
),
|
data: StreamChatTheme.of(context)
|
||||||
|
.channelTheme
|
||||||
|
.messageInputButtonIconTheme,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Center(
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {},
|
||||||
|
child: Icon(
|
||||||
|
StreamIcons.send_message,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
duration: Duration(milliseconds: 300),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<QueryUsersResponse> _queryUsers(context) {
|
Future<QueryUsersResponse> _queryUsers(context) {
|
||||||
@@ -587,4 +605,43 @@ class _ImageFooterState extends State<ImageFooter> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sends the current message
|
||||||
|
void sendMessage() async {
|
||||||
|
var text = _messageController.text.trim();
|
||||||
|
|
||||||
|
final attachments = widget.message.attachments;
|
||||||
|
|
||||||
|
_messageController.clear();
|
||||||
|
|
||||||
|
final client = StreamChat.of(context).client;
|
||||||
|
|
||||||
|
for(var user in _selectedUsers) {
|
||||||
|
var c = client.channel('messaging', extraData: {
|
||||||
|
'members': [
|
||||||
|
user.id,
|
||||||
|
StreamChat.of(context).user.id,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
await c.create();
|
||||||
|
|
||||||
|
Future sendingFuture;
|
||||||
|
Message message;
|
||||||
|
|
||||||
|
message = (Message()).copyWith(
|
||||||
|
text: text,
|
||||||
|
attachments: attachments,
|
||||||
|
mentionedUsers: [],
|
||||||
|
showInChannel: false,
|
||||||
|
);
|
||||||
|
|
||||||
|
sendingFuture = c.sendMessage(message);
|
||||||
|
|
||||||
|
await sendingFuture;
|
||||||
|
}
|
||||||
|
|
||||||
|
Navigator.pop(context);
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:carousel_slider/carousel_slider.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:stream_chat/stream_chat.dart';
|
import 'package:stream_chat/stream_chat.dart';
|
||||||
import 'package:stream_chat_flutter/src/full_screen_image.dart';
|
import 'package:stream_chat_flutter/src/full_screen_image.dart';
|
||||||
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
|
|
||||||
class ImageGroup extends StatelessWidget {
|
class ImageGroup extends StatelessWidget {
|
||||||
const ImageGroup({
|
const ImageGroup({
|
||||||
@@ -107,14 +108,20 @@ class ImageGroup extends StatelessWidget {
|
|||||||
BuildContext context, [
|
BuildContext context, [
|
||||||
int index,
|
int index,
|
||||||
]) {
|
]) {
|
||||||
|
final channel = StreamChannel.of(context).channel;
|
||||||
|
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) =>
|
||||||
FullScreenImage(urls: images.map((e) => e.imageUrl ?? e.thumbUrl ?? e.assetUrl).toList(),
|
StreamChannel(
|
||||||
startIndex: index,
|
channel: channel,
|
||||||
userName: message.user.name,
|
child: FullScreenImage(urls: images.map((e) => e.imageUrl ?? e.thumbUrl ?? e.assetUrl).toList(),
|
||||||
sentAt: message.createdAt,
|
startIndex: index,
|
||||||
|
userName: message.user.name,
|
||||||
|
sentAt: message.createdAt,
|
||||||
|
message: message,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -25,12 +25,15 @@ class ImageHeader extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
/// Callback to call when the image is tapped.
|
/// Callback to call when the image is tapped.
|
||||||
final VoidCallback onImageTap;
|
final VoidCallback onImageTap;
|
||||||
|
|
||||||
|
final Message message;
|
||||||
|
|
||||||
final String userName;
|
final String userName;
|
||||||
final String sentAt;
|
final String sentAt;
|
||||||
|
|
||||||
/// Creates a channel header
|
/// Creates a channel header
|
||||||
ImageHeader({
|
ImageHeader({
|
||||||
Key key,
|
Key key,
|
||||||
|
this.message,
|
||||||
this.showBackButton = true,
|
this.showBackButton = true,
|
||||||
this.onBackPressed,
|
this.onBackPressed,
|
||||||
this.onTitleTap,
|
this.onTitleTap,
|
||||||
@@ -103,12 +106,18 @@ class ImageHeader extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
final Size preferredSize;
|
final Size preferredSize;
|
||||||
|
|
||||||
void _showMessageActionModalBottomSheet(BuildContext context) {
|
void _showMessageActionModalBottomSheet(BuildContext context) {
|
||||||
|
final channel = StreamChannel.of(context).channel;
|
||||||
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return ImageActionsModal(
|
return StreamChannel(
|
||||||
userName: userName,
|
channel: channel,
|
||||||
sentAt: sentAt,
|
child: ImageActionsModal(
|
||||||
|
userName: userName,
|
||||||
|
sentAt: sentAt,
|
||||||
|
message: message,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user