mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 12:44:31 +00:00
update remaining ui to handle new data models
This commit is contained in:
parent
f8c6a17fa7
commit
525d0fa7c4
13 changed files with 111 additions and 91 deletions
|
@ -2,6 +2,8 @@ import 'dart:async';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
|
||||
import 'package:stackwallet/pages/exchange_view/exchange_form.dart';
|
||||
import 'package:stackwallet/pages/exchange_view/trade_details_view.dart';
|
||||
import 'package:stackwallet/providers/global/trades_service_provider.dart';
|
||||
|
@ -129,10 +131,10 @@ class _ExchangeViewState extends ConsumerState<ExchangeView> {
|
|||
//todo: check if print needed
|
||||
// debugPrint("name: ${manager.walletName}");
|
||||
|
||||
// TODO store tx data completely locally in isar so we don't lock up ui here when querying txData
|
||||
final txData = await manager.transactionData;
|
||||
|
||||
final tx = txData.getAllTransactions()[txid];
|
||||
final tx = await manager.db.transactions
|
||||
.filter()
|
||||
.txidEqualTo(txid)
|
||||
.findFirst();
|
||||
|
||||
if (mounted) {
|
||||
unawaited(Navigator.of(context).pushNamed(
|
||||
|
|
|
@ -438,8 +438,10 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|||
style: STextStyles.itemSubtitle(context),
|
||||
),
|
||||
FutureBuilder(
|
||||
future: (manager.wallet as FiroWallet)
|
||||
.availablePrivateBalance(),
|
||||
// TODO redo this widget now that its not actually a future
|
||||
future: Future(() =>
|
||||
(manager.wallet as FiroWallet)
|
||||
.availablePrivateBalance()),
|
||||
builder: (builderContext,
|
||||
AsyncSnapshot<Decimal> snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
|
@ -524,8 +526,10 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|||
style: STextStyles.itemSubtitle(context),
|
||||
),
|
||||
FutureBuilder(
|
||||
future: (manager.wallet as FiroWallet)
|
||||
.availablePublicBalance(),
|
||||
// TODO redo this widget now that its not actually a future
|
||||
future: Future(() =>
|
||||
(manager.wallet as FiroWallet)
|
||||
.availablePublicBalance()),
|
||||
builder: (builderContext,
|
||||
AsyncSnapshot<Decimal> snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
|
@ -634,7 +638,8 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|||
),
|
||||
if (!isFiro)
|
||||
FutureBuilder(
|
||||
future: manager.totalBalance,
|
||||
// TODO redo this widget now that its not actually a future
|
||||
future: Future(() => manager.balance.getTotal()),
|
||||
builder:
|
||||
(builderContext, AsyncSnapshot<Decimal> snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
|
|
|
@ -485,22 +485,22 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
coin == Coin.firoTestNet)
|
||||
const Spacer(),
|
||||
FutureBuilder(
|
||||
// TODO redo this widget now that its not actually a future
|
||||
future: (coin != Coin.firo &&
|
||||
coin != Coin.firoTestNet)
|
||||
? ref.watch(provider.select(
|
||||
(value) => value.availableBalance))
|
||||
: ref
|
||||
.watch(
|
||||
publicPrivateBalanceStateProvider
|
||||
.state)
|
||||
.state ==
|
||||
? Future(() => ref.watch(
|
||||
provider.select((value) =>
|
||||
value.balance.getSpendable())))
|
||||
: ref.watch(publicPrivateBalanceStateProvider.state).state ==
|
||||
"Private"
|
||||
? (ref.watch(provider).wallet
|
||||
as FiroWallet)
|
||||
.availablePrivateBalance()
|
||||
: (ref.watch(provider).wallet
|
||||
as FiroWallet)
|
||||
.availablePublicBalance(),
|
||||
? Future(() => (ref
|
||||
.watch(provider)
|
||||
.wallet as FiroWallet)
|
||||
.availablePrivateBalance())
|
||||
: Future(() => (ref
|
||||
.watch(provider)
|
||||
.wallet as FiroWallet)
|
||||
.availablePublicBalance()),
|
||||
builder:
|
||||
(_, AsyncSnapshot<Decimal> snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
|
@ -1085,9 +1085,10 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
.decimalPlacesForCoin(coin));
|
||||
}
|
||||
} else {
|
||||
cryptoAmountController.text = (await ref
|
||||
cryptoAmountController.text = (ref
|
||||
.read(provider)
|
||||
.availableBalance)
|
||||
.balance
|
||||
.getSpendable())
|
||||
.toStringAsFixed(
|
||||
Constants.decimalPlacesForCoin(
|
||||
coin));
|
||||
|
@ -1523,43 +1524,43 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
.read(walletsChangeNotifierProvider)
|
||||
.getManager(walletId);
|
||||
|
||||
// TODO: remove the need for this!!
|
||||
final bool isOwnAddress =
|
||||
await manager.isOwnAddress(_address!);
|
||||
if (isOwnAddress && coin != Coin.dogecoinTestNet) {
|
||||
await showDialog<dynamic>(
|
||||
context: context,
|
||||
useSafeArea: false,
|
||||
barrierDismissible: true,
|
||||
builder: (context) {
|
||||
return StackDialog(
|
||||
title: "Transaction failed",
|
||||
message:
|
||||
"Sending to self is currently disabled",
|
||||
rightButton: TextButton(
|
||||
style: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.getSecondaryEnabledButtonColor(
|
||||
context),
|
||||
child: Text(
|
||||
"Ok",
|
||||
style: STextStyles.button(
|
||||
context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<
|
||||
StackColors>()!
|
||||
.accentColorDark),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
return;
|
||||
}
|
||||
// // TODO: remove the need for this!!
|
||||
// final bool isOwnAddress =
|
||||
// await manager.isOwnAddress(_address!);
|
||||
// if (isOwnAddress && coin != Coin.dogecoinTestNet) {
|
||||
// await showDialog<dynamic>(
|
||||
// context: context,
|
||||
// useSafeArea: false,
|
||||
// barrierDismissible: true,
|
||||
// builder: (context) {
|
||||
// return StackDialog(
|
||||
// title: "Transaction failed",
|
||||
// message:
|
||||
// "Sending to self is currently disabled",
|
||||
// rightButton: TextButton(
|
||||
// style: Theme.of(context)
|
||||
// .extension<StackColors>()!
|
||||
// .getSecondaryEnabledButtonColor(
|
||||
// context),
|
||||
// child: Text(
|
||||
// "Ok",
|
||||
// style: STextStyles.button(
|
||||
// context)
|
||||
// .copyWith(
|
||||
// color: Theme.of(context)
|
||||
// .extension<
|
||||
// StackColors>()!
|
||||
// .accentColorDark),
|
||||
// ),
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pop();
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// return;
|
||||
// }
|
||||
|
||||
final amount =
|
||||
Format.decimalAmountToSatoshis(
|
||||
|
@ -1575,22 +1576,20 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
"Private") {
|
||||
availableBalance =
|
||||
Format.decimalAmountToSatoshis(
|
||||
await (manager.wallet
|
||||
as FiroWallet)
|
||||
(manager.wallet as FiroWallet)
|
||||
.availablePrivateBalance(),
|
||||
coin);
|
||||
} else {
|
||||
availableBalance =
|
||||
Format.decimalAmountToSatoshis(
|
||||
await (manager.wallet
|
||||
as FiroWallet)
|
||||
(manager.wallet as FiroWallet)
|
||||
.availablePublicBalance(),
|
||||
coin);
|
||||
}
|
||||
} else {
|
||||
availableBalance =
|
||||
Format.decimalAmountToSatoshis(
|
||||
await manager.availableBalance,
|
||||
manager.balance.getSpendable(),
|
||||
coin);
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,9 @@ class _FiroBalanceSelectionSheetState
|
|||
width: 2,
|
||||
),
|
||||
FutureBuilder(
|
||||
future: firoWallet.availablePrivateBalance(),
|
||||
// TODO redo this widget now that its not actually a future
|
||||
future: Future(
|
||||
() => firoWallet.availablePrivateBalance()),
|
||||
builder:
|
||||
(context, AsyncSnapshot<Decimal> snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
|
@ -244,7 +246,9 @@ class _FiroBalanceSelectionSheetState
|
|||
width: 2,
|
||||
),
|
||||
FutureBuilder(
|
||||
future: firoWallet.availablePublicBalance(),
|
||||
// TODO redo this widget now that its not actually a future
|
||||
future: Future(
|
||||
() => firoWallet.availablePublicBalance()),
|
||||
builder:
|
||||
(context, AsyncSnapshot<Decimal> snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
|
|
|
@ -145,7 +145,8 @@ class WalletSyncingOptionsView extends ConsumerWidget {
|
|||
height: 2,
|
||||
),
|
||||
FutureBuilder(
|
||||
future: manager.totalBalance,
|
||||
future: Future(
|
||||
() => manager.balance.getTotal()),
|
||||
builder: (builderContext,
|
||||
AsyncSnapshot<Decimal> snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
|
|
|
@ -217,8 +217,8 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
|
|||
),
|
||||
),
|
||||
FutureBuilder(
|
||||
future: ref.watch(
|
||||
managerProvider.select((value) => value.totalBalance)),
|
||||
future: Future(() => ref.watch(managerProvider
|
||||
.select((value) => value.balance.getTotal()))),
|
||||
builder: (builderContext, AsyncSnapshot<Decimal> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/contact.dart';
|
||||
import 'package:stackwallet/models/paymint/transactions_model.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
|
||||
import 'package:stackwallet/pages/address_book_views/subviews/add_new_contact_address_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/address_book_view/subwidgets/desktop_address_card.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_options_menu_popup.dart';
|
||||
|
@ -57,11 +58,12 @@ class _DesktopContactDetailsState extends ConsumerState<DesktopContactDetails> {
|
|||
|
||||
List<Tuple2<String, Transaction>> result = [];
|
||||
for (final manager in managers) {
|
||||
final transactions = (await manager.transactionData)
|
||||
.getAllTransactions()
|
||||
.values
|
||||
.toList()
|
||||
.where((e) => _contactHasAddress(e.address, contact));
|
||||
final transactions = await manager.db.transactions
|
||||
.filter()
|
||||
.anyOf(contact.addresses.map((e) => e.address),
|
||||
(q, String e) => q.addressEqualTo(e))
|
||||
.sortByTimestampDesc()
|
||||
.findAll();
|
||||
|
||||
for (final tx in transactions) {
|
||||
result.add(Tuple2(manager.walletId, tx));
|
||||
|
|
|
@ -4,12 +4,15 @@ import 'package:decimal/decimal.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart';
|
||||
import 'package:stackwallet/models/exchange/response_objects/trade.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||
import 'package:stackwallet/pages/exchange_view/trade_details_view.dart';
|
||||
import 'package:stackwallet/providers/exchange/trade_sent_from_stack_lookup_provider.dart';
|
||||
import 'package:stackwallet/providers/global/trades_service_provider.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/format.dart';
|
||||
|
@ -26,8 +29,6 @@ import 'package:stackwallet/widgets/stack_text_field.dart';
|
|||
import 'package:stackwallet/widgets/textfield_icon_button.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
import '../../route_generator.dart';
|
||||
|
||||
class DesktopAllTradesView extends ConsumerStatefulWidget {
|
||||
const DesktopAllTradesView({Key? key}) : super(key: key);
|
||||
|
||||
|
@ -349,10 +350,11 @@ class _DesktopTradeRowCardState extends ConsumerState<DesktopTradeRowCard> {
|
|||
//todo: check if print needed
|
||||
// debugPrint("name: ${manager.walletName}");
|
||||
|
||||
// TODO store tx data completely locally in isar so we don't lock up ui here when querying txData
|
||||
final txData = await manager.transactionData;
|
||||
final tx = await manager.db.transactions
|
||||
.filter()
|
||||
.txidEqualTo(txid)
|
||||
.findFirst();
|
||||
|
||||
final tx = txData.getAllTransactions()[txid];
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => DesktopDialog(
|
||||
|
|
|
@ -305,8 +305,9 @@ class _BalanceDisplayState extends ConsumerState<BalanceDisplay> {
|
|||
final locale = ref.watch(
|
||||
localeServiceChangeNotifierProvider.select((value) => value.locale));
|
||||
|
||||
// TODO redo this widget now that its not actually a future
|
||||
return FutureBuilder(
|
||||
future: manager.availableBalance,
|
||||
future: Future(() => manager.balance.getSpendable()),
|
||||
builder: (context, AsyncSnapshot<Decimal> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData &&
|
||||
|
|
|
@ -2,6 +2,8 @@ import 'dart:async';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
|
||||
import 'package:stackwallet/pages/exchange_view/trade_details_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart';
|
||||
import 'package:stackwallet/providers/exchange/trade_sent_from_stack_lookup_provider.dart';
|
||||
|
@ -126,10 +128,10 @@ class _DesktopTradeHistoryState extends ConsumerState<DesktopTradeHistory> {
|
|||
//todo: check if print needed
|
||||
// debugPrint("name: ${manager.walletName}");
|
||||
|
||||
// TODO store tx data completely locally in isar so we don't lock up ui here when querying txData
|
||||
final txData = await manager.transactionData;
|
||||
|
||||
final tx = txData.getAllTransactions()[txid];
|
||||
final tx = await manager.db.transactions
|
||||
.filter()
|
||||
.txidEqualTo(txid)
|
||||
.findFirst();
|
||||
|
||||
if (mounted) {
|
||||
await showDialog<void>(
|
||||
|
|
|
@ -5,7 +5,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||
import 'package:stackwallet/models/contact_address_entry.dart';
|
||||
import 'package:stackwallet/models/exchange/incomplete_exchange.dart';
|
||||
import 'package:stackwallet/models/exchange/response_objects/trade.dart';
|
||||
import 'package:stackwallet/models/paymint/transactions_model.dart';
|
||||
import 'package:stackwallet/models/send_view_auto_fill_data.dart';
|
||||
import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart';
|
||||
import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart';
|
||||
|
@ -122,6 +121,8 @@ import 'package:stackwallet/utilities/enums/add_wallet_type_enum.dart';
|
|||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
import 'models/isar/models/blockchain_data/transaction.dart';
|
||||
|
||||
class RouteGenerator {
|
||||
static const bool useMaterialPageRoute = true;
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ class _ManagedFavoriteCardState extends ConsumerState<ManagedFavorite> {
|
|||
Expanded(
|
||||
child: Text(
|
||||
"${Format.localizedStringAsFixed(
|
||||
value: manager.cachedTotalBalance,
|
||||
value: manager.balance.getTotal(),
|
||||
locale: ref.watch(
|
||||
localeServiceChangeNotifierProvider
|
||||
.select((value) => value.locale)),
|
||||
|
@ -147,7 +147,7 @@ class _ManagedFavoriteCardState extends ConsumerState<ManagedFavorite> {
|
|||
),
|
||||
Text(
|
||||
"${Format.localizedStringAsFixed(
|
||||
value: manager.cachedTotalBalance,
|
||||
value: manager.balance.getTotal(),
|
||||
locale: ref.watch(localeServiceChangeNotifierProvider
|
||||
.select((value) => value.locale)),
|
||||
decimalPlaces: 8,
|
||||
|
|
|
@ -27,8 +27,9 @@ class WalletInfoRowBalanceFuture extends ConsumerWidget {
|
|||
),
|
||||
);
|
||||
|
||||
// TODO redo this widget now that its not actually a future
|
||||
return FutureBuilder(
|
||||
future: manager.totalBalance,
|
||||
future: Future(() => manager.balance.getTotal()),
|
||||
builder: (builderContext, AsyncSnapshot<Decimal> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
|
|
Loading…
Reference in a new issue