Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Other review fixes
  • Loading branch information
stuartmorgan-g committed May 18, 2023
commit 933c0d4167b1f5803918bf086dc3b1359a8072e3
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#import <LocalAuthentication/LocalAuthentication.h>

typedef void (^AuthCompletion)(FLAAuthResultDetails *_Nullable, FlutterError *_Nullable);
typedef void (^FLAAuthCompletion)(FLAAuthResultDetails *_Nullable, FlutterError *_Nullable);

/**
* A default context factory that wraps standard LAContext allocation.
Expand All @@ -28,16 +28,16 @@ - (LAContext *)createAuthContext {
@interface FLAStickyAuthState : NSObject
@property(nonatomic, strong, nonnull) FLAAuthOptions *options;
@property(nonatomic, strong, nonnull) FLAAuthStrings *strings;
@property(nonatomic, strong, nonnull) AuthCompletion resultHandler;
@property(nonatomic, copy, nonnull) FLAAuthCompletion resultHandler;
- (instancetype)initWithOptions:(nonnull FLAAuthOptions *)options
strings:(nonnull FLAAuthStrings *)strings
resultHandler:(nonnull AuthCompletion)resultHandler;
resultHandler:(nonnull FLAAuthCompletion)resultHandler;
@end

@implementation FLAStickyAuthState
- (instancetype)initWithOptions:(nonnull FLAAuthOptions *)options
strings:(nonnull FLAAuthStrings *)strings
resultHandler:(nonnull AuthCompletion)resultHandler {
resultHandler:(nonnull FLAAuthCompletion)resultHandler {
self = [super init];
if (self) {
_options = options;
Expand Down Expand Up @@ -155,25 +155,25 @@ - (nullable NSNumber *)isDeviceSupportedWithError:
#pragma mark Private Methods

- (void)showAlertWithMessage:(NSString *)message
firstButton:(NSString *)firstButton
additionalButton:(NSString *)secondButton
completion:(AuthCompletion)completion {
dismissButtonTitle:(NSString *)dismissButtonTitle
openSettingsButtonTitle:(NSString *)openSettingsButtonTitle
completion:(FLAAuthCompletion)completion {
UIAlertController *alert =
[UIAlertController alertControllerWithTitle:@""
message:message
preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:firstButton
UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:dismissButtonTitle
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[self handleSucceeded:NO
withCompletion:completion];
}];

[alert addAction:defaultAction];
if (secondButton != nil) {
if (openSettingsButtonTitle != nil) {
UIAlertAction *additionalAction = [UIAlertAction
actionWithTitle:secondButton
actionWithTitle:openSettingsButtonTitle
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
Expand All @@ -193,7 +193,7 @@ - (void)handleAuthReplyWithSuccess:(BOOL)success
error:(NSError *)error
options:(FLAAuthOptions *)options
strings:(FLAAuthStrings *)strings
completion:(nonnull AuthCompletion)completion {
completion:(nonnull FLAAuthCompletion)completion {
NSAssert([NSThread isMainThread], @"Response handling must be done on the main thread.");
if (success) {
[self handleSucceeded:YES withCompletion:completion];
Expand Down Expand Up @@ -221,7 +221,7 @@ - (void)handleAuthReplyWithSuccess:(BOOL)success
}
}

- (void)handleSucceeded:(BOOL)succeeded withCompletion:(nonnull AuthCompletion)completion {
- (void)handleSucceeded:(BOOL)succeeded withCompletion:(nonnull FLAAuthCompletion)completion {
completion(
[FLAAuthResultDetails makeWithResult:(succeeded ? FLAAuthResultSuccess : FLAAuthResultFailure)
errorMessage:nil
Expand All @@ -232,7 +232,7 @@ - (void)handleSucceeded:(BOOL)succeeded withCompletion:(nonnull AuthCompletion)c
- (void)handleError:(NSError *)authError
withOptions:(FLAAuthOptions *)options
strings:(FLAAuthStrings *)strings
completion:(nonnull AuthCompletion)completion {
completion:(nonnull FLAAuthCompletion)completion {
FLAAuthResult result = FLAAuthResultErrorNotAvailable;
switch (authError.code) {
case LAErrorPasscodeNotSet:
Expand Down