flutter format
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
erinn 2021-09-29 17:20:35 -07:00
parent a9cc4b7425
commit 01d816209b
5 changed files with 39 additions and 50 deletions

View File

@ -24,7 +24,6 @@ class ChatMessage {
}; };
} }
class AppState extends ChangeNotifier { class AppState extends ChangeNotifier {
bool cwtchInit = false; bool cwtchInit = false;
bool cwtchIsClosing = false; bool cwtchIsClosing = false;
@ -365,7 +364,7 @@ class ProfileInfoState extends ChangeNotifier {
void downloadUpdate(String fileKey, int progress) { void downloadUpdate(String fileKey, int progress) {
if (!downloadActive(fileKey)) { if (!downloadActive(fileKey)) {
print("error: received progress for unknown download "+fileKey); print("error: received progress for unknown download " + fileKey);
} else { } else {
this._downloads[fileKey]!.chunksDownloaded = progress; this._downloads[fileKey]!.chunksDownloaded = progress;
notifyListeners(); notifyListeners();
@ -374,7 +373,7 @@ class ProfileInfoState extends ChangeNotifier {
void downloadMarkManifest(String fileKey) { void downloadMarkManifest(String fileKey) {
if (!downloadActive(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 { } else {
this._downloads[fileKey]!.gotManifest = true; this._downloads[fileKey]!.gotManifest = true;
notifyListeners(); notifyListeners();
@ -407,7 +406,7 @@ class ProfileInfoState extends ChangeNotifier {
} }
double downloadProgress(String fileKey) { 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) { String? downloadFinalPath(String fileKey) {

View File

@ -47,7 +47,7 @@ class FileMessage extends Message {
String nameSuggestion = shareObj['n'] as String; String nameSuggestion = shareObj['n'] as String;
String rootHash = shareObj['h'] as String; String rootHash = shareObj['h'] as String;
String nonce = shareObj['n'] 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); return FileBubble(nameSuggestion, rootHash, nonce, fileSize);
}); });
} }

View File

@ -89,17 +89,16 @@ class _MessageViewState extends State<MessageView> {
onPressed: _showFilePicker, onPressed: _showFilePicker,
)); ));
appBarButtons.add(IconButton( appBarButtons.add(IconButton(
icon: Icon(CwtchIcons.send_invite, size: 24), icon: Icon(CwtchIcons.send_invite, size: 24),
tooltip: AppLocalizations.of(context)!.sendInvite, tooltip: AppLocalizations.of(context)!.sendInvite,
onPressed: () { onPressed: () {
_modalSendInvitation(context); _modalSendInvitation(context);
})); }));
} }
appBarButtons.add(IconButton( appBarButtons.add(IconButton(
icon: Provider.of<ContactInfoState>(context, listen: false).isGroup == true ? Icon(CwtchIcons.group_settings_24px) : Icon(CwtchIcons.peer_settings_24px), icon: Provider.of<ContactInfoState>(context, listen: false).isGroup == true ? Icon(CwtchIcons.group_settings_24px) : Icon(CwtchIcons.peer_settings_24px),
tooltip: AppLocalizations.of(context)!.conversationSettings, tooltip: AppLocalizations.of(context)!.conversationSettings,
onPressed: _pushContactSettings onPressed: _pushContactSettings));
));
var appState = Provider.of<AppState>(context); var appState = Provider.of<AppState>(context);
return WillPopScope( return WillPopScope(
@ -374,10 +373,10 @@ class _MessageViewState extends State<MessageView> {
void _showFilePicker() async { void _showFilePicker() async {
FilePickerResult? result = await FilePicker.platform.pickFiles(); FilePickerResult? result = await FilePicker.platform.pickFiles();
if(result != null) { if (result != null) {
File file = File(result.files.first.path); File file = File(result.files.first.path);
if (file.lengthSync() <= 10737418240) { if (file.lengthSync() <= 10737418240) {
print("Sending " +file.path); print("Sending " + file.path);
_sendFile(file.path); _sendFile(file.path);
} else { } else {
print("file size cannot exceed 10 gigabytes"); print("file size cannot exceed 10 gigabytes");

View File

@ -63,9 +63,9 @@ class FileBubbleState extends State<FileBubble> {
var wdgMessage = !showFileSharing var wdgMessage = !showFileSharing
? Text(AppLocalizations.of(context)!.messageEnableFileSharing) ? Text(AppLocalizations.of(context)!.messageEnableFileSharing)
: fromMe : fromMe
? senderFileChrome( ? senderFileChrome(AppLocalizations.of(context)!.messageFileSent, widget.nameSuggestion, widget.rootHash, widget.fileSize)
AppLocalizations.of(context)!.messageFileSent, widget.nameSuggestion, widget.rootHash, widget.fileSize) : (fileChrome(AppLocalizations.of(context)!.messageFileOffered + ":", widget.nameSuggestion, widget.rootHash, widget.fileSize,
: (fileChrome(AppLocalizations.of(context)!.messageFileOffered + ":", widget.nameSuggestion, widget.rootHash, widget.fileSize, Provider.of<ProfileInfoState>(context).downloadSpeed(widget.fileKey()))); Provider.of<ProfileInfoState>(context).downloadSpeed(widget.fileKey())));
Widget wdgDecorations; Widget wdgDecorations;
if (!showFileSharing) { if (!showFileSharing) {
wdgDecorations = Text('\u202F'); wdgDecorations = Text('\u202F');
@ -76,18 +76,12 @@ class FileBubbleState extends State<FileBubble> {
var path = Provider.of<ProfileInfoState>(context).downloadFinalPath(widget.fileKey())!; var path = Provider.of<ProfileInfoState>(context).downloadFinalPath(widget.fileKey())!;
wdgDecorations = Text('Saved to: ' + path + '\u202F'); wdgDecorations = Text('Saved to: ' + path + '\u202F');
} else if (Provider.of<ProfileInfoState>(context).downloadActive(widget.fileKey())) { } else if (Provider.of<ProfileInfoState>(context).downloadActive(widget.fileKey())) {
if (!Provider.of<ProfileInfoState>(context).downloadGotManifest( if (!Provider.of<ProfileInfoState>(context).downloadGotManifest(widget.fileKey())) {
widget.fileKey())) { wdgDecorations = Text(AppLocalizations.of(context)!.retrievingManifestMessage + '\u202F');
wdgDecorations = Text(
AppLocalizations.of(context)!.retrievingManifestMessage + '\u202F');
} else { } else {
wdgDecorations = LinearProgressIndicator( wdgDecorations = LinearProgressIndicator(
value: Provider.of<ProfileInfoState>(context).downloadProgress( value: Provider.of<ProfileInfoState>(context).downloadProgress(widget.fileKey()),
widget.fileKey()), color: Provider.of<Settings>(context).theme.defaultButtonActiveColor(),
color: Provider
.of<Settings>(context)
.theme
.defaultButtonActiveColor(),
); );
} }
} else if (flagStarted) { } else if (flagStarted) {
@ -129,8 +123,7 @@ class FileBubbleState extends State<FileBubble> {
child: Padding( child: Padding(
padding: EdgeInsets.all(9.0), padding: EdgeInsets.all(9.0),
child: Wrap(runAlignment: WrapAlignment.spaceEvenly, alignment: WrapAlignment.spaceEvenly, runSpacing: 1.0, crossAxisAlignment: WrapCrossAlignment.center, children: [ child: Wrap(runAlignment: WrapAlignment.spaceEvenly, alignment: WrapAlignment.spaceEvenly, runSpacing: 1.0, crossAxisAlignment: WrapCrossAlignment.center, children: [
Center( Center(widthFactor: 1, child: Padding(padding: EdgeInsets.all(10.0), child: Icon(Icons.attach_file, size: 32))),
widthFactor: 1, child: Padding(padding: EdgeInsets.all(10.0), child: Icon(Icons.attach_file, size: 32))),
Center( Center(
widthFactor: 1.0, widthFactor: 1.0,
child: Column( child: Column(
@ -158,16 +151,18 @@ class FileBubbleState extends State<FileBubble> {
Provider.of<FlwtchState>(context, listen: false).cwtch.CreateDownloadableFile(profileOnion, handle, widget.nameSuggestion, widget.fileKey()); Provider.of<FlwtchState>(context, listen: false).cwtch.CreateDownloadableFile(profileOnion, handle, widget.nameSuggestion, widget.fileKey());
} else { } else {
try { try {
selectedFileName = await saveFile(defaultFileName: widget.nameSuggestion,); selectedFileName = await saveFile(
if (selectedFileName != null) { defaultFileName: widget.nameSuggestion,
file = File(selectedFileName); );
print("saving to " + file.path); if (selectedFileName != null) {
var manifestPath = file.path + ".manifest"; file = File(selectedFileName);
Provider.of<ProfileInfoState>(context, listen: false).downloadInit(widget.fileKey(), (widget.fileSize / 4096).ceil()); print("saving to " + file.path);
Provider.of<FlwtchState>(context, listen: false).cwtch.UpdateMessageFlags(profileOnion, contact, idx, Provider.of<MessageMetadata>(context, listen: false).flags | 0x02); var manifestPath = file.path + ".manifest";
Provider.of<MessageMetadata>(context, listen: false).flags |= 0x02; Provider.of<ProfileInfoState>(context, listen: false).downloadInit(widget.fileKey(), (widget.fileSize / 4096).ceil());
Provider.of<FlwtchState>(context, listen: false).cwtch.DownloadFile(profileOnion, handle, file.path, manifestPath, widget.fileKey()); Provider.of<FlwtchState>(context, listen: false).cwtch.UpdateMessageFlags(profileOnion, contact, idx, Provider.of<MessageMetadata>(context, listen: false).flags | 0x02);
} Provider.of<MessageMetadata>(context, listen: false).flags |= 0x02;
Provider.of<FlwtchState>(context, listen: false).cwtch.DownloadFile(profileOnion, handle, file.path, manifestPath, widget.fileKey());
}
} catch (e) { } catch (e) {
print(e); print(e);
} }
@ -176,7 +171,7 @@ class FileBubbleState extends State<FileBubble> {
// Construct an invite chrome for the sender // Construct an invite chrome for the sender
Widget senderFileChrome(String chrome, String fileName, String rootHash, int fileSize) { Widget senderFileChrome(String chrome, String fileName, String rootHash, int fileSize) {
return Wrap(direction: Axis.vertical,children: [ return Wrap(direction: Axis.vertical, children: [
SelectableText( SelectableText(
chrome + '\u202F', chrome + '\u202F',
style: TextStyle( style: TextStyle(
@ -220,14 +215,10 @@ class FileBubbleState extends State<FileBubble> {
Widget fileChrome(String chrome, String fileName, String rootHash, int fileSize, String speed) { Widget fileChrome(String chrome, String fileName, String rootHash, int fileSize, String speed) {
var prettyHash = rootHash; var prettyHash = rootHash;
if (rootHash.length == 128) { if (rootHash.length == 128) {
prettyHash = rootHash.substring(0, 32) + '\n' + prettyHash = rootHash.substring(0, 32) + '\n' + rootHash.substring(32, 64) + '\n' + rootHash.substring(64, 96) + '\n' + rootHash.substring(96);
rootHash.substring(32, 64) + '\n' +
rootHash.substring(64, 96) + '\n' +
rootHash.substring(96);
} }
return Wrap(direction: Axis.vertical, return Wrap(direction: Axis.vertical, children: [
children: [
SelectableText( SelectableText(
chrome + '\u202F', chrome + '\u202F',
style: TextStyle( style: TextStyle(
@ -238,7 +229,7 @@ class FileBubbleState extends State<FileBubble> {
maxLines: 2, maxLines: 2,
), ),
SelectableText( SelectableText(
AppLocalizations.of(context)!.labelFilename +': ' + fileName + '\u202F', AppLocalizations.of(context)!.labelFilename + ': ' + fileName + '\u202F',
style: TextStyle( style: TextStyle(
color: Provider.of<Settings>(context).theme.messageFromMeTextColor(), color: Provider.of<Settings>(context).theme.messageFromMeTextColor(),
), ),

View File

@ -87,7 +87,7 @@ class _MessageListState extends State<MessageList> {
// Already includes MessageRow,, // Already includes MessageRow,,
return message.getWidget(context); return message.getWidget(context);
} else { } else {
return Text('');//MessageLoadingBubble(); return Text(''); //MessageLoadingBubble();
} }
}, },
); );