Create and Leave Groups / Conversations Pane Cleanup
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
This commit is contained in:
parent
b35ddd145f
commit
0136795107
|
@ -178,6 +178,17 @@ class MainActivity: FlutterActivity() {
|
||||||
val value = (call.argument("value") as? String) ?: "";
|
val value = (call.argument("value") as? String) ?: "";
|
||||||
Cwtch.setGroupAttribute(profile, groupHandle, key, value);
|
Cwtch.setGroupAttribute(profile, groupHandle, key, value);
|
||||||
}
|
}
|
||||||
|
"CreateGroup" -> {
|
||||||
|
val profile = (call.argument("ProfileOnion") as? String) ?: "";
|
||||||
|
val server = (call.argument("server") as? String) ?: "";
|
||||||
|
val groupName = (call.argument("groupname") as? String) ?: "";
|
||||||
|
Cwtch.createGroup(profile, server, groupName);
|
||||||
|
}
|
||||||
|
"LeaveGroup" -> {
|
||||||
|
val profile = (call.argument("ProfileOnion") as? String) ?: "";
|
||||||
|
val groupHandle = (call.argument("groupHandle") as? String) ?: "";
|
||||||
|
Cwtch.leaveGroup(profile, groupHandle);
|
||||||
|
}
|
||||||
"RejectInvite" -> {
|
"RejectInvite" -> {
|
||||||
val profile = (call.argument("ProfileOnion") as? String) ?: "";
|
val profile = (call.argument("ProfileOnion") as? String) ?: "";
|
||||||
val groupHandle = (call.argument("groupHandle") as? String) ?: "";
|
val groupHandle = (call.argument("groupHandle") as? String) ?: "";
|
||||||
|
|
|
@ -44,6 +44,11 @@ abstract class Cwtch {
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void SendInvitation(String profile, String handle, String target);
|
void SendInvitation(String profile, String handle, String target);
|
||||||
|
|
||||||
|
// ignore: non_constant_identifier_names
|
||||||
|
void CreateGroup(String profile, String server, String groupName);
|
||||||
|
// ignore: non_constant_identifier_names
|
||||||
|
void LeaveGroup(String profile, String groupID);
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void ImportBundle(String profile, String bundle);
|
void ImportBundle(String profile, String bundle);
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
|
|
|
@ -48,6 +48,16 @@ class CwtchNotifier {
|
||||||
lastMessageTime: DateTime.now(), //show at the top of the contact list even if no messages yet
|
lastMessageTime: DateTime.now(), //show at the top of the contact list even if no messages yet
|
||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
|
case "GroupCreated":
|
||||||
|
if (profileCN.getProfile(data["ProfileOnion"]).contactList.getContact(data["GroupID"]) == null) {
|
||||||
|
profileCN.getProfile(data["ProfileOnion"]).contactList.add(ContactInfoState(data["ProfileOnion"], data["GroupID"],
|
||||||
|
isInvitation: false, imagePath: data["PicturePath"], nickname: data["GroupName"], server: data["GroupServer"], isGroup: true, lastMessageTime: DateTime.now()));
|
||||||
|
profileCN.getProfile(data["ProfileOnion"]).contactList.updateLastMessageTime(data["GroupID"], DateTime.now());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "DeleteGroup":
|
||||||
|
profileCN.getProfile(data["ProfileOnion"]).contactList.removeContact(data["GroupID"]);
|
||||||
|
break;
|
||||||
case "PeerStateChange":
|
case "PeerStateChange":
|
||||||
ContactInfoState? contact = profileCN.getProfile(data["ProfileOnion"]).contactList.getContact(data["RemotePeer"]);
|
ContactInfoState? contact = profileCN.getProfile(data["ProfileOnion"]).contactList.getContact(data["RemotePeer"]);
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
|
@ -144,7 +154,7 @@ class CwtchNotifier {
|
||||||
if (data["Key"] == "public.name") {
|
if (data["Key"] == "public.name") {
|
||||||
profileCN.getProfile(data["ProfileOnion"]).nickname = data["Data"];
|
profileCN.getProfile(data["ProfileOnion"]).nickname = data["Data"];
|
||||||
} else {
|
} else {
|
||||||
print("unhandled set attribute event: $type");
|
print("unhandled set attribute event: $type $data");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "NetworkError":
|
case "NetworkError":
|
||||||
|
@ -186,9 +196,17 @@ class CwtchNotifier {
|
||||||
});
|
});
|
||||||
profileCN.getProfile(data["ProfileOnion"]).contactList.resort();
|
profileCN.getProfile(data["ProfileOnion"]).contactList.resort();
|
||||||
break;
|
break;
|
||||||
|
case "SetGroupAttribute":
|
||||||
|
if (data["Key"] == "local.name") {
|
||||||
|
if (profileCN.getProfile(data["ProfileOnion"]).contactList.getContact(data["GroupID"]) != null) {
|
||||||
|
profileCN.getProfile(data["ProfileOnion"]).contactList.getContact(data["GroupID"])!.nickname = data["Data"];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print("unhandled set group attribute event: $type $data");
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
print("unhandled event: $type");
|
print("unhandled event: $type $data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -356,4 +356,26 @@ class CwtchFfi implements Cwtch {
|
||||||
final u2 = groupHandle.toNativeUtf8();
|
final u2 = groupHandle.toNativeUtf8();
|
||||||
RejectInvite(u1, u1.length, u2, u2.length);
|
RejectInvite(u1, u1.length, u2, u2.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void CreateGroup(String profileOnion, String server, String groupName) {
|
||||||
|
var createGroup = library.lookup<NativeFunction<void_from_string_string_string_function>>("c_CreateGroup");
|
||||||
|
// ignore: non_constant_identifier_names
|
||||||
|
final CreateGroup = createGroup.asFunction<VoidFromStringStringStringFn>();
|
||||||
|
final u1 = profileOnion.toNativeUtf8();
|
||||||
|
final u2 = server.toNativeUtf8();
|
||||||
|
final u3 = groupName.toNativeUtf8();
|
||||||
|
CreateGroup(u1, u1.length, u2, u2.length, u3, u3.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
// ignore: non_constant_identifier_names
|
||||||
|
void LeaveGroup(String profileOnion, String groupHandle) {
|
||||||
|
var leaveGroup = library.lookup<NativeFunction<string_string_to_void_function>>("c_LeaveGroup");
|
||||||
|
// ignore: non_constant_identifier_names
|
||||||
|
final RejectInvite = leaveGroup.asFunction<VoidFromStringStringFn>();
|
||||||
|
final u1 = profileOnion.toNativeUtf8();
|
||||||
|
final u2 = groupHandle.toNativeUtf8();
|
||||||
|
RejectInvite(u1, u1.length, u2, u2.length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,4 +172,15 @@ class CwtchGomobile implements Cwtch {
|
||||||
void RejectInvite(String profileOnion, String groupHandle) {
|
void RejectInvite(String profileOnion, String groupHandle) {
|
||||||
cwtchPlatform.invokeMethod("RejectInvite", {"ProfileOnion": profileOnion, "handle": groupHandle});
|
cwtchPlatform.invokeMethod("RejectInvite", {"ProfileOnion": profileOnion, "handle": groupHandle});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void CreateGroup(String profileOnion, String server, String groupName) {
|
||||||
|
cwtchPlatform.invokeMethod("CreateGroup", {"ProfileOnion": profileOnion, "server": server, "groupName": groupName});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
// ignore: non_constant_identifier_names
|
||||||
|
void LeaveGroup(String profileOnion, String groupHandle) {
|
||||||
|
cwtchPlatform.invokeMethod("LeaveGroup", {"ProfileOnion": profileOnion, "handle": groupHandle});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,13 @@ class ContactListState extends ChangeNotifier {
|
||||||
int idx = _contacts.indexWhere((element) => element.onion == onion);
|
int idx = _contacts.indexWhere((element) => element.onion == onion);
|
||||||
return idx >= 0 ? _contacts[idx] : null;
|
return idx >= 0 ? _contacts[idx] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void removeContact(String onion) {
|
||||||
|
int idx = _contacts.indexWhere((element) => element.onion == onion);
|
||||||
|
if (idx >= 0) {
|
||||||
|
_contacts.removeAt(idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProfileInfoState extends ChangeNotifier {
|
class ProfileInfoState extends ChangeNotifier {
|
||||||
|
|
|
@ -1383,6 +1383,7 @@ ThemeData mkThemeData(Settings opaque) {
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
tabBarTheme: TabBarTheme(indicator: UnderlineTabIndicator(borderSide: BorderSide(color: opaque.current().defaultButtonActiveColor()))),
|
||||||
dialogTheme: DialogTheme(
|
dialogTheme: DialogTheme(
|
||||||
backgroundColor: opaque.current().backgroundPaneColor(),
|
backgroundColor: opaque.current().backgroundPaneColor(),
|
||||||
titleTextStyle: TextStyle(color: opaque.current().mainTextColor()),
|
titleTextStyle: TextStyle(color: opaque.current().mainTextColor()),
|
||||||
|
|
|
@ -26,7 +26,6 @@ class AddContactView extends StatefulWidget {
|
||||||
class _AddContactViewState extends State<AddContactView> {
|
class _AddContactViewState extends State<AddContactView> {
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
final _createGroupFormKey = GlobalKey<FormState>();
|
final _createGroupFormKey = GlobalKey<FormState>();
|
||||||
final _joinGroupFormKey = GlobalKey<FormState>();
|
|
||||||
final ctrlrOnion = TextEditingController(text: "");
|
final ctrlrOnion = TextEditingController(text: "");
|
||||||
final ctrlrContact = TextEditingController(text: "");
|
final ctrlrContact = TextEditingController(text: "");
|
||||||
final ctrlrGroupName = TextEditingController(text: "");
|
final ctrlrGroupName = TextEditingController(text: "");
|
||||||
|
@ -34,6 +33,11 @@ class _AddContactViewState extends State<AddContactView> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
// if we haven't picked a server yet, pick the first one in the list...
|
||||||
|
if (server.isEmpty) {
|
||||||
|
server = Provider.of<ProfileInfoState>(context).serverList.servers.first.onion;
|
||||||
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(AppLocalizations.of(context)!.titleManageContacts),
|
title: Text(AppLocalizations.of(context)!.titleManageContacts),
|
||||||
|
@ -49,12 +53,17 @@ class _AddContactViewState extends State<AddContactView> {
|
||||||
bool groupsEnabled = Provider.of<Settings>(context).experimentsEnabled && Provider.of<Settings>(context).experiments[TapirGroupsExperiment]!;
|
bool groupsEnabled = Provider.of<Settings>(context).experimentsEnabled && Provider.of<Settings>(context).experiments[TapirGroupsExperiment]!;
|
||||||
return Consumer<ErrorHandler>(builder: (context, globalErrorHandler, child) {
|
return Consumer<ErrorHandler>(builder: (context, globalErrorHandler, child) {
|
||||||
return DefaultTabController(
|
return DefaultTabController(
|
||||||
length: groupsEnabled ? 4 : 1,
|
length: groupsEnabled ? 2 : 1,
|
||||||
child: Column(children: [
|
child: Column(children: [
|
||||||
(groupsEnabled ? getTabBarWithGroups() : getTabBarWithAddPeerOnly()),
|
(groupsEnabled ? getTabBarWithGroups() : getTabBarWithAddPeerOnly()),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
children: (groupsEnabled ? [addPeerTab(), manageServersTab(), addGroupTab(), joinGroupTab()] : [addPeerTab()]),
|
children: (groupsEnabled
|
||||||
|
? [
|
||||||
|
addPeerTab(),
|
||||||
|
addGroupTab(),
|
||||||
|
]
|
||||||
|
: [addPeerTab()]),
|
||||||
)),
|
)),
|
||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
|
@ -84,11 +93,10 @@ class _AddContactViewState extends State<AddContactView> {
|
||||||
tabs: [
|
tabs: [
|
||||||
Tab(
|
Tab(
|
||||||
icon: Icon(Icons.person_add_rounded),
|
icon: Icon(Icons.person_add_rounded),
|
||||||
text: AppLocalizations.of(context)!.addPeer,
|
text: AppLocalizations.of(context)!.tooltipAddContact,
|
||||||
),
|
),
|
||||||
Tab(icon: Icon(Icons.backup), text: AppLocalizations.of(context)!.titleManageServers),
|
//Tab(icon: Icon(Icons.backup), text: AppLocalizations.of(context)!.titleManageServers),
|
||||||
Tab(icon: Icon(Icons.group), text: AppLocalizations.of(context)!.createGroup),
|
Tab(icon: Icon(Icons.group), text: AppLocalizations.of(context)!.createGroup),
|
||||||
Tab(icon: Icon(Icons.group_add), text: AppLocalizations.of(context)!.joinGroup),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -133,18 +141,13 @@ class _AddContactViewState extends State<AddContactView> {
|
||||||
} else if (globalErrorHandler.explicitAddContactSuccess) {}
|
} else if (globalErrorHandler.explicitAddContactSuccess) {}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
onChanged: (String peerAddr) async {
|
onChanged: (String importBundle) async {
|
||||||
var profileOnion = Provider.of<ProfileInfoState>(context, listen: false).onion;
|
var profileOnion = Provider.of<ProfileInfoState>(context, listen: false).onion;
|
||||||
final setPeerAttribute = {
|
Provider.of<FlwtchState>(context, listen: false).cwtch.ImportBundle(profileOnion, importBundle);
|
||||||
"EventType": "AddContact",
|
|
||||||
"Data": {"ImportString": peerAddr},
|
|
||||||
};
|
|
||||||
final setPeerAttributeJson = jsonEncode(setPeerAttribute);
|
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.SendProfileEvent(profileOnion, setPeerAttributeJson);
|
|
||||||
|
|
||||||
Future.delayed(const Duration(milliseconds: 500), () {
|
Future.delayed(const Duration(milliseconds: 500), () {
|
||||||
if (globalErrorHandler.explicitAddContactSuccess) {
|
if (globalErrorHandler.importBundleSuccess) {
|
||||||
final snackBar = SnackBar(content: Text(AppLocalizations.of(context)!.successfullAddedContact + peerAddr));
|
final snackBar = SnackBar(content: Text(AppLocalizations.of(context)!.successfullAddedContact + importBundle));
|
||||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
}
|
}
|
||||||
|
@ -162,11 +165,6 @@ class _AddContactViewState extends State<AddContactView> {
|
||||||
return Text("You need to add a server before you can create a group.");
|
return Text("You need to add a server before you can create a group.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we haven't picked a server yet, pick the first one in the list...
|
|
||||||
if (server.isEmpty) {
|
|
||||||
server = Provider.of<ProfileInfoState>(context).serverList.servers.first.onion;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
margin: EdgeInsets.all(30),
|
margin: EdgeInsets.all(30),
|
||||||
padding: EdgeInsets.all(20),
|
padding: EdgeInsets.all(20),
|
||||||
|
@ -182,14 +180,20 @@ class _AddContactViewState extends State<AddContactView> {
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
DropdownButton(
|
DropdownButton(
|
||||||
onChanged: (newServer) {
|
onChanged: (String? newServer) {
|
||||||
server = newServer.toString();
|
setState(() {
|
||||||
|
server = newServer!;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
isExpanded: true, // magic property
|
||||||
value: server,
|
value: server,
|
||||||
items: Provider.of<ProfileInfoState>(context).serverList.servers.map<DropdownMenuItem<String>>((ServerInfoState serverInfo) {
|
items: Provider.of<ProfileInfoState>(context).serverList.servers.map<DropdownMenuItem<String>>((ServerInfoState serverInfo) {
|
||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
value: serverInfo.onion,
|
value: serverInfo.onion,
|
||||||
child: Text(serverInfo.onion),
|
child: Text(
|
||||||
|
serverInfo.onion,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}).toList()),
|
}).toList()),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
@ -209,54 +213,21 @@ class _AddContactViewState extends State<AddContactView> {
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {},
|
onPressed: () {
|
||||||
|
var profileOnion = Provider.of<ProfileInfoState>(context, listen: false).onion;
|
||||||
|
Provider.of<FlwtchState>(context, listen: false).cwtch.CreateGroup(profileOnion, server, ctrlrGroupName.text);
|
||||||
|
Future.delayed(const Duration(milliseconds: 500), () {
|
||||||
|
final snackBar = SnackBar(content: Text(AppLocalizations.of(context)!.successfullAddedContact + " " + ctrlrGroupName.text));
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||||
|
Navigator.pop(context);
|
||||||
|
});
|
||||||
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.createGroupBtn),
|
child: Text(AppLocalizations.of(context)!.createGroupBtn),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TODO Join Group Pane
|
|
||||||
Widget joinGroupTab() {
|
|
||||||
return Container(
|
|
||||||
margin: EdgeInsets.all(30),
|
|
||||||
padding: EdgeInsets.all(20),
|
|
||||||
child: Form(
|
|
||||||
autovalidateMode: AutovalidateMode.always,
|
|
||||||
key: _joinGroupFormKey,
|
|
||||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
||||||
CwtchLabel(label: AppLocalizations.of(context)!.joinGroupTab),
|
|
||||||
SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
CwtchTextField(
|
|
||||||
controller: ctrlrContact,
|
|
||||||
validator: (value) {
|
|
||||||
if (value == "") {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (globalErrorHandler.importBundleError) {
|
|
||||||
return AppLocalizations.of(context)!.invalidImportString;
|
|
||||||
} else if (globalErrorHandler.importBundleSuccess) {}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
onChanged: (String importBundle) async {
|
|
||||||
var profileOnion = Provider.of<ProfileInfoState>(context, listen: false).onion;
|
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.ImportBundle(profileOnion, importBundle);
|
|
||||||
|
|
||||||
Future.delayed(const Duration(milliseconds: 500), () {
|
|
||||||
if (globalErrorHandler.importBundleSuccess) {
|
|
||||||
final snackBar = SnackBar(content: Text(AppLocalizations.of(context)!.successfullAddedContact + importBundle));
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
|
||||||
Navigator.pop(context);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
labelText: '',
|
|
||||||
)
|
|
||||||
])));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// TODO Manage Servers Tab
|
/// TODO Manage Servers Tab
|
||||||
Widget manageServersTab() {
|
Widget manageServersTab() {
|
||||||
final tiles = Provider.of<ProfileInfoState>(context).serverList.servers.map((ServerInfoState server) {
|
final tiles = Provider.of<ProfileInfoState>(context).serverList.servers.map((ServerInfoState server) {
|
||||||
|
|
|
@ -129,6 +129,21 @@ class _GroupSettingsViewState extends State<GroupSettingsView> {
|
||||||
),
|
),
|
||||||
// TODO
|
// TODO
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.end, children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Tooltip(
|
||||||
|
message: AppLocalizations.of(context)!.rejectGroupBtn,
|
||||||
|
child: ElevatedButton.icon(
|
||||||
|
onPressed: () {
|
||||||
|
showAlertDialog(context);
|
||||||
|
},
|
||||||
|
icon: Icon(Icons.delete),
|
||||||
|
label: Text(AppLocalizations.of(context)!.deleteBtn),
|
||||||
|
))
|
||||||
|
])
|
||||||
])))));
|
])))));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -139,4 +154,44 @@ class _GroupSettingsViewState extends State<GroupSettingsView> {
|
||||||
final snackBar = SnackBar(content: Text(AppLocalizations.of(context)!.copiedClipboardNotification));
|
final snackBar = SnackBar(content: Text(AppLocalizations.of(context)!.copiedClipboardNotification));
|
||||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showAlertDialog(BuildContext context) {
|
||||||
|
// set up the buttons
|
||||||
|
Widget cancelButton = TextButton(
|
||||||
|
child: Text("Cancel"),
|
||||||
|
style: ButtonStyle(padding: MaterialStateProperty.all(EdgeInsets.all(20))),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop(); // dismiss dialog
|
||||||
|
},
|
||||||
|
);
|
||||||
|
Widget continueButton = TextButton(
|
||||||
|
style: ButtonStyle(padding: MaterialStateProperty.all(EdgeInsets.all(20))),
|
||||||
|
child: Text(AppLocalizations.of(context)!.deleteProfileConfirmBtn),
|
||||||
|
onPressed: () {
|
||||||
|
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
||||||
|
var handle = Provider.of<ContactInfoState>(context, listen: false).onion;
|
||||||
|
Provider.of<FlwtchState>(context, listen: false).cwtch.LeaveGroup(profileOnion, handle);
|
||||||
|
Future.delayed(Duration(milliseconds: 500), () {
|
||||||
|
Navigator.of(context).popUntil((route) => route.settings.name == "conversations"); // dismiss dialog
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// set up the AlertDialog
|
||||||
|
AlertDialog alert = AlertDialog(
|
||||||
|
title: Text(AppLocalizations.of(context)!.deleteProfileConfirmBtn),
|
||||||
|
actions: [
|
||||||
|
cancelButton,
|
||||||
|
continueButton,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
// show the dialog
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return alert;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,7 @@ class _ProfileRowState extends State<ProfileRow> {
|
||||||
void _pushContactList(ProfileInfoState profile, bool includeDoublePane) {
|
void _pushContactList(ProfileInfoState profile, bool includeDoublePane) {
|
||||||
Navigator.of(context).push(
|
Navigator.of(context).push(
|
||||||
MaterialPageRoute<void>(
|
MaterialPageRoute<void>(
|
||||||
|
settings: RouteSettings(name: "conversations"),
|
||||||
builder: (BuildContext buildcontext) {
|
builder: (BuildContext buildcontext) {
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
|
|
Loading…
Reference in New Issue