mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-22 10:34:32 +00:00
feat: WIP fee slider widget
This commit is contained in:
parent
b371e59182
commit
5880e0c5fa
1 changed files with 56 additions and 0 deletions
56
lib/widgets/fee_slider.dart
Normal file
56
lib/widgets/fee_slider.dart
Normal file
|
@ -0,0 +1,56 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
|
||||
class FeeSlider extends StatefulWidget {
|
||||
const FeeSlider({
|
||||
super.key,
|
||||
required this.onSatVByteChanged,
|
||||
});
|
||||
|
||||
final void Function(int) onSatVByteChanged;
|
||||
|
||||
@override
|
||||
State<FeeSlider> createState() => _FeeSliderState();
|
||||
}
|
||||
|
||||
class _FeeSliderState extends State<FeeSlider> {
|
||||
static const int min = 1;
|
||||
static const int max = 10;
|
||||
|
||||
double sliderValue = 0;
|
||||
|
||||
int rate = min;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"sat/vByte",
|
||||
style: STextStyles.smallMed12(context),
|
||||
),
|
||||
Text(
|
||||
"$rate",
|
||||
style: STextStyles.smallMed12(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
Slider(
|
||||
value: sliderValue,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
sliderValue = value;
|
||||
rate = pow(sliderValue * (max - min) + min, 4).toInt();
|
||||
});
|
||||
widget.onSatVByteChanged(rate);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue