Skip to content

Commit

Permalink
changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCyjaneK committed Nov 8, 2024
1 parent 1233b0f commit f1205ac
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 86 deletions.
12 changes: 6 additions & 6 deletions lib/coins/abstract.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ typedef ProgressCallback = int Function({String? title, String? description});

enum Coins { monero, unknown }

class Coin {
abstract class Coin {
Coins get type => Coins.unknown;
CoinStrings get strings => CoinStrings();
CoinStrings get strings => throw UnimplementedError();

bool get isEnabled => false;

Expand All @@ -49,10 +49,10 @@ class Coin {
throw UnimplementedError();
}

class CoinWalletInfo {
abstract class CoinWalletInfo {
String get walletName => throw UnimplementedError();
Coins get type => coin.type;
Coin get coin => Coin();
Coin get coin => throw UnimplementedError();
void openUI(BuildContext context) => throw UnimplementedError();

Future<bool> checkWalletPassword(String password) async =>
Expand Down Expand Up @@ -86,7 +86,7 @@ class CoinWalletInfo {
Future<void> renameWallet(String newName) => throw UnimplementedError();
}

class CoinStrings {
abstract class CoinStrings {
String get nameLowercase => "coin";
String get nameCapitalized => "Coin";
String get nameUppercase => "COIN";
Expand Down Expand Up @@ -116,7 +116,7 @@ class WalletSeedDetail {
class CoinWallet {
CoinWallet();

Coin coin = Coin();
Coin get coin => throw UnimplementedError();
Future<void> handleUR(BuildContext context, URQRData ur) =>
throw UnimplementedError();
bool get hasAccountSupport => false;
Expand Down
4 changes: 4 additions & 0 deletions lib/coins/monero/coin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ class Monero implements Coin {
details: "unable to create wallet, recoveryWallet failed.",
);
}
monero.Wallet_store(newWptr);
monero.Wallet_store(newWptr);
progressCallback?.call(description: "Wallet created");
}

Expand Down Expand Up @@ -204,6 +206,8 @@ class Monero implements Coin {
details: "unable to create wallet, recoveryWallet failed.",
);
}
monero.Wallet_store(newWptr);
monero.Wallet_store(newWptr);
progressCallback?.call(description: "Wallet created");
}

Expand Down
4 changes: 2 additions & 2 deletions lib/coins/monero/wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ class MoneroWallet implements CoinWallet {

@override
String get seed =>
nullIfEmpty(polyseed ?? "") ??
nullIfEmpty(polyseedDart ?? "") ??
(polyseed ?? "").nullIfEmpty() ??
(polyseedDart ?? "").nullIfEmpty() ??
legacySeed;

String? get polyseed =>
Expand Down
8 changes: 5 additions & 3 deletions lib/utils/null_if_empty.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
String? nullIfEmpty(String str) {
if (str.isEmpty) return null;
return str;
extension NullIfEmpty on String {
String? nullIfEmpty() {
if (isEmpty) return null;
return this;
}
}
10 changes: 5 additions & 5 deletions lib/view_model/create_wallet_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,13 @@ class CreateWalletViewModel extends ViewModel {
final cw = await selectedCoin!.createNewWallet(
await walletName.value,
await walletPassword.value,
primaryAddress: nullIfEmpty(await walletAddress.value),
primaryAddress: (await walletAddress.value).nullIfEmpty(),
createWallet: (currentForm == _createForm),
seed: nullIfEmpty(await seed.value),
seed: (await seed.value).nullIfEmpty(),
restoreHeight: int.tryParse(await restoreHeight.value),
viewKey: nullIfEmpty(await secretViewKey.value),
spendKey: nullIfEmpty(await secretSpendKey.value),
seedOffsetOrEncryption: nullIfEmpty(await seedOffset.value),
viewKey: (await secretViewKey.value).nullIfEmpty(),
spendKey: (await secretSpendKey.value).nullIfEmpty(),
seedOffsetOrEncryption: (await seedOffset.value).nullIfEmpty(),
);

final List<NewWalletInfoPage> pages = [
Expand Down
23 changes: 0 additions & 23 deletions lib/view_model/wallet_details_view_model.dart

This file was deleted.

62 changes: 31 additions & 31 deletions lib/views/receive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,45 +33,45 @@ class Receive extends AbstractView {
Padding(
padding:
const EdgeInsets.only(top: 8, left: 48, right: 48, bottom: 32),
child: Container(
padding: const EdgeInsets.all(10.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: Colors.white,
),
child: QrImageView(
data: "monero:${viewModel.address}",
foregroundColor: Colors.black,
child: Container(
padding: const EdgeInsets.all(10.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: Colors.white,
),
child: QrImageView(
data: "monero:${viewModel.address}",
foregroundColor: Colors.black,
),
),
),
),
Container(
padding: const EdgeInsets.all(25.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: Color.fromRGBO(35, 44, 79, 1),
color: const Color.fromRGBO(35, 44, 79, 1),
),
child: InkWell(
onTap: () {
Clipboard.setData(
ClipboardData(
text: viewModel.address,
child: InkWell(
onTap: () {
Clipboard.setData(
ClipboardData(
text: viewModel.address,
),
);
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 0),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
child: SelectableText(
viewModel.address,
style: const TextStyle(color: Colors.white),
)),
const Icon(Icons.copy, color: Colors.grey),
],
),
);
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 0),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
child: SelectableText(
viewModel.address,
style: const TextStyle(color: Colors.white),
)),
const Icon(Icons.copy, color: Colors.grey),
],
),
),
),
),
Expand Down
24 changes: 12 additions & 12 deletions lib/views/urqr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ class _URQRState extends State<URQR> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: Container(
padding: const EdgeInsets.all(17.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: Colors.white,
),
child: QrImageView(
foregroundColor: Colors.black,
data: widget.frames[frame % widget.frames.length],
version: -1,
size: 275,
child: Container(
padding: const EdgeInsets.all(17.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: Colors.white,
),
child: QrImageView(
foregroundColor: Colors.black,
data: widget.frames[frame % widget.frames.length],
version: -1,
size: 275,
),
),
),
),
],
);
Expand Down
4 changes: 2 additions & 2 deletions lib/views/wallet_home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ class WalletHome extends AbstractView {
child: ElevatedButton.icon(
onPressed: () =>
Receive.pushStatic(context, viewModel.wallet),
icon:
const Icon(Icons.call_received, size: 35, color: Colors.white),
icon: const Icon(Icons.call_received,
size: 35, color: Colors.white),
label: Text(
L.receive,
style: const TextStyle(color: Colors.white, fontSize: 18),
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -988,10 +988,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "14.2.4"
version: "14.2.5"
watcher:
dependency: transitive
description:
Expand Down

0 comments on commit f1205ac

Please sign in to comment.