Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog
## [9.0.1+1] - 2023-09-04

- update customizedButton
## [9.0.0+1] - 2023-02-15

- Disable splash animation for hidden buttons.
Expand Down
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
.pub-cache/
.pub/
/build/
/windows/

# Web related
lib/generated_plugin_registrant.dart
Expand Down
13 changes: 8 additions & 5 deletions example/.metadata
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.
# This file should be version controlled and should not be manually edited.

version:
revision: eb6d86ee27deecba4a83536aa20f366a6044895c
channel: stable
revision: "ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c
base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c
create_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a
base_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a
- platform: windows
create_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a
base_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a

# User provided section

Expand Down
17 changes: 15 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ class _MyHomePageState extends State<MyHomePage> {
},
child: const Text('Reset input'),
),
customizedButtonChild: (bool confirmed) => Icon(
confirmed
? Icons.restart_alt_rounded
: Icons.arrow_back,
),
customizedButtonTap: (confirmed, controller) {
if (confirmed) {
controller.unsetConfirmed();
} else {
Navigator.of(context).pop();
}
},
);
},
child: const Text('Confirm mode'),
Expand All @@ -103,10 +115,11 @@ class _MyHomePageState extends State<MyHomePage> {
onPressed: () => screenLock(
context: context,
correctString: '1234',
customizedButtonChild: const Icon(
customizedButtonChild: (_) => const Icon(
Icons.fingerprint,
),
customizedButtonTap: () async => await localAuth(context),
customizedButtonTap: (confirmed, controller) async =>
await localAuth(context),
onOpened: () async => await localAuth(context),
),
child: const Text(
Expand Down
61 changes: 41 additions & 20 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,26 @@ packages:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
version: "1.3.0"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
sha256: "6021e0172ab6e6eaa1d391afed0a99353921f00c54385c574dc53e55d67c092c"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
url: "https://pub.dev"
source: hosted
version: "1.16.0"
version: "1.17.2"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -31,14 +34,16 @@ packages:
dependency: "direct dev"
description:
name: flutter_lints
url: "https://pub.dartlang.org"
sha256: b543301ad291598523947dc534aaddc5aaad597b709d2426d3a0e0d44c5cb493
url: "https://pub.dev"
source: hosted
version: "1.0.4"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
name: flutter_plugin_android_lifecycle
url: "https://pub.dartlang.org"
sha256: "0ba8a1854c2098ddbd043e47eb28451a13f4cab7db9b2696f13a39fd8853421d"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
flutter_screen_lock:
Expand All @@ -47,54 +52,61 @@ packages:
path: ".."
relative: true
source: path
version: "9.0.0+1"
version: "9.0.1+1"
intl:
dependency: transitive
description:
name: intl
url: "https://pub.dartlang.org"
sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91"
url: "https://pub.dev"
source: hosted
version: "0.17.0"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
sha256: a2c3d198cb5ea2e179926622d433331d8b58374ab8f29cdda6e863bd62fd369c
url: "https://pub.dev"
source: hosted
version: "1.0.1"
local_auth:
dependency: "direct main"
description:
name: local_auth
url: "https://pub.dartlang.org"
sha256: e726cb95a302f3fd9186a97133ff00061aad993cce14fadc5d552a7eb66c7191
url: "https://pub.dev"
source: hosted
version: "1.1.0"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev"
source: hosted
version: "0.1.5"
version: "0.5.0"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
url: "https://pub.dev"
source: hosted
version: "1.8.0"
version: "1.9.1"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
sha256: "2ad4cddff7f5cc0e2d13069f2a3f7a73ca18f66abd6f5ecf215219cdb3638edb"
url: "https://pub.dev"
source: hosted
version: "1.8.0"
platform:
dependency: "direct main"
description:
name: platform
url: "https://pub.dartlang.org"
sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76"
url: "https://pub.dev"
source: hosted
version: "3.1.0"
sky_engine:
Expand All @@ -106,9 +118,18 @@ packages:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
web:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
url: "https://pub.dev"
source: hosted
version: "2.1.2"
version: "0.1.4-beta"
sdks:
dart: ">=2.17.0 <3.0.0"
dart: ">=3.1.0-185.0.dev <4.0.0"
flutter: ">=1.20.0"
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
sdk: flutter
flutter_screen_lock:
path: ../
local_auth: 1.1.0
local_auth:
platform: ^3.1.0

dev_dependencies:
Expand Down
4 changes: 2 additions & 2 deletions lib/src/configurations/screen_lock_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class ScreenLockConfig {
scaffoldBackgroundColor: backgroundColor,
outlinedButtonTheme: OutlinedButtonThemeData(style: buttonStyle),
textTheme: TextTheme(
headline6: titleTextStyle,
bodyText2: textStyle,
titleLarge: titleTextStyle,
bodySmall: textStyle,
),
);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/src/functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ Future<void> screenLock({
SecretsConfig? secretsConfig,
KeyPadConfig? keyPadConfig,
DelayBuilderCallback? delayBuilder,
Widget? customizedButtonChild,
VoidCallback? customizedButtonTap,
Widget Function(bool confirmed)? customizedButtonChild,
Function(bool confirmed, InputController controller)? customizedButtonTap,
Widget? footer,
Widget? cancelButton,
Widget? deleteButton,
Expand Down Expand Up @@ -151,8 +151,8 @@ Future<void> screenLockCreate({
SecretsConfig? secretsConfig,
KeyPadConfig? keyPadConfig,
DelayBuilderCallback? delayBuilder,
Widget? customizedButtonChild,
VoidCallback? customizedButtonTap,
Widget Function(bool confirmed)? customizedButtonChild,
Function(bool confirmed, InputController controller)? customizedButtonTap,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing a return type for the Function.

Suggested change
Function(bool confirmed, InputController controller)? customizedButtonTap,
void Function(bool confirmed, InputController controller)? customizedButtonTap,

Widget? footer,
Widget? cancelButton,
Widget? deleteButton,
Expand Down
47 changes: 32 additions & 15 deletions lib/src/screen_lock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ class ScreenLock extends StatefulWidget {
final ValueChanged<int>? onMaxRetries;

/// Tapped for left side lower button.
final VoidCallback? customizedButtonTap;
final Function(bool confirmed, InputController controller)?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final Function(bool confirmed, InputController controller)?
final void Function(bool confirmed, InputController controller)?

customizedButtonTap;

/// `0` is unlimited.
/// For example, if it is set to 1, didMaxRetries will be called on the first failure.
Expand Down Expand Up @@ -140,7 +141,7 @@ class ScreenLock extends StatefulWidget {
final DelayBuilderCallback? delayBuilder;

/// Child for bottom left side button.
final Widget? customizedButtonChild;
final Widget Function(bool confirmed)? customizedButtonChild;

/// Footer widget.
final Widget? footer;
Expand Down Expand Up @@ -313,7 +314,7 @@ class _ScreenLockState extends State<ScreenLock> {

return Builder(
builder: (context) => DefaultTextStyle(
style: Theme.of(context).textTheme.headline6!,
style: Theme.of(context).textTheme.titleLarge!,
textAlign: TextAlign.center,
child: buildDelay(
buildConfirmed(
Expand All @@ -324,6 +325,17 @@ class _ScreenLockState extends State<ScreenLock> {
);
}

Widget? customizedButtonChild() {
if (widget.customizedButtonChild != null) {
return StreamBuilder<bool>(
stream: inputController.confirmed,
builder: (context, snapshot) =>
widget.customizedButtonChild!(snapshot.data == true),
);
}
return null;
}

@override
Widget build(BuildContext context) {
final orientations = <Orientation, Axis>{
Expand Down Expand Up @@ -352,18 +364,23 @@ class _ScreenLockState extends State<ScreenLock> {
}

Widget buildKeyPad() {
return Center(
child: KeyPad(
enabled: enabled && !inputDelayed,
config: widget.keyPadConfig,
inputState: inputController,
didCancelled: widget.onCancelled,
customizedButtonTap: widget.customizedButtonTap,
customizedButtonChild: widget.customizedButtonChild,
deleteButton: widget.deleteButton,
cancelButton: widget.cancelButton,
),
);
return StreamBuilder<bool>(
stream: inputController.confirmed,
builder: (context, snapshot) {
return Center(
child: KeyPad(
enabled: enabled && !inputDelayed,
config: widget.keyPadConfig,
inputState: inputController,
didCancelled: widget.onCancelled,
customizedButtonTap: () => widget.customizedButtonTap
?.call(snapshot.data == true, inputController),
customizedButtonChild: customizedButtonChild(),
deleteButton: widget.deleteButton,
cancelButton: widget.cancelButton,
),
);
});
}

Widget buildContent() {
Expand Down
Loading