From c81662de83e6297eaeed11b6caa523d817c48852 Mon Sep 17 00:00:00 2001 From: poka Date: Tue, 6 Dec 2022 04:38:33 +0100 Subject: [PATCH] refacto: new UdUnitDisplay Widget --- lib/providers/wallet_options.dart | 31 +-------------------- lib/widgets/balance.dart | 5 ++-- lib/widgets/ud_unit_display.dart | 45 +++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 32 deletions(-) create mode 100644 lib/widgets/ud_unit_display.dart diff --git a/lib/providers/wallet_options.dart b/lib/providers/wallet_options.dart index e09da33..81abd47 100644 --- a/lib/providers/wallet_options.dart +++ b/lib/providers/wallet_options.dart @@ -390,34 +390,5 @@ class WalletOptionsProvider with ChangeNotifier { return addressGet; } - - Widget udUnitDisplay(double size, [Color color = Colors.black]) { - final bool isUdUnit = configBox.get('isUdUnit') ?? false; - return isUdUnit - ? Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Text( - 'ud'.tr(args: ['']), - style: TextStyle( - fontSize: isTall ? size : size * 0.9, color: color), - ), - Column( - children: [ - Text( - currencyName, - style: TextStyle( - fontSize: (isTall ? size : size * 0.9) * 0.7, - fontWeight: FontWeight.w500, - color: color), - ), - const SizedBox(height: 15) - ], - ) - ], - ) - : Text(currencyName, - style: - TextStyle(fontSize: isTall ? size : size * 0.9, color: color)); - } } + diff --git a/lib/widgets/balance.dart b/lib/widgets/balance.dart index 96aae00..53517f0 100644 --- a/lib/widgets/balance.dart +++ b/lib/widgets/balance.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/providers/substrate_sdk.dart'; import 'package:gecko/providers/wallet_options.dart'; +import 'package:gecko/widgets/ud_unit_display.dart'; import 'package:provider/provider.dart'; class Balance extends StatelessWidget { @@ -37,7 +38,7 @@ class Balance extends StatelessWidget { fontSize: isTall ? size : size * 0.9, color: color)), const SizedBox(width: 5), - walletOptions.udUnitDisplay(size, color), + UdUnitDisplay(size: size, color: color), ]); } else { return SizedBox( @@ -62,7 +63,7 @@ class Balance extends StatelessWidget { ), ), const SizedBox(width: 5), - walletOptions.udUnitDisplay(size, color), + UdUnitDisplay(size: size, color: color), ]); } else { return const Text(''); diff --git a/lib/widgets/ud_unit_display.dart b/lib/widgets/ud_unit_display.dart new file mode 100644 index 0000000..942b155 --- /dev/null +++ b/lib/widgets/ud_unit_display.dart @@ -0,0 +1,45 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:gecko/globals.dart'; + +class UdUnitDisplay extends StatelessWidget { + const UdUnitDisplay({ + Key? key, + required this.size, + required this.color, + }) : super(key: key); + + final double size; + final Color color; + + @override + Widget build(BuildContext context) { + final bool isUdUnit = configBox.get('isUdUnit') ?? false; + return isUdUnit + ? Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Text( + 'ud'.tr(args: ['']), + style: TextStyle( + fontSize: isTall ? size : size * 0.9, color: color), + ), + Column( + children: [ + Text( + currencyName, + style: TextStyle( + fontSize: (isTall ? size : size * 0.9) * 0.7, + fontWeight: FontWeight.w500, + color: color), + ), + const SizedBox(height: 15) + ], + ) + ], + ) + : Text(currencyName, + style: + TextStyle(fontSize: isTall ? size : size * 0.9, color: color)); + } +}