mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-02-02 03:06:29 +00:00
desktop exchange provider options dropdown style
This commit is contained in:
parent
9ba83f36eb
commit
16113fd1d5
1 changed files with 379 additions and 327 deletions
|
@ -15,7 +15,9 @@ import 'package:stackwallet/utilities/format.dart';
|
|||
import 'package:stackwallet/utilities/logger.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/widgets/animated_text.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||
|
||||
class ExchangeProviderOptions extends ConsumerWidget {
|
||||
|
@ -38,22 +40,38 @@ class ExchangeProviderOptions extends ConsumerWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final isDesktop = Util.isDesktop;
|
||||
return RoundedWhiteContainer(
|
||||
padding: isDesktop ? const EdgeInsets.all(0) : const EdgeInsets.all(12),
|
||||
borderColor: isDesktop
|
||||
? Theme.of(context).extension<StackColors>()!.background
|
||||
: null,
|
||||
child: Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
ConditionalParent(
|
||||
condition: isDesktop,
|
||||
builder: (child) => MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: child,
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (ref.read(currentExchangeNameStateProvider.state).state !=
|
||||
ChangeNowExchange.exchangeName) {
|
||||
ref.read(currentExchangeNameStateProvider.state).state =
|
||||
ChangeNowExchange.exchangeName;
|
||||
ref.read(exchangeFormStateProvider).exchange =
|
||||
Exchange.fromName(
|
||||
ref.read(currentExchangeNameStateProvider.state).state);
|
||||
Exchange.fromName(ref
|
||||
.read(currentExchangeNameStateProvider.state)
|
||||
.state);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: Padding(
|
||||
padding: isDesktop
|
||||
? const EdgeInsets.all(16)
|
||||
: const EdgeInsets.all(0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
@ -75,7 +93,8 @@ class ExchangeProviderOptions extends ConsumerWidget {
|
|||
.state = value;
|
||||
ref.read(exchangeFormStateProvider).exchange =
|
||||
Exchange.fromName(ref
|
||||
.read(currentExchangeNameStateProvider.state)
|
||||
.read(currentExchangeNameStateProvider
|
||||
.state)
|
||||
.state);
|
||||
}
|
||||
},
|
||||
|
@ -86,8 +105,8 @@ class ExchangeProviderOptions extends ConsumerWidget {
|
|||
),
|
||||
SvgPicture.asset(
|
||||
Assets.exchange.changeNow,
|
||||
width: 24,
|
||||
height: 24,
|
||||
width: isDesktop ? 32 : 24,
|
||||
height: isDesktop ? 32 : 24,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
|
@ -130,13 +149,13 @@ class ExchangeProviderOptions extends ConsumerWidget {
|
|||
if (estimate != null) {
|
||||
Decimal rate;
|
||||
if (estimate.reversed) {
|
||||
rate =
|
||||
(toAmount! / estimate.estimatedAmount)
|
||||
rate = (toAmount! /
|
||||
estimate.estimatedAmount)
|
||||
.toDecimal(
|
||||
scaleOnInfinitePrecision: 12);
|
||||
} else {
|
||||
rate =
|
||||
(estimate.estimatedAmount / fromAmount!)
|
||||
rate = (estimate.estimatedAmount /
|
||||
fromAmount!)
|
||||
.toDecimal(
|
||||
scaleOnInfinitePrecision: 12);
|
||||
}
|
||||
|
@ -145,14 +164,17 @@ class ExchangeProviderOptions extends ConsumerWidget {
|
|||
value: rate,
|
||||
locale: ref.watch(
|
||||
localeServiceChangeNotifierProvider
|
||||
.select((value) => value.locale),
|
||||
.select(
|
||||
(value) => value.locale),
|
||||
),
|
||||
decimalPlaces: to!.toUpperCase() ==
|
||||
Coin.monero.ticker.toUpperCase()
|
||||
Coin.monero.ticker
|
||||
.toUpperCase()
|
||||
? Constants.decimalPlacesMonero
|
||||
: Constants.decimalPlaces,
|
||||
)} ${to!.toUpperCase()}",
|
||||
style: STextStyles.itemSubtitle12(context)
|
||||
style:
|
||||
STextStyles.itemSubtitle12(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
|
@ -166,7 +188,8 @@ class ExchangeProviderOptions extends ConsumerWidget {
|
|||
);
|
||||
return Text(
|
||||
"Failed to fetch rate",
|
||||
style: STextStyles.itemSubtitle12(context)
|
||||
style:
|
||||
STextStyles.itemSubtitle12(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
|
@ -200,7 +223,8 @@ class ExchangeProviderOptions extends ConsumerWidget {
|
|||
fromAmount! > Decimal.zero))
|
||||
Text(
|
||||
"n/a",
|
||||
style: STextStyles.itemSubtitle12(context).copyWith(
|
||||
style: STextStyles.itemSubtitle12(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textSubtitle1,
|
||||
|
@ -213,22 +237,41 @@ class ExchangeProviderOptions extends ConsumerWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (isDesktop)
|
||||
Container(
|
||||
height: 1,
|
||||
color: Theme.of(context).extension<StackColors>()!.background,
|
||||
),
|
||||
if (!isDesktop)
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
GestureDetector(
|
||||
ConditionalParent(
|
||||
condition: isDesktop,
|
||||
builder: (child) => MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: child,
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (ref.read(currentExchangeNameStateProvider.state).state !=
|
||||
SimpleSwapExchange.exchangeName) {
|
||||
ref.read(currentExchangeNameStateProvider.state).state =
|
||||
SimpleSwapExchange.exchangeName;
|
||||
ref.read(exchangeFormStateProvider).exchange =
|
||||
Exchange.fromName(
|
||||
ref.read(currentExchangeNameStateProvider.state).state);
|
||||
Exchange.fromName(ref
|
||||
.read(currentExchangeNameStateProvider.state)
|
||||
.state);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: Padding(
|
||||
padding: isDesktop
|
||||
? const EdgeInsets.all(16)
|
||||
: const EdgeInsets.all(0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
@ -250,7 +293,8 @@ class ExchangeProviderOptions extends ConsumerWidget {
|
|||
.state = value;
|
||||
ref.read(exchangeFormStateProvider).exchange =
|
||||
Exchange.fromName(ref
|
||||
.read(currentExchangeNameStateProvider.state)
|
||||
.read(currentExchangeNameStateProvider
|
||||
.state)
|
||||
.state);
|
||||
}
|
||||
},
|
||||
|
@ -261,8 +305,8 @@ class ExchangeProviderOptions extends ConsumerWidget {
|
|||
),
|
||||
SvgPicture.asset(
|
||||
Assets.exchange.simpleSwap,
|
||||
width: 24,
|
||||
height: 24,
|
||||
width: isDesktop ? 32 : 24,
|
||||
height: isDesktop ? 32 : 24,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
|
@ -307,21 +351,25 @@ class ExchangeProviderOptions extends ConsumerWidget {
|
|||
if (estimate != null) {
|
||||
Decimal rate = (estimate.estimatedAmount /
|
||||
fromAmount!)
|
||||
.toDecimal(scaleOnInfinitePrecision: 12);
|
||||
.toDecimal(
|
||||
scaleOnInfinitePrecision: 12);
|
||||
|
||||
return Text(
|
||||
"1 ${from!.toUpperCase()} ~ ${Format.localizedStringAsFixed(
|
||||
value: rate,
|
||||
locale: ref.watch(
|
||||
localeServiceChangeNotifierProvider
|
||||
.select((value) => value.locale),
|
||||
.select(
|
||||
(value) => value.locale),
|
||||
),
|
||||
decimalPlaces: to!.toUpperCase() ==
|
||||
Coin.monero.ticker.toUpperCase()
|
||||
Coin.monero.ticker
|
||||
.toUpperCase()
|
||||
? Constants.decimalPlacesMonero
|
||||
: Constants.decimalPlaces,
|
||||
)} ${to!.toUpperCase()}",
|
||||
style: STextStyles.itemSubtitle12(context)
|
||||
style:
|
||||
STextStyles.itemSubtitle12(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
|
@ -335,7 +383,8 @@ class ExchangeProviderOptions extends ConsumerWidget {
|
|||
);
|
||||
return Text(
|
||||
"Failed to fetch rate",
|
||||
style: STextStyles.itemSubtitle12(context)
|
||||
style:
|
||||
STextStyles.itemSubtitle12(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
|
@ -375,7 +424,8 @@ class ExchangeProviderOptions extends ConsumerWidget {
|
|||
fromAmount! > Decimal.zero))
|
||||
Text(
|
||||
"n/a",
|
||||
style: STextStyles.itemSubtitle12(context).copyWith(
|
||||
style: STextStyles.itemSubtitle12(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textSubtitle1,
|
||||
|
@ -388,6 +438,8 @@ class ExchangeProviderOptions extends ConsumerWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue