fluffychat/lib/views/widgets/lock_screen.dart

37 lines
1.3 KiB
Dart
Raw Normal View History

2021-01-18 08:38:19 +01:00
import 'package:fluffychat/config/setting_keys.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app_lock/flutter_app_lock.dart';
2021-04-21 14:19:54 +02:00
import 'package:flutter_screen_lock/functions.dart';
2021-01-18 08:38:19 +01:00
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
class LockScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
2021-01-18 10:07:37 +01:00
final applock = FlutterSecureStorage().read(key: SettingKeys.appLockKey);
2021-01-18 08:38:19 +01:00
return FutureBuilder<String>(
2021-01-18 10:07:37 +01:00
future: applock,
2021-01-18 08:38:19 +01:00
builder: (context, snapshot) {
if (snapshot.hasError) {
return Scaffold(body: Center(child: Text(snapshot.error.toString())));
}
if (snapshot.connectionState == ConnectionState.done) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (snapshot.data?.isNotEmpty ?? false) {
2021-04-21 14:19:54 +02:00
screenLock(
2021-01-18 08:38:19 +01:00
context: context,
correctString: snapshot.data,
2021-04-21 14:19:54 +02:00
didConfirmed: (_) => AppLock.of(context).didUnlock(),
2021-01-18 08:38:19 +01:00
canCancel: false,
);
} else {
AppLock.of(context).didUnlock();
2021-01-18 09:43:53 +01:00
AppLock.of(context).disable();
2021-01-18 08:38:19 +01:00
}
});
}
return Scaffold(body: Center(child: CircularProgressIndicator()));
},
);
}
}