mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 01:37:54 +00:00
WIP stash (force push overwrite me later)
This commit is contained in:
parent
f86d2ef95e
commit
9509e8f5f7
4 changed files with 242 additions and 145 deletions
|
@ -2,12 +2,13 @@ import 'dart:convert';
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:isar/isar.dart';
|
||||
import '../transaction.dart';
|
||||
import 'input_v2.dart';
|
||||
import 'output_v2.dart';
|
||||
|
||||
import '../../../../../utilities/amount/amount.dart';
|
||||
import '../../../../../utilities/extensions/extensions.dart';
|
||||
import '../../../../../wallets/wallet/wallet_mixin_interfaces/spark_interface.dart';
|
||||
import '../transaction.dart';
|
||||
import 'input_v2.dart';
|
||||
import 'output_v2.dart';
|
||||
|
||||
part 'transaction_v2.g.dart';
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ import '../../../../utilities/logger.dart';
|
|||
import '../../../../utilities/text_styles.dart';
|
||||
import '../../../../utilities/util.dart';
|
||||
import '../../../../wallets/crypto_currency/crypto_currency.dart';
|
||||
import '../../../../wallets/crypto_currency/intermediate/nano_currency.dart';
|
||||
import '../../../../wallets/isar/models/spark_coin.dart';
|
||||
import '../../../../wallets/isar/providers/wallet_info_provider.dart';
|
||||
import '../../../../wallets/wallet/impl/epiccash_wallet.dart';
|
||||
|
@ -1252,13 +1251,11 @@ class _BoostTransactionViewState extends ConsumerState<BoostTransactionView> {
|
|||
// ],
|
||||
// ),
|
||||
// ),
|
||||
if (coin is! NanoCurrency)
|
||||
isDesktop
|
||||
? const _Divider()
|
||||
: const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
if (coin is! NanoCurrency)
|
||||
RoundedWhiteContainer(
|
||||
padding: isDesktop
|
||||
? const EdgeInsets.all(16)
|
||||
|
@ -1281,7 +1278,6 @@ class _BoostTransactionViewState extends ConsumerState<BoostTransactionView> {
|
|||
.format(
|
||||
fee,
|
||||
);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
|
@ -1301,8 +1297,7 @@ class _BoostTransactionViewState extends ConsumerState<BoostTransactionView> {
|
|||
.desktopTextExtraExtraSmall(
|
||||
context,
|
||||
)
|
||||
: STextStyles
|
||||
.itemSubtitle(
|
||||
: STextStyles.itemSubtitle(
|
||||
context,
|
||||
),
|
||||
),
|
||||
|
@ -1344,8 +1339,7 @@ class _BoostTransactionViewState extends ConsumerState<BoostTransactionView> {
|
|||
StackColors>()!
|
||||
.textDark,
|
||||
)
|
||||
: STextStyles
|
||||
.itemSubtitle12(
|
||||
: STextStyles.itemSubtitle12(
|
||||
context,
|
||||
),
|
||||
),
|
||||
|
@ -1353,21 +1347,6 @@ class _BoostTransactionViewState extends ConsumerState<BoostTransactionView> {
|
|||
// IconCopyButton(data: feeString),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
bottom: 12,
|
||||
top: 16,
|
||||
),
|
||||
child: BoostFeeSlider(
|
||||
coin: coin,
|
||||
onFeeChanged: (fee) {
|
||||
customFee = fee;
|
||||
},
|
||||
min: fee.raw,
|
||||
max: fee.raw * BigInt.from(4),
|
||||
// TODO [prio=med]: The max fee should be set to an absurd fee.
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
|
@ -1806,6 +1785,110 @@ class _BoostTransactionViewState extends ConsumerState<BoostTransactionView> {
|
|||
: const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
|
||||
isDesktop
|
||||
? const _Divider()
|
||||
: const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
RoundedWhiteContainer(
|
||||
padding: isDesktop
|
||||
? const EdgeInsets.all(16)
|
||||
: const EdgeInsets.all(12),
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
final String feeString = showFeePending
|
||||
? _transaction.isConfirmed(
|
||||
currentHeight,
|
||||
minConfirms,
|
||||
)
|
||||
? ref
|
||||
.watch(pAmountFormatter(coin))
|
||||
.format(
|
||||
fee,
|
||||
)
|
||||
: "Pending"
|
||||
: ref
|
||||
.watch(pAmountFormatter(coin))
|
||||
.format(
|
||||
fee,
|
||||
);
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Boost fee",
|
||||
style: isDesktop
|
||||
? STextStyles
|
||||
.desktopTextExtraExtraSmall(
|
||||
context,
|
||||
)
|
||||
: STextStyles.itemSubtitle(
|
||||
context,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (!isDesktop)
|
||||
SelectableText(
|
||||
feeString,
|
||||
style: isDesktop
|
||||
? STextStyles
|
||||
.desktopTextExtraExtraSmall(
|
||||
context,
|
||||
).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<
|
||||
StackColors>()!
|
||||
.textDark,
|
||||
)
|
||||
: STextStyles.itemSubtitle12(
|
||||
context,
|
||||
),
|
||||
),
|
||||
// if (isDesktop)
|
||||
// IconCopyButton(data: feeString),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
bottom: 12,
|
||||
top: 16,
|
||||
),
|
||||
child: BoostFeeSlider(
|
||||
coin: coin,
|
||||
onFeeChanged: (fee) {
|
||||
customFee = fee;
|
||||
},
|
||||
min: fee.raw,
|
||||
max: fee.raw * BigInt.from(4),
|
||||
// TODO [prio=med]: The max fee should be set to an absurd fee.
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 36,
|
||||
),
|
||||
PrimaryButton(
|
||||
buttonHeight: ButtonHeight.l,
|
||||
label: "Preview send",
|
||||
onPressed:
|
||||
/* // TODO [prio=high]: define previewSend*/
|
||||
() => null,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -1336,7 +1336,8 @@ class _TransactionV2DetailsViewState
|
|||
_transaction,
|
||||
currentHeight,
|
||||
) ==
|
||||
"Sending")
|
||||
"Sending" &&
|
||||
coin is! NanoCurrency)
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
|
@ -1344,7 +1345,8 @@ class _TransactionV2DetailsViewState
|
|||
_transaction,
|
||||
currentHeight,
|
||||
) ==
|
||||
"Sending")
|
||||
"Sending" &&
|
||||
coin is! NanoCurrency)
|
||||
CustomTextButton(
|
||||
text: "Boost transaction",
|
||||
onTap: () async {
|
||||
|
|
|
@ -13,6 +13,7 @@ class BoostFeeSlider extends ConsumerStatefulWidget {
|
|||
final BigInt max;
|
||||
|
||||
BoostFeeSlider({
|
||||
super.key,
|
||||
required this.coin,
|
||||
required this.onFeeChanged,
|
||||
required this.min,
|
||||
|
@ -40,14 +41,18 @@ class _BoostFeeSliderState extends ConsumerState<BoostFeeSlider> {
|
|||
),
|
||||
);
|
||||
_textEditingController.addListener(() {
|
||||
BigInt? value =
|
||||
BigInt.tryParse(_textEditingController.text.replaceAll(',', ''));
|
||||
if (value != null && value >= widget.min && value <= widget.max) {
|
||||
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());
|
||||
if (bigIntValue >= widget.min && bigIntValue <= widget.max) {
|
||||
setState(() {
|
||||
_currentSliderValue = value.toDouble();
|
||||
widget.onFeeChanged(value);
|
||||
_currentSliderValue = value;
|
||||
widget.onFeeChanged(bigIntValue);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -87,29 +92,35 @@ class _BoostFeeSliderState extends ConsumerState<BoostFeeSlider> {
|
|||
},
|
||||
),
|
||||
),
|
||||
SizedBox(width: 16),
|
||||
Container(
|
||||
width: 122,
|
||||
SizedBox(
|
||||
width: 16 + // Left and right padding.
|
||||
122 / 8 * widget.coin.fractionDigits + // Variable width.
|
||||
8 * widget.coin.ticker.length, // End padding for ticker.
|
||||
child: TextField(
|
||||
controller: _textEditingController,
|
||||
keyboardType: TextInputType.number,
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d*')),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
onChanged: (value) {
|
||||
BigInt? newValue =
|
||||
BigInt.tryParse(value.replaceAll(',', ''));
|
||||
if (newValue != null &&
|
||||
newValue >= widget.min &&
|
||||
newValue <= widget.max) {
|
||||
final double? newValue =
|
||||
double.tryParse(value.replaceAll(',', ''));
|
||||
if (newValue != null) {
|
||||
final BigInt bigIntValue = BigInt.from(newValue *
|
||||
BigInt.from(10)
|
||||
.pow(widget.coin.fractionDigits)
|
||||
.toInt());
|
||||
if (bigIntValue >= widget.min &&
|
||||
bigIntValue <= widget.max) {
|
||||
setState(() {
|
||||
_currentSliderValue = newValue.toDouble();
|
||||
widget.onFeeChanged(newValue);
|
||||
_currentSliderValue = newValue;
|
||||
widget.onFeeChanged(bigIntValue);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue