refacto: new UdUnitDisplay Widget

This commit is contained in:
poka 2022-12-06 04:38:33 +01:00
parent 150f6892f8
commit c81662de83
3 changed files with 49 additions and 32 deletions

View File

@ -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));
}
}

View File

@ -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('');

View File

@ -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));
}
}