2024-01-03 22:10:07 +00:00
|
|
|
import 'package:cwtch/config.dart';
|
2021-06-24 23:10:45 +00:00
|
|
|
import 'package:cwtch/cwtch_icons_icons.dart';
|
2022-01-18 21:26:52 +00:00
|
|
|
import 'package:cwtch/models/appstate.dart';
|
|
|
|
import 'package:cwtch/models/contact.dart';
|
2022-02-07 22:53:33 +00:00
|
|
|
import 'package:cwtch/models/profile.dart';
|
2022-02-08 21:59:24 +00:00
|
|
|
import 'package:cwtch/widgets/profileimage.dart';
|
2021-06-24 23:10:45 +00:00
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:cwtch/widgets/buttontextfield.dart';
|
|
|
|
import 'package:cwtch/widgets/cwtchlabel.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:cwtch/settings.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
|
|
|
|
|
|
import '../main.dart';
|
2023-08-02 18:14:18 +00:00
|
|
|
import '../themes/opaque.dart';
|
2021-06-24 23:10:45 +00:00
|
|
|
|
|
|
|
/// Peer Settings View Provides way to Configure .
|
|
|
|
class PeerSettingsView extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_PeerSettingsViewState createState() => _PeerSettingsViewState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _PeerSettingsViewState extends State<PeerSettingsView> {
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
final ctrlrNick = TextEditingController(text: "");
|
2022-12-29 03:44:52 +00:00
|
|
|
ScrollController peerSettingsScrollController = ScrollController();
|
2021-06-24 23:10:45 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
final nickname = Provider.of<ContactInfoState>(context, listen: false).nickname;
|
|
|
|
if (nickname.isNotEmpty) {
|
|
|
|
ctrlrNick.text = nickname;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-02-04 22:19:02 +00:00
|
|
|
var handle = Provider.of<ContactInfoState>(context).nickname;
|
|
|
|
if (handle.isEmpty) {
|
|
|
|
handle = Provider.of<ContactInfoState>(context).onion;
|
|
|
|
}
|
2021-06-24 23:10:45 +00:00
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
2024-02-09 21:34:10 +00:00
|
|
|
title: Container(
|
|
|
|
height: Provider.of<Settings>(context).fontScaling * 24.0,
|
|
|
|
clipBehavior: Clip.hardEdge,
|
|
|
|
decoration: BoxDecoration(),
|
|
|
|
child: Text(handle + " " + AppLocalizations.of(context)!.conversationSettings)),
|
2021-06-24 23:10:45 +00:00
|
|
|
),
|
|
|
|
body: _buildSettingsList(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildSettingsList() {
|
|
|
|
return Consumer<Settings>(builder: (context, settings, child) {
|
|
|
|
return LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) {
|
2022-01-13 23:21:09 +00:00
|
|
|
String? acnCircuit = Provider.of<ContactInfoState>(context).acnCircuit;
|
|
|
|
|
2022-02-22 19:09:44 +00:00
|
|
|
Widget path = Text(Provider.of<ContactInfoState>(context).status);
|
2022-01-13 23:21:09 +00:00
|
|
|
|
|
|
|
if (acnCircuit != null) {
|
|
|
|
var hops = acnCircuit.split(",");
|
|
|
|
if (hops.length == 3) {
|
|
|
|
List<Widget> paths = hops.map((String countryCodeAndIp) {
|
|
|
|
var parts = countryCodeAndIp.split(":");
|
|
|
|
var country = parts[0];
|
|
|
|
var ip = parts[1];
|
|
|
|
return RichText(
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
text: TextSpan(
|
2022-01-17 20:29:13 +00:00
|
|
|
text: country,
|
2022-04-21 00:20:31 +00:00
|
|
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 10, fontFamily: "RobotoMono"),
|
2022-01-13 23:21:09 +00:00
|
|
|
children: [TextSpan(text: " ($ip)", style: TextStyle(fontSize: 8, fontWeight: FontWeight.normal))]));
|
|
|
|
}).toList(growable: true);
|
|
|
|
|
2022-01-17 20:24:48 +00:00
|
|
|
paths.add(RichText(text: TextSpan(text: AppLocalizations.of(context)!.labelTorNetwork, style: TextStyle(fontWeight: FontWeight.normal, fontSize: 8, fontFamily: "monospace"))));
|
2022-01-13 23:21:09 +00:00
|
|
|
|
|
|
|
path = Column(
|
|
|
|
children: paths,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-03 22:10:07 +00:00
|
|
|
List<Widget> evWidgets = Provider.of<ContactInfoState>(context, listen: false).contactEvents.map((ev) {
|
|
|
|
return ListTile(
|
|
|
|
title: Text(ev.summary, style: Provider.of<Settings>(context).scaleFonts(defaultTextStyle)),
|
|
|
|
subtitle: Text(ev.timestamp.toLocal().toIso8601String(), style: Provider.of<Settings>(context).scaleFonts(defaultTextStyle)),
|
|
|
|
);
|
|
|
|
}).toList();
|
|
|
|
|
2021-06-24 23:10:45 +00:00
|
|
|
return Scrollbar(
|
2022-12-29 03:44:52 +00:00
|
|
|
trackVisibility: true,
|
|
|
|
controller: peerSettingsScrollController,
|
2021-06-24 23:10:45 +00:00
|
|
|
child: SingleChildScrollView(
|
|
|
|
clipBehavior: Clip.antiAlias,
|
2022-12-29 03:44:52 +00:00
|
|
|
controller: peerSettingsScrollController,
|
2021-06-24 23:10:45 +00:00
|
|
|
child: ConstrainedBox(
|
|
|
|
constraints: BoxConstraints(
|
|
|
|
minHeight: viewportConstraints.maxHeight,
|
|
|
|
),
|
|
|
|
child: Container(
|
2024-03-20 19:34:26 +00:00
|
|
|
color: settings.theme.backgroundPaneColor,
|
|
|
|
padding: EdgeInsets.all(12),
|
2023-04-04 20:58:42 +00:00
|
|
|
child: Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [
|
|
|
|
Column(crossAxisAlignment: CrossAxisAlignment.center, children: [
|
2022-02-08 21:59:24 +00:00
|
|
|
ProfileImage(
|
|
|
|
imagePath: Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment)
|
|
|
|
? Provider.of<ContactInfoState>(context).imagePath
|
|
|
|
: Provider.of<ContactInfoState>(context).defaultImagePath,
|
|
|
|
diameter: 120,
|
|
|
|
maskOut: false,
|
|
|
|
border: settings.theme.portraitOnlineBorderColor,
|
|
|
|
badgeTextColor: settings.theme.portraitContactBadgeTextColor,
|
|
|
|
badgeColor: settings.theme.portraitContactBadgeColor,
|
2023-04-04 20:58:42 +00:00
|
|
|
badgeEdit: false),
|
|
|
|
SizedBox(
|
|
|
|
width: MediaQuery.of(context).size.width / 2,
|
|
|
|
child: Column(children: [
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.all(1),
|
2023-04-17 17:37:56 +00:00
|
|
|
child: SelectableText(
|
|
|
|
Provider.of<ContactInfoState>(context, listen: false).attributes[0] ?? "",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
2023-04-04 20:58:42 +00:00
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.all(1),
|
2023-04-17 17:37:56 +00:00
|
|
|
child: SelectableText(
|
|
|
|
Provider.of<ContactInfoState>(context, listen: false).attributes[1] ?? "",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
2023-04-04 20:58:42 +00:00
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.all(1),
|
2023-04-17 17:37:56 +00:00
|
|
|
child: SelectableText(
|
|
|
|
Provider.of<ContactInfoState>(context, listen: false).attributes[2] ?? "",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
2023-04-04 20:58:42 +00:00
|
|
|
)
|
|
|
|
]))
|
2022-02-08 21:59:24 +00:00
|
|
|
]),
|
|
|
|
|
2021-06-24 23:10:45 +00:00
|
|
|
Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
|
|
CwtchLabel(label: AppLocalizations.of(context)!.displayNameLabel),
|
|
|
|
SizedBox(
|
|
|
|
height: 20,
|
|
|
|
),
|
|
|
|
CwtchButtonTextField(
|
|
|
|
controller: ctrlrNick,
|
|
|
|
readonly: false,
|
|
|
|
onPressed: () {
|
|
|
|
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
2021-11-26 23:07:37 +00:00
|
|
|
var conversation = Provider.of<ContactInfoState>(context, listen: false).identifier;
|
2023-04-20 22:48:00 +00:00
|
|
|
Provider.of<ContactInfoState>(context, listen: false).localNickname = ctrlrNick.text;
|
2021-11-26 23:07:37 +00:00
|
|
|
Provider.of<FlwtchState>(context, listen: false).cwtch.SetConversationAttribute(profileOnion, conversation, "profile.name", ctrlrNick.text);
|
2021-06-24 23:10:45 +00:00
|
|
|
final snackBar = SnackBar(content: Text(AppLocalizations.of(context)!.nickChangeSuccess));
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
|
|
|
},
|
|
|
|
icon: Icon(Icons.save),
|
|
|
|
tooltip: AppLocalizations.of(context)!.saveBtn,
|
|
|
|
)
|
|
|
|
]),
|
|
|
|
|
|
|
|
// Address Copy Button
|
2022-11-23 19:53:48 +00:00
|
|
|
Visibility(
|
|
|
|
visible: settings.streamerMode == false,
|
|
|
|
child: Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
|
|
SizedBox(
|
|
|
|
height: 20,
|
|
|
|
),
|
|
|
|
CwtchLabel(label: AppLocalizations.of(context)!.addressLabel),
|
|
|
|
SizedBox(
|
|
|
|
height: 20,
|
|
|
|
),
|
|
|
|
CwtchButtonTextField(
|
|
|
|
controller: TextEditingController(text: Provider.of<ContactInfoState>(context, listen: false).onion),
|
|
|
|
onPressed: _copyOnion,
|
|
|
|
icon: Icon(CwtchIcons.address_copy),
|
|
|
|
tooltip: AppLocalizations.of(context)!.copyBtn,
|
|
|
|
)
|
|
|
|
])),
|
2021-06-24 23:10:45 +00:00
|
|
|
Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
|
|
SizedBox(
|
|
|
|
height: 20,
|
|
|
|
),
|
|
|
|
CwtchLabel(label: AppLocalizations.of(context)!.conversationSettings),
|
|
|
|
SizedBox(
|
|
|
|
height: 20,
|
|
|
|
),
|
2022-01-13 23:21:09 +00:00
|
|
|
ListTile(
|
|
|
|
leading: Icon(CwtchIcons.onion_on, color: settings.current().mainTextColor),
|
|
|
|
isThreeLine: true,
|
2022-01-17 20:24:48 +00:00
|
|
|
title: Text(AppLocalizations.of(context)!.labelACNCircuitInfo),
|
|
|
|
subtitle: Text(AppLocalizations.of(context)!.descriptionACNCircuitInfo),
|
2022-01-13 23:21:09 +00:00
|
|
|
trailing: path,
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 20,
|
|
|
|
),
|
2021-06-24 23:10:45 +00:00
|
|
|
SwitchListTile(
|
2021-12-10 04:22:55 +00:00
|
|
|
title: Text(AppLocalizations.of(context)!.blockBtn, style: TextStyle(color: settings.current().mainTextColor)),
|
2021-06-24 23:10:45 +00:00
|
|
|
value: Provider.of<ContactInfoState>(context).isBlocked,
|
|
|
|
onChanged: (bool blocked) {
|
2022-01-06 21:54:25 +00:00
|
|
|
Provider.of<ContactInfoState>(context, listen: false).blocked = blocked;
|
2021-06-24 23:10:45 +00:00
|
|
|
|
|
|
|
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
2022-01-06 21:54:25 +00:00
|
|
|
var identifier = Provider.of<ContactInfoState>(context, listen: false).identifier;
|
2021-06-24 23:10:45 +00:00
|
|
|
|
|
|
|
if (blocked) {
|
2022-01-06 21:54:25 +00:00
|
|
|
Provider.of<FlwtchState>(context, listen: false).cwtch.BlockContact(profileOnion, identifier);
|
2021-06-24 23:10:45 +00:00
|
|
|
} else {
|
2022-01-06 21:54:25 +00:00
|
|
|
Provider.of<FlwtchState>(context, listen: false).cwtch.UnblockContact(profileOnion, identifier);
|
2021-06-24 23:10:45 +00:00
|
|
|
}
|
|
|
|
},
|
2021-12-11 05:07:47 +00:00
|
|
|
activeTrackColor: settings.theme.defaultButtonColor,
|
2021-12-10 04:22:55 +00:00
|
|
|
inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
|
|
|
|
secondary: Icon(CwtchIcons.block_peer, color: settings.current().mainTextColor),
|
2021-06-24 23:10:45 +00:00
|
|
|
),
|
|
|
|
ListTile(
|
2021-12-10 04:22:55 +00:00
|
|
|
title: Text(AppLocalizations.of(context)!.savePeerHistory, style: TextStyle(color: settings.current().mainTextColor)),
|
2021-06-24 23:10:45 +00:00
|
|
|
subtitle: Text(AppLocalizations.of(context)!.savePeerHistoryDescription),
|
2021-12-10 04:22:55 +00:00
|
|
|
leading: Icon(CwtchIcons.peer_history, color: settings.current().mainTextColor),
|
2021-06-24 23:10:45 +00:00
|
|
|
trailing: DropdownButton(
|
2023-09-06 17:54:51 +00:00
|
|
|
value:
|
|
|
|
(Provider.of<ContactInfoState>(context).savePeerHistory == "DefaultDeleteHistory" || Provider.of<ContactInfoState>(context).savePeerHistory == "HistoryDefault")
|
|
|
|
? AppLocalizations.of(context)!.conversationNotificationPolicyDefault
|
|
|
|
: (Provider.of<ContactInfoState>(context).savePeerHistory == "SaveHistory"
|
|
|
|
? AppLocalizations.of(context)!.savePeerHistory
|
|
|
|
: AppLocalizations.of(context)!.dontSavePeerHistory),
|
2021-06-24 23:10:45 +00:00
|
|
|
onChanged: (newValue) {
|
|
|
|
setState(() {
|
|
|
|
// Set whether or not to dave the Contact History...
|
|
|
|
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
2022-01-07 14:52:58 +00:00
|
|
|
var identifier = Provider.of<ContactInfoState>(context, listen: false).identifier;
|
|
|
|
const SaveHistoryKey = "profile.SavePeerHistory";
|
|
|
|
const SaveHistory = "SaveHistory";
|
|
|
|
const DelHistory = "DeleteHistoryConfirmed";
|
2023-08-21 17:50:55 +00:00
|
|
|
const HistoryDefault = "HistoryDefault";
|
2021-06-24 23:10:45 +00:00
|
|
|
|
2023-08-21 17:50:55 +00:00
|
|
|
// NOTE: .savePeerHistory is used to show ephemeral warnings so it's state is important to update.
|
2023-09-06 17:54:51 +00:00
|
|
|
if (newValue == AppLocalizations.of(context)!.conversationNotificationPolicyDefault) {
|
2023-08-21 17:50:55 +00:00
|
|
|
Provider.of<ContactInfoState>(context, listen: false).savePeerHistory = HistoryDefault;
|
|
|
|
Provider.of<FlwtchState>(context, listen: false).cwtch.SetConversationAttribute(profileOnion, identifier, SaveHistoryKey, HistoryDefault);
|
|
|
|
} else if (newValue == AppLocalizations.of(context)!.savePeerHistory) {
|
2022-01-07 14:52:58 +00:00
|
|
|
Provider.of<ContactInfoState>(context, listen: false).savePeerHistory = SaveHistory;
|
|
|
|
Provider.of<FlwtchState>(context, listen: false).cwtch.SetConversationAttribute(profileOnion, identifier, SaveHistoryKey, SaveHistory);
|
2021-06-24 23:10:45 +00:00
|
|
|
} else {
|
2022-01-07 14:52:58 +00:00
|
|
|
Provider.of<ContactInfoState>(context, listen: false).savePeerHistory = DelHistory;
|
|
|
|
Provider.of<FlwtchState>(context, listen: false).cwtch.SetConversationAttribute(profileOnion, identifier, SaveHistoryKey, DelHistory);
|
2021-06-24 23:10:45 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2023-09-06 17:54:51 +00:00
|
|
|
items: [
|
|
|
|
AppLocalizations.of(context)!.conversationNotificationPolicyDefault,
|
|
|
|
AppLocalizations.of(context)!.savePeerHistory,
|
|
|
|
AppLocalizations.of(context)!.dontSavePeerHistory
|
|
|
|
].map<DropdownMenuItem<String>>((String value) {
|
2021-06-24 23:10:45 +00:00
|
|
|
return DropdownMenuItem<String>(
|
|
|
|
value: value,
|
2023-08-02 18:14:18 +00:00
|
|
|
child: Text(value, style: settings.scaleFonts(defaultDropDownMenuItemTextStyle)),
|
2021-06-24 23:10:45 +00:00
|
|
|
);
|
|
|
|
}).toList())),
|
2022-02-08 02:13:49 +00:00
|
|
|
ListTile(
|
2022-02-08 21:54:17 +00:00
|
|
|
title: Text(AppLocalizations.of(context)!.conversationNotificationPolicySettingLabel, style: TextStyle(color: settings.current().mainTextColor)),
|
|
|
|
subtitle: Text(AppLocalizations.of(context)!.conversationNotificationPolicySettingDescription),
|
2022-02-08 02:13:49 +00:00
|
|
|
leading: Icon(CwtchIcons.chat_bubble_empty_24px, color: settings.current().mainTextColor),
|
|
|
|
trailing: DropdownButton(
|
|
|
|
value: Provider.of<ContactInfoState>(context).notificationsPolicy,
|
|
|
|
items: ConversationNotificationPolicy.values.map<DropdownMenuItem<ConversationNotificationPolicy>>((ConversationNotificationPolicy value) {
|
|
|
|
return DropdownMenuItem<ConversationNotificationPolicy>(
|
|
|
|
value: value,
|
2023-08-02 18:14:18 +00:00
|
|
|
child: Text(value.toName(context), style: settings.scaleFonts(defaultDropDownMenuItemTextStyle)),
|
2022-02-08 02:13:49 +00:00
|
|
|
);
|
|
|
|
}).toList(),
|
|
|
|
onChanged: (ConversationNotificationPolicy? newVal) {
|
|
|
|
Provider.of<ContactInfoState>(context, listen: false).notificationsPolicy = newVal!;
|
2022-02-04 22:19:02 +00:00
|
|
|
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
|
|
|
var identifier = Provider.of<ContactInfoState>(context, listen: false).identifier;
|
2022-02-08 02:13:49 +00:00
|
|
|
const NotificationPolicyKey = "profile.notification-policy";
|
|
|
|
Provider.of<FlwtchState>(context, listen: false).cwtch.SetConversationAttribute(profileOnion, identifier, NotificationPolicyKey, newVal.toString());
|
2022-02-04 22:19:02 +00:00
|
|
|
},
|
2022-02-08 02:13:49 +00:00
|
|
|
)),
|
2021-06-24 23:10:45 +00:00
|
|
|
]),
|
|
|
|
Column(mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end, children: [
|
|
|
|
SizedBox(
|
|
|
|
height: 20,
|
|
|
|
),
|
|
|
|
Row(crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.end, children: [
|
|
|
|
Tooltip(
|
2021-08-27 20:46:13 +00:00
|
|
|
message: AppLocalizations.of(context)!.archiveConversation,
|
2021-06-24 23:10:45 +00:00
|
|
|
child: ElevatedButton.icon(
|
|
|
|
onPressed: () {
|
2021-08-27 20:46:13 +00:00
|
|
|
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
2021-11-18 23:44:54 +00:00
|
|
|
var handle = Provider.of<ContactInfoState>(context, listen: false).identifier;
|
2021-08-27 20:46:13 +00:00
|
|
|
// locally update cache...
|
|
|
|
Provider.of<ContactInfoState>(context, listen: false).isArchived = true;
|
|
|
|
Provider.of<FlwtchState>(context, listen: false).cwtch.ArchiveConversation(profileOnion, handle);
|
|
|
|
Future.delayed(Duration(milliseconds: 500), () {
|
|
|
|
Provider.of<AppState>(context, listen: false).selectedConversation = null;
|
|
|
|
Navigator.of(context).popUntil((route) => route.settings.name == "conversations"); // dismiss dialog
|
|
|
|
});
|
2021-06-24 23:10:45 +00:00
|
|
|
},
|
2022-02-07 22:53:33 +00:00
|
|
|
icon: Icon(Icons.archive),
|
2021-08-27 20:46:13 +00:00
|
|
|
label: Text(AppLocalizations.of(context)!.archiveConversation),
|
2021-06-24 23:10:45 +00:00
|
|
|
))
|
2022-02-07 22:53:33 +00:00
|
|
|
]),
|
|
|
|
SizedBox(
|
|
|
|
height: 20,
|
|
|
|
),
|
|
|
|
Row(crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.end, children: [
|
|
|
|
Tooltip(
|
|
|
|
message: AppLocalizations.of(context)!.leaveConversation,
|
|
|
|
child: TextButton.icon(
|
|
|
|
onPressed: () {
|
|
|
|
showAlertDialog(context);
|
|
|
|
},
|
2022-04-26 19:16:09 +00:00
|
|
|
style: ButtonStyle(
|
|
|
|
backgroundColor: MaterialStateProperty.all(Provider.of<Settings>(context).theme.backgroundPaneColor),
|
|
|
|
foregroundColor: MaterialStateProperty.all(Provider.of<Settings>(context).theme.mainTextColor)),
|
2022-02-07 22:53:33 +00:00
|
|
|
icon: Icon(CwtchIcons.leave_group),
|
|
|
|
label: Text(
|
|
|
|
AppLocalizations.of(context)!.leaveConversation,
|
2023-09-26 21:01:57 +00:00
|
|
|
style: settings.scaleFonts(defaultTextButtonStyle.copyWith(decoration: TextDecoration.underline)),
|
2022-02-07 22:53:33 +00:00
|
|
|
),
|
|
|
|
))
|
2024-01-03 22:10:07 +00:00
|
|
|
]),
|
|
|
|
]),
|
|
|
|
Visibility(
|
|
|
|
visible: EnvironmentConfig.BUILD_VER == dev_version,
|
|
|
|
maintainSize: false,
|
|
|
|
child: Column(
|
|
|
|
children: evWidgets,
|
|
|
|
))
|
2021-06-24 23:10:45 +00:00
|
|
|
])))));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void _copyOnion() {
|
|
|
|
Clipboard.setData(new ClipboardData(text: Provider.of<ContactInfoState>(context, listen: false).onion));
|
2022-03-02 19:28:43 +00:00
|
|
|
final snackBar = SnackBar(content: Text(AppLocalizations.of(context)!.copiedToClipboardNotification));
|
2021-06-24 23:10:45 +00:00
|
|
|
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
|
|
|
}
|
|
|
|
|
|
|
|
showAlertDialog(BuildContext context) {
|
|
|
|
// set up the buttons
|
2023-09-26 21:01:57 +00:00
|
|
|
Widget cancelButton = ElevatedButton(
|
2021-07-09 22:16:06 +00:00
|
|
|
child: Text(AppLocalizations.of(context)!.cancel),
|
2021-06-24 23:10:45 +00:00
|
|
|
style: ButtonStyle(padding: MaterialStateProperty.all(EdgeInsets.all(20))),
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pop(); // dismiss dialog
|
|
|
|
},
|
|
|
|
);
|
2021-08-27 18:28:04 +00:00
|
|
|
Widget continueButton = ElevatedButton(
|
2021-06-24 23:10:45 +00:00
|
|
|
style: ButtonStyle(padding: MaterialStateProperty.all(EdgeInsets.all(20))),
|
|
|
|
child: Text(AppLocalizations.of(context)!.yesLeave),
|
|
|
|
onPressed: () {
|
|
|
|
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
2022-02-07 22:53:33 +00:00
|
|
|
var identifier = Provider.of<ContactInfoState>(context, listen: false).identifier;
|
2021-08-27 20:46:13 +00:00
|
|
|
// locally update cache...
|
2022-02-07 22:53:33 +00:00
|
|
|
Provider.of<ProfileInfoState>(context, listen: false).contactList.removeContact(identifier);
|
|
|
|
Provider.of<FlwtchState>(context, listen: false).cwtch.DeleteContact(profileOnion, identifier);
|
2021-06-24 23:10:45 +00:00
|
|
|
Future.delayed(Duration(milliseconds: 500), () {
|
2021-07-08 20:28:30 +00:00
|
|
|
Provider.of<AppState>(context, listen: false).selectedConversation = null;
|
2021-06-24 23:10:45 +00:00
|
|
|
Navigator.of(context).popUntil((route) => route.settings.name == "conversations"); // dismiss dialog
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
// set up the AlertDialog
|
|
|
|
AlertDialog alert = AlertDialog(
|
|
|
|
title: Text(AppLocalizations.of(context)!.reallyLeaveThisGroupPrompt),
|
|
|
|
actions: [
|
|
|
|
cancelButton,
|
|
|
|
continueButton,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
|
|
|
// show the dialog
|
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return alert;
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|