Fixing Duplicate Key Issues + FileBubble SetState Builder Issues
This commit is contained in:
parent
51fae2e7ef
commit
a4cb5051b5
|
@ -282,8 +282,6 @@ class ProfileInfoState extends ChangeNotifier {
|
||||||
this._contacts.updateLastMessageTime(this._contacts._contacts.first.identifier, this._contacts._contacts.first.lastMessageTime);
|
this._contacts.updateLastMessageTime(this._contacts._contacts.first.identifier, this._contacts._contacts.first.lastMessageTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse out the server list json into our server info state struct...
|
// Parse out the server list json into our server info state struct...
|
||||||
|
|
|
@ -58,12 +58,16 @@ Message compileOverlay(MessageMetadata metadata, String messageData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Message> messageHandler(BuildContext context, String profileOnion, int conversationIdentifier, int index, {bool byID = false}) {
|
Future<Message> messageHandler(BuildContext context, String profileOnion, int conversationIdentifier, int index, {bool byID = false}) {
|
||||||
var cache = Provider.of<ProfileInfoState>(context).contactList.getContact(conversationIdentifier)?.messageCache;
|
try {
|
||||||
|
var cache = Provider.of<ProfileInfoState>(context, listen: false).contactList.getContact(conversationIdentifier)?.messageCache;
|
||||||
if (cache != null && cache.length > index) {
|
if (cache != null && cache.length > index) {
|
||||||
if (cache[index] != null) {
|
if (cache[index] != null) {
|
||||||
return Future.value(compileOverlay(cache[index]!.metadata, cache[index]!.wrapper));
|
return Future.value(compileOverlay(cache[index]!.metadata, cache[index]!.wrapper));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// provider check failed...make an expensive call...
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Future<dynamic> rawMessageEnvelopeFuture;
|
Future<dynamic> rawMessageEnvelopeFuture;
|
||||||
|
|
|
@ -19,7 +19,6 @@ class FileMessage extends Message {
|
||||||
@override
|
@override
|
||||||
Widget getWidget(BuildContext context, Key key) {
|
Widget getWidget(BuildContext context, Key key) {
|
||||||
return ChangeNotifierProvider.value(
|
return ChangeNotifierProvider.value(
|
||||||
key: key,
|
|
||||||
value: this.metadata,
|
value: this.metadata,
|
||||||
builder: (bcontext, child) {
|
builder: (bcontext, child) {
|
||||||
dynamic shareObj = jsonDecode(this.content);
|
dynamic shareObj = jsonDecode(this.content);
|
||||||
|
|
|
@ -19,7 +19,6 @@ class InviteMessage extends Message {
|
||||||
@override
|
@override
|
||||||
Widget getWidget(BuildContext context, Key key) {
|
Widget getWidget(BuildContext context, Key key) {
|
||||||
return ChangeNotifierProvider.value(
|
return ChangeNotifierProvider.value(
|
||||||
key: key,
|
|
||||||
value: this.metadata,
|
value: this.metadata,
|
||||||
builder: (bcontext, child) {
|
builder: (bcontext, child) {
|
||||||
String inviteTarget;
|
String inviteTarget;
|
||||||
|
@ -37,7 +36,7 @@ class InviteMessage extends Message {
|
||||||
inviteTarget = jsonObj['GroupID'];
|
inviteTarget = jsonObj['GroupID'];
|
||||||
inviteNick = jsonObj['GroupName'];
|
inviteNick = jsonObj['GroupName'];
|
||||||
} else {
|
} else {
|
||||||
return MessageRow(MalformedBubble(), key: key);
|
return MessageRow(MalformedBubble());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return MessageRow(InvitationBubble(overlay, inviteTarget, inviteNick, invite), key: key);
|
return MessageRow(InvitationBubble(overlay, inviteTarget, inviteNick, invite), key: key);
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:convert';
|
||||||
|
|
||||||
import 'package:cwtch/models/message.dart';
|
import 'package:cwtch/models/message.dart';
|
||||||
import 'package:cwtch/models/messages/malformedmessage.dart';
|
import 'package:cwtch/models/messages/malformedmessage.dart';
|
||||||
|
import 'package:cwtch/widgets/malformedbubble.dart';
|
||||||
import 'package:cwtch/widgets/messagerow.dart';
|
import 'package:cwtch/widgets/messagerow.dart';
|
||||||
import 'package:cwtch/widgets/quotedmessage.dart';
|
import 'package:cwtch/widgets/quotedmessage.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
@ -51,7 +52,7 @@ class QuotedMessage extends Message {
|
||||||
dynamic message = jsonDecode(this.content);
|
dynamic message = jsonDecode(this.content);
|
||||||
return Text(message["body"]);
|
return Text(message["body"]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return MalformedMessage(this.metadata).getWidget(context, Key("malformed"));
|
return MalformedBubble();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -67,7 +68,7 @@ class QuotedMessage extends Message {
|
||||||
dynamic message = jsonDecode(this.content);
|
dynamic message = jsonDecode(this.content);
|
||||||
|
|
||||||
if (message["body"] == null || message["quotedHash"] == null) {
|
if (message["body"] == null || message["quotedHash"] == null) {
|
||||||
return MalformedMessage(this.metadata).getWidget(context, key);
|
return MalformedBubble();
|
||||||
}
|
}
|
||||||
|
|
||||||
var quotedMessagePotentials = Provider.of<FlwtchState>(context).cwtch.GetMessageByContentHash(metadata.profileOnion, metadata.conversationIdentifier, message["quotedHash"]);
|
var quotedMessagePotentials = Provider.of<FlwtchState>(context).cwtch.GetMessageByContentHash(metadata.profileOnion, metadata.conversationIdentifier, message["quotedHash"]);
|
||||||
|
@ -94,14 +95,14 @@ class QuotedMessage extends Message {
|
||||||
return MessageRow(
|
return MessageRow(
|
||||||
QuotedMessageBubble(message["body"], quotedMessage.then((LocallyIndexedMessage? localIndex) {
|
QuotedMessageBubble(message["body"], quotedMessage.then((LocallyIndexedMessage? localIndex) {
|
||||||
if (localIndex != null) {
|
if (localIndex != null) {
|
||||||
return messageHandler(context, metadata.profileOnion, metadata.conversationIdentifier, localIndex.index);
|
return messageHandler(bcontext, metadata.profileOnion, metadata.conversationIdentifier, localIndex.index);
|
||||||
}
|
}
|
||||||
return MalformedMessage(this.metadata);
|
return MalformedMessage(this.metadata);
|
||||||
})),
|
})),
|
||||||
key: key);
|
key: key);
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return MalformedMessage(this.metadata).getWidget(context, key);
|
return MalformedBubble();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,14 +10,12 @@ import '../main.dart';
|
||||||
import '../model.dart';
|
import '../model.dart';
|
||||||
import '../settings.dart';
|
import '../settings.dart';
|
||||||
|
|
||||||
|
|
||||||
class ProfileServersView extends StatefulWidget {
|
class ProfileServersView extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
_ProfileServersView createState() => _ProfileServersView();
|
_ProfileServersView createState() => _ProfileServersView();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ProfileServersView extends State<ProfileServersView> {
|
class _ProfileServersView extends State<ProfileServersView> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
@ -25,8 +23,9 @@ class _ProfileServersView extends State<ProfileServersView> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
var knownServers = Provider.of<ProfileInfoState>(context).serverList.servers.map<String>((RemoteServerInfoState remoteServer) {
|
||||||
var knownServers = Provider.of<ProfileInfoState>(context).serverList.servers.map<String>((RemoteServerInfoState remoteServer) { return remoteServer.onion + ".onion"; }).toSet();
|
return remoteServer.onion + ".onion";
|
||||||
|
}).toSet();
|
||||||
var importServerList = Provider.of<ServerListState>(context).servers.where((server) => !knownServers.contains(server.onion)).map<DropdownMenuItem<String>>((ServerInfoState serverInfo) {
|
var importServerList = Provider.of<ServerListState>(context).servers.where((server) => !knownServers.contains(server.onion)).map<DropdownMenuItem<String>>((ServerInfoState serverInfo) {
|
||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
value: serverInfo.onion,
|
value: serverInfo.onion,
|
||||||
|
@ -37,20 +36,17 @@ class _ProfileServersView extends State<ProfileServersView> {
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
importServerList.insert(0, DropdownMenuItem<String>(
|
importServerList.insert(0, DropdownMenuItem<String>(value: "", child: Text(AppLocalizations.of(context)!.importLocalServerSelectText)));
|
||||||
value: "",
|
|
||||||
child: Text(AppLocalizations.of(context)!.importLocalServerSelectText)));
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(MediaQuery
|
title: Text(MediaQuery.of(context).size.width > 600 ? AppLocalizations.of(context)!.manageKnownServersLong : AppLocalizations.of(context)!.manageKnownServersShort),
|
||||||
.of(context)
|
|
||||||
.size
|
|
||||||
.width > 600 ? AppLocalizations.of(context)!.manageKnownServersLong : AppLocalizations.of(context)!.manageKnownServersShort),
|
|
||||||
),
|
),
|
||||||
body: Consumer<ProfileInfoState>(builder: (context, profile, child) {
|
body: Consumer<ProfileInfoState>(
|
||||||
|
builder: (context, profile, child) {
|
||||||
ProfileServerListState servers = profile.serverList;
|
ProfileServerListState servers = profile.serverList;
|
||||||
final tiles = servers.servers.map((RemoteServerInfoState server) {
|
final tiles = servers.servers.map(
|
||||||
|
(RemoteServerInfoState server) {
|
||||||
return ChangeNotifierProvider<RemoteServerInfoState>.value(
|
return ChangeNotifierProvider<RemoteServerInfoState>.value(
|
||||||
value: server,
|
value: server,
|
||||||
builder: (context, child) => RepaintBoundary(child: RemoteServerRow()),
|
builder: (context, child) => RepaintBoundary(child: RemoteServerRow()),
|
||||||
|
@ -63,7 +59,8 @@ class _ProfileServersView extends State<ProfileServersView> {
|
||||||
tiles: tiles,
|
tiles: tiles,
|
||||||
).toList();
|
).toList();
|
||||||
|
|
||||||
final importCard = Card( child: ListTile(
|
final importCard = Card(
|
||||||
|
child: ListTile(
|
||||||
title: Text(AppLocalizations.of(context)!.importLocalServerLabel),
|
title: Text(AppLocalizations.of(context)!.importLocalServerLabel),
|
||||||
leading: Icon(CwtchIcons.add_circle_24px, color: Provider.of<Settings>(context).current().mainTextColor()),
|
leading: Icon(CwtchIcons.add_circle_24px, color: Provider.of<Settings>(context).current().mainTextColor()),
|
||||||
trailing: DropdownButton(
|
trailing: DropdownButton(
|
||||||
|
@ -72,11 +69,9 @@ class _ProfileServersView extends State<ProfileServersView> {
|
||||||
var server = Provider.of<ServerListState>(context).getServer(importServer)!;
|
var server = Provider.of<ServerListState>(context).getServer(importServer)!;
|
||||||
showImportConfirm(context, profile.onion, server.onion, server.description, server.serverBundle);
|
showImportConfirm(context, profile.onion, server.onion, server.description, server.serverBundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
value: "",
|
value: "",
|
||||||
items: importServerList,
|
items: importServerList,
|
||||||
|
|
||||||
)));
|
)));
|
||||||
|
|
||||||
return LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) {
|
return LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) {
|
||||||
|
@ -84,16 +79,11 @@ class _ProfileServersView extends State<ProfileServersView> {
|
||||||
isAlwaysShown: true,
|
isAlwaysShown: true,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
child:
|
child: Container(
|
||||||
Container(
|
|
||||||
margin: EdgeInsets.fromLTRB(5, 0, 5, 10),
|
margin: EdgeInsets.fromLTRB(5, 0, 5, 10),
|
||||||
padding: EdgeInsets.fromLTRB(5, 0, 5, 10),
|
padding: EdgeInsets.fromLTRB(5, 0, 5, 10),
|
||||||
child: Column(children: [
|
child: Column(children: [if (importServerList.length > 1) importCard, Column(children: divided)]))));
|
||||||
|
});
|
||||||
if (importServerList.length > 1) importCard,
|
|
||||||
|
|
||||||
Column( children: divided )
|
|
||||||
]))));});
|
|
||||||
|
|
||||||
return ListView(children: divided);
|
return ListView(children: divided);
|
||||||
},
|
},
|
||||||
|
@ -118,15 +108,9 @@ class _ProfileServersView extends State<ProfileServersView> {
|
||||||
Future.delayed(const Duration(milliseconds: 500), () {
|
Future.delayed(const Duration(milliseconds: 500), () {
|
||||||
var profile = Provider.of<ProfileInfoState>(context);
|
var profile = Provider.of<ProfileInfoState>(context);
|
||||||
if (profile.serverList.getServer(serverHandle) != null) {
|
if (profile.serverList.getServer(serverHandle) != null) {
|
||||||
profile.serverList.getServer(serverHandle)?.updateDescription(
|
profile.serverList.getServer(serverHandle)?.updateDescription(serverDesc);
|
||||||
serverDesc);
|
|
||||||
|
|
||||||
Provider
|
Provider.of<FlwtchState>(context, listen: false).cwtch.SetConversationAttribute(profile.onion, profile.serverList.getServer(serverHandle)!.identifier, "server.description", serverDesc);
|
||||||
.of<FlwtchState>(context, listen: false)
|
|
||||||
.cwtch
|
|
||||||
.SetConversationAttribute(profile.onion, profile.serverList
|
|
||||||
.getServer(serverHandle)
|
|
||||||
!.identifier, "server.description", serverDesc);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
@ -149,7 +133,4 @@ class _ProfileServersView extends State<ProfileServersView> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -50,9 +50,7 @@ class _RemoteServerViewState extends State<RemoteServerView> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Consumer3<ProfileInfoState, RemoteServerInfoState, Settings>(builder: (context, profile, serverInfoState, settings, child) {
|
return Consumer3<ProfileInfoState, RemoteServerInfoState, Settings>(builder: (context, profile, serverInfoState, settings, child) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(title: Text(ctrlrDesc.text.isNotEmpty ? ctrlrDesc.text : serverInfoState.onion)),
|
||||||
title: Text(ctrlrDesc.text.isNotEmpty ? ctrlrDesc.text : serverInfoState.onion)
|
|
||||||
),
|
|
||||||
body: Container(
|
body: 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),
|
||||||
|
@ -64,9 +62,7 @@ class _RemoteServerViewState extends State<RemoteServerView> {
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
SelectableText(
|
SelectableText(serverInfoState.onion),
|
||||||
serverInfoState.onion
|
|
||||||
),
|
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
@ -93,15 +89,18 @@ class _RemoteServerViewState extends State<RemoteServerView> {
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
|
|
||||||
Padding(padding: EdgeInsets.all(8), child: Text( AppLocalizations.of(context)!.groupsOnThisServerLabel),),
|
Padding(
|
||||||
|
padding: EdgeInsets.all(8),
|
||||||
|
child: Text(AppLocalizations.of(context)!.groupsOnThisServerLabel),
|
||||||
|
),
|
||||||
Expanded(child: _buildGroupsList(serverInfoState))
|
Expanded(child: _buildGroupsList(serverInfoState))
|
||||||
])));
|
])));
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildGroupsList(RemoteServerInfoState serverInfoState) {
|
Widget _buildGroupsList(RemoteServerInfoState serverInfoState) {
|
||||||
final tiles = serverInfoState.groups.map((ContactInfoState group) {
|
final tiles = serverInfoState.groups.map(
|
||||||
|
(ContactInfoState group) {
|
||||||
return ChangeNotifierProvider<ContactInfoState>.value(
|
return ChangeNotifierProvider<ContactInfoState>.value(
|
||||||
value: group,
|
value: group,
|
||||||
builder: (context, child) => RepaintBoundary(child: _buildGroupRow(group)), // ServerRow()),
|
builder: (context, child) => RepaintBoundary(child: _buildGroupRow(group)), // ServerRow()),
|
||||||
|
@ -126,8 +125,7 @@ class _RemoteServerViewState extends State<RemoteServerView> {
|
||||||
Widget _buildGroupRow(ContactInfoState group) {
|
Widget _buildGroupRow(ContactInfoState group) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(6.0), //border size
|
padding: const EdgeInsets.all(6.0), //border size
|
||||||
child: Column(
|
child: Column(children: [
|
||||||
children: [
|
|
||||||
Text(
|
Text(
|
||||||
group.nickname,
|
group.nickname,
|
||||||
style: Provider.of<FlwtchState>(context).biggerFont.apply(color: Provider.of<Settings>(context).theme.portraitOnlineBorderColor()),
|
style: Provider.of<FlwtchState>(context).biggerFont.apply(color: Provider.of<Settings>(context).theme.portraitOnlineBorderColor()),
|
||||||
|
@ -143,9 +141,6 @@ class _RemoteServerViewState extends State<RemoteServerView> {
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(color: Provider.of<Settings>(context).theme.portraitOnlineBorderColor()),
|
style: TextStyle(color: Provider.of<Settings>(context).theme.portraitOnlineBorderColor()),
|
||||||
)))
|
)))
|
||||||
])
|
]));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,26 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
var borderRadiousEh = 15.0;
|
var borderRadiousEh = 15.0;
|
||||||
var showFileSharing = Provider.of<Settings>(context).isExperimentEnabled(FileSharingExperiment);
|
var showFileSharing = Provider.of<Settings>(context).isExperimentEnabled(FileSharingExperiment);
|
||||||
var prettyDate = DateFormat.yMd(Platform.localeName).add_jm().format(Provider.of<MessageMetadata>(context).timestamp);
|
var prettyDate = DateFormat.yMd(Platform.localeName).add_jm().format(Provider.of<MessageMetadata>(context).timestamp);
|
||||||
|
var downloadComplete = Provider.of<ProfileInfoState>(context).downloadComplete(widget.fileKey());
|
||||||
|
var downloadInterrupted = Provider.of<ProfileInfoState>(context).downloadInterrupted(widget.fileKey());
|
||||||
|
|
||||||
|
if (downloadInterrupted) {
|
||||||
|
Provider.of<FlwtchState>(context, listen: false).cwtch.CheckDownloadStatus(Provider.of<ProfileInfoState>(context, listen: false).onion, widget.fileKey());
|
||||||
|
}
|
||||||
|
var path = Provider.of<ProfileInfoState>(context).downloadFinalPath(widget.fileKey());
|
||||||
|
if (downloadComplete) {
|
||||||
|
var lpath = path!.toLowerCase();
|
||||||
|
if (lpath.endsWith("jpg") || lpath.endsWith("jpeg") || lpath.endsWith("png") || lpath.endsWith("gif") || lpath.endsWith("webp") || lpath.endsWith("bmp")) {
|
||||||
|
if (myFile == null) {
|
||||||
|
setState(() {
|
||||||
|
myFile = new File(path);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var downloadActive = Provider.of<ProfileInfoState>(context).downloadActive(widget.fileKey());
|
||||||
|
var downloadGotManifest = Provider.of<ProfileInfoState>(context).downloadGotManifest(widget.fileKey());
|
||||||
|
|
||||||
// If the sender is not us, then we want to give them a nickname...
|
// If the sender is not us, then we want to give them a nickname...
|
||||||
var senderDisplayStr = "";
|
var senderDisplayStr = "";
|
||||||
|
@ -78,17 +98,10 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
wdgDecorations = Text('\u202F');
|
wdgDecorations = Text('\u202F');
|
||||||
} else if (fromMe) {
|
} else if (fromMe) {
|
||||||
wdgDecorations = MessageBubbleDecoration(ackd: Provider.of<MessageMetadata>(context).ackd, errored: Provider.of<MessageMetadata>(context).error, fromMe: fromMe, prettyDate: prettyDate);
|
wdgDecorations = MessageBubbleDecoration(ackd: Provider.of<MessageMetadata>(context).ackd, errored: Provider.of<MessageMetadata>(context).error, fromMe: fromMe, prettyDate: prettyDate);
|
||||||
} else if (Provider.of<ProfileInfoState>(context).downloadComplete(widget.fileKey())) {
|
} else if (downloadComplete) {
|
||||||
// in this case, whatever marked download.complete would have also set the path
|
// in this case, whatever marked download.complete would have also set the path
|
||||||
var path = Provider.of<ProfileInfoState>(context).downloadFinalPath(widget.fileKey())!;
|
var lpath = path!.toLowerCase();
|
||||||
var lpath = path.toLowerCase();
|
|
||||||
if (lpath.endsWith("jpg") || lpath.endsWith("jpeg") || lpath.endsWith("png") || lpath.endsWith("gif") || lpath.endsWith("webp") || lpath.endsWith("bmp")) {
|
if (lpath.endsWith("jpg") || lpath.endsWith("jpeg") || lpath.endsWith("png") || lpath.endsWith("gif") || lpath.endsWith("webp") || lpath.endsWith("bmp")) {
|
||||||
if (myFile == null) {
|
|
||||||
setState(() {
|
|
||||||
myFile = new File(path);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
isPreview = true;
|
isPreview = true;
|
||||||
wdgDecorations = GestureDetector(
|
wdgDecorations = GestureDetector(
|
||||||
child: Image.file(
|
child: Image.file(
|
||||||
|
@ -110,8 +123,8 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
} else {
|
} else {
|
||||||
wdgDecorations = Text(AppLocalizations.of(context)!.fileSavedTo + ': ' + path + '\u202F');
|
wdgDecorations = Text(AppLocalizations.of(context)!.fileSavedTo + ': ' + path + '\u202F');
|
||||||
}
|
}
|
||||||
} else if (Provider.of<ProfileInfoState>(context).downloadActive(widget.fileKey())) {
|
} else if (downloadActive) {
|
||||||
if (!Provider.of<ProfileInfoState>(context).downloadGotManifest(widget.fileKey())) {
|
if (!downloadGotManifest) {
|
||||||
wdgDecorations = Text(AppLocalizations.of(context)!.retrievingManifestMessage + '\u202F');
|
wdgDecorations = Text(AppLocalizations.of(context)!.retrievingManifestMessage + '\u202F');
|
||||||
} else {
|
} else {
|
||||||
wdgDecorations = LinearProgressIndicator(
|
wdgDecorations = LinearProgressIndicator(
|
||||||
|
@ -122,9 +135,8 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
} else if (flagStarted) {
|
} else if (flagStarted) {
|
||||||
// in this case, the download was done in a previous application launch,
|
// in this case, the download was done in a previous application launch,
|
||||||
// so we probably have to request an info lookup
|
// so we probably have to request an info lookup
|
||||||
if (!Provider.of<ProfileInfoState>(context).downloadInterrupted(widget.fileKey())) {
|
if (!downloadInterrupted) {
|
||||||
wdgDecorations = Text(AppLocalizations.of(context)!.fileCheckingStatus + '...' + '\u202F');
|
wdgDecorations = Text(AppLocalizations.of(context)!.fileCheckingStatus + '...' + '\u202F');
|
||||||
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(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
wdgDecorations = Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||||
|
@ -140,7 +152,6 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
constraints: constraints,
|
constraints: constraints,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
@ -193,7 +204,7 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
Provider.of<ProfileInfoState>(context, listen: false).downloadInit(widget.fileKey(), (widget.fileSize / 4096).ceil());
|
Provider.of<ProfileInfoState>(context, listen: false).downloadInit(widget.fileKey(), (widget.fileSize / 4096).ceil());
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.SetMessageAttribute(profileOnion, conversation, 0, idx, "file-downloaded", "true");
|
Provider.of<FlwtchState>(context, listen: false).cwtch.SetMessageAttribute(profileOnion, conversation, 0, idx, "file-downloaded", "true");
|
||||||
//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, listen: false).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle);
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.DownloadFile(profileOnion, contact.identifier, file.path, manifestPath, widget.fileKey());
|
Provider.of<FlwtchState>(context, listen: false).cwtch.DownloadFile(profileOnion, contact.identifier, file.path, manifestPath, widget.fileKey());
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,28 +25,25 @@ class _RemoteServerRowState extends State<RemoteServerRow> {
|
||||||
var server = Provider.of<RemoteServerInfoState>(context);
|
var server = Provider.of<RemoteServerInfoState>(context);
|
||||||
var description = server.description.isNotEmpty ? server.description : server.onion;
|
var description = server.description.isNotEmpty ? server.description : server.onion;
|
||||||
var running = server.status == "Synced";
|
var running = server.status == "Synced";
|
||||||
return Consumer<ProfileInfoState>(
|
return Consumer<ProfileInfoState>(builder: (context, profile, child) {
|
||||||
builder: (context, profile, child) {
|
return Card(
|
||||||
return Card(clipBehavior: Clip.antiAlias,
|
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: running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor() : Provider.of<Settings>(context).theme.portraitOfflineBorderColor(),
|
color: 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(
|
||||||
description,
|
description,
|
||||||
semanticsLabel: description,
|
semanticsLabel: description,
|
||||||
style: Provider.of<FlwtchState>(context).biggerFont.apply(color: running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor() : Provider.of<Settings>(context).theme.portraitOfflineBorderColor()),
|
style: Provider.of<FlwtchState>(context)
|
||||||
|
.biggerFont
|
||||||
|
.apply(color: running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor() : Provider.of<Settings>(context).theme.portraitOfflineBorderColor()),
|
||||||
softWrap: true,
|
softWrap: true,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
|
@ -61,7 +58,6 @@ class _RemoteServerRowState extends State<RemoteServerRow> {
|
||||||
)))
|
)))
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
|
|
||||||
]),
|
]),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).push(MaterialPageRoute<void>(
|
Navigator.of(context).push(MaterialPageRoute<void>(
|
||||||
|
@ -72,7 +68,7 @@ class _RemoteServerRowState extends State<RemoteServerRow> {
|
||||||
child: RemoteServerView(),
|
child: RemoteServerView(),
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
}
|
}));
|
||||||
));});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,8 +76,7 @@ class _ServerRowState extends State<ServerRow> {
|
||||||
]),
|
]),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_pushEditServer(server);
|
_pushEditServer(server);
|
||||||
}
|
}));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _pushEditServer(ServerInfoState server) {
|
void _pushEditServer(ServerInfoState server) {
|
||||||
|
|
Loading…
Reference in New Issue