pin lock? bug fixes
parent
e1301e7340
commit
8a53233afd
|
|
@ -18,7 +18,7 @@ class SettingState {
|
|||
mode: payload?.mode ?? SettingModeKassa,
|
||||
tradeType: payload?.tradeType ?? SettingTradeTypeGood,
|
||||
pinCode: payload?.pinCode ?? null,
|
||||
pinLocked: payload?.pinLocked ?? false,
|
||||
pinLocked: true,
|
||||
pinSkip: false,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ class _HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
|||
AppLifecycleState.values[prevState] != AppLifecycleState.paused;
|
||||
final bool pinIsExist = Redux.store.state.settingState?.pinCode?.isNotEmpty;
|
||||
final bool pinSkipped = Redux.store.state.settingState.pinSkip;
|
||||
print('prevStateIsNotPaused=$prevStateIsNotPaused, pinIsExist=$pinIsExist, pinSkipped=$pinSkipped');
|
||||
if(prevStateIsNotPaused && pinSkipped == false && pinIsExist == true) {
|
||||
// save App backgrounded time to Shared preferences
|
||||
sp.setInt(backgroundedTimeKey, DateTime.now().millisecondsSinceEpoch);
|
||||
|
|
@ -72,37 +73,34 @@ class _HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
|||
final allowedBackgroundTime = bgTime + pinLockMillis;
|
||||
final shouldShowPIN = DateTime.now().millisecondsSinceEpoch > allowedBackgroundTime;
|
||||
if(shouldShowPIN && bgTime > 0) {
|
||||
Redux.store.dispatch(changePinLockedFromSetting(true));
|
||||
// show PIN screen
|
||||
// Navigator.pushReplacement(context, MaterialPageRoute(
|
||||
// builder: (_) => PassCodeScreen( title: 'Безопасность',)));
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (_) =>
|
||||
WillPopScope(
|
||||
onWillPop: () async {
|
||||
return false;
|
||||
},
|
||||
child: PassCodeScreen( title: 'Безопасность',)
|
||||
)
|
||||
));
|
||||
|
||||
await Redux.store.dispatch(changePinLockedFromSetting(true));
|
||||
pushToLockScreen();
|
||||
}
|
||||
sp.remove(backgroundedTimeKey); // clean
|
||||
sp.setInt(lastKnownStateKey, AppLifecycleState.resumed.index);// previous state
|
||||
}
|
||||
|
||||
void pushToLockScreen() {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (_) =>
|
||||
WillPopScope(
|
||||
onWillPop: () async {
|
||||
return false;
|
||||
},
|
||||
child: PassCodeScreen( title: 'Безопасность',)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
_checkLockPin () async {
|
||||
if ( Redux.store.state.settingState.pinLocked == true) {
|
||||
await Future.delayed(Duration(milliseconds: 200));
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (_) =>
|
||||
WillPopScope(
|
||||
onWillPop: () async {
|
||||
return false;
|
||||
},
|
||||
child: PassCodeScreen( title: 'Безопасность',)
|
||||
)
|
||||
));
|
||||
final bool pinIsExist = Redux.store.state.settingState?.pinCode?.isNotEmpty;
|
||||
final bool pinLocked = Redux.store.state.settingState?.pinLocked;
|
||||
final sp = await SharedPreferences.getInstance();
|
||||
sp.remove(backgroundedTimeKey);
|
||||
sp.setInt(lastKnownStateKey, AppLifecycleState.resumed.index);// previous state
|
||||
if ( pinIsExist == true && pinLocked == true ) {
|
||||
await Future.delayed(Duration(milliseconds: 50));
|
||||
pushToLockScreen();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ class KassaTab extends StatelessWidget {
|
|||
|
||||
Future<void> scan() async {
|
||||
try {
|
||||
Redux.store.dispatch(changePinSkipFromSetting(true));
|
||||
await Redux.store.dispatch(changePinSkipFromSetting(true));
|
||||
var options = ScanOptions(strings: {
|
||||
"cancel": 'Отмена',
|
||||
"flash_on": 'Вкл фонарик',
|
||||
|
|
@ -219,7 +219,7 @@ class KassaTab extends StatelessWidget {
|
|||
List<Good> goods =
|
||||
await _dataService.getGoodsByBarcode(barcode: barcode);
|
||||
if (goods != null && goods.isNotEmpty) {
|
||||
Redux.store.dispatch(addProductToKassaItems(goods.first, dataMatrix));
|
||||
await Redux.store.dispatch(addProductToKassaItems(goods.first, dataMatrix));
|
||||
} else {
|
||||
_dialogService.showDialog(
|
||||
description: 'Товар не найден: $barcode');
|
||||
|
|
@ -241,7 +241,7 @@ class KassaTab extends StatelessWidget {
|
|||
_dialogService.showDialog(description: 'Неизвестная ошибка: $e');
|
||||
}
|
||||
} finally {
|
||||
Redux.store.dispatch(changePinSkipFromSetting(false));
|
||||
await Redux.store.dispatch(changePinSkipFromSetting(false));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class _SettingViewState extends State<SettingView> {
|
|||
void _setPinCode(BuildContext _context) async {
|
||||
FocusScope.of(_context).unfocus();
|
||||
var value = _pinController.text;
|
||||
if(value.isEmpty || value.length !=4){
|
||||
if(value.isNotEmpty && value.length !=4){
|
||||
_dialogService.showDialog(description: 'Необходимо указать 4-х значный числовой код');
|
||||
} else {
|
||||
await Redux.store.dispatch(changePinCodeFromSetting(_pinController.text));
|
||||
|
|
@ -62,7 +62,7 @@ class _SettingViewState extends State<SettingView> {
|
|||
children: <Widget>[
|
||||
verticalSpaceTiny,
|
||||
Text(
|
||||
'Ддя блокировки приложения пин-кодом, укажите 4-ех значный числовой код',
|
||||
'Для блокировки приложения пин-кодом, укажите 4-х значный числовой код',
|
||||
style: TextStyle(fontSize: 15.0),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
|
|
|
|||
Loading…
Reference in New Issue