mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-16 09:17:37 +00:00
clean up boost txn view
This commit is contained in:
parent
0fea4a78dc
commit
425dc1ca5a
4 changed files with 258 additions and 2137 deletions
File diff suppressed because it is too large
Load diff
|
@ -101,6 +101,59 @@ class _TransactionV2DetailsViewState
|
|||
|
||||
String? _sparkMemo;
|
||||
|
||||
bool _boostButtonLock = false;
|
||||
Future<void> _boostPressed() async {
|
||||
if (_boostButtonLock) {
|
||||
return;
|
||||
}
|
||||
_boostButtonLock = true;
|
||||
try {
|
||||
if (Util.isDesktop) {
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => DesktopDialog(
|
||||
maxHeight: null,
|
||||
maxWidth: 580,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 32),
|
||||
child: Text(
|
||||
"Boost transaction",
|
||||
style: STextStyles.desktopH3(context),
|
||||
),
|
||||
),
|
||||
const DesktopDialogCloseButton(),
|
||||
],
|
||||
),
|
||||
Flexible(
|
||||
child: SingleChildScrollView(
|
||||
child: BoostTransactionView(
|
||||
transaction: _transaction,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
unawaited(
|
||||
Navigator.of(context).pushNamed(
|
||||
BoostTransactionView.routeName,
|
||||
arguments: (tx: _transaction,),
|
||||
),
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
_boostButtonLock = false;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
isDesktop = Util.isDesktop;
|
||||
|
@ -484,6 +537,15 @@ class _TransactionV2DetailsViewState
|
|||
outputLabel = "Sent to";
|
||||
}
|
||||
|
||||
// TODO [prio=high]: set to true for ui testing
|
||||
final showBoost = true;
|
||||
// final showBoost = coin is! NanoCurrency &&
|
||||
// _transaction.type == TransactionType.outgoing &&
|
||||
// !_transaction.isConfirmed(
|
||||
// currentHeight,
|
||||
// coin.minConfirms,
|
||||
// );
|
||||
|
||||
return ConditionalParent(
|
||||
condition: !isDesktop,
|
||||
builder: (child) => Background(
|
||||
|
@ -1332,60 +1394,14 @@ class _TransactionV2DetailsViewState
|
|||
context,
|
||||
),
|
||||
),
|
||||
if (whatIsIt(
|
||||
_transaction,
|
||||
currentHeight,
|
||||
) ==
|
||||
"Sending" &&
|
||||
coin is! NanoCurrency)
|
||||
if (showBoost)
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
if (whatIsIt(
|
||||
_transaction,
|
||||
currentHeight,
|
||||
) ==
|
||||
"Sending" &&
|
||||
coin is! NanoCurrency)
|
||||
if (showBoost)
|
||||
CustomTextButton(
|
||||
text: "Boost transaction",
|
||||
onTap: () async {
|
||||
if (Util.isDesktop) {
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) =>
|
||||
DesktopDialog(
|
||||
maxHeight:
|
||||
MediaQuery.of(
|
||||
context)
|
||||
.size
|
||||
.height -
|
||||
64,
|
||||
maxWidth: 580,
|
||||
child:
|
||||
BoostTransactionView(
|
||||
transaction:
|
||||
_transaction,
|
||||
coin: coin,
|
||||
walletId: walletId,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
unawaited(
|
||||
Navigator.of(context)
|
||||
.pushNamed(
|
||||
BoostTransactionView
|
||||
.routeName,
|
||||
arguments: (
|
||||
tx: _transaction,
|
||||
coin: coin,
|
||||
walletId: walletId,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
onTap: _boostPressed,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -1836,16 +1852,16 @@ class _TransactionV2DetailsViewState
|
|||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
if (whatIsIt(
|
||||
_transaction,
|
||||
currentHeight,
|
||||
) !=
|
||||
"Sending")
|
||||
isDesktop
|
||||
? const _Divider()
|
||||
: const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
// if (whatIsIt(
|
||||
// _transaction,
|
||||
// currentHeight,
|
||||
// ) !=
|
||||
// "Sending")
|
||||
// isDesktop
|
||||
// ? const _Divider()
|
||||
// : const SizedBox(
|
||||
// height: 12,
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -144,6 +144,7 @@ import 'pages/wallet_view/transaction_views/edit_note_view.dart';
|
|||
import 'pages/wallet_view/transaction_views/transaction_details_view.dart';
|
||||
import 'pages/wallet_view/transaction_views/transaction_search_filter_view.dart';
|
||||
import 'pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart';
|
||||
import 'pages/wallet_view/transaction_views/tx_v2/boost_transaction_view.dart';
|
||||
import 'pages/wallet_view/transaction_views/tx_v2/fusion_group_details_view.dart';
|
||||
import 'pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart';
|
||||
import 'pages/wallet_view/wallet_view.dart';
|
||||
|
@ -2173,6 +2174,20 @@ class RouteGenerator {
|
|||
}
|
||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||
|
||||
case BoostTransactionView.routeName:
|
||||
if (args is TransactionV2) {
|
||||
return getRoute(
|
||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||
builder: (_) => BoostTransactionView(
|
||||
transaction: args,
|
||||
),
|
||||
settings: RouteSettings(
|
||||
name: settings.name,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||
|
||||
case BackupRestoreSettings.routeName:
|
||||
return getRoute(
|
||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||
|
|
|
@ -8,11 +8,11 @@ import '../wallets/crypto_currency/crypto_currency.dart'; // Update with your ac
|
|||
|
||||
class BoostFeeSlider extends ConsumerStatefulWidget {
|
||||
final CryptoCurrency coin;
|
||||
final Function(BigInt) onFeeChanged;
|
||||
final void Function(BigInt) onFeeChanged;
|
||||
final BigInt min;
|
||||
final BigInt max;
|
||||
|
||||
BoostFeeSlider({
|
||||
const BoostFeeSlider({
|
||||
super.key,
|
||||
required this.coin,
|
||||
required this.onFeeChanged,
|
||||
|
@ -21,7 +21,7 @@ class BoostFeeSlider extends ConsumerStatefulWidget {
|
|||
});
|
||||
|
||||
@override
|
||||
_BoostFeeSliderState createState() => _BoostFeeSliderState();
|
||||
ConsumerState<BoostFeeSlider> createState() => _BoostFeeSliderState();
|
||||
}
|
||||
|
||||
class _BoostFeeSliderState extends ConsumerState<BoostFeeSlider> {
|
||||
|
@ -35,17 +35,20 @@ class _BoostFeeSliderState extends ConsumerState<BoostFeeSlider> {
|
|||
_textEditingController = TextEditingController(
|
||||
text: ref.read(pAmountFormatter(widget.coin)).format(
|
||||
Amount(
|
||||
rawValue: BigInt.from(_currentSliderValue),
|
||||
fractionDigits: widget.coin.fractionDigits),
|
||||
rawValue: BigInt.from(_currentSliderValue),
|
||||
fractionDigits: widget.coin.fractionDigits,
|
||||
),
|
||||
withUnitName: false,
|
||||
),
|
||||
);
|
||||
_textEditingController.addListener(() {
|
||||
// TODO: value.replaceAll(',', '') doesn't work for certain locales
|
||||
final double? value =
|
||||
double.tryParse(_textEditingController.text.replaceAll(',', ''));
|
||||
if (value != null) {
|
||||
final BigInt bigIntValue = BigInt.from(
|
||||
value * BigInt.from(10).pow(widget.coin.fractionDigits).toInt());
|
||||
value * BigInt.from(10).pow(widget.coin.fractionDigits).toInt(),
|
||||
);
|
||||
if (bigIntValue >= widget.min && bigIntValue <= widget.max) {
|
||||
setState(() {
|
||||
_currentSliderValue = value;
|
||||
|
@ -76,17 +79,22 @@ class _BoostFeeSliderState extends ConsumerState<BoostFeeSlider> {
|
|||
min: widget.min.toDouble(),
|
||||
max: widget.max.toDouble(),
|
||||
divisions: (widget.max - widget.min).toInt(),
|
||||
label: ref.read(pAmountFormatter(widget.coin)).format(Amount(
|
||||
rawValue: BigInt.from(_currentSliderValue),
|
||||
fractionDigits: widget.coin.fractionDigits)),
|
||||
label: ref.read(pAmountFormatter(widget.coin)).format(
|
||||
Amount(
|
||||
rawValue: BigInt.from(_currentSliderValue),
|
||||
fractionDigits: widget.coin.fractionDigits,
|
||||
),
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_currentSliderValue = value;
|
||||
_textEditingController.text = ref
|
||||
.read(pAmountFormatter(widget.coin))
|
||||
.format(Amount(
|
||||
rawValue: BigInt.from(_currentSliderValue),
|
||||
fractionDigits: widget.coin.fractionDigits));
|
||||
_textEditingController.text =
|
||||
ref.read(pAmountFormatter(widget.coin)).format(
|
||||
Amount(
|
||||
rawValue: BigInt.from(_currentSliderValue),
|
||||
fractionDigits: widget.coin.fractionDigits,
|
||||
),
|
||||
);
|
||||
widget.onFeeChanged(BigInt.from(_currentSliderValue));
|
||||
});
|
||||
},
|
||||
|
@ -98,7 +106,8 @@ class _BoostFeeSliderState extends ConsumerState<BoostFeeSlider> {
|
|||
8 * widget.coin.ticker.length, // End padding for ticker.
|
||||
child: TextField(
|
||||
controller: _textEditingController,
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
keyboardType:
|
||||
const TextInputType.numberWithOptions(decimal: true),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d*')),
|
||||
],
|
||||
|
@ -106,13 +115,16 @@ class _BoostFeeSliderState extends ConsumerState<BoostFeeSlider> {
|
|||
border: OutlineInputBorder(),
|
||||
),
|
||||
onChanged: (value) {
|
||||
// TODO: value.replaceAll(',', '') doesn't work for certain locales
|
||||
final double? newValue =
|
||||
double.tryParse(value.replaceAll(',', ''));
|
||||
if (newValue != null) {
|
||||
final BigInt bigIntValue = BigInt.from(newValue *
|
||||
BigInt.from(10)
|
||||
.pow(widget.coin.fractionDigits)
|
||||
.toInt());
|
||||
final BigInt bigIntValue = BigInt.from(
|
||||
newValue *
|
||||
BigInt.from(10)
|
||||
.pow(widget.coin.fractionDigits)
|
||||
.toInt(),
|
||||
);
|
||||
if (bigIntValue >= widget.min &&
|
||||
bigIntValue <= widget.max) {
|
||||
setState(() {
|
||||
|
|
Loading…
Reference in a new issue