Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/pages/connecting_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class ConnectingPage extends StatefulWidget {
}

class _ConnectingPageState extends State<ConnectingPage> {
int? total;
int? totalFileNr;
BigInt? total;
BigInt? totalFileNr;
ConnectionType? connectionType;
String? connectionTypeName;

Expand Down
7 changes: 4 additions & 3 deletions lib/pages/transfer_widgets/transfer_progress.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ class TransferProgress extends StatelessWidget {
this.linkName});

final TUpdate data;
final int? total;
final BigInt? total;
final ConnectionType? linkType;
final String? linkName;

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final int sent = data.getValue();
final BigInt sent = data.getValue();
double? percent;
if (total != null) {
percent = sent.toDouble() / total!.toDouble();
Expand All @@ -32,7 +32,8 @@ class TransferProgress extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text('${sent.readableFileSize()}/${total?.readableFileSize()}'),
Text(
'${sent.toInt().readableFileSize()}/${total?.toInt().readableFileSize()}'),
const SizedBox(
height: 10,
),
Expand Down
6 changes: 3 additions & 3 deletions lib/pages/transfer_widgets/transfer_zip_progress.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class TransferZipProgress extends StatelessWidget {
{super.key, required this.data, required this.totalFileNr});

final TUpdate data;
final int? totalFileNr;
final BigInt? totalFileNr;

@override
Widget build(BuildContext context) {
final int alreadyProcessed = data.getValue();
final BigInt alreadyProcessed = data.getValue();
double? percent;
if (totalFileNr != null) {
percent = alreadyProcessed.toDouble() / totalFileNr!.toDouble();
Expand All @@ -32,7 +32,7 @@ class TransferZipProgress extends StatelessWidget {
height: 16,
),
Text(
'${AppLocalizations.of(context)!.transfer_zipping} $alreadyProcessed/$totalFileNr'),
'${AppLocalizations.of(context)!.transfer_zipping} ${alreadyProcessed.toInt()}/${totalFileNr?.toInt()}'),
const SizedBox(
height: 10,
),
Expand Down
6 changes: 3 additions & 3 deletions lib/src/rust/frb_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
switch (raw[0]) {
case 0:
return Value_Int(
dco_decode_i_32(raw[1]),
dco_decode_u_64(raw[1]),
);
case 1:
return Value_String(
Expand Down Expand Up @@ -752,7 +752,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
var tag_ = sse_decode_i_32(deserializer);
switch (tag_) {
case 0:
var var_field0 = sse_decode_i_32(deserializer);
var var_field0 = sse_decode_u_64(deserializer);
return Value_Int(var_field0);
case 1:
var var_field0 = sse_decode_String(deserializer);
Expand Down Expand Up @@ -943,7 +943,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
switch (self) {
case Value_Int(field0: final field0):
sse_encode_i_32(0, serializer);
sse_encode_i_32(field0, serializer);
sse_encode_u_64(field0, serializer);
case Value_String(field0: final field0):
sse_encode_i_32(1, serializer);
sse_encode_String(field0, serializer);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/rust/wormhole/types/value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sealed class Value with _$Value {

/// Integer value
const factory Value.int(
int field0,
BigInt field0,
) = Value_Int;

/// String value
Expand Down
12 changes: 6 additions & 6 deletions lib/src/rust/wormhole/types/value.freezed.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions lib/transfer/demo_transfer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ import '../src/rust/wormhole/types/value.dart';
/// This is used for App Store review demonstrations.
Stream<TUpdate> generateDemoReceiveStream(String downloadPath) async* {
// Step 1: Connecting
yield const TUpdate(
yield TUpdate(
event: Events.connecting,
value: Value.int(0),
value: Value.int(BigInt.zero),
);
await Future.delayed(const Duration(milliseconds: 800));

// Step 2: Start transfer
yield const TUpdate(
yield TUpdate(
event: Events.startTransfer,
value: Value.int(0),
value: Value.int(BigInt.zero),
);
await Future.delayed(const Duration(milliseconds: 500));

// Step 3: Send total size (1MB demo file)
const int totalBytes = 1048576; // 1 MB
yield const TUpdate(
final BigInt totalBytes = BigInt.from(1048576); // 1 MB
yield TUpdate(
event: Events.total,
value: Value.int(totalBytes),
);
await Future.delayed(const Duration(milliseconds: 200));

// Step 4: Simulate progress in chunks
const int chunkSize = 131072; // 128 KB chunks
for (int sent = chunkSize; sent <= totalBytes; sent += chunkSize) {
final int bytesToSend = sent > totalBytes ? totalBytes : sent;
final BigInt chunkSize = BigInt.from(131072); // 128 KB chunks
for (BigInt sent = chunkSize; sent <= totalBytes; sent += chunkSize) {
final BigInt bytesToSend = sent > totalBytes ? totalBytes : sent;
yield TUpdate(
event: Events.sent,
value: Value.int(bytesToSend),
Expand Down
4 changes: 2 additions & 2 deletions rust/src/frb_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ impl SseDecode for crate::wormhole::types::value::Value {
let mut tag_ = <i32>::sse_decode(deserializer);
match tag_ {
0 => {
let mut var_field0 = <i32>::sse_decode(deserializer);
let mut var_field0 = <u64>::sse_decode(deserializer);
return crate::wormhole::types::value::Value::Int(var_field0);
}
1 => {
Expand Down Expand Up @@ -1185,7 +1185,7 @@ impl SseEncode for crate::wormhole::types::value::Value {
match self {
crate::wormhole::types::value::Value::Int(field0) => {
<i32>::sse_encode(0, serializer);
<i32>::sse_encode(field0, serializer);
<u64>::sse_encode(field0, serializer);
}
crate::wormhole::types::value::Value::String(field0) => {
<i32>::sse_encode(1, serializer);
Expand Down
6 changes: 3 additions & 3 deletions rust/src/wormhole/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ pub fn gen_transit_handler(actions: Rc<StreamSink<TUpdate>>) -> Box<dyn Fn(Trans
pub fn gen_progress_handler(action: Rc<StreamSink<TUpdate>>) -> Box<dyn Fn(u64, u64)> {
let handler = move |received: u64, total: u64| {
if received == 0 {
_ = action.add(TUpdate::new(Events::Total, Value::Int(total as i32)));
_ = action.add(TUpdate::new(Events::StartTransfer, Value::Int(-1)));
_ = action.add(TUpdate::new(Events::Total, Value::Int(total)));
_ = action.add(TUpdate::new(Events::StartTransfer, Value::Int(0)));
}
_ = action.add(TUpdate::new(Events::Sent, Value::Int(received as i32)));
_ = action.add(TUpdate::new(Events::Sent, Value::Int(received)));
};
Box::new(handler)
}
2 changes: 1 addition & 1 deletion rust/src/wormhole/types/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::api::ErrorType;

pub enum Value {
/// Integer value
Int(i32),
Int(u64),
/// String value
String(String),
/// Error value with message
Expand Down
4 changes: 2 additions & 2 deletions rust/src/wormhole/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ pub fn create_zip_file(
// send zip start event + nr of total files
_ = actions.add(TUpdate::new(
Events::ZipFilesTotal,
Value::Int(files.len() as i32),
Value::Int(files.len() as u64),
));

let mut buffer = Vec::new();

let mut file_counter = 1;
let mut file_counter: u64 = 1;
// zip files
for (fs_path, zip_path) in files.into_iter() {
_ = actions.add(TUpdate::new(Events::ZipFiles, Value::Int(file_counter)));
Expand Down
Loading