diff --git a/lib/model.dart b/lib/model.dart index ae1d9c1f..f036be0f 100644 --- a/lib/model.dart +++ b/lib/model.dart @@ -24,7 +24,6 @@ class ChatMessage { }; } - class AppState extends ChangeNotifier { bool cwtchInit = false; bool cwtchIsClosing = false; @@ -365,7 +364,7 @@ class ProfileInfoState extends ChangeNotifier { void downloadUpdate(String fileKey, int progress) { if (!downloadActive(fileKey)) { - print("error: received progress for unknown download "+fileKey); + print("error: received progress for unknown download " + fileKey); } else { this._downloads[fileKey]!.chunksDownloaded = progress; notifyListeners(); @@ -374,7 +373,7 @@ class ProfileInfoState extends ChangeNotifier { void downloadMarkManifest(String fileKey) { if (!downloadActive(fileKey)) { - print("error: received download completion notice for unknown download "+fileKey); + print("error: received download completion notice for unknown download " + fileKey); } else { this._downloads[fileKey]!.gotManifest = true; notifyListeners(); @@ -407,7 +406,7 @@ class ProfileInfoState extends ChangeNotifier { } double downloadProgress(String fileKey) { - return this._downloads.containsKey(fileKey) ? this._downloads[fileKey]!.progress() : 0.0; + return this._downloads.containsKey(fileKey) ? this._downloads[fileKey]!.progress() : 0.0; } String? downloadFinalPath(String fileKey) { diff --git a/lib/models/messages/filemessage.dart b/lib/models/messages/filemessage.dart index a7e1cca0..49b23667 100644 --- a/lib/models/messages/filemessage.dart +++ b/lib/models/messages/filemessage.dart @@ -47,7 +47,7 @@ class FileMessage extends Message { String nameSuggestion = shareObj['n'] as String; String rootHash = shareObj['h'] as String; String nonce = shareObj['n'] as String; - int fileSize = shareObj['s'] as int; + int fileSize = shareObj['s'] as int; return FileBubble(nameSuggestion, rootHash, nonce, fileSize); }); } diff --git a/lib/views/messageview.dart b/lib/views/messageview.dart index 0dcb9e07..21ecbb32 100644 --- a/lib/views/messageview.dart +++ b/lib/views/messageview.dart @@ -89,17 +89,16 @@ class _MessageViewState extends State { onPressed: _showFilePicker, )); appBarButtons.add(IconButton( - icon: Icon(CwtchIcons.send_invite, size: 24), - tooltip: AppLocalizations.of(context)!.sendInvite, - onPressed: () { - _modalSendInvitation(context); - })); + icon: Icon(CwtchIcons.send_invite, size: 24), + tooltip: AppLocalizations.of(context)!.sendInvite, + onPressed: () { + _modalSendInvitation(context); + })); } appBarButtons.add(IconButton( - icon: Provider.of(context, listen: false).isGroup == true ? Icon(CwtchIcons.group_settings_24px) : Icon(CwtchIcons.peer_settings_24px), - tooltip: AppLocalizations.of(context)!.conversationSettings, - onPressed: _pushContactSettings - )); + icon: Provider.of(context, listen: false).isGroup == true ? Icon(CwtchIcons.group_settings_24px) : Icon(CwtchIcons.peer_settings_24px), + tooltip: AppLocalizations.of(context)!.conversationSettings, + onPressed: _pushContactSettings)); var appState = Provider.of(context); return WillPopScope( @@ -374,10 +373,10 @@ class _MessageViewState extends State { void _showFilePicker() async { FilePickerResult? result = await FilePicker.platform.pickFiles(); - if(result != null) { + if (result != null) { File file = File(result.files.first.path); if (file.lengthSync() <= 10737418240) { - print("Sending " +file.path); + print("Sending " + file.path); _sendFile(file.path); } else { print("file size cannot exceed 10 gigabytes"); diff --git a/lib/widgets/filebubble.dart b/lib/widgets/filebubble.dart index e58f2400..166ec164 100644 --- a/lib/widgets/filebubble.dart +++ b/lib/widgets/filebubble.dart @@ -63,9 +63,9 @@ class FileBubbleState extends State { var wdgMessage = !showFileSharing ? Text(AppLocalizations.of(context)!.messageEnableFileSharing) : fromMe - ? senderFileChrome( - AppLocalizations.of(context)!.messageFileSent, widget.nameSuggestion, widget.rootHash, widget.fileSize) - : (fileChrome(AppLocalizations.of(context)!.messageFileOffered + ":", widget.nameSuggestion, widget.rootHash, widget.fileSize, Provider.of(context).downloadSpeed(widget.fileKey()))); + ? senderFileChrome(AppLocalizations.of(context)!.messageFileSent, widget.nameSuggestion, widget.rootHash, widget.fileSize) + : (fileChrome(AppLocalizations.of(context)!.messageFileOffered + ":", widget.nameSuggestion, widget.rootHash, widget.fileSize, + Provider.of(context).downloadSpeed(widget.fileKey()))); Widget wdgDecorations; if (!showFileSharing) { wdgDecorations = Text('\u202F'); @@ -76,18 +76,12 @@ class FileBubbleState extends State { var path = Provider.of(context).downloadFinalPath(widget.fileKey())!; wdgDecorations = Text('Saved to: ' + path + '\u202F'); } else if (Provider.of(context).downloadActive(widget.fileKey())) { - if (!Provider.of(context).downloadGotManifest( - widget.fileKey())) { - wdgDecorations = Text( - AppLocalizations.of(context)!.retrievingManifestMessage + '\u202F'); + if (!Provider.of(context).downloadGotManifest(widget.fileKey())) { + wdgDecorations = Text(AppLocalizations.of(context)!.retrievingManifestMessage + '\u202F'); } else { wdgDecorations = LinearProgressIndicator( - value: Provider.of(context).downloadProgress( - widget.fileKey()), - color: Provider - .of(context) - .theme - .defaultButtonActiveColor(), + value: Provider.of(context).downloadProgress(widget.fileKey()), + color: Provider.of(context).theme.defaultButtonActiveColor(), ); } } else if (flagStarted) { @@ -129,8 +123,7 @@ class FileBubbleState extends State { child: Padding( padding: EdgeInsets.all(9.0), child: Wrap(runAlignment: WrapAlignment.spaceEvenly, alignment: WrapAlignment.spaceEvenly, runSpacing: 1.0, crossAxisAlignment: WrapCrossAlignment.center, children: [ - Center( - widthFactor: 1, child: Padding(padding: EdgeInsets.all(10.0), child: Icon(Icons.attach_file, size: 32))), + Center(widthFactor: 1, child: Padding(padding: EdgeInsets.all(10.0), child: Icon(Icons.attach_file, size: 32))), Center( widthFactor: 1.0, child: Column( @@ -158,16 +151,18 @@ class FileBubbleState extends State { Provider.of(context, listen: false).cwtch.CreateDownloadableFile(profileOnion, handle, widget.nameSuggestion, widget.fileKey()); } else { try { - selectedFileName = await saveFile(defaultFileName: widget.nameSuggestion,); - if (selectedFileName != null) { - file = File(selectedFileName); - print("saving to " + file.path); - var manifestPath = file.path + ".manifest"; - Provider.of(context, listen: false).downloadInit(widget.fileKey(), (widget.fileSize / 4096).ceil()); - Provider.of(context, listen: false).cwtch.UpdateMessageFlags(profileOnion, contact, idx, Provider.of(context, listen: false).flags | 0x02); - Provider.of(context, listen: false).flags |= 0x02; - Provider.of(context, listen: false).cwtch.DownloadFile(profileOnion, handle, file.path, manifestPath, widget.fileKey()); - } + selectedFileName = await saveFile( + defaultFileName: widget.nameSuggestion, + ); + if (selectedFileName != null) { + file = File(selectedFileName); + print("saving to " + file.path); + var manifestPath = file.path + ".manifest"; + Provider.of(context, listen: false).downloadInit(widget.fileKey(), (widget.fileSize / 4096).ceil()); + Provider.of(context, listen: false).cwtch.UpdateMessageFlags(profileOnion, contact, idx, Provider.of(context, listen: false).flags | 0x02); + Provider.of(context, listen: false).flags |= 0x02; + Provider.of(context, listen: false).cwtch.DownloadFile(profileOnion, handle, file.path, manifestPath, widget.fileKey()); + } } catch (e) { print(e); } @@ -176,7 +171,7 @@ class FileBubbleState extends State { // Construct an invite chrome for the sender Widget senderFileChrome(String chrome, String fileName, String rootHash, int fileSize) { - return Wrap(direction: Axis.vertical,children: [ + return Wrap(direction: Axis.vertical, children: [ SelectableText( chrome + '\u202F', style: TextStyle( @@ -220,14 +215,10 @@ class FileBubbleState extends State { Widget fileChrome(String chrome, String fileName, String rootHash, int fileSize, String speed) { var prettyHash = rootHash; if (rootHash.length == 128) { - prettyHash = rootHash.substring(0, 32) + '\n' + - rootHash.substring(32, 64) + '\n' + - rootHash.substring(64, 96) + '\n' + - rootHash.substring(96); + prettyHash = rootHash.substring(0, 32) + '\n' + rootHash.substring(32, 64) + '\n' + rootHash.substring(64, 96) + '\n' + rootHash.substring(96); } - return Wrap(direction: Axis.vertical, - children: [ + return Wrap(direction: Axis.vertical, children: [ SelectableText( chrome + '\u202F', style: TextStyle( @@ -238,7 +229,7 @@ class FileBubbleState extends State { maxLines: 2, ), SelectableText( - AppLocalizations.of(context)!.labelFilename +': ' + fileName + '\u202F', + AppLocalizations.of(context)!.labelFilename + ': ' + fileName + '\u202F', style: TextStyle( color: Provider.of(context).theme.messageFromMeTextColor(), ), diff --git a/lib/widgets/messagelist.dart b/lib/widgets/messagelist.dart index ac42a8a7..f541a12d 100644 --- a/lib/widgets/messagelist.dart +++ b/lib/widgets/messagelist.dart @@ -87,7 +87,7 @@ class _MessageListState extends State { // Already includes MessageRow,, return message.getWidget(context); } else { - return Text('');//MessageLoadingBubble(); + return Text(''); //MessageLoadingBubble(); } }, );