Merge pull request #146 from cypherstack/ui-fixes

various incognito mode fixes
This commit is contained in:
julian-CStack 2022-10-18 09:41:14 -06:00 committed by GitHub
commit 90a80ce7a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 123 additions and 98 deletions

View file

@ -79,23 +79,25 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
transactionIfSentFromStack = widget.transactionIfSentFromStack;
walletId = widget.walletId;
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
final trade = ref
.read(tradesServiceProvider)
.trades
.firstWhere((e) => e.tradeId == tradeId);
if (ref.read(prefsChangeNotifierProvider).externalCalls) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
final trade = ref
.read(tradesServiceProvider)
.trades
.firstWhere((e) => e.tradeId == tradeId);
if (mounted) {
final exchange = Exchange.fromName(trade.exchangeName);
final response = await exchange.updateTrade(trade);
if (mounted) {
final exchange = Exchange.fromName(trade.exchangeName);
final response = await exchange.updateTrade(trade);
if (mounted && response.value != null) {
await ref
.read(tradesServiceProvider)
.edit(trade: response.value!, shouldNotifyListeners: true);
if (mounted && response.value != null) {
await ref
.read(tradesServiceProvider)
.edit(trade: response.value!, shouldNotifyListeners: true);
}
}
}
});
});
}
super.initState();
}

View file

@ -11,13 +11,13 @@ import 'package:stackwallet/pages/settings_views/global_settings_view/global_set
import 'package:stackwallet/pages/settings_views/global_settings_view/hidden_settings.dart';
import 'package:stackwallet/pages/wallets_view/wallets_view.dart';
import 'package:stackwallet/providers/global/notifications_provider.dart';
import 'package:stackwallet/providers/global/prefs_provider.dart';
import 'package:stackwallet/providers/ui/home_view_index_provider.dart';
import 'package:stackwallet/providers/ui/unread_notifications_provider.dart';
import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/prefs.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
@ -83,9 +83,7 @@ class _HomeViewState extends ConsumerState<HomeView> {
void _loadCNData() {
// unawaited future
//
final externalCalls = Prefs.instance.externalCalls;
if (externalCalls) {
if (ref.read(prefsChangeNotifierProvider).externalCalls) {
_exchangeDataLoadingService.loadAll(ref);
} else {
Logging.instance.log("User does not want to use external calls",

View file

@ -70,6 +70,8 @@ class _WalletSummaryInfoState extends State<WalletSummaryInfo> {
builder: (_, ref, __) {
final Coin coin =
ref.watch(managerProvider.select((value) => value.coin));
final externalCalls = ref.watch(prefsChangeNotifierProvider
.select((value) => value.externalCalls));
Future<Decimal>? totalBalanceFuture;
Future<Decimal>? availableBalanceFuture;
@ -176,18 +178,19 @@ class _WalletSummaryInfoState extends State<WalletSummaryInfo> {
),
),
),
Text(
"${Format.localizedStringAsFixed(
value: priceTuple.item1 * balanceToShow,
locale: locale,
decimalPlaces: 2,
)} $baseCurrency",
style: STextStyles.subtitle500(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textFavoriteCard,
if (externalCalls)
Text(
"${Format.localizedStringAsFixed(
value: priceTuple.item1 * balanceToShow,
locale: locale,
decimalPlaces: 2,
)} $baseCurrency",
style: STextStyles.subtitle500(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textFavoriteCard,
),
),
),
],
);
} else {

View file

@ -255,17 +255,19 @@ class _TransactionDetailsViewState
const SizedBox(
height: 2,
),
SelectableText(
"${Format.localizedStringAsFixed(value: (coin == Coin.monero ? (amount / 10000.toDecimal()).toDecimal() : coin == Coin.wownero ? (amount / 1000.toDecimal()).toDecimal() : amount) * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin).item1)), locale: ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
), decimalPlaces: 2)} ${ref.watch(
prefsChangeNotifierProvider.select(
(value) => value.currency,
),
)}",
style: STextStyles.itemSubtitle(context),
),
if (ref.watch(prefsChangeNotifierProvider
.select((value) => value.externalCalls)))
SelectableText(
"${Format.localizedStringAsFixed(value: (coin == Coin.monero ? (amount / 10000.toDecimal()).toDecimal() : coin == Coin.wownero ? (amount / 1000.toDecimal()).toDecimal() : amount) * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin).item1)), locale: ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
), decimalPlaces: 2)} ${ref.watch(
prefsChangeNotifierProvider.select(
(value) => value.currency,
),
)}",
style: STextStyles.itemSubtitle(context),
),
],
),
TxIcon(

View file

@ -49,6 +49,8 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
@override
Widget build(BuildContext context) {
final coin = ref.watch(managerProvider.select((value) => value.coin));
final externalCalls = ref.watch(
prefsChangeNotifierProvider.select((value) => value.externalCalls));
return GestureDetector(
onTap: () {
@ -70,7 +72,9 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
width: widget.width,
height: widget.height,
decoration: BoxDecoration(
color: Theme.of(context).extension<StackColors>()!.colorForCoin(coin),
color: Theme.of(context)
.extension<StackColors>()!
.colorForCoin(coin),
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
@ -138,7 +142,9 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
ref.watch(managerProvider
.select((value) => value.walletName)),
style: STextStyles.itemSubtitle12(context).copyWith(
color: Theme.of(context).extension<StackColors>()!.textFavoriteCard,
color: Theme.of(context)
.extension<StackColors>()!
.textFavoriteCard,
),
overflow: TextOverflow.fade,
),
@ -159,14 +165,16 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
snapshot.hasData) {
if (snapshot.data != null) {
_cachedBalance = snapshot.data!;
_cachedFiatValue = _cachedBalance *
ref
.watch(
priceAnd24hChangeNotifierProvider.select(
(value) => value.getPrice(coin),
),
)
.item1;
if (externalCalls) {
_cachedFiatValue = _cachedBalance *
ref
.watch(
priceAnd24hChangeNotifierProvider.select(
(value) => value.getPrice(coin),
),
)
.item1;
}
}
}
return Column(
@ -185,30 +193,36 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
)} ${coin.ticker}",
style: STextStyles.titleBold12(context).copyWith(
fontSize: 16,
color: Theme.of(context).extension<StackColors>()!.textFavoriteCard,
color: Theme.of(context)
.extension<StackColors>()!
.textFavoriteCard,
),
),
),
const SizedBox(
height: 4,
),
Text(
"${Format.localizedStringAsFixed(
decimalPlaces: 2,
value: _cachedFiatValue,
locale: ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
),
)} ${ref.watch(
prefsChangeNotifierProvider
.select((value) => value.currency),
)}",
style: STextStyles.itemSubtitle12(context).copyWith(
fontSize: 10,
color: Theme.of(context).extension<StackColors>()!.textFavoriteCard,
if (externalCalls)
const SizedBox(
height: 4,
),
if (externalCalls)
Text(
"${Format.localizedStringAsFixed(
decimalPlaces: 2,
value: _cachedFiatValue,
locale: ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
),
)} ${ref.watch(
prefsChangeNotifierProvider
.select((value) => value.currency),
)}",
style: STextStyles.itemSubtitle12(context).copyWith(
fontSize: 10,
color: Theme.of(context)
.extension<StackColors>()!
.textFavoriteCard,
),
),
),
],
);
},

View file

@ -84,7 +84,9 @@ class NotificationsService extends ChangeNotifier {
_timer = Timer.periodic(notificationRefreshInterval, (_) {
Logging.instance
.log("Periodic notifications update check", level: LogLevel.Info);
_checkTrades();
if (prefs.externalCalls) {
_checkTrades();
}
_checkTransactions();
});
}

View file

@ -569,6 +569,6 @@ class Prefs extends ChangeNotifier {
Future<bool> _getHasExternalCalls() async {
return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "externalCalls") as bool? ??
false;
true;
}
}

View file

@ -202,35 +202,39 @@ class _TransactionCardState extends ConsumerState<TransactionCard> {
),
),
),
const SizedBox(
width: 10,
),
Flexible(
child: FittedBox(
fit: BoxFit.scaleDown,
child: Builder(
builder: (_) {
// TODO: modify Format.<functions> to take optional Coin parameter so this type oif check isn't done in ui
int value = _transaction.amount;
if (coin == Coin.monero) {
value = (value ~/ 10000);
} else if (coin == Coin.wownero) {
value = (value ~/ 1000);
}
if (ref.watch(prefsChangeNotifierProvider
.select((value) => value.externalCalls)))
const SizedBox(
width: 10,
),
if (ref.watch(prefsChangeNotifierProvider
.select((value) => value.externalCalls)))
Flexible(
child: FittedBox(
fit: BoxFit.scaleDown,
child: Builder(
builder: (_) {
// TODO: modify Format.<functions> to take optional Coin parameter so this type oif check isn't done in ui
int value = _transaction.amount;
if (coin == Coin.monero) {
value = (value ~/ 10000);
} else if (coin == Coin.wownero) {
value = (value ~/ 1000);
}
return Text(
"${Format.localizedStringAsFixed(
value: Format.satoshisToAmount(value) *
price,
locale: locale,
decimalPlaces: 2,
)} $baseCurrency",
style: STextStyles.label(context),
);
},
return Text(
"${Format.localizedStringAsFixed(
value: Format.satoshisToAmount(value) *
price,
locale: locale,
decimalPlaces: 2,
)} $baseCurrency",
style: STextStyles.label(context),
);
},
),
),
),
),
],
),
],