exchange rate type toggle mouse regions

This commit is contained in:
julian 2022-11-19 09:24:32 -06:00
parent b2ff99be19
commit cc4dc9e3c7

View file

@ -8,6 +8,7 @@ import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/rounded_container.dart'; import 'package:stackwallet/widgets/rounded_container.dart';
class RateTypeToggle extends ConsumerWidget { class RateTypeToggle extends ConsumerWidget {
@ -35,145 +36,163 @@ class RateTypeToggle extends ConsumerWidget {
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(
child: GestureDetector( child: ConditionalParent(
onTap: () { condition: isDesktop,
if (!estimated) { builder: (child) => MouseRegion(
ref.read(prefsChangeNotifierProvider).exchangeRateType = cursor: estimated
ExchangeRateType.estimated; ? SystemMouseCursors.basic
onChanged?.call(ExchangeRateType.estimated); : SystemMouseCursors.click,
} child: child,
}, ),
child: RoundedContainer( child: GestureDetector(
padding: isDesktop onTap: () {
? const EdgeInsets.all(17) if (!estimated) {
: const EdgeInsets.all(0), ref.read(prefsChangeNotifierProvider).exchangeRateType =
color: estimated ExchangeRateType.estimated;
? Theme.of(context) onChanged?.call(ExchangeRateType.estimated);
.extension<StackColors>()! }
.textFieldDefaultBG },
: Colors.transparent, child: RoundedContainer(
child: Row( padding: isDesktop
mainAxisAlignment: MainAxisAlignment.center, ? const EdgeInsets.all(17)
children: [ : const EdgeInsets.all(0),
SvgPicture.asset( color: estimated
Assets.svg.lockOpen, ? Theme.of(context)
width: 12, .extension<StackColors>()!
height: 14, .textFieldDefaultBG
color: isDesktop : Colors.transparent,
? estimated child: Row(
? Theme.of(context) mainAxisAlignment: MainAxisAlignment.center,
.extension<StackColors>()! children: [
.accentColorBlue SvgPicture.asset(
: Theme.of(context) Assets.svg.lockOpen,
.extension<StackColors>()! width: 12,
.buttonTextSecondary height: 14,
: estimated color: isDesktop
? Theme.of(context) ? estimated
.extension<StackColors>()! ? Theme.of(context)
.textDark .extension<StackColors>()!
: Theme.of(context) .accentColorBlue
.extension<StackColors>()! : Theme.of(context)
.textSubtitle1, .extension<StackColors>()!
), .buttonTextSecondary
const SizedBox( : estimated
width: 5, ? Theme.of(context)
), .extension<StackColors>()!
Text( .textDark
"Estimate rate", : Theme.of(context)
style: isDesktop .extension<StackColors>()!
? STextStyles.desktopTextExtraExtraSmall(context) .textSubtitle1,
.copyWith( ),
color: estimated const SizedBox(
? Theme.of(context) width: 5,
.extension<StackColors>()! ),
.accentColorBlue Text(
: Theme.of(context) "Estimate rate",
.extension<StackColors>()! style: isDesktop
.buttonTextSecondary, ? STextStyles.desktopTextExtraExtraSmall(context)
) .copyWith(
: STextStyles.smallMed12(context).copyWith( color: estimated
color: estimated ? Theme.of(context)
? Theme.of(context) .extension<StackColors>()!
.extension<StackColors>()! .accentColorBlue
.textDark : Theme.of(context)
: Theme.of(context) .extension<StackColors>()!
.extension<StackColors>()! .buttonTextSecondary,
.textSubtitle1, )
), : STextStyles.smallMed12(context).copyWith(
), color: estimated
], ? Theme.of(context)
.extension<StackColors>()!
.textDark
: Theme.of(context)
.extension<StackColors>()!
.textSubtitle1,
),
),
],
),
), ),
), ),
), ),
), ),
Expanded( Expanded(
child: GestureDetector( child: ConditionalParent(
onTap: () { condition: isDesktop,
if (estimated) { builder: (child) => MouseRegion(
ref.read(prefsChangeNotifierProvider).exchangeRateType = cursor: !estimated
ExchangeRateType.fixed; ? SystemMouseCursors.basic
onChanged?.call(ExchangeRateType.fixed); : SystemMouseCursors.click,
} child: child,
}, ),
child: RoundedContainer( child: GestureDetector(
padding: isDesktop onTap: () {
? const EdgeInsets.all(17) if (estimated) {
: const EdgeInsets.all(0), ref.read(prefsChangeNotifierProvider).exchangeRateType =
color: !estimated ExchangeRateType.fixed;
? Theme.of(context) onChanged?.call(ExchangeRateType.fixed);
.extension<StackColors>()! }
.textFieldDefaultBG },
: Colors.transparent, child: RoundedContainer(
child: Row( padding: isDesktop
mainAxisAlignment: MainAxisAlignment.center, ? const EdgeInsets.all(17)
children: [ : const EdgeInsets.all(0),
SvgPicture.asset( color: !estimated
Assets.svg.lock, ? Theme.of(context)
width: 12, .extension<StackColors>()!
height: 14, .textFieldDefaultBG
color: isDesktop : Colors.transparent,
? !estimated child: Row(
? Theme.of(context) mainAxisAlignment: MainAxisAlignment.center,
.extension<StackColors>()! children: [
.accentColorBlue SvgPicture.asset(
: Theme.of(context) Assets.svg.lock,
.extension<StackColors>()! width: 12,
.buttonTextSecondary height: 14,
: !estimated color: isDesktop
? Theme.of(context) ? !estimated
.extension<StackColors>()! ? Theme.of(context)
.textDark .extension<StackColors>()!
: Theme.of(context) .accentColorBlue
.extension<StackColors>()! : Theme.of(context)
.textSubtitle1, .extension<StackColors>()!
), .buttonTextSecondary
const SizedBox( : !estimated
width: 5, ? Theme.of(context)
), .extension<StackColors>()!
Text( .textDark
"Fixed rate", : Theme.of(context)
style: isDesktop .extension<StackColors>()!
? STextStyles.desktopTextExtraExtraSmall(context) .textSubtitle1,
.copyWith( ),
color: !estimated const SizedBox(
? Theme.of(context) width: 5,
.extension<StackColors>()! ),
.accentColorBlue Text(
: Theme.of(context) "Fixed rate",
.extension<StackColors>()! style: isDesktop
.buttonTextSecondary, ? STextStyles.desktopTextExtraExtraSmall(context)
) .copyWith(
: STextStyles.smallMed12(context).copyWith( color: !estimated
color: !estimated ? Theme.of(context)
? Theme.of(context) .extension<StackColors>()!
.extension<StackColors>()! .accentColorBlue
.textDark : Theme.of(context)
: Theme.of(context) .extension<StackColors>()!
.extension<StackColors>()! .buttonTextSecondary,
.textSubtitle1, )
), : STextStyles.smallMed12(context).copyWith(
), color: !estimated
], ? Theme.of(context)
.extension<StackColors>()!
.textDark
: Theme.of(context)
.extension<StackColors>()!
.textSubtitle1,
),
),
],
),
), ),
), ),
), ),