mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-01-25 19:44:17 +01:00
fix: Lock screen
This commit is contained in:
parent
15c3178ca4
commit
f8ba7bdbcd
@ -1372,6 +1372,11 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
},
|
},
|
||||||
|
"pleaseEnterYourPin": "Please enter your pin",
|
||||||
|
"@pleaseEnterYourPin": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
"pleaseEnterYourPassword": "Please enter your password",
|
"pleaseEnterYourPassword": "Please enter your password",
|
||||||
"@pleaseEnterYourPassword": {
|
"@pleaseEnterYourPassword": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
|
@ -7,7 +7,6 @@ import 'package:famedlysdk/famedlysdk.dart';
|
|||||||
import 'package:fluffychat/config/routes.dart';
|
import 'package:fluffychat/config/routes.dart';
|
||||||
import 'package:fluffychat/utils/platform_infos.dart';
|
import 'package:fluffychat/utils/platform_infos.dart';
|
||||||
import 'package:fluffychat/utils/sentry_controller.dart';
|
import 'package:fluffychat/utils/sentry_controller.dart';
|
||||||
import 'package:fluffychat/views/widgets/layouts/lock_screen.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -16,6 +15,7 @@ import 'package:flutter_app_lock/flutter_app_lock.dart';
|
|||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
import 'package:universal_html/html.dart' as html;
|
import 'package:universal_html/html.dart' as html;
|
||||||
|
|
||||||
|
import 'views/widgets/lock_screen.dart';
|
||||||
import 'views/widgets/matrix.dart';
|
import 'views/widgets/matrix.dart';
|
||||||
import 'config/themes.dart';
|
import 'config/themes.dart';
|
||||||
import 'config/app_config.dart';
|
import 'config/app_config.dart';
|
||||||
|
@ -11,7 +11,6 @@ import 'package:fluffychat/utils/sentry_controller.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_app_lock/flutter_app_lock.dart';
|
import 'package:flutter_app_lock/flutter_app_lock.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
import 'package:flutter_screen_lock/functions.dart';
|
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
|
||||||
@ -290,13 +289,7 @@ class SettingsController extends State<Settings> {
|
|||||||
final currentLock =
|
final currentLock =
|
||||||
await FlutterSecureStorage().read(key: SettingKeys.appLockKey);
|
await FlutterSecureStorage().read(key: SettingKeys.appLockKey);
|
||||||
if (currentLock?.isNotEmpty ?? false) {
|
if (currentLock?.isNotEmpty ?? false) {
|
||||||
var unlocked = false;
|
await AppLock.of(context).showLockScreen();
|
||||||
await screenLock(
|
|
||||||
context: context,
|
|
||||||
correctString: currentLock,
|
|
||||||
didConfirmed: (_) => unlocked = true,
|
|
||||||
);
|
|
||||||
if (unlocked != true) return;
|
|
||||||
}
|
}
|
||||||
final newLock = await showTextInputDialog(
|
final newLock = await showTextInputDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
import 'package:fluffychat/config/setting_keys.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_app_lock/flutter_app_lock.dart';
|
|
||||||
import 'package:flutter_screen_lock/functions.dart';
|
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
||||||
|
|
||||||
class LockScreen extends StatelessWidget {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final applock = FlutterSecureStorage().read(key: SettingKeys.appLockKey);
|
|
||||||
return FutureBuilder<String>(
|
|
||||||
future: applock,
|
|
||||||
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) {
|
|
||||||
screenLock(
|
|
||||||
context: context,
|
|
||||||
correctString: snapshot.data,
|
|
||||||
didConfirmed: (_) => AppLock.of(context).didUnlock(),
|
|
||||||
canCancel: false,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
AppLock.of(context).didUnlock();
|
|
||||||
AppLock.of(context).disable();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return Scaffold(body: Center(child: CircularProgressIndicator()));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
86
lib/views/widgets/lock_screen.dart
Normal file
86
lib/views/widgets/lock_screen.dart
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
import 'package:fluffychat/config/app_config.dart';
|
||||||
|
import 'package:fluffychat/config/setting_keys.dart';
|
||||||
|
import 'package:fluffychat/config/themes.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_app_lock/flutter_app_lock.dart';
|
||||||
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
|
import 'package:pin_code_text_field/pin_code_text_field.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
|
|
||||||
|
import 'layouts/one_page_card.dart';
|
||||||
|
|
||||||
|
class LockScreen extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_LockScreenState createState() => _LockScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LockScreenState extends State<LockScreen> {
|
||||||
|
final TextEditingController _textEditingController = TextEditingController();
|
||||||
|
final FocusNode _focusNode = FocusNode();
|
||||||
|
bool _wrongInput = false;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MaterialApp(
|
||||||
|
theme: FluffyThemes.light,
|
||||||
|
darkTheme: FluffyThemes.light,
|
||||||
|
localizationsDelegates: L10n.localizationsDelegates,
|
||||||
|
supportedLocales: L10n.supportedLocales,
|
||||||
|
home: Builder(
|
||||||
|
builder: (context) => OnePageCard(
|
||||||
|
child: Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
automaticallyImplyLeading: false,
|
||||||
|
elevation: 0,
|
||||||
|
centerTitle: true,
|
||||||
|
title: Text(L10n.of(context).pleaseEnterYourPin),
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
),
|
||||||
|
extendBodyBehindAppBar: true,
|
||||||
|
body: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).backgroundColor,
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.topRight,
|
||||||
|
end: Alignment.bottomLeft,
|
||||||
|
stops: [
|
||||||
|
0.1,
|
||||||
|
0.4,
|
||||||
|
0.6,
|
||||||
|
0.9,
|
||||||
|
],
|
||||||
|
colors: [
|
||||||
|
Theme.of(context).secondaryHeaderColor.withAlpha(16),
|
||||||
|
Theme.of(context).primaryColor.withAlpha(16),
|
||||||
|
Theme.of(context).accentColor.withAlpha(16),
|
||||||
|
Theme.of(context).backgroundColor.withAlpha(16),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: PinCodeTextField(
|
||||||
|
autofocus: true,
|
||||||
|
controller: _textEditingController,
|
||||||
|
focusNode: _focusNode,
|
||||||
|
pinBoxRadius: AppConfig.borderRadius,
|
||||||
|
pinTextStyle: TextStyle(fontSize: 32),
|
||||||
|
hideCharacter: true,
|
||||||
|
hasError: _wrongInput,
|
||||||
|
onDone: (String input) async {
|
||||||
|
if (input ==
|
||||||
|
await FlutterSecureStorage()
|
||||||
|
.read(key: SettingKeys.appLockKey)) {
|
||||||
|
AppLock.of(context).didUnlock();
|
||||||
|
} else {
|
||||||
|
_textEditingController.clear();
|
||||||
|
setState(() => _wrongInput = true);
|
||||||
|
_focusNode.requestFocus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
14
pubspec.lock
14
pubspec.lock
@ -393,13 +393,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
version: "2.0.1"
|
||||||
flutter_screen_lock:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: flutter_screen_lock
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "4.0.3"
|
|
||||||
flutter_secure_storage:
|
flutter_secure_storage:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -790,6 +783,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.1.0"
|
version: "4.1.0"
|
||||||
|
pin_code_text_field:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: pin_code_text_field
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.8.0"
|
||||||
platform:
|
platform:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -37,7 +37,6 @@ dependencies:
|
|||||||
flutter_matrix_html: ^0.3.0
|
flutter_matrix_html: ^0.3.0
|
||||||
flutter_olm: ^1.1.1
|
flutter_olm: ^1.1.1
|
||||||
flutter_openssl_crypto: ^0.0.1
|
flutter_openssl_crypto: ^0.0.1
|
||||||
flutter_screen_lock: ^4.0.3
|
|
||||||
flutter_secure_storage: ^3.3.5 # Do not upgrade or this will break Linux builds!
|
flutter_secure_storage: ^3.3.5 # Do not upgrade or this will break Linux builds!
|
||||||
flutter_slidable: ^0.6.0
|
flutter_slidable: ^0.6.0
|
||||||
flutter_svg: ^0.21.0+1
|
flutter_svg: ^0.21.0+1
|
||||||
@ -55,6 +54,7 @@ dependencies:
|
|||||||
open_file: ^3.2.0
|
open_file: ^3.2.0
|
||||||
open_noti_settings: ^0.1.0
|
open_noti_settings: ^0.1.0
|
||||||
package_info: ^2.0.0
|
package_info: ^2.0.0
|
||||||
|
pin_code_text_field: ^1.8.0
|
||||||
path_provider: ^2.0.1
|
path_provider: ^2.0.1
|
||||||
permission_handler: ^6.1.3
|
permission_handler: ^6.1.3
|
||||||
provider: ^5.0.0
|
provider: ^5.0.0
|
||||||
|
Loading…
Reference in New Issue
Block a user