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 'dart:math';
|
||||||
|
|
||||||
import 'package:isar/isar.dart';
|
import 'package:isar/isar.dart';
|
||||||
import '../transaction.dart';
|
|
||||||
import 'input_v2.dart';
|
|
||||||
import 'output_v2.dart';
|
|
||||||
import '../../../../../utilities/amount/amount.dart';
|
import '../../../../../utilities/amount/amount.dart';
|
||||||
import '../../../../../utilities/extensions/extensions.dart';
|
import '../../../../../utilities/extensions/extensions.dart';
|
||||||
import '../../../../../wallets/wallet/wallet_mixin_interfaces/spark_interface.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';
|
part 'transaction_v2.g.dart';
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ import '../../../../utilities/logger.dart';
|
||||||
import '../../../../utilities/text_styles.dart';
|
import '../../../../utilities/text_styles.dart';
|
||||||
import '../../../../utilities/util.dart';
|
import '../../../../utilities/util.dart';
|
||||||
import '../../../../wallets/crypto_currency/crypto_currency.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/models/spark_coin.dart';
|
||||||
import '../../../../wallets/isar/providers/wallet_info_provider.dart';
|
import '../../../../wallets/isar/providers/wallet_info_provider.dart';
|
||||||
import '../../../../wallets/wallet/impl/epiccash_wallet.dart';
|
import '../../../../wallets/wallet/impl/epiccash_wallet.dart';
|
||||||
|
@ -1252,127 +1251,107 @@ class _BoostTransactionViewState extends ConsumerState<BoostTransactionView> {
|
||||||
// ],
|
// ],
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
if (coin is! NanoCurrency)
|
isDesktop
|
||||||
isDesktop
|
? const _Divider()
|
||||||
? const _Divider()
|
: const SizedBox(
|
||||||
: const SizedBox(
|
height: 12,
|
||||||
height: 12,
|
),
|
||||||
),
|
RoundedWhiteContainer(
|
||||||
if (coin is! NanoCurrency)
|
padding: isDesktop
|
||||||
RoundedWhiteContainer(
|
? const EdgeInsets.all(16)
|
||||||
padding: isDesktop
|
: const EdgeInsets.all(12),
|
||||||
? const EdgeInsets.all(16)
|
child: Builder(
|
||||||
: const EdgeInsets.all(12),
|
builder: (context) {
|
||||||
child: Builder(
|
final String feeString = showFeePending
|
||||||
builder: (context) {
|
? _transaction.isConfirmed(
|
||||||
final String feeString = showFeePending
|
currentHeight,
|
||||||
? _transaction.isConfirmed(
|
minConfirms,
|
||||||
currentHeight,
|
)
|
||||||
minConfirms,
|
? ref
|
||||||
)
|
.watch(pAmountFormatter(coin))
|
||||||
? ref
|
.format(
|
||||||
.watch(pAmountFormatter(coin))
|
fee,
|
||||||
.format(
|
)
|
||||||
fee,
|
: "Pending"
|
||||||
)
|
: ref
|
||||||
: "Pending"
|
.watch(pAmountFormatter(coin))
|
||||||
: ref
|
.format(
|
||||||
.watch(pAmountFormatter(coin))
|
fee,
|
||||||
.format(
|
);
|
||||||
fee,
|
return Column(
|
||||||
);
|
children: [
|
||||||
|
Row(
|
||||||
return Column(
|
mainAxisAlignment:
|
||||||
children: [
|
MainAxisAlignment.spaceBetween,
|
||||||
Row(
|
crossAxisAlignment:
|
||||||
mainAxisAlignment:
|
CrossAxisAlignment.start,
|
||||||
MainAxisAlignment.spaceBetween,
|
children: [
|
||||||
crossAxisAlignment:
|
Column(
|
||||||
CrossAxisAlignment.start,
|
crossAxisAlignment:
|
||||||
children: [
|
CrossAxisAlignment.start,
|
||||||
Column(
|
children: [
|
||||||
crossAxisAlignment:
|
Text(
|
||||||
CrossAxisAlignment.start,
|
"Transaction fee",
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Transaction fee",
|
|
||||||
style: isDesktop
|
|
||||||
? STextStyles
|
|
||||||
.desktopTextExtraExtraSmall(
|
|
||||||
context,
|
|
||||||
)
|
|
||||||
: STextStyles
|
|
||||||
.itemSubtitle(
|
|
||||||
context,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (isDesktop)
|
|
||||||
const SizedBox(
|
|
||||||
height: 2,
|
|
||||||
),
|
|
||||||
if (isDesktop)
|
|
||||||
SelectableText(
|
|
||||||
feeString,
|
|
||||||
style: isDesktop
|
|
||||||
? STextStyles
|
|
||||||
.desktopTextExtraExtraSmall(
|
|
||||||
context,
|
|
||||||
).copyWith(
|
|
||||||
color: Theme.of(
|
|
||||||
context)
|
|
||||||
.extension<
|
|
||||||
StackColors>()!
|
|
||||||
.textDark,
|
|
||||||
)
|
|
||||||
: STextStyles
|
|
||||||
.itemSubtitle12(
|
|
||||||
context,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (!isDesktop)
|
|
||||||
SelectableText(
|
|
||||||
feeString,
|
|
||||||
style: isDesktop
|
style: isDesktop
|
||||||
? STextStyles
|
? STextStyles
|
||||||
.desktopTextExtraExtraSmall(
|
.desktopTextExtraExtraSmall(
|
||||||
context,
|
context,
|
||||||
).copyWith(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.extension<
|
|
||||||
StackColors>()!
|
|
||||||
.textDark,
|
|
||||||
)
|
)
|
||||||
: STextStyles
|
: STextStyles.itemSubtitle(
|
||||||
.itemSubtitle12(
|
|
||||||
context,
|
context,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// if (isDesktop)
|
if (isDesktop)
|
||||||
// IconCopyButton(data: feeString),
|
const SizedBox(
|
||||||
],
|
height: 2,
|
||||||
),
|
),
|
||||||
Padding(
|
if (isDesktop)
|
||||||
padding: const EdgeInsets.only(
|
SelectableText(
|
||||||
bottom: 12,
|
feeString,
|
||||||
top: 16,
|
style: isDesktop
|
||||||
|
? STextStyles
|
||||||
|
.desktopTextExtraExtraSmall(
|
||||||
|
context,
|
||||||
|
).copyWith(
|
||||||
|
color: Theme.of(
|
||||||
|
context)
|
||||||
|
.extension<
|
||||||
|
StackColors>()!
|
||||||
|
.textDark,
|
||||||
|
)
|
||||||
|
: STextStyles
|
||||||
|
.itemSubtitle12(
|
||||||
|
context,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
child: BoostFeeSlider(
|
if (!isDesktop)
|
||||||
coin: coin,
|
SelectableText(
|
||||||
onFeeChanged: (fee) {
|
feeString,
|
||||||
customFee = fee;
|
style: isDesktop
|
||||||
},
|
? STextStyles
|
||||||
min: fee.raw,
|
.desktopTextExtraExtraSmall(
|
||||||
max: fee.raw * BigInt.from(4),
|
context,
|
||||||
// TODO [prio=med]: The max fee should be set to an absurd fee.
|
).copyWith(
|
||||||
),
|
color: Theme.of(context)
|
||||||
)
|
.extension<
|
||||||
],
|
StackColors>()!
|
||||||
);
|
.textDark,
|
||||||
},
|
)
|
||||||
),
|
: STextStyles.itemSubtitle12(
|
||||||
|
context,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// if (isDesktop)
|
||||||
|
// IconCopyButton(data: feeString),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
// isDesktop
|
// isDesktop
|
||||||
// ? const _Divider()
|
// ? const _Divider()
|
||||||
// : const SizedBox(
|
// : const SizedBox(
|
||||||
|
@ -1806,6 +1785,110 @@ class _BoostTransactionViewState extends ConsumerState<BoostTransactionView> {
|
||||||
: const SizedBox(
|
: const SizedBox(
|
||||||
height: 12,
|
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,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -1333,18 +1333,20 @@ class _TransactionV2DetailsViewState
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (whatIsIt(
|
if (whatIsIt(
|
||||||
_transaction,
|
_transaction,
|
||||||
currentHeight,
|
currentHeight,
|
||||||
) ==
|
) ==
|
||||||
"Sending")
|
"Sending" &&
|
||||||
|
coin is! NanoCurrency)
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 8,
|
height: 8,
|
||||||
),
|
),
|
||||||
if (whatIsIt(
|
if (whatIsIt(
|
||||||
_transaction,
|
_transaction,
|
||||||
currentHeight,
|
currentHeight,
|
||||||
) ==
|
) ==
|
||||||
"Sending")
|
"Sending" &&
|
||||||
|
coin is! NanoCurrency)
|
||||||
CustomTextButton(
|
CustomTextButton(
|
||||||
text: "Boost transaction",
|
text: "Boost transaction",
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
|
|
|
@ -13,6 +13,7 @@ class BoostFeeSlider extends ConsumerStatefulWidget {
|
||||||
final BigInt max;
|
final BigInt max;
|
||||||
|
|
||||||
BoostFeeSlider({
|
BoostFeeSlider({
|
||||||
|
super.key,
|
||||||
required this.coin,
|
required this.coin,
|
||||||
required this.onFeeChanged,
|
required this.onFeeChanged,
|
||||||
required this.min,
|
required this.min,
|
||||||
|
@ -40,13 +41,17 @@ class _BoostFeeSliderState extends ConsumerState<BoostFeeSlider> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
_textEditingController.addListener(() {
|
_textEditingController.addListener(() {
|
||||||
BigInt? value =
|
final double? value =
|
||||||
BigInt.tryParse(_textEditingController.text.replaceAll(',', ''));
|
double.tryParse(_textEditingController.text.replaceAll(',', ''));
|
||||||
if (value != null && value >= widget.min && value <= widget.max) {
|
if (value != null) {
|
||||||
setState(() {
|
final BigInt bigIntValue = BigInt.from(
|
||||||
_currentSliderValue = value.toDouble();
|
value * BigInt.from(10).pow(widget.coin.fractionDigits).toInt());
|
||||||
widget.onFeeChanged(value);
|
if (bigIntValue >= widget.min && bigIntValue <= widget.max) {
|
||||||
});
|
setState(() {
|
||||||
|
_currentSliderValue = value;
|
||||||
|
widget.onFeeChanged(bigIntValue);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -87,28 +92,34 @@ class _BoostFeeSliderState extends ConsumerState<BoostFeeSlider> {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 16),
|
SizedBox(
|
||||||
Container(
|
width: 16 + // Left and right padding.
|
||||||
width: 122,
|
122 / 8 * widget.coin.fractionDigits + // Variable width.
|
||||||
|
8 * widget.coin.ticker.length, // End padding for ticker.
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _textEditingController,
|
controller: _textEditingController,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||||
inputFormatters: [
|
inputFormatters: [
|
||||||
FilteringTextInputFormatter.digitsOnly,
|
FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d*')),
|
||||||
],
|
],
|
||||||
decoration: InputDecoration(
|
decoration: const InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
),
|
),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
BigInt? newValue =
|
final double? newValue =
|
||||||
BigInt.tryParse(value.replaceAll(',', ''));
|
double.tryParse(value.replaceAll(',', ''));
|
||||||
if (newValue != null &&
|
if (newValue != null) {
|
||||||
newValue >= widget.min &&
|
final BigInt bigIntValue = BigInt.from(newValue *
|
||||||
newValue <= widget.max) {
|
BigInt.from(10)
|
||||||
setState(() {
|
.pow(widget.coin.fractionDigits)
|
||||||
_currentSliderValue = newValue.toDouble();
|
.toInt());
|
||||||
widget.onFeeChanged(newValue);
|
if (bigIntValue >= widget.min &&
|
||||||
});
|
bigIntValue <= widget.max) {
|
||||||
|
setState(() {
|
||||||
|
_currentSliderValue = newValue;
|
||||||
|
widget.onFeeChanged(bigIntValue);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue