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
21 changes: 21 additions & 0 deletions Example/DMPasscode.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; };
6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5B8195388D20070C39A /* InfoPlist.strings */; };
6003F5BC195388D20070C39A /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5BB195388D20070C39A /* Tests.m */; };
8419BE1B1A606AC200880D45 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8419BE1D1A606AC200880D45 /* Localizable.strings */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -54,6 +55,10 @@
606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = "<group>"; };
6A7507787FC44B769011E24F /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
7BB550C53786F18EB50CBA9E /* Pods-Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-Tests/Pods-Tests.release.xcconfig"; sourceTree = "<group>"; };
8419BE1C1A606AC200880D45 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
8419BE1E1A606ADD00880D45 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/InfoPlist.strings; sourceTree = "<group>"; };
8419BE1F1A606ADD00880D45 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
8419BE201A606ADD00880D45 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/InfoPlist.strings; sourceTree = "<group>"; };
96B51248A87F48C3A0A0A014 /* libPods-Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
99223ECC932347BCB3D78023 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
C9218A9104BCEE3C6FA88A0C /* Pods-DMPasscode.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DMPasscode.debug.xcconfig"; path = "Pods/Target Support Files/Pods-DMPasscode/Pods-DMPasscode.debug.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -129,6 +134,7 @@
6003F59D195388D20070C39A /* DMAppDelegate.m */,
6003F5A8195388D20070C39A /* Images.xcassets */,
6003F594195388D20070C39A /* Supporting Files */,
8419BE1D1A606AC200880D45 /* Localizable.strings */,
);
path = DMPasscode;
sourceTree = "<group>";
Expand Down Expand Up @@ -248,6 +254,7 @@
knownRegions = (
en,
Base,
ru,
);
mainGroup = 6003F581195388D10070C39A;
productRefGroup = 6003F58B195388D20070C39A /* Products */;
Expand All @@ -266,6 +273,7 @@
buildActionMask = 2147483647;
files = (
6003F5A9195388D20070C39A /* Images.xcassets in Resources */,
8419BE1B1A606AC200880D45 /* Localizable.strings in Resources */,
6003F598195388D20070C39A /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -376,6 +384,7 @@
isa = PBXVariantGroup;
children = (
6003F597195388D20070C39A /* en */,
8419BE1E1A606ADD00880D45 /* ru */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
Expand All @@ -384,10 +393,20 @@
isa = PBXVariantGroup;
children = (
6003F5B9195388D20070C39A /* en */,
8419BE201A606ADD00880D45 /* ru */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
8419BE1D1A606AC200880D45 /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
8419BE1C1A606AC200880D45 /* en */,
8419BE1F1A606ADD00880D45 /* ru */,
);
name = Localizable.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
Expand Down Expand Up @@ -469,6 +488,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "DMPasscode/DMPasscode-Prefix.pch";
INFOPLIST_FILE = "DMPasscode/DMPasscode-Info.plist";
Expand All @@ -483,6 +503,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "DMPasscode/DMPasscode-Prefix.pch";
INFOPLIST_FILE = "DMPasscode/DMPasscode-Info.plist";
Expand Down
45 changes: 28 additions & 17 deletions Example/DMPasscode/DMAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ @implementation DMAppDelegate {
UIButton* _setupButton;
UIButton* _checkButton;
UIButton* _removeButton;
BOOL _showingPasscode;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
_rootViewController = [[UIViewController alloc] init];
self.window.rootViewController = _rootViewController;
[self addViews];
Expand All @@ -37,13 +35,27 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
config.statusBarStyle = UIStatusBarStyleLightContent;
[DMPasscode setConfig:config];
*/


DMPasscodeConfig* config = [[DMPasscodeConfig alloc] init];
config.enterNewCodeTitle = NSLocalizedString(@"dmpasscode_enter_new_code", @"");
config.enterCoodeToUnlockTitle = NSLocalizedString(@"dmpasscode_enter_to_unlock", @"");
config.repeatCodeTitle = NSLocalizedString(@"dmpasscode_repeat", @"");
config.noMatchTitle = NSLocalizedString(@"dmpasscode_not_match", @"");
config.okayTitle = NSLocalizedString(@"dmpasscode_okay", @"");
config.leftAttemptsTitle = NSLocalizedString(@"dmpasscode_n_left", @"");
config.touchIdReasonTitle = NSLocalizedString(@"dmpasscode_touchid_reason", @"");
[DMPasscode setConfig:config];

[self.window makeKeyAndVisible];

[self applicationWillResignActive:application];

return YES;
}

- (void)addViews {
_setupButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 50, _rootViewController.view.frame.size.width, 50)];
[_setupButton setTitle:@"Setup" forState:UIControlStateNormal];
[_setupButton setTitle:NSLocalizedString(@"setup", @"") forState:UIControlStateNormal];
[_setupButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[_setupButton addTarget:self action:@selector(actionSetup:) forControlEvents:UIControlEventTouchUpInside];
[_rootViewController.view addSubview:_setupButton];
Expand Down Expand Up @@ -92,21 +104,20 @@ - (void)updateViews {
_removeButton.enabled = passcodeSet;
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
if ([DMPasscode isPasscodeSet] && !_showingPasscode) {
_showingPasscode = YES;
[DMPasscode showPasscodeInViewController:self.window.rootViewController completion:^(BOOL success) {
if (success) {
NSLog(@"Win");
}else{
NSLog(@"Loss");
}
}];
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[self applicationWillResignActive:application];
}

-(void)applicationWillEnterForeground:(UIApplication *)application{
_showingPasscode = NO;
- (void)applicationWillResignActive:(UIApplication *)application
{
[DMPasscode lockScreenWithCompletion:^(BOOL success) {
if (success) {
NSLog(@"Win");
}else{
NSLog(@"Loss");
}
}];
}

@end
17 changes: 17 additions & 0 deletions Example/DMPasscode/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Localizable.strings
DMPasscode

Created by Alex on 09.01.15.
Copyright (c) 2015 Dylan Marriott. All rights reserved.
*/

"dmpasscode_enter_new_code" = "Enter new code";
"dmpasscode_enter_to_unlock" = "Enter code to unlock";
"dmpasscode_repeat" = "Repeat code";
"dmpasscode_not_match" = "Codes did not match, please try again.";
"dmpasscode_okay" = "Okay";
"dmpasscode_n_left" = "%i attempts left";
"dmpasscode_touchid_reason" = "Authenticate to access locked feature.";

"setup" = "Setup";
2 changes: 2 additions & 0 deletions Example/DMPasscode/ru.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

17 changes: 17 additions & 0 deletions Example/DMPasscode/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Localizable.strings
DMPasscode

Created by Alex on 09.01.15.
Copyright (c) 2015 Dylan Marriott. All rights reserved.
*/

"dmpasscode_enter_new_code" = "Введите новый код";
"dmpasscode_enter_to_unlock" = "Введите код, что бы разблокировать";
"dmpasscode_repeat" = "Повторите код";
"dmpasscode_not_match" = "Коды не совпали, пожалуйста, попробуйте еще раз.";
"dmpasscode_okay" = "Ок";
"dmpasscode_n_left" = "Осталось %i попыток";
"dmpasscode_touchid_reason" = "Авторизуйтесь, что бы получить доступ";

"setup" = "Настройка";
2 changes: 2 additions & 0 deletions Example/Tests/ru.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

9 changes: 9 additions & 0 deletions Pod/Classes/DMPasscode.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ typedef void (^PasscodeCompletionBlock)(BOOL success);
*/
+ (void)showPasscodeInViewController:(UIViewController *)viewController completion:(PasscodeCompletionBlock)completion;

+ (void)lockScreenWithCompletion:(PasscodeCompletionBlock)completion;

/**
* Remove the passcode from the keychain.
*/
Expand All @@ -55,4 +57,11 @@ typedef void (^PasscodeCompletionBlock)(BOOL success);
*/
+ (void)setConfig:(DMPasscodeConfig *)config;

/**
* Check if a input is already set.
*
* @return BOOL indicating if a passcode is set
*/
+ (BOOL)isShowingPasscode;

@end
Loading