Minor merge fixes

This commit is contained in:
xsahil03x
2020-11-25 11:41:07 +05:30
parent f08976fad1
commit 3cda66a255
2 changed files with 331 additions and 327 deletions
+160 -154
View File
@@ -52,169 +52,175 @@ class _GroupChatDetailsScreenState extends State<GroupChatDetailsScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return WillPopScope(
backgroundColor: Color.fromRGBO(252, 252, 252, 1), onWillPop: () async {
appBar: AppBar( Navigator.pop(context, _selectedUsers);
elevation: 1, return false;
backgroundColor: Colors.white, },
leading: const StreamBackButton(), child: Scaffold(
title: Text( backgroundColor: Color.fromRGBO(252, 252, 252, 1),
'Name of Group Chat', appBar: AppBar(
style: TextStyle( elevation: 1,
color: Colors.black, backgroundColor: Colors.white,
fontSize: 16, leading: const StreamBackButton(),
), title: Text(
), 'Name of Group Chat',
centerTitle: true, style: TextStyle(
bottom: PreferredSize( color: Colors.black,
preferredSize: Size.fromHeight(kToolbarHeight), fontSize: 16,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 18, horizontal: 16),
child: Row(
children: [
Text(
'NAME',
style: TextStyle(
fontSize: 12,
color: Colors.black.withOpacity(0.5),
),
),
SizedBox(width: 16),
Expanded(
child: TextField(
controller: _groupNameController,
decoration: InputDecoration(
isDense: true,
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
disabledBorder: InputBorder.none,
contentPadding: const EdgeInsets.all(0),
hintText: 'Choose a group chat name',
hintStyle: TextStyle(
fontSize: 14, color: Colors.black.withOpacity(.5)),
),
),
),
],
), ),
), ),
), centerTitle: true,
actions: [ bottom: PreferredSize(
NeumorphicButton( preferredSize: Size.fromHeight(kToolbarHeight),
child: IconButton(
padding: const EdgeInsets.all(0),
icon: StreamSvgIcon.check(
size: 24,
color: _isGroupNameEmpty ? Colors.grey : Color(0xFF006CFF),
),
onPressed: _isGroupNameEmpty
? null
: () async {
final groupName = _groupNameController.text;
final client = StreamChat.of(context).client;
final channel = client
.channel('messaging', id: Uuid().v4(), extraData: {
'members': [
client.state.user.id,
..._selectedUsers.map((e) => e.id),
],
'name': groupName,
});
await channel.watch();
Navigator.of(context)
..pop()
..pushReplacement(
MaterialPageRoute(
builder: (context) {
return StreamChannel(
child: ChannelPage(),
channel: channel,
);
},
),
);
},
),
),
],
),
body: Column(
children: [
Container(
width: double.maxFinite,
color: Colors.grey.shade50,
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(vertical: 18, horizontal: 16),
vertical: 8, child: Row(
horizontal: 8, children: [
Text(
'NAME',
style: TextStyle(
fontSize: 12,
color: Colors.black.withOpacity(0.5),
),
),
SizedBox(width: 16),
Expanded(
child: TextField(
controller: _groupNameController,
decoration: InputDecoration(
isDense: true,
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
disabledBorder: InputBorder.none,
contentPadding: const EdgeInsets.all(0),
hintText: 'Choose a group chat name',
hintStyle: TextStyle(
fontSize: 14, color: Colors.black.withOpacity(.5)),
),
),
),
],
), ),
child: Text( ),
'$_totalUsers ${_totalUsers > 1 ? 'Members' : 'Member'}', ),
style: TextStyle( actions: [
fontWeight: FontWeight.w500, StreamNeumorphicButton(
child: IconButton(
padding: const EdgeInsets.all(0),
icon: StreamSvgIcon.check(
size: 24,
color: _isGroupNameEmpty ? Colors.grey : Color(0xFF006CFF),
),
onPressed: _isGroupNameEmpty
? null
: () async {
final groupName = _groupNameController.text;
final client = StreamChat.of(context).client;
final channel = client
.channel('messaging', id: Uuid().v4(), extraData: {
'members': [
client.state.user.id,
..._selectedUsers.map((e) => e.id),
],
'name': groupName,
});
await channel.watch();
Navigator.of(context)
..pop()
..pushReplacement(
MaterialPageRoute(
builder: (context) {
return StreamChannel(
child: ChannelPage(),
channel: channel,
);
},
),
);
},
),
),
],
),
body: Column(
children: [
Container(
width: double.maxFinite,
color: Colors.grey.shade50,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 8,
horizontal: 8,
),
child: Text(
'$_totalUsers ${_totalUsers > 1 ? 'Members' : 'Member'}',
style: TextStyle(
fontWeight: FontWeight.w500,
),
), ),
), ),
), ),
), Expanded(
Expanded( child: ListView.separated(
child: ListView.separated( itemCount: _selectedUsers.length + 1,
itemCount: _selectedUsers.length + 1, separatorBuilder: (_, __) => Container(
separatorBuilder: (_, __) => Container( height: 1,
height: 1, color: Theme.of(context).brightness == Brightness.dark
color: Theme.of(context).brightness == Brightness.dark ? Colors.white.withOpacity(0.1)
? Colors.white.withOpacity(0.1) : Colors.black.withOpacity(0.1),
: Colors.black.withOpacity(0.1), ),
), itemBuilder: (_, index) {
itemBuilder: (_, index) { if (index == _selectedUsers.length) {
if (index == _selectedUsers.length) { return Container(
return Container( height: 1,
height: 1, color: Theme.of(context).brightness == Brightness.dark
color: Theme.of(context).brightness == Brightness.dark ? Colors.white.withOpacity(0.1)
? Colors.white.withOpacity(0.1) : Colors.black.withOpacity(0.1),
: Colors.black.withOpacity(0.1), );
}
final user = _selectedUsers[index];
return ListTile(
key: ObjectKey(user),
leading: UserAvatar(
user: user,
constraints: BoxConstraints.tightFor(
width: 40,
height: 40,
),
),
title: Text(
user.name,
style: TextStyle(fontWeight: FontWeight.bold),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
trailing: IconButton(
icon: Icon(
Icons.clear_rounded,
color: Colors.black,
),
padding: const EdgeInsets.all(0),
splashRadius: 24,
onPressed: () {
setState(() {
_selectedUsers.remove(user);
});
if (_selectedUsers.isEmpty) {
Navigator.pop(context, _selectedUsers);
}
},
),
); );
} },
final user = _selectedUsers[index]; ),
return ListTile(
key: ObjectKey(user),
leading: UserAvatar(
user: user,
constraints: BoxConstraints.tightFor(
width: 40,
height: 40,
),
),
title: Text(
user.name,
style: TextStyle(fontWeight: FontWeight.bold),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
trailing: IconButton(
icon: Icon(
Icons.clear_rounded,
color: Colors.black,
),
padding: const EdgeInsets.all(0),
splashRadius: 24,
onPressed: () {
setState(() {
_selectedUsers.remove(user);
});
if (_selectedUsers.isEmpty) {
Navigator.pop(context);
}
},
),
);
},
), ),
), ],
], ),
), ),
); );
} }
+171 -173
View File
@@ -50,198 +50,196 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SafeArea( return SafeArea(
child: UsersBloc( child: Scaffold(
child: Scaffold( backgroundColor: Color.fromRGBO(252, 252, 252, 1),
backgroundColor: Color.fromRGBO(252, 252, 252, 1), body: NestedScrollView(
body: NestedScrollView( floatHeaderSlivers: true,
floatHeaderSlivers: true, headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
headerSliverBuilder: return <Widget>[
(BuildContext context, bool innerBoxIsScrolled) { SliverAppBar(
return <Widget>[ // floating: true,
SliverAppBar( pinned: true,
// floating: true, forceElevated: true,
pinned: true, elevation: 1,
forceElevated: true, backgroundColor: Colors.white,
elevation: 1, leading: const StreamBackButton(),
backgroundColor: Colors.white, title: Text(
leading: const StreamBackButton(), 'Add Group Members',
title: Text( style: TextStyle(
'Add Group Members', color: Colors.black,
style: TextStyle( fontSize: 16,
color: Colors.black, ),
fontSize: 16, ),
centerTitle: true,
actions: [
if (_selectedUsers.isNotEmpty)
IconButton(
icon: StreamSvgIcon.right(
color: Color(0xFF006CFF),
),
onPressed: () async {
final updatedList = await Navigator.push(
context,
MaterialPageRoute(
builder: (_) => GroupChatDetailsScreen(
selectedUsers:
_selectedUsers.toList(growable: false),
),
),
);
if (updatedList != null) {
setState(() {
_selectedUsers
..clear()
..addAll(updatedList);
});
}
},
)
],
),
SliverToBoxAdapter(
child: Container(
height: 36,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Colors.grey.shade300,
),
borderRadius: BorderRadius.circular(24),
),
margin: const EdgeInsets.symmetric(
vertical: 8,
horizontal: 8,
),
child: TextField(
controller: _controller,
decoration: InputDecoration(
prefixIcon: StreamSvgIcon.search(
color: Colors.black,
size: 24,
),
hintText: 'Search',
hintStyle: TextStyle(
color: Colors.black.withOpacity(0.5),
fontSize: 14,
),
contentPadding: const EdgeInsets.all(0),
border: OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.circular(24),
),
), ),
), ),
centerTitle: true,
actions: [
if (_selectedUsers.isNotEmpty)
IconButton(
icon: StreamSvgIcon.right(
color: Color(0xFF006CFF),
),
onPressed: () async {
final updatedList = await Navigator.push(
context,
MaterialPageRoute(
builder: (_) => GroupChatDetailsScreen(
selectedUsers:
_selectedUsers.toList(growable: false),
),
),
);
if (updatedList != null) {
setState(() {
_selectedUsers
..clear()
..addAll(updatedList);
});
}
},
)
],
), ),
),
if (_selectedUsers.isNotEmpty)
SliverToBoxAdapter( SliverToBoxAdapter(
child: Container( child: Container(
height: 36, height: 104,
decoration: BoxDecoration( child: ListView.separated(
color: Colors.white, scrollDirection: Axis.horizontal,
border: Border.all( itemCount: _selectedUsers.length,
color: Colors.grey.shade300, padding: const EdgeInsets.all(8),
), separatorBuilder: (_, __) => SizedBox(width: 16),
borderRadius: BorderRadius.circular(24), itemBuilder: (_, index) {
), final user = _selectedUsers.elementAt(index);
margin: const EdgeInsets.symmetric( return Column(
vertical: 8, children: [
horizontal: 8, Stack(
), children: [
child: TextField( UserAvatar(
controller: _controller, onlineIndicatorAlignment: Alignment(0.9, 0.9),
decoration: InputDecoration( user: user,
prefixIcon: StreamSvgIcon.search( showOnlineStatus: true,
color: Colors.black, borderRadius: BorderRadius.circular(32),
size: 24, constraints: BoxConstraints.tightFor(
), height: 64,
hintText: 'Search', width: 64,
hintStyle: TextStyle(
color: Colors.black.withOpacity(0.5),
fontSize: 14,
),
contentPadding: const EdgeInsets.all(0),
border: OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.circular(24),
),
),
),
),
),
if (_selectedUsers.isNotEmpty)
SliverToBoxAdapter(
child: Container(
height: 104,
child: ListView.separated(
scrollDirection: Axis.horizontal,
itemCount: _selectedUsers.length,
padding: const EdgeInsets.all(8),
separatorBuilder: (_, __) => SizedBox(width: 16),
itemBuilder: (_, index) {
final user = _selectedUsers.elementAt(index);
return Column(
children: [
Stack(
children: [
UserAvatar(
onlineIndicatorAlignment:
Alignment(0.9, 0.9),
user: user,
showOnlineStatus: true,
borderRadius: BorderRadius.circular(32),
constraints: BoxConstraints.tightFor(
height: 64,
width: 64,
),
), ),
Positioned( ),
top: -4, Positioned(
right: -4, top: -4,
child: GestureDetector( right: -4,
onTap: () { child: GestureDetector(
if (_selectedUsers.contains(user)) { onTap: () {
setState(() => if (_selectedUsers.contains(user)) {
_selectedUsers.remove(user)); setState(
} () => _selectedUsers.remove(user));
}, }
child: Container( },
decoration: BoxDecoration( child: Container(
color: Colors.white, decoration: BoxDecoration(
shape: BoxShape.circle, color: Colors.white,
border: Border.all( shape: BoxShape.circle,
color: Colors.grey.shade100, border: Border.all(
), color: Colors.grey.shade100,
), ),
child: Padding( ),
padding: const EdgeInsets.all(0.0), child: Padding(
child: StreamSvgIcon.close( padding: const EdgeInsets.all(0.0),
color: Colors.black, child: StreamSvgIcon.close(
size: 24, color: Colors.black,
), size: 24,
), ),
), ),
), ),
) ),
], )
],
),
SizedBox(height: 4),
Text(
user.name.split(' ')[0],
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 12,
), ),
SizedBox(height: 4), ),
Text( ],
user.name.split(' ')[0], );
style: TextStyle( },
fontWeight: FontWeight.bold,
fontSize: 12,
),
),
],
);
},
),
), ),
), ),
SliverPersistentHeader( ),
pinned: true, SliverPersistentHeader(
delegate: _HeaderDelegate( pinned: true,
height: 30, delegate: _HeaderDelegate(
child: Container( height: 30,
width: double.maxFinite, child: Container(
decoration: BoxDecoration( width: double.maxFinite,
gradient: LinearGradient( decoration: BoxDecoration(
begin: Alignment.centerLeft, gradient: LinearGradient(
end: Alignment.centerRight, begin: Alignment.centerLeft,
colors: [ end: Alignment.centerRight,
Colors.black.withOpacity(0.02), colors: [
Colors.white.withOpacity(0.05), Colors.black.withOpacity(0.02),
], Colors.white.withOpacity(0.05),
stops: [0, 1], ],
), stops: [0, 1],
), ),
child: Padding( ),
padding: const EdgeInsets.symmetric( child: Padding(
vertical: 8, padding: const EdgeInsets.symmetric(
horizontal: 8, vertical: 8,
), horizontal: 8,
child: Text( ),
_isSearchActive child: Text(
? 'Matches for \"$_userNameQuery\"' _isSearchActive
: 'On the platform', ? 'Matches for \"$_userNameQuery\"'
style: TextStyle( : 'On the platform',
color: Colors.black.withOpacity(0.5), style: TextStyle(
), color: Colors.black.withOpacity(0.5),
), ),
), ),
), ),
), ),
), ),
]; ),
}, ];
body: UserListView( },
body: UsersBloc(
child: UserListView(
selectedUsers: _selectedUsers, selectedUsers: _selectedUsers,
pullToRefresh: false, pullToRefresh: false,
groupAlphabetically: _isSearchActive ? false : true, groupAlphabetically: _isSearchActive ? false : true,