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