forked from cwtch.im/cwtch-ui
Filesharing UI Updates
This commit is contained in:
parent
d8453bc530
commit
bf31a2b062
|
@ -182,8 +182,10 @@ class CwtchNotifier {
|
||||||
if (contactHandle == null || contactHandle == "") contactHandle = data["GroupID"];
|
if (contactHandle == null || contactHandle == "") contactHandle = data["GroupID"];
|
||||||
profileCN.getProfile(data["Identity"])?.contactList.getContact(contactHandle)!.totalMessages = int.parse(data["Data"]);
|
profileCN.getProfile(data["Identity"])?.contactList.getContact(contactHandle)!.totalMessages = int.parse(data["Data"]);
|
||||||
break;
|
break;
|
||||||
|
case "SendMessageToPeerError":
|
||||||
|
// Ignore
|
||||||
|
break;
|
||||||
case "IndexedFailure":
|
case "IndexedFailure":
|
||||||
EnvironmentConfig.debugLog("IndexedFailure");
|
|
||||||
var idx = data["Index"];
|
var idx = data["Index"];
|
||||||
var key = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])?.getMessageKey(idx);
|
var key = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])?.getMessageKey(idx);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -382,10 +382,11 @@ class ProfileInfoState extends ChangeNotifier {
|
||||||
|
|
||||||
void downloadMarkFinished(String fileKey, String finalPath) {
|
void downloadMarkFinished(String fileKey, String finalPath) {
|
||||||
if (!downloadActive(fileKey)) {
|
if (!downloadActive(fileKey)) {
|
||||||
// happens as a result of a CheckDownloadStatus call,
|
print("error: received download completion notice for unknown download " + fileKey);
|
||||||
// invoked from a historical (timeline) download message
|
} else {
|
||||||
// so setting numChunks correctly shouldn't matter
|
this._downloads[fileKey]!.timeEnd = DateTime.now();
|
||||||
this.downloadInit(fileKey, 1);
|
this._downloads[fileKey]!.complete = true;
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
this._downloads[fileKey]!.timeEnd = DateTime.now();
|
this._downloads[fileKey]!.timeEnd = DateTime.now();
|
||||||
this._downloads[fileKey]!.downloadedTo = finalPath;
|
this._downloads[fileKey]!.downloadedTo = finalPath;
|
||||||
|
|
|
@ -2,7 +2,6 @@ import 'dart:convert';
|
||||||
|
|
||||||
import 'package:cwtch/models/message.dart';
|
import 'package:cwtch/models/message.dart';
|
||||||
import 'package:cwtch/widgets/filebubble.dart';
|
import 'package:cwtch/widgets/filebubble.dart';
|
||||||
import 'package:cwtch/widgets/invitationbubble.dart';
|
|
||||||
import 'package:cwtch/widgets/malformedbubble.dart';
|
import 'package:cwtch/widgets/malformedbubble.dart';
|
||||||
import 'package:cwtch/widgets/messagerow.dart';
|
import 'package:cwtch/widgets/messagerow.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
@ -48,7 +47,13 @@ class FileMessage extends Message {
|
||||||
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,
|
||||||
|
interactive: false,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import 'package:cwtch/models/message.dart';
|
||||||
import 'package:cwtch/widgets/malformedbubble.dart';
|
import 'package:cwtch/widgets/malformedbubble.dart';
|
||||||
import 'package:file_picker/file_picker.dart' as androidPicker;
|
import 'package:file_picker/file_picker.dart' as androidPicker;
|
||||||
import 'package:file_picker_desktop/file_picker_desktop.dart';
|
import 'package:file_picker_desktop/file_picker_desktop.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
@ -24,8 +25,9 @@ class FileBubble extends StatefulWidget {
|
||||||
final String rootHash;
|
final String rootHash;
|
||||||
final String nonce;
|
final String nonce;
|
||||||
final int fileSize;
|
final int fileSize;
|
||||||
|
final bool interactive;
|
||||||
|
|
||||||
FileBubble(this.nameSuggestion, this.rootHash, this.nonce, this.fileSize);
|
FileBubble(this.nameSuggestion, this.rootHash, this.nonce, this.fileSize, {this.interactive = true});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
FileBubbleState createState() => FileBubbleState();
|
FileBubbleState createState() => FileBubbleState();
|
||||||
|
@ -122,15 +124,16 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
widthFactor: 1.0,
|
widthFactor: 1.0,
|
||||||
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(alignment: WrapAlignment.start, children: [
|
||||||
Center(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(
|
||||||
crossAxisAlignment: fromMe ? CrossAxisAlignment.end : CrossAxisAlignment.start,
|
crossAxisAlignment: fromMe ? CrossAxisAlignment.end : CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: fromMe ? MainAxisAlignment.end : MainAxisAlignment.start,
|
mainAxisAlignment: fromMe ? MainAxisAlignment.end : MainAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: fromMe ? [wdgMessage, wdgDecorations] : [wdgSender, wdgMessage, wdgDecorations]),
|
children: fromMe
|
||||||
|
? [wdgMessage, Visibility(visible: widget.interactive, child: wdgDecorations)]
|
||||||
|
: [wdgSender, wdgMessage, Visibility(visible: widget.interactive, child: wdgDecorations)]),
|
||||||
)
|
)
|
||||||
])))));
|
])))));
|
||||||
});
|
});
|
||||||
|
@ -171,99 +174,109 @@ 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 ListTile(
|
||||||
SelectableText(
|
visualDensity: VisualDensity.compact,
|
||||||
chrome + '\u202F',
|
title: Wrap(direction: Axis.horizontal, alignment: WrapAlignment.start, children: [
|
||||||
style: TextStyle(
|
SelectableText(
|
||||||
color: Provider.of<Settings>(context).theme.messageFromMeTextColor(),
|
chrome + '\u202F',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Provider.of<Settings>(context).theme.messageFromMeTextColor(),
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
maxLines: 2,
|
||||||
|
textWidthBasis: TextWidthBasis.longestLine,
|
||||||
|
),
|
||||||
|
SelectableText(
|
||||||
|
fileName + '\u202F',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Provider.of<Settings>(context).theme.messageFromMeTextColor(),
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
textWidthBasis: TextWidthBasis.parent,
|
||||||
|
maxLines: 2,
|
||||||
|
),
|
||||||
|
SelectableText(
|
||||||
|
prettyBytes(fileSize) + '\u202F' + '\n',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Provider.of<Settings>(context).theme.messageFromMeTextColor(),
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
maxLines: 2,
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
subtitle: SelectableText(
|
||||||
|
'sha512: ' + rootHash + '\u202F',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Provider.of<Settings>(context).theme.messageFromMeTextColor(),
|
||||||
|
fontSize: 10,
|
||||||
|
fontFamily: "monospace",
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
maxLines: 4,
|
||||||
|
textWidthBasis: TextWidthBasis.parent,
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.left,
|
leading: Icon(Icons.attach_file, size: 32, color: Provider.of<Settings>(context).theme.messageFromMeTextColor()));
|
||||||
maxLines: 2,
|
|
||||||
textWidthBasis: TextWidthBasis.longestLine,
|
|
||||||
),
|
|
||||||
SelectableText(
|
|
||||||
fileName + '\u202F',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Provider.of<Settings>(context).theme.messageFromMeTextColor(),
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.left,
|
|
||||||
maxLines: 2,
|
|
||||||
textWidthBasis: TextWidthBasis.longestLine,
|
|
||||||
),
|
|
||||||
SelectableText(
|
|
||||||
prettyBytes(fileSize) + '\u202F',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Provider.of<Settings>(context).theme.messageFromMeTextColor(),
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.left,
|
|
||||||
maxLines: 2,
|
|
||||||
textWidthBasis: TextWidthBasis.longestLine,
|
|
||||||
),
|
|
||||||
SelectableText(
|
|
||||||
'sha512: ' + rootHash + '\u202F',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Provider.of<Settings>(context).theme.messageFromMeTextColor(),
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.left,
|
|
||||||
maxLines: 2,
|
|
||||||
textWidthBasis: TextWidthBasis.longestLine,
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct an invite chrome
|
// Construct an invite chrome
|
||||||
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;
|
return ListTile(
|
||||||
if (rootHash.length == 128) {
|
visualDensity: VisualDensity.compact,
|
||||||
prettyHash = rootHash.substring(0, 32) + '\n' + rootHash.substring(32, 64) + '\n' + rootHash.substring(64, 96) + '\n' + rootHash.substring(96);
|
title: Wrap(direction: Axis.horizontal, alignment: WrapAlignment.start, children: [
|
||||||
}
|
SelectableText(
|
||||||
|
chrome + '\u202F',
|
||||||
return Wrap(direction: Axis.vertical, children: [
|
style: TextStyle(
|
||||||
SelectableText(
|
color: Provider.of<Settings>(context).theme.messageFromOtherTextColor(),
|
||||||
chrome + '\u202F',
|
),
|
||||||
style: TextStyle(
|
textAlign: TextAlign.left,
|
||||||
color: Provider.of<Settings>(context).theme.messageFromOtherTextColor(),
|
maxLines: 2,
|
||||||
|
textWidthBasis: TextWidthBasis.longestLine,
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.left,
|
SelectableText(
|
||||||
textWidthBasis: TextWidthBasis.longestLine,
|
fileName + '\u202F',
|
||||||
maxLines: 2,
|
style: TextStyle(
|
||||||
),
|
color: Provider.of<Settings>(context).theme.messageFromOtherTextColor(),
|
||||||
SelectableText(
|
fontWeight: FontWeight.bold,
|
||||||
AppLocalizations.of(context)!.labelFilename + ': ' + fileName + '\u202F',
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
),
|
||||||
color: Provider.of<Settings>(context).theme.messageFromMeTextColor(),
|
textAlign: TextAlign.left,
|
||||||
),
|
textWidthBasis: TextWidthBasis.parent,
|
||||||
textAlign: TextAlign.left,
|
maxLines: 2,
|
||||||
maxLines: 2,
|
),
|
||||||
textWidthBasis: TextWidthBasis.longestLine,
|
SelectableText(
|
||||||
),
|
AppLocalizations.of(context)!.labelFilesize + ': ' + prettyBytes(fileSize) + '\u202F' + '\n',
|
||||||
SelectableText(
|
style: TextStyle(
|
||||||
AppLocalizations.of(context)!.labelFilesize + ': ' + prettyBytes(fileSize) + '\u202F',
|
color: Provider.of<Settings>(context).theme.messageFromOtherTextColor(),
|
||||||
style: TextStyle(
|
),
|
||||||
color: Provider.of<Settings>(context).theme.messageFromMeTextColor(),
|
textAlign: TextAlign.left,
|
||||||
),
|
maxLines: 2,
|
||||||
textAlign: TextAlign.left,
|
)
|
||||||
maxLines: 2,
|
]),
|
||||||
textWidthBasis: TextWidthBasis.longestLine,
|
subtitle: SelectableText(
|
||||||
),
|
'sha512: ' + rootHash + '\u202F',
|
||||||
SelectableText(
|
|
||||||
'sha512: ' + prettyHash + '\u202F',
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Provider.of<Settings>(context).theme.messageFromMeTextColor(),
|
color: Provider.of<Settings>(context).theme.messageFromMeTextColor(),
|
||||||
|
fontSize: 10,
|
||||||
|
fontFamily: "monospace",
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
maxLines: 4,
|
maxLines: 4,
|
||||||
textWidthBasis: TextWidthBasis.longestLine,
|
textWidthBasis: TextWidthBasis.parent,
|
||||||
),
|
),
|
||||||
SelectableText(
|
leading: Icon(Icons.attach_file, size: 32, color: Provider.of<Settings>(context).theme.messageFromOtherTextColor()),
|
||||||
speed + '\u202F',
|
trailing: Visibility(
|
||||||
style: TextStyle(
|
visible: speed != "0 B/s",
|
||||||
color: Provider.of<Settings>(context).theme.messageFromMeTextColor(),
|
child: SelectableText(
|
||||||
),
|
speed + '\u202F',
|
||||||
textAlign: TextAlign.left,
|
style: TextStyle(
|
||||||
maxLines: 1,
|
color: Provider.of<Settings>(context).theme.messageFromMeTextColor(),
|
||||||
textWidthBasis: TextWidthBasis.longestLine,
|
),
|
||||||
),
|
textAlign: TextAlign.left,
|
||||||
]);
|
maxLines: 1,
|
||||||
|
textWidthBasis: TextWidthBasis.longestLine,
|
||||||
|
)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ packages:
|
||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.8.2"
|
version: "2.8.1"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -195,7 +195,7 @@ packages:
|
||||||
name: matcher
|
name: matcher
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.11"
|
version: "0.12.10"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -403,7 +403,7 @@ packages:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.3"
|
version: "0.4.2"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
Loading…
Reference in New Issue