|
@ -1,4 +1,5 @@ |
|
|
import 'package:Envelope/models/conversation_users.dart'; |
|
|
import 'package:Envelope/models/conversation_users.dart'; |
|
|
|
|
|
import 'package:Envelope/models/my_profile.dart'; |
|
|
import 'package:flutter/material.dart'; |
|
|
import 'package:flutter/material.dart'; |
|
|
import '/views/main/conversation_settings_user_list_item.dart'; |
|
|
import '/views/main/conversation_settings_user_list_item.dart'; |
|
|
import '/models/conversations.dart'; |
|
|
import '/models/conversations.dart'; |
|
@ -16,9 +17,8 @@ class ConversationSettings extends StatefulWidget { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class _ConversationSettingsState extends State<ConversationSettings> { |
|
|
class _ConversationSettingsState extends State<ConversationSettings> { |
|
|
final _formKey = GlobalKey<FormState>(); |
|
|
|
|
|
|
|
|
|
|
|
List<ConversationUser> users = []; |
|
|
List<ConversationUser> users = []; |
|
|
|
|
|
MyProfile? profile; |
|
|
|
|
|
|
|
|
TextEditingController nameController = TextEditingController(); |
|
|
TextEditingController nameController = TextEditingController(); |
|
|
|
|
|
|
|
@ -31,6 +31,7 @@ class _ConversationSettingsState extends State<ConversationSettings> { |
|
|
|
|
|
|
|
|
Future<void> getUsers() async { |
|
|
Future<void> getUsers() async { |
|
|
users = await getConversationUsers(widget.conversation); |
|
|
users = await getConversationUsers(widget.conversation); |
|
|
|
|
|
profile = await MyProfile.getProfile(); |
|
|
setState(() {}); |
|
|
setState(() {}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -50,7 +51,101 @@ class _ConversationSettingsState extends State<ConversationSettings> { |
|
|
fontWeight: FontWeight.w500, |
|
|
fontWeight: FontWeight.w500, |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
], |
|
|
|
|
|
|
|
|
widget.conversation.admin ? IconButton( |
|
|
|
|
|
iconSize: 20, |
|
|
|
|
|
icon: const Icon(Icons.edit), |
|
|
|
|
|
padding: const EdgeInsets.all(5.0), |
|
|
|
|
|
splashRadius: 25, |
|
|
|
|
|
onPressed: () { |
|
|
|
|
|
// TODO: Redirect to edit screen |
|
|
|
|
|
}, |
|
|
|
|
|
) : const SizedBox.shrink(), |
|
|
|
|
|
], |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Widget sectionTitle(String title) { |
|
|
|
|
|
return Align( |
|
|
|
|
|
alignment: Alignment.centerLeft, |
|
|
|
|
|
child: Container( |
|
|
|
|
|
padding: const EdgeInsets.only(left: 12), |
|
|
|
|
|
child: Text( |
|
|
|
|
|
title, |
|
|
|
|
|
style: const TextStyle(fontSize: 20), |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Widget settings() { |
|
|
|
|
|
return Align( |
|
|
|
|
|
alignment: Alignment.centerLeft, |
|
|
|
|
|
child: Column( |
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch, |
|
|
|
|
|
children: [ |
|
|
|
|
|
const SizedBox(height: 5), |
|
|
|
|
|
TextButton.icon( |
|
|
|
|
|
label: const Text( |
|
|
|
|
|
'Disappearing Messages', |
|
|
|
|
|
style: TextStyle(fontSize: 16) |
|
|
|
|
|
), |
|
|
|
|
|
icon: const Icon(Icons.timer), |
|
|
|
|
|
style: ButtonStyle( |
|
|
|
|
|
alignment: Alignment.centerLeft, |
|
|
|
|
|
foregroundColor: MaterialStateProperty.resolveWith<Color>( |
|
|
|
|
|
(Set<MaterialState> states) { |
|
|
|
|
|
return Theme.of(context).colorScheme.onBackground; |
|
|
|
|
|
}, |
|
|
|
|
|
) |
|
|
|
|
|
), |
|
|
|
|
|
onPressed: () { |
|
|
|
|
|
print('Disappearing Messages'); |
|
|
|
|
|
} |
|
|
|
|
|
), |
|
|
|
|
|
TextButton.icon( |
|
|
|
|
|
label: const Text( |
|
|
|
|
|
'Permissions', |
|
|
|
|
|
style: TextStyle(fontSize: 16) |
|
|
|
|
|
), |
|
|
|
|
|
icon: const Icon(Icons.lock), |
|
|
|
|
|
style: ButtonStyle( |
|
|
|
|
|
alignment: Alignment.centerLeft, |
|
|
|
|
|
foregroundColor: MaterialStateProperty.resolveWith<Color>( |
|
|
|
|
|
(Set<MaterialState> states) { |
|
|
|
|
|
return Theme.of(context).colorScheme.onBackground; |
|
|
|
|
|
}, |
|
|
|
|
|
) |
|
|
|
|
|
), |
|
|
|
|
|
onPressed: () { |
|
|
|
|
|
print('Permissions'); |
|
|
|
|
|
} |
|
|
|
|
|
), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Widget myAccess() { |
|
|
|
|
|
return Align( |
|
|
|
|
|
alignment: Alignment.centerLeft, |
|
|
|
|
|
child: Column( |
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch, |
|
|
|
|
|
children: [ |
|
|
|
|
|
TextButton.icon( |
|
|
|
|
|
label: const Text( |
|
|
|
|
|
'Leave Conversation', |
|
|
|
|
|
style: TextStyle(fontSize: 16) |
|
|
|
|
|
), |
|
|
|
|
|
icon: const Icon(Icons.exit_to_app), |
|
|
|
|
|
style: const ButtonStyle( |
|
|
|
|
|
alignment: Alignment.centerLeft, |
|
|
|
|
|
), |
|
|
|
|
|
onPressed: () { |
|
|
|
|
|
print('Leave Group'); |
|
|
|
|
|
} |
|
|
|
|
|
), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -58,11 +153,12 @@ class _ConversationSettingsState extends State<ConversationSettings> { |
|
|
return ListView.builder( |
|
|
return ListView.builder( |
|
|
itemCount: users.length, |
|
|
itemCount: users.length, |
|
|
shrinkWrap: true, |
|
|
shrinkWrap: true, |
|
|
padding: const EdgeInsets.only(top: 16), |
|
|
|
|
|
|
|
|
padding: const EdgeInsets.only(top: 5, bottom: 0), |
|
|
itemBuilder: (context, i) { |
|
|
itemBuilder: (context, i) { |
|
|
return ConversationSettingsUserListItem( |
|
|
return ConversationSettingsUserListItem( |
|
|
user: users[i], |
|
|
user: users[i], |
|
|
isAdmin: widget.conversation.admin, |
|
|
isAdmin: widget.conversation.admin, |
|
|
|
|
|
profile: profile!, // TODO: Fix this |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
@ -112,9 +208,20 @@ class _ConversationSettingsState extends State<ConversationSettings> { |
|
|
children: <Widget> [ |
|
|
children: <Widget> [ |
|
|
const SizedBox(height: 30), |
|
|
const SizedBox(height: 30), |
|
|
conversationName(), |
|
|
conversationName(), |
|
|
const SizedBox(height: 10), |
|
|
|
|
|
const Text('Users', style: TextStyle(fontSize: 20)), |
|
|
|
|
|
|
|
|
const SizedBox(height: 25), |
|
|
|
|
|
widget.conversation.admin ? |
|
|
|
|
|
sectionTitle('Settings') : |
|
|
|
|
|
const SizedBox.shrink(), |
|
|
|
|
|
widget.conversation.admin ? |
|
|
|
|
|
settings() : |
|
|
|
|
|
const SizedBox.shrink(), |
|
|
|
|
|
widget.conversation.admin ? |
|
|
|
|
|
const SizedBox(height: 25) : |
|
|
|
|
|
const SizedBox.shrink(), |
|
|
|
|
|
sectionTitle('Members'), |
|
|
usersList(), |
|
|
usersList(), |
|
|
|
|
|
const SizedBox(height: 25), |
|
|
|
|
|
myAccess(), |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|