coin control setting

This commit is contained in:
julian 2023-03-08 15:12:04 -06:00
parent 9716bed96f
commit 8706a6350c
2 changed files with 71 additions and 0 deletions

View file

@ -121,6 +121,53 @@ class AdvancedSettingsView extends StatelessWidget {
const SizedBox(
height: 8,
),
RoundedWhiteContainer(
child: Consumer(
builder: (_, ref, __) {
return RawMaterialButton(
// splashColor: Theme.of(context).extension<StackColors>()!.highlight,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
),
onPressed: null,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Enable coin control",
style: STextStyles.titleBold12(context),
textAlign: TextAlign.left,
),
SizedBox(
height: 20,
width: 40,
child: DraggableSwitchButton(
isOn: ref.watch(
prefsChangeNotifierProvider.select(
(value) => value.enableCoinControl),
),
onValueChanged: (newValue) {
ref
.read(prefsChangeNotifierProvider)
.enableCoinControl = newValue;
},
),
),
],
),
),
);
},
),
),
const SizedBox(
height: 8,
),
RoundedWhiteContainer(
padding: const EdgeInsets.all(0),
child: Consumer(

View file

@ -40,6 +40,7 @@ class Prefs extends ChangeNotifier {
_familiarity = await _getHasFamiliarity();
_userId = await _getUserId();
_signupEpoch = await _getSignupEpoch();
_enableCoinControl = await _getEnableCoinControl();
_initialized = true;
}
@ -645,4 +646,27 @@ class Prefs extends ChangeNotifier {
boxName: DB.boxNamePrefs, key: "signupEpoch", value: _signupEpoch);
// notifyListeners();
}
// show testnet coins
bool _enableCoinControl = false;
bool get enableCoinControl => _enableCoinControl;
set enableCoinControl(bool enableCoinControl) {
if (_enableCoinControl != enableCoinControl) {
DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs,
key: "enableCoinControl",
value: enableCoinControl);
_enableCoinControl = enableCoinControl;
notifyListeners();
}
}
Future<bool> _getEnableCoinControl() async {
return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "enableCoinControl") as bool? ??
false;
}
}