WIP: randomize PIN provider + toggle added

This commit is contained in:
ryleedavis 2023-04-28 12:03:54 -06:00
parent 096aab834b
commit cede462681
2 changed files with 68 additions and 0 deletions

View file

@ -146,6 +146,53 @@ class SecurityView 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(
"Randomize PIN Pad",
style: STextStyles.titleBold12(context),
textAlign: TextAlign.left,
),
SizedBox(
height: 20,
width: 40,
child: DraggableSwitchButton(
isOn: ref.watch(
prefsChangeNotifierProvider
.select((value) => value.randomizePIN),
),
onValueChanged: (newValue) {
ref
.read(prefsChangeNotifierProvider)
.randomizePIN = newValue;
},
),
),
],
),
),
);
},
),
),
],
),
),

View file

@ -295,6 +295,27 @@ class Prefs extends ChangeNotifier {
// }
// }
// randomize PIN
bool _randomizePIN = false;
bool get randomizePIN => _randomizePIN;
set randomizePIN(bool randomizePIN) {
if (_randomizePIN != randomizePIN) {
DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, key: "randomizePIN", value: randomizePIN);
_randomizePIN = randomizePIN;
notifyListeners();
}
}
Future<bool> _getRandomizePIN() async {
return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "randomizePIN") as bool? ??
false;
}
// use biometrics
bool _useBiometrics = false;