UI Updates to new Cwtch API
continuous-integration/drone/pr Build is pending Details

This commit is contained in:
Sarah Jamie Lewis 2021-11-25 15:59:54 -08:00
parent 1d6b533df3
commit 880c1c107b
17 changed files with 369 additions and 415 deletions

View File

@ -23,7 +23,8 @@ class CwtchNotifier {
late AppState appState; late AppState appState;
late ServerListState serverListState; late ServerListState serverListState;
CwtchNotifier(ProfileListState pcn, Settings settingsCN, ErrorHandler errorCN, TorStatus torStatusCN, NotificationsManager notificationManagerP, AppState appStateCN, ServerListState serverListStateCN) { CwtchNotifier(
ProfileListState pcn, Settings settingsCN, ErrorHandler errorCN, TorStatus torStatusCN, NotificationsManager notificationManagerP, AppState appStateCN, ServerListState serverListStateCN) {
profileCN = pcn; profileCN = pcn;
settings = settingsCN; settings = settingsCN;
error = errorCN; error = errorCN;
@ -51,7 +52,7 @@ class CwtchNotifier {
EnvironmentConfig.debugLog("NewServer $data"); EnvironmentConfig.debugLog("NewServer $data");
profileCN.getProfile(data["ProfileOnion"])?.contactList.add(ContactInfoState( profileCN.getProfile(data["ProfileOnion"])?.contactList.add(ContactInfoState(
data["ProfileOnion"], data["ProfileOnion"],
data["ConversationID"], int.parse(data["ConversationID"]),
data["RemotePeer"], data["RemotePeer"],
nickname: data["nick"], nickname: data["nick"],
status: data["status"], status: data["status"],
@ -68,13 +69,7 @@ class CwtchNotifier {
break; break;
case "NewServer": case "NewServer":
EnvironmentConfig.debugLog("NewServer $data"); EnvironmentConfig.debugLog("NewServer $data");
serverListState.add( serverListState.add(data["Onion"], data["ServerBundle"], data["Running"] == "true", data["Description"], data["Autostart"] == "true", data["StorageType"] == "storage-password");
data["Onion"],
data["ServerBundle"],
data["Running"] == "true",
data["Description"],
data["Autostart"] == "true",
data["StorageType"] == "storage-password");
break; break;
case "ServerIntentUpdate": case "ServerIntentUpdate":
EnvironmentConfig.debugLog("ServerIntentUpdate $data"); EnvironmentConfig.debugLog("ServerIntentUpdate $data");
@ -207,7 +202,7 @@ class CwtchNotifier {
// For now we perform some minimal checks on the sent timestamp to use to provide a useful ordering for honest contacts // For now we perform some minimal checks on the sent timestamp to use to provide a useful ordering for honest contacts
// and ensure that malicious contacts in groups can only set this timestamp to a value within the range of `last seen message time` // and ensure that malicious contacts in groups can only set this timestamp to a value within the range of `last seen message time`
// and `local now`. // and `local now`.
profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(data["GroupID"], timestampSent.toLocal()); profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(identifier, timestampSent.toLocal());
notificationManager.notify("New Message From Group!"); notificationManager.notify("New Message From Group!");
} }
} else { } else {
@ -271,8 +266,8 @@ class CwtchNotifier {
case "UpdateGlobalSettings": case "UpdateGlobalSettings":
settings.handleUpdate(jsonDecode(data["Data"])); settings.handleUpdate(jsonDecode(data["Data"]));
break; break;
case "SetAttribute": case "UpdatedProfileAttribute":
if (data["Key"] == "public.name") { if (data["Key"] == "public.profile.name") {
profileCN.getProfile(data["ProfileOnion"])?.nickname = data["Data"]; profileCN.getProfile(data["ProfileOnion"])?.nickname = data["Data"];
} else { } else {
EnvironmentConfig.debugLog("unhandled set attribute event: ${data['Key']}"); EnvironmentConfig.debugLog("unhandled set attribute event: ${data['Key']}");

View File

@ -66,7 +66,13 @@ typedef get_json_blob_from_str_int_int_function = Pointer<Utf8> Function(Pointer
typedef GetJsonBlobFromStrIntIntFn = Pointer<Utf8> Function(Pointer<Utf8>, int, int, int); typedef GetJsonBlobFromStrIntIntFn = Pointer<Utf8> Function(Pointer<Utf8>, int, int, int);
typedef get_json_blob_from_str_int_string_function = Pointer<Utf8> Function(Pointer<Utf8>, Int32, Int32, Pointer<Utf8>, Int32); typedef get_json_blob_from_str_int_string_function = Pointer<Utf8> Function(Pointer<Utf8>, Int32, Int32, Pointer<Utf8>, Int32);
typedef GetJsonBlobFromStrIntStringFn = Pointer<Utf8> Function(Pointer<Utf8>, int, int, Pointer<Utf8>, int,); typedef GetJsonBlobFromStrIntStringFn = Pointer<Utf8> Function(
Pointer<Utf8>,
int,
int,
Pointer<Utf8>,
int,
);
// func c_GetMessagesByContentHash(profile_ptr *C.char, profile_len C.int, handle_ptr *C.char, handle_len C.int, contenthash_ptr *C.char, contenthash_len C.int) *C.char // func c_GetMessagesByContentHash(profile_ptr *C.char, profile_len C.int, handle_ptr *C.char, handle_len C.int, contenthash_ptr *C.char, contenthash_len C.int) *C.char
typedef get_json_blob_from_str_str_str_function = Pointer<Utf8> Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32); typedef get_json_blob_from_str_str_str_function = Pointer<Utf8> Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32);
@ -81,7 +87,6 @@ typedef VoidFromStringIntStringStringFn = void Function(Pointer<Utf8>, int, int,
typedef void_from_string_int_int_function = Void Function(Pointer<Utf8>, Int32, Int32, Int32); typedef void_from_string_int_int_function = Void Function(Pointer<Utf8>, Int32, Int32, Int32);
typedef VoidFromStringIntIntFn = void Function(Pointer<Utf8>, int, int, int); typedef VoidFromStringIntIntFn = void Function(Pointer<Utf8>, int, int, int);
typedef appbus_events_function = Pointer<Utf8> Function(); typedef appbus_events_function = Pointer<Utf8> Function();
typedef AppbusEventsFn = Pointer<Utf8> Function(); typedef AppbusEventsFn = Pointer<Utf8> Function();
@ -325,7 +330,7 @@ class CwtchFfi implements Cwtch {
@override @override
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
void AcceptContact(String profileOnion, int contactHandle) { void AcceptContact(String profileOnion, int contactHandle) {
var acceptContact = library.lookup<NativeFunction<string_int_to_void_function>>("c_AcceptContact"); var acceptContact = library.lookup<NativeFunction<string_int_to_void_function>>("c_AcceptConversation");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
final AcceptContact = acceptContact.asFunction<VoidFromStringIntFn>(); final AcceptContact = acceptContact.asFunction<VoidFromStringIntFn>();
final u1 = profileOnion.toNativeUtf8(); final u1 = profileOnion.toNativeUtf8();
@ -430,7 +435,6 @@ class CwtchFfi implements Cwtch {
malloc.free(u3); malloc.free(u3);
} }
@override @override
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
void ResetTor() { void ResetTor() {
@ -453,7 +457,6 @@ class CwtchFfi implements Cwtch {
malloc.free(u2); malloc.free(u2);
} }
@override @override
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
void RejectInvite(String profileOnion, int groupHandle) { void RejectInvite(String profileOnion, int groupHandle) {
@ -490,7 +493,6 @@ class CwtchFfi implements Cwtch {
final u1 = profileOnion.toNativeUtf8(); final u1 = profileOnion.toNativeUtf8();
ArchiveConversation(u1, u1.length, handle); ArchiveConversation(u1, u1.length, handle);
malloc.free(u1); malloc.free(u1);
} }
@override @override
@ -504,7 +506,6 @@ class CwtchFfi implements Cwtch {
malloc.free(u1); malloc.free(u1);
} }
@override @override
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
void DeleteProfile(String onion, String currentPassword) { void DeleteProfile(String onion, String currentPassword) {
@ -526,7 +527,7 @@ class CwtchFfi implements Cwtch {
final SetProfileAttribute = setProfileAttribute.asFunction<VoidFromStringStringStringFn>(); final SetProfileAttribute = setProfileAttribute.asFunction<VoidFromStringStringStringFn>();
final u1 = profile.toNativeUtf8(); final u1 = profile.toNativeUtf8();
final u2 = key.toNativeUtf8(); final u2 = key.toNativeUtf8();
final u3 = key.toNativeUtf8(); final u3 = val.toNativeUtf8();
SetProfileAttribute(u1, u1.length, u2, u2.length, u3, u3.length); SetProfileAttribute(u1, u1.length, u2, u2.length, u3, u3.length);
malloc.free(u1); malloc.free(u1);
malloc.free(u2); malloc.free(u2);

View File

@ -201,7 +201,6 @@ class CwtchGomobile implements Cwtch {
cwtchPlatform.invokeMethod("ArchiveConversation", {"ProfileOnion": profileOnion, "handle": contactHandle}); cwtchPlatform.invokeMethod("ArchiveConversation", {"ProfileOnion": profileOnion, "handle": contactHandle});
} }
@override @override
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
void SetProfileAttribute(String profile, String key, String val) { void SetProfileAttribute(String profile, String key, String val) {

View File

@ -208,7 +208,6 @@ class ContactListState extends ChangeNotifier {
int idx = _contacts.indexWhere((element) => element.onion == byHandle); int idx = _contacts.indexWhere((element) => element.onion == byHandle);
return idx >= 0 ? _contacts[idx] : null; return idx >= 0 ? _contacts[idx] : null;
} }
} }
class ProfileInfoState extends ChangeNotifier { class ProfileInfoState extends ChangeNotifier {
@ -616,6 +615,7 @@ class ContactInfoState extends ChangeNotifier {
} }
return this._newMarker; return this._newMarker;
} }
// what's a getter that sometimes sets without a setter // what's a getter that sometimes sets without a setter
// that sometimes doesn't set // that sometimes doesn't set
set newMarker(int newVal) { set newMarker(int newVal) {

View File

@ -127,5 +127,6 @@ class MessageMetadata extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
MessageMetadata(this.profileOnion, this.conversationIdentifier, this.messageIndex, this.messageID, this.timestamp, this.senderHandle, this.senderImage, this.signature, this._flags, this._ackd, this._error); MessageMetadata(
this.profileOnion, this.conversationIdentifier, this.messageIndex, this.messageID, this.timestamp, this.senderHandle, this.senderImage, this.signature, this._flags, this._ackd, this._error);
} }

View File

@ -24,12 +24,7 @@ class ServerListState extends ChangeNotifier {
if (idx >= 0) { if (idx >= 0) {
_servers[idx] = sis; _servers[idx] = sis;
} else { } else {
_servers.add(ServerInfoState(onion: onion, _servers.add(ServerInfoState(onion: onion, serverBundle: serverBundle, running: running, description: description, autoStart: autoStart, isEncrypted: isEncrypted));
serverBundle: serverBundle,
running: running,
description: description,
autoStart: autoStart,
isEncrypted: isEncrypted));
} }
notifyListeners(); notifyListeners();
} }

View File

@ -296,11 +296,13 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
// Profile Editing // Profile Editing
if (ctrlrPass.value.text.isEmpty) { if (ctrlrPass.value.text.isEmpty) {
// Don't update password, only update name // Don't update password, only update name
Provider.of<ProfileInfoState>(context, listen: false).nickname = ctrlrNick.value.text;
Provider.of<FlwtchState>(context, listen: false).cwtch.SetProfileAttribute(Provider.of<ProfileInfoState>(context, listen: false).onion, "profile.name", ctrlrNick.value.text); Provider.of<FlwtchState>(context, listen: false).cwtch.SetProfileAttribute(Provider.of<ProfileInfoState>(context, listen: false).onion, "profile.name", ctrlrNick.value.text);
Navigator.of(context).pop(); Navigator.of(context).pop();
} else { } else {
// At this points passwords have been validated to be the same and not empty // At this points passwords have been validated to be the same and not empty
// Update both password and name, even if name hasn't been changed... // Update both password and name, even if name hasn't been changed...
Provider.of<ProfileInfoState>(context, listen: false).nickname = ctrlrNick.value.text;
Provider.of<FlwtchState>(context, listen: false).cwtch.SetProfileAttribute(Provider.of<ProfileInfoState>(context, listen: false).onion, "profile.name", ctrlrNick.value.text); Provider.of<FlwtchState>(context, listen: false).cwtch.SetProfileAttribute(Provider.of<ProfileInfoState>(context, listen: false).onion, "profile.name", ctrlrNick.value.text);
final updatePasswordEvent = { final updatePasswordEvent = {
"EventType": "ChangePassword", "EventType": "ChangePassword",

View File

@ -53,7 +53,6 @@ class _AddEditServerViewState extends State<AddEditServerView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: ctrlrOnion.text.isEmpty ? Text(AppLocalizations.of(context)!.addServerTitle) : Text(AppLocalizations.of(context)!.editServerTitle), title: ctrlrOnion.text.isEmpty ? Text(AppLocalizations.of(context)!.addServerTitle) : Text(AppLocalizations.of(context)!.editServerTitle),
@ -84,9 +83,7 @@ class _AddEditServerViewState extends State<AddEditServerView> {
child: Container( child: Container(
margin: EdgeInsets.fromLTRB(30, 0, 30, 10), margin: EdgeInsets.fromLTRB(30, 0, 30, 10),
padding: EdgeInsets.fromLTRB(20, 0, 20, 10), padding: EdgeInsets.fromLTRB(20, 0, 20, 10),
child: Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.stretch, child: Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.stretch, children: [
children: [
// Onion // Onion
Visibility( Visibility(
visible: serverInfoState.onion.isNotEmpty, visible: serverInfoState.onion.isNotEmpty,
@ -98,9 +95,7 @@ class _AddEditServerViewState extends State<AddEditServerView> {
SizedBox( SizedBox(
height: 20, height: 20,
), ),
SelectableText( SelectableText(serverInfoState.onion)
serverInfoState.onion
)
])), ])),
// Description // Description
@ -161,7 +156,6 @@ class _AddEditServerViewState extends State<AddEditServerView> {
secondary: Icon(CwtchIcons.favorite_24dp, color: settings.current().mainTextColor()), secondary: Icon(CwtchIcons.favorite_24dp, color: settings.current().mainTextColor()),
), ),
// ***** Password ***** // ***** Password *****
// use password toggle // use password toggle
@ -195,7 +189,6 @@ class _AddEditServerViewState extends State<AddEditServerView> {
), ),
])), ])),
// current password // current password
Visibility( Visibility(
visible: serverInfoState.onion.isNotEmpty && serverInfoState.isEncrypted, visible: serverInfoState.onion.isNotEmpty && serverInfoState.isEncrypted,
@ -209,10 +202,7 @@ class _AddEditServerViewState extends State<AddEditServerView> {
autoFillHints: [AutofillHints.newPassword], autoFillHints: [AutofillHints.newPassword],
validator: (value) { validator: (value) {
// Password field can be empty when just updating the profile, not on creation // Password field can be empty when just updating the profile, not on creation
if (serverInfoState.isEncrypted && if (serverInfoState.isEncrypted && serverInfoState.onion.isEmpty && value.isEmpty && usePassword) {
serverInfoState.onion.isEmpty &&
value.isEmpty &&
usePassword) {
return AppLocalizations.of(context)!.passwordErrorEmpty; return AppLocalizations.of(context)!.passwordErrorEmpty;
} }
if (Provider.of<ErrorHandler>(context).deletedServerError == true) { if (Provider.of<ErrorHandler>(context).deletedServerError == true) {
@ -306,7 +296,6 @@ class _AddEditServerViewState extends State<AddEditServerView> {
])) ]))
// ***** END Password ***** // ***** END Password *****
])))))); ]))))));
}); });
}); });
@ -318,29 +307,20 @@ class _AddEditServerViewState extends State<AddEditServerView> {
// match (and are provided if the user has requested an encrypted profile). // match (and are provided if the user has requested an encrypted profile).
if (_formKey.currentState!.validate()) { if (_formKey.currentState!.validate()) {
if (usePassword) { if (usePassword) {
Provider Provider.of<FlwtchState>(context, listen: false).cwtch.CreateServer(ctrlrPass.value.text, ctrlrDesc.value.text, Provider.of<ServerInfoState>(context, listen: false).autoStart);
.of<FlwtchState>(context, listen: false)
.cwtch
.CreateServer(ctrlrPass.value.text, ctrlrDesc.value.text, Provider.of<ServerInfoState>(context, listen: false).autoStart);
} else { } else {
Provider Provider.of<FlwtchState>(context, listen: false).cwtch.CreateServer(DefaultPassword, ctrlrDesc.value.text, Provider.of<ServerInfoState>(context, listen: false).autoStart);
.of<FlwtchState>(context, listen: false)
.cwtch
.CreateServer(DefaultPassword, ctrlrDesc.value.text, Provider.of<ServerInfoState>(context, listen: false).autoStart);
} }
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
} }
void _savePressed() { void _savePressed() {
var server = Provider.of<ServerInfoState>(context, listen: false); var server = Provider.of<ServerInfoState>(context, listen: false);
Provider.of<FlwtchState>(context, listen: false) Provider.of<FlwtchState>(context, listen: false).cwtch.SetServerAttribute(server.onion, "description", ctrlrDesc.text);
.cwtch.SetServerAttribute(server.onion, "description", ctrlrDesc.text);
server.setDescription(ctrlrDesc.text); server.setDescription(ctrlrDesc.text);
if (_formKey.currentState!.validate()) { if (_formKey.currentState!.validate()) {
// TODO support change password // TODO support change password
} }
@ -358,13 +338,8 @@ class _AddEditServerViewState extends State<AddEditServerView> {
Widget continueButton = ElevatedButton( Widget continueButton = ElevatedButton(
child: Text(AppLocalizations.of(context)!.deleteServerConfirmBtn), child: Text(AppLocalizations.of(context)!.deleteServerConfirmBtn),
onPressed: () { onPressed: () {
var onion = Provider var onion = Provider.of<ServerInfoState>(context, listen: false).onion;
.of<ServerInfoState>(context, listen: false) Provider.of<FlwtchState>(context, listen: false).cwtch.DeleteServer(onion, Provider.of<ServerInfoState>(context, listen: false).isEncrypted ? ctrlrOldPass.value.text : DefaultPassword);
.onion;
Provider
.of<FlwtchState>(context, listen: false)
.cwtch
.DeleteServer(onion, Provider.of<ServerInfoState>(context, listen: false).isEncrypted ? ctrlrOldPass.value.text : DefaultPassword);
Future.delayed( Future.delayed(
const Duration(milliseconds: 500), const Duration(milliseconds: 500),
() { () {

View File

@ -112,7 +112,6 @@ class _ContactsViewState extends State<ContactsView> {
Clipboard.setData(new ClipboardData(text: Provider.of<ProfileInfoState>(context, listen: false).onion)); Clipboard.setData(new ClipboardData(text: Provider.of<ProfileInfoState>(context, listen: false).onion));
})); }));
// TODO servers // TODO servers
// Search contacts // Search contacts

View File

@ -192,8 +192,7 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
), ),
Visibility( Visibility(
visible: !Platform.isAndroid && !Platform.isIOS, visible: !Platform.isAndroid && !Platform.isIOS,
child: child: SwitchListTile(
SwitchListTile(
title: Text(AppLocalizations.of(context)!.settingServers, style: TextStyle(color: settings.current().mainTextColor())), title: Text(AppLocalizations.of(context)!.settingServers, style: TextStyle(color: settings.current().mainTextColor())),
subtitle: Text(AppLocalizations.of(context)!.settingServersDescription), subtitle: Text(AppLocalizations.of(context)!.settingServersDescription),
value: settings.isExperimentEnabled(ServerManagementExperiment), value: settings.isExperimentEnabled(ServerManagementExperiment),

View File

@ -57,8 +57,8 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
SizedBox( SizedBox(
width: 10, width: 10,
), ),
Expanded(child: Text(MediaQuery.of(context).size.width > 600 ? Expanded(
AppLocalizations.of(context)!.titleManageProfiles : AppLocalizations.of(context)!.titleManageProfilesShort, child: Text(MediaQuery.of(context).size.width > 600 ? AppLocalizations.of(context)!.titleManageProfiles : AppLocalizations.of(context)!.titleManageProfilesShort,
style: TextStyle(color: settings.current().mainTextColor()))) style: TextStyle(color: settings.current().mainTextColor())))
]), ]),
actions: getActions(), actions: getActions(),

View File

@ -44,7 +44,8 @@ class _ServersView extends State<ServersView> {
), ),
body: Consumer<ServerListState>( body: Consumer<ServerListState>(
builder: (context, svrs, child) { builder: (context, svrs, child) {
final tiles = svrs.servers.map((ServerInfoState server) { final tiles = svrs.servers.map(
(ServerInfoState server) {
return ChangeNotifierProvider<ServerInfoState>.value( return ChangeNotifierProvider<ServerInfoState>.value(
value: server, value: server,
builder: (context, child) => RepaintBoundary(child: ServerRow()), builder: (context, child) => RepaintBoundary(child: ServerRow()),
@ -141,9 +142,11 @@ class _ServersView extends State<ServersView> {
Navigator.of(context).push(MaterialPageRoute<void>( Navigator.of(context).push(MaterialPageRoute<void>(
builder: (BuildContext context) { builder: (BuildContext context) {
return MultiProvider( return MultiProvider(
providers: [ChangeNotifierProvider<ServerInfoState>( providers: [
ChangeNotifierProvider<ServerInfoState>(
create: (_) => ServerInfoState(onion: "", serverBundle: "", description: "", autoStart: true, running: false, isEncrypted: true), create: (_) => ServerInfoState(onion: "", serverBundle: "", description: "", autoStart: true, running: false, isEncrypted: true),
)], )
],
child: AddEditServerView(), child: AddEditServerView(),
); );
}, },

View File

@ -94,10 +94,10 @@ class FileBubbleState extends State<FileBubble> {
Provider.of<FlwtchState>(context, listen: false).cwtch.CheckDownloadStatus(Provider.of<ProfileInfoState>(context, listen: false).onion, widget.fileKey()); Provider.of<FlwtchState>(context, listen: false).cwtch.CheckDownloadStatus(Provider.of<ProfileInfoState>(context, listen: false).onion, widget.fileKey());
} else { } else {
var path = Provider.of<ProfileInfoState>(context).downloadFinalPath(widget.fileKey()) ?? ""; var path = Provider.of<ProfileInfoState>(context).downloadFinalPath(widget.fileKey()) ?? "";
wdgDecorations = Column( wdgDecorations = Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
crossAxisAlignment: CrossAxisAlignment.start, Text(AppLocalizations.of(context)!.fileInterrupted + ': ' + path + '\u202F'),
children:[Text(AppLocalizations.of(context)!.fileInterrupted + ': ' + path + '\u202F'),ElevatedButton(onPressed: _btnResume, child: Text(AppLocalizations.of(context)!.verfiyResumeButton))] ElevatedButton(onPressed: _btnResume, child: Text(AppLocalizations.of(context)!.verfiyResumeButton))
); ]);
} }
} else { } else {
wdgDecorations = Center( wdgDecorations = Center(
@ -156,11 +156,7 @@ class FileBubbleState extends State<FileBubble> {
Provider.of<MessageMetadata>(context, listen: false).flags |= 0x02; Provider.of<MessageMetadata>(context, listen: false).flags |= 0x02;
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle); ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle);
if (contact != null) { if (contact != null) {
Provider Provider.of<FlwtchState>(context, listen: false).cwtch.CreateDownloadableFile(profileOnion, contact.identifier, widget.nameSuggestion, widget.fileKey());
.of<FlwtchState>(context, listen: false)
.cwtch
.CreateDownloadableFile(
profileOnion, contact.identifier, widget.nameSuggestion, widget.fileKey());
} }
} else { } else {
try { try {
@ -176,11 +172,7 @@ class FileBubbleState extends State<FileBubble> {
Provider.of<MessageMetadata>(context, listen: false).flags |= 0x02; Provider.of<MessageMetadata>(context, listen: false).flags |= 0x02;
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle); ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle);
if (contact != null) { if (contact != null) {
Provider Provider.of<FlwtchState>(context, listen: false).cwtch.DownloadFile(profileOnion, contact.identifier, file.path, manifestPath, widget.fileKey());
.of<FlwtchState>(context, listen: false)
.cwtch
.DownloadFile(profileOnion, contact.identifier, file.path, manifestPath,
widget.fileKey());
} }
} }
} catch (e) { } catch (e) {

View File

@ -134,8 +134,7 @@ class MessageBubbleState extends State<MessageBubble> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
Text( Text(
"Opening this link will launch an application outside of Cwtch and may reveal metadata or otherwise compromise the security of Cwtch. Only open links from people you trust. Are you sure you want to continue?" "Opening this link will launch an application outside of Cwtch and may reveal metadata or otherwise compromise the security of Cwtch. Only open links from people you trust. Are you sure you want to continue?"),
),
Flex(direction: Axis.horizontal, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Flex(direction: Axis.horizontal, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
Container( Container(
margin: EdgeInsets.symmetric(vertical: 20, horizontal: 10), margin: EdgeInsets.symmetric(vertical: 20, horizontal: 10),

View File

@ -209,9 +209,7 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Provider.of<Settings>(context).theme.messageFromMeBackgroundColor(), color: Provider.of<Settings>(context).theme.messageFromMeBackgroundColor(),
border: Border.all( border: Border.all(color: Provider.of<Settings>(context).theme.messageFromMeBackgroundColor(), width: 1),
color: Provider.of<Settings>(context).theme.messageFromMeBackgroundColor(),
width: 1),
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
topLeft: Radius.circular(8), topLeft: Radius.circular(8),
topRight: Radius.circular(8), topRight: Radius.circular(8),
@ -219,9 +217,7 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
bottomRight: Radius.circular(8), bottomRight: Radius.circular(8),
), ),
), ),
child: Padding( child: Padding(padding: EdgeInsets.all(9.0), child: Text(AppLocalizations.of(context)!.newMessagesLabel)));
padding: EdgeInsets.all(9.0),
child: Text(AppLocalizations.of(context)!.newMessagesLabel)));
} }
void _runAnimation(Offset pixelsPerSecond, Size size) { void _runAnimation(Offset pixelsPerSecond, Size size) {

View File

@ -21,26 +21,24 @@ class _ServerRowState extends State<ServerRow> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var server = Provider.of<ServerInfoState>(context); var server = Provider.of<ServerInfoState>(context);
return Card(clipBehavior: Clip.antiAlias, return Card(
clipBehavior: Clip.antiAlias,
margin: EdgeInsets.all(0.0), margin: EdgeInsets.all(0.0),
child: InkWell( child: InkWell(
child: Row( child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding( Padding(
padding: const EdgeInsets.all(6.0), //border size padding: const EdgeInsets.all(6.0), //border size
child: Icon(CwtchIcons.dns_24px, child: Icon(CwtchIcons.dns_24px,
color: server.running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor() : Provider.of<Settings>(context).theme.portraitOfflineBorderColor(), color: server.running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor() : Provider.of<Settings>(context).theme.portraitOfflineBorderColor(), size: 64)),
size: 64)
),
Expanded( Expanded(
child: Column( child: Column(
children: [ children: [
Text( Text(
server.description, server.description,
semanticsLabel: server.description, semanticsLabel: server.description,
style: Provider.of<FlwtchState>(context).biggerFont.apply(color: server.running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor() : Provider.of<Settings>(context).theme.portraitOfflineBorderColor()), style: Provider.of<FlwtchState>(context)
.biggerFont
.apply(color: server.running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor() : Provider.of<Settings>(context).theme.portraitOfflineBorderColor()),
softWrap: true, softWrap: true,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
@ -75,8 +73,6 @@ class _ServerRowState extends State<ServerRow> {
_pushEditServer(server); _pushEditServer(server);
}, },
) )
]))); ])));
} }
@ -86,9 +82,11 @@ class _ServerRowState extends State<ServerRow> {
settings: RouteSettings(name: "serveraddedit"), settings: RouteSettings(name: "serveraddedit"),
builder: (BuildContext context) { builder: (BuildContext context) {
return MultiProvider( return MultiProvider(
providers: [ChangeNotifierProvider<ServerInfoState>( providers: [
ChangeNotifierProvider<ServerInfoState>(
create: (_) => server, create: (_) => server,
)], )
],
child: AddEditServerView(), child: AddEditServerView(),
); );
}, },