mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Refactor PasscodeUI
This commit is contained in:
22
submodules/PasscodeUI/Info.plist
Normal file
22
submodules/PasscodeUI/Info.plist
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
</dict>
|
||||
</plist>
|
||||
635
submodules/PasscodeUI/PasscodeUI_Xcode.xcodeproj/project.pbxproj
Normal file
635
submodules/PasscodeUI/PasscodeUI_Xcode.xcodeproj/project.pbxproj
Normal file
@@ -0,0 +1,635 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 50;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
D0C9C9FA230228D400FAB518 /* PasscodeUI.h in Headers */ = {isa = PBXBuildFile; fileRef = D0C9C9F8230228D400FAB518 /* PasscodeUI.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D0C9CA0E2302293400FAB518 /* PasscodeEntryControllerNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0C9CA042302293200FAB518 /* PasscodeEntryControllerNode.swift */; };
|
||||
D0C9CA0F2302293400FAB518 /* PasscodeBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0C9CA052302293300FAB518 /* PasscodeBackground.swift */; };
|
||||
D0C9CA102302293400FAB518 /* PasscodeEntryController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0C9CA062302293300FAB518 /* PasscodeEntryController.swift */; };
|
||||
D0C9CA112302293400FAB518 /* PasscodeSetupControllerNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0C9CA072302293300FAB518 /* PasscodeSetupControllerNode.swift */; };
|
||||
D0C9CA122302293400FAB518 /* PasscodeLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0C9CA082302293300FAB518 /* PasscodeLayout.swift */; };
|
||||
D0C9CA132302293400FAB518 /* PasscodeLockIconNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0C9CA092302293300FAB518 /* PasscodeLockIconNode.swift */; };
|
||||
D0C9CA142302293400FAB518 /* PasscodeEntryInputFieldNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0C9CA0A2302293400FAB518 /* PasscodeEntryInputFieldNode.swift */; };
|
||||
D0C9CA152302293400FAB518 /* PasscodeEntryLabelNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0C9CA0B2302293400FAB518 /* PasscodeEntryLabelNode.swift */; };
|
||||
D0C9CA162302293400FAB518 /* PasscodeEntryKeyboardNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0C9CA0C2302293400FAB518 /* PasscodeEntryKeyboardNode.swift */; };
|
||||
D0C9CA172302293400FAB518 /* PasscodeSetupController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0C9CA0D2302293400FAB518 /* PasscodeSetupController.swift */; };
|
||||
D0C9CA1C2302298E00FAB518 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9CA1B2302298E00FAB518 /* Foundation.framework */; };
|
||||
D0C9CA1E2302299200FAB518 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9CA1D2302299200FAB518 /* UIKit.framework */; };
|
||||
D0C9CA202302299500FAB518 /* Display.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9CA1F2302299500FAB518 /* Display.framework */; };
|
||||
D0C9CA222302299A00FAB518 /* ImageBlur.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9CA212302299A00FAB518 /* ImageBlur.framework */; };
|
||||
D0C9CA24230229A200FAB518 /* AsyncDisplayKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9CA23230229A200FAB518 /* AsyncDisplayKit.framework */; };
|
||||
D0C9CA26230229AA00FAB518 /* SwiftSignalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9CA25230229AA00FAB518 /* SwiftSignalKit.framework */; };
|
||||
D0C9CA28230229AF00FAB518 /* Postbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9CA27230229AF00FAB518 /* Postbox.framework */; };
|
||||
D0C9CA2A230229BA00FAB518 /* TelegramPresentationData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9CA29230229BA00FAB518 /* TelegramPresentationData.framework */; };
|
||||
D0C9CA2C230229C200FAB518 /* TelegramUIPreferences.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9CA2B230229C200FAB518 /* TelegramUIPreferences.framework */; };
|
||||
D0C9CA2E230229C900FAB518 /* AccountContext.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9CA2D230229C900FAB518 /* AccountContext.framework */; };
|
||||
D0C9CA30230229D100FAB518 /* LocalAuth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9CA2F230229D100FAB518 /* LocalAuth.framework */; };
|
||||
D0C9CA32230229DE00FAB518 /* TelegramCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9CA31230229DE00FAB518 /* TelegramCore.framework */; };
|
||||
D0C9CA34230229F100FAB518 /* LegacyComponents.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9CA33230229F100FAB518 /* LegacyComponents.framework */; };
|
||||
D0C9CA3623022A7400FAB518 /* TelegramStringFormatting.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9CA3523022A7400FAB518 /* TelegramStringFormatting.framework */; };
|
||||
D0C9CA3A23022AA300FAB518 /* FrameworkBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0C9CA3923022AA300FAB518 /* FrameworkBundle.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
D0C9C9F5230228D400FAB518 /* PasscodeUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PasscodeUI.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D0C9C9F8230228D400FAB518 /* PasscodeUI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PasscodeUI.h; sourceTree = "<group>"; };
|
||||
D0C9C9F9230228D400FAB518 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
D0C9CA042302293200FAB518 /* PasscodeEntryControllerNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasscodeEntryControllerNode.swift; sourceTree = "<group>"; };
|
||||
D0C9CA052302293300FAB518 /* PasscodeBackground.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasscodeBackground.swift; sourceTree = "<group>"; };
|
||||
D0C9CA062302293300FAB518 /* PasscodeEntryController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasscodeEntryController.swift; sourceTree = "<group>"; };
|
||||
D0C9CA072302293300FAB518 /* PasscodeSetupControllerNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasscodeSetupControllerNode.swift; sourceTree = "<group>"; };
|
||||
D0C9CA082302293300FAB518 /* PasscodeLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasscodeLayout.swift; sourceTree = "<group>"; };
|
||||
D0C9CA092302293300FAB518 /* PasscodeLockIconNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasscodeLockIconNode.swift; sourceTree = "<group>"; };
|
||||
D0C9CA0A2302293400FAB518 /* PasscodeEntryInputFieldNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasscodeEntryInputFieldNode.swift; sourceTree = "<group>"; };
|
||||
D0C9CA0B2302293400FAB518 /* PasscodeEntryLabelNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasscodeEntryLabelNode.swift; sourceTree = "<group>"; };
|
||||
D0C9CA0C2302293400FAB518 /* PasscodeEntryKeyboardNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasscodeEntryKeyboardNode.swift; sourceTree = "<group>"; };
|
||||
D0C9CA0D2302293400FAB518 /* PasscodeSetupController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasscodeSetupController.swift; sourceTree = "<group>"; };
|
||||
D0C9CA1B2302298E00FAB518 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
D0C9CA1D2302299200FAB518 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||
D0C9CA1F2302299500FAB518 /* Display.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Display.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D0C9CA212302299A00FAB518 /* ImageBlur.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = ImageBlur.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D0C9CA23230229A200FAB518 /* AsyncDisplayKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = AsyncDisplayKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D0C9CA25230229AA00FAB518 /* SwiftSignalKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = SwiftSignalKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D0C9CA27230229AF00FAB518 /* Postbox.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Postbox.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D0C9CA29230229BA00FAB518 /* TelegramPresentationData.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = TelegramPresentationData.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D0C9CA2B230229C200FAB518 /* TelegramUIPreferences.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = TelegramUIPreferences.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D0C9CA2D230229C900FAB518 /* AccountContext.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = AccountContext.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D0C9CA2F230229D100FAB518 /* LocalAuth.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = LocalAuth.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D0C9CA31230229DE00FAB518 /* TelegramCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = TelegramCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D0C9CA33230229F100FAB518 /* LegacyComponents.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = LegacyComponents.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D0C9CA3523022A7400FAB518 /* TelegramStringFormatting.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = TelegramStringFormatting.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D0C9CA3923022AA300FAB518 /* FrameworkBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FrameworkBundle.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
D0C9C9F2230228D400FAB518 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D0C9CA3623022A7400FAB518 /* TelegramStringFormatting.framework in Frameworks */,
|
||||
D0C9CA34230229F100FAB518 /* LegacyComponents.framework in Frameworks */,
|
||||
D0C9CA32230229DE00FAB518 /* TelegramCore.framework in Frameworks */,
|
||||
D0C9CA30230229D100FAB518 /* LocalAuth.framework in Frameworks */,
|
||||
D0C9CA2E230229C900FAB518 /* AccountContext.framework in Frameworks */,
|
||||
D0C9CA2C230229C200FAB518 /* TelegramUIPreferences.framework in Frameworks */,
|
||||
D0C9CA2A230229BA00FAB518 /* TelegramPresentationData.framework in Frameworks */,
|
||||
D0C9CA28230229AF00FAB518 /* Postbox.framework in Frameworks */,
|
||||
D0C9CA26230229AA00FAB518 /* SwiftSignalKit.framework in Frameworks */,
|
||||
D0C9CA24230229A200FAB518 /* AsyncDisplayKit.framework in Frameworks */,
|
||||
D0C9CA222302299A00FAB518 /* ImageBlur.framework in Frameworks */,
|
||||
D0C9CA202302299500FAB518 /* Display.framework in Frameworks */,
|
||||
D0C9CA1E2302299200FAB518 /* UIKit.framework in Frameworks */,
|
||||
D0C9CA1C2302298E00FAB518 /* Foundation.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
D0C9C9EB230228D400FAB518 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D0C9C9F9230228D400FAB518 /* Info.plist */,
|
||||
D0C9C9F7230228D400FAB518 /* Sources */,
|
||||
D0C9C9F6230228D400FAB518 /* Products */,
|
||||
D0C9CA1A2302298D00FAB518 /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D0C9C9F6230228D400FAB518 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D0C9C9F5230228D400FAB518 /* PasscodeUI.framework */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D0C9C9F7230228D400FAB518 /* Sources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D0C9CA052302293300FAB518 /* PasscodeBackground.swift */,
|
||||
D0C9CA062302293300FAB518 /* PasscodeEntryController.swift */,
|
||||
D0C9CA042302293200FAB518 /* PasscodeEntryControllerNode.swift */,
|
||||
D0C9CA0A2302293400FAB518 /* PasscodeEntryInputFieldNode.swift */,
|
||||
D0C9CA0C2302293400FAB518 /* PasscodeEntryKeyboardNode.swift */,
|
||||
D0C9CA0B2302293400FAB518 /* PasscodeEntryLabelNode.swift */,
|
||||
D0C9CA082302293300FAB518 /* PasscodeLayout.swift */,
|
||||
D0C9CA092302293300FAB518 /* PasscodeLockIconNode.swift */,
|
||||
D0C9CA0D2302293400FAB518 /* PasscodeSetupController.swift */,
|
||||
D0C9CA072302293300FAB518 /* PasscodeSetupControllerNode.swift */,
|
||||
D0C9CA3923022AA300FAB518 /* FrameworkBundle.swift */,
|
||||
D0C9C9F8230228D400FAB518 /* PasscodeUI.h */,
|
||||
);
|
||||
path = Sources;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D0C9CA1A2302298D00FAB518 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D0C9CA3523022A7400FAB518 /* TelegramStringFormatting.framework */,
|
||||
D0C9CA33230229F100FAB518 /* LegacyComponents.framework */,
|
||||
D0C9CA31230229DE00FAB518 /* TelegramCore.framework */,
|
||||
D0C9CA2F230229D100FAB518 /* LocalAuth.framework */,
|
||||
D0C9CA2D230229C900FAB518 /* AccountContext.framework */,
|
||||
D0C9CA2B230229C200FAB518 /* TelegramUIPreferences.framework */,
|
||||
D0C9CA29230229BA00FAB518 /* TelegramPresentationData.framework */,
|
||||
D0C9CA27230229AF00FAB518 /* Postbox.framework */,
|
||||
D0C9CA25230229AA00FAB518 /* SwiftSignalKit.framework */,
|
||||
D0C9CA23230229A200FAB518 /* AsyncDisplayKit.framework */,
|
||||
D0C9CA212302299A00FAB518 /* ImageBlur.framework */,
|
||||
D0C9CA1F2302299500FAB518 /* Display.framework */,
|
||||
D0C9CA1D2302299200FAB518 /* UIKit.framework */,
|
||||
D0C9CA1B2302298E00FAB518 /* Foundation.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
D0C9C9F0230228D400FAB518 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D0C9C9FA230228D400FAB518 /* PasscodeUI.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
D0C9C9F4230228D400FAB518 /* PasscodeUI */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = D0C9C9FD230228D400FAB518 /* Build configuration list for PBXNativeTarget "PasscodeUI" */;
|
||||
buildPhases = (
|
||||
D0C9C9F0230228D400FAB518 /* Headers */,
|
||||
D0C9C9F1230228D400FAB518 /* Sources */,
|
||||
D0C9C9F2230228D400FAB518 /* Frameworks */,
|
||||
D0C9C9F3230228D400FAB518 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = PasscodeUI;
|
||||
productName = PasscodeUI;
|
||||
productReference = D0C9C9F5230228D400FAB518 /* PasscodeUI.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
D0C9C9EC230228D400FAB518 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
DefaultBuildSystemTypeForWorkspace = Latest;
|
||||
LastUpgradeCheck = 1030;
|
||||
ORGANIZATIONNAME = "Telegram Messenger LLP";
|
||||
TargetAttributes = {
|
||||
D0C9C9F4230228D400FAB518 = {
|
||||
CreatedOnToolsVersion = 10.3;
|
||||
LastSwiftMigration = 1030;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = D0C9C9EF230228D400FAB518 /* Build configuration list for PBXProject "PasscodeUI_Xcode" */;
|
||||
compatibilityVersion = "Xcode 9.3";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = D0C9C9EB230228D400FAB518;
|
||||
productRefGroup = D0C9C9F6230228D400FAB518 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
D0C9C9F4230228D400FAB518 /* PasscodeUI */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
D0C9C9F3230228D400FAB518 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
D0C9C9F1230228D400FAB518 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D0C9CA0E2302293400FAB518 /* PasscodeEntryControllerNode.swift in Sources */,
|
||||
D0C9CA152302293400FAB518 /* PasscodeEntryLabelNode.swift in Sources */,
|
||||
D0C9CA162302293400FAB518 /* PasscodeEntryKeyboardNode.swift in Sources */,
|
||||
D0C9CA172302293400FAB518 /* PasscodeSetupController.swift in Sources */,
|
||||
D0C9CA0F2302293400FAB518 /* PasscodeBackground.swift in Sources */,
|
||||
D0C9CA142302293400FAB518 /* PasscodeEntryInputFieldNode.swift in Sources */,
|
||||
D0C9CA122302293400FAB518 /* PasscodeLayout.swift in Sources */,
|
||||
D0C9CA132302293400FAB518 /* PasscodeLockIconNode.swift in Sources */,
|
||||
D0C9CA3A23022AA300FAB518 /* FrameworkBundle.swift in Sources */,
|
||||
D0C9CA102302293400FAB518 /* PasscodeEntryController.swift in Sources */,
|
||||
D0C9CA112302293400FAB518 /* PasscodeSetupControllerNode.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
D0C9C9FB230228D400FAB518 /* DebugAppStoreLLC */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = DebugAppStoreLLC;
|
||||
};
|
||||
D0C9C9FC230228D400FAB518 /* ReleaseAppStoreLLC */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = ReleaseAppStoreLLC;
|
||||
};
|
||||
D0C9C9FE230228D400FAB518 /* DebugAppStoreLLC */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
MACH_O_TYPE = staticlib;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.telegram.PasscodeUI;
|
||||
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = DebugAppStoreLLC;
|
||||
};
|
||||
D0C9C9FF230228D400FAB518 /* ReleaseAppStoreLLC */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
MACH_O_TYPE = staticlib;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.telegram.PasscodeUI;
|
||||
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = ReleaseAppStoreLLC;
|
||||
};
|
||||
D0C9CA00230228FB00FAB518 /* DebugHockeyapp */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = DebugHockeyapp;
|
||||
};
|
||||
D0C9CA01230228FB00FAB518 /* DebugHockeyapp */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
MACH_O_TYPE = staticlib;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.telegram.PasscodeUI;
|
||||
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = DebugHockeyapp;
|
||||
};
|
||||
D0C9CA022302290600FAB518 /* ReleaseHockeyappInternal */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = ReleaseHockeyappInternal;
|
||||
};
|
||||
D0C9CA032302290600FAB518 /* ReleaseHockeyappInternal */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
MACH_O_TYPE = staticlib;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.telegram.PasscodeUI;
|
||||
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = ReleaseHockeyappInternal;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
D0C9C9EF230228D400FAB518 /* Build configuration list for PBXProject "PasscodeUI_Xcode" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
D0C9C9FB230228D400FAB518 /* DebugAppStoreLLC */,
|
||||
D0C9CA00230228FB00FAB518 /* DebugHockeyapp */,
|
||||
D0C9C9FC230228D400FAB518 /* ReleaseAppStoreLLC */,
|
||||
D0C9CA022302290600FAB518 /* ReleaseHockeyappInternal */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = ReleaseAppStoreLLC;
|
||||
};
|
||||
D0C9C9FD230228D400FAB518 /* Build configuration list for PBXNativeTarget "PasscodeUI" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
D0C9C9FE230228D400FAB518 /* DebugAppStoreLLC */,
|
||||
D0C9CA01230228FB00FAB518 /* DebugHockeyapp */,
|
||||
D0C9C9FF230228D400FAB518 /* ReleaseAppStoreLLC */,
|
||||
D0C9CA032302290600FAB518 /* ReleaseHockeyappInternal */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = ReleaseAppStoreLLC;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = D0C9C9EC230228D400FAB518 /* Project object */;
|
||||
}
|
||||
13
submodules/PasscodeUI/Sources/FrameworkBundle.swift
Normal file
13
submodules/PasscodeUI/Sources/FrameworkBundle.swift
Normal file
@@ -0,0 +1,13 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
private class FrameworkBundleClass: NSObject {
|
||||
}
|
||||
|
||||
let frameworkBundle: Bundle = Bundle(for: FrameworkBundleClass.self)
|
||||
|
||||
extension UIImage {
|
||||
convenience init?(bundleImageName: String) {
|
||||
self.init(named: bundleImageName, in: frameworkBundle, compatibleWith: nil)
|
||||
}
|
||||
}
|
||||
81
submodules/PasscodeUI/Sources/PasscodeBackground.swift
Normal file
81
submodules/PasscodeUI/Sources/PasscodeBackground.swift
Normal file
@@ -0,0 +1,81 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import ImageBlur
|
||||
|
||||
protocol PasscodeBackground {
|
||||
var size: CGSize { get }
|
||||
var backgroundImage: UIImage { get }
|
||||
var foregroundImage: UIImage { get }
|
||||
}
|
||||
|
||||
final class GradientPasscodeBackground: PasscodeBackground {
|
||||
public private(set) var size: CGSize
|
||||
public private(set) var backgroundImage: UIImage
|
||||
public private(set) var foregroundImage: UIImage
|
||||
|
||||
init(size: CGSize, backgroundColors: (UIColor, UIColor), buttonColor: UIColor) {
|
||||
self.size = size
|
||||
self.backgroundImage = generateImage(CGSize(width: 8.0, height: size.height), contextGenerator: { size, context in
|
||||
let gradientColors = [backgroundColors.1.cgColor, backgroundColors.0.cgColor] as CFArray
|
||||
var locations: [CGFloat] = [0.0, 1.0]
|
||||
let colorSpace = CGColorSpaceCreateDeviceRGB()
|
||||
let gradient = CGGradient(colorsSpace: colorSpace, colors: gradientColors, locations: &locations)!
|
||||
context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: 0.0, y: size.height), options: CGGradientDrawingOptions())
|
||||
})!
|
||||
self.foregroundImage = generateImage(CGSize(width: 1.0, height: 1.0), contextGenerator: { size, context in
|
||||
let bounds = CGRect(origin: CGPoint(), size: size)
|
||||
context.clear(bounds)
|
||||
if buttonColor != UIColor.clear {
|
||||
context.setFillColor(buttonColor.cgColor)
|
||||
} else {
|
||||
context.setFillColor(UIColor.white.withAlphaComponent(0.5).cgColor)
|
||||
}
|
||||
context.fill(bounds)
|
||||
})!
|
||||
}
|
||||
}
|
||||
|
||||
final class ImageBasedPasscodeBackground: PasscodeBackground {
|
||||
public private(set) var size: CGSize
|
||||
public private(set) var backgroundImage: UIImage
|
||||
public private(set) var foregroundImage: UIImage
|
||||
|
||||
init(image: UIImage, size: CGSize) {
|
||||
self.size = size
|
||||
|
||||
let contextSize = size.fitted(CGSize(width: 320.0, height: 320.0))
|
||||
let foregroundContext = DrawingContext(size: contextSize, scale: 1.0)
|
||||
let bounds = CGRect(origin: CGPoint(), size: contextSize)
|
||||
|
||||
foregroundContext.withFlippedContext { c in
|
||||
c.interpolationQuality = .medium
|
||||
c.draw(image.cgImage!, in: bounds)
|
||||
}
|
||||
telegramFastBlurMore(Int32(contextSize.width), Int32(contextSize.height), Int32(foregroundContext.bytesPerRow), foregroundContext.bytes)
|
||||
telegramFastBlurMore(Int32(contextSize.width), Int32(contextSize.height), Int32(foregroundContext.bytesPerRow), foregroundContext.bytes)
|
||||
telegramFastBlurMore(Int32(contextSize.width), Int32(contextSize.height), Int32(foregroundContext.bytesPerRow), foregroundContext.bytes)
|
||||
telegramBrightenImage(Int32(contextSize.width), Int32(contextSize.height), Int32(foregroundContext.bytesPerRow), foregroundContext.bytes)
|
||||
|
||||
foregroundContext.withFlippedContext { c in
|
||||
c.setFillColor(UIColor(white: 1.0, alpha: 0.1).cgColor)
|
||||
c.fill(bounds)
|
||||
}
|
||||
self.foregroundImage = foregroundContext.generateImage()!
|
||||
|
||||
let backgroundContext = DrawingContext(size: contextSize, scale: 1.0)
|
||||
backgroundContext.withFlippedContext { c in
|
||||
c.interpolationQuality = .medium
|
||||
c.draw(image.cgImage!, in: bounds)
|
||||
}
|
||||
telegramFastBlurMore(Int32(contextSize.width), Int32(contextSize.height), Int32(backgroundContext.bytesPerRow), backgroundContext.bytes)
|
||||
telegramFastBlurMore(Int32(contextSize.width), Int32(contextSize.height), Int32(backgroundContext.bytesPerRow), backgroundContext.bytes)
|
||||
telegramFastBlurMore(Int32(contextSize.width), Int32(contextSize.height), Int32(foregroundContext.bytesPerRow), foregroundContext.bytes)
|
||||
|
||||
backgroundContext.withFlippedContext { context in
|
||||
context.setFillColor(UIColor(white: 0.0, alpha: 0.35).cgColor)
|
||||
context.fill(bounds)
|
||||
}
|
||||
self.backgroundImage = backgroundContext.generateImage()!
|
||||
}
|
||||
}
|
||||
316
submodules/PasscodeUI/Sources/PasscodeEntryController.swift
Normal file
316
submodules/PasscodeUI/Sources/PasscodeEntryController.swift
Normal file
@@ -0,0 +1,316 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
import AccountContext
|
||||
import LocalAuth
|
||||
import TelegramStringFormatting
|
||||
|
||||
public final class PasscodeEntryControllerPresentationArguments {
|
||||
let animated: Bool
|
||||
let fadeIn: Bool
|
||||
let lockIconInitialFrame: () -> CGRect
|
||||
let cancel: (() -> Void)?
|
||||
|
||||
public init(animated: Bool = true, fadeIn: Bool = false, lockIconInitialFrame: @escaping () -> CGRect = { return CGRect() }, cancel: (() -> Void)? = nil) {
|
||||
self.animated = animated
|
||||
self.fadeIn = fadeIn
|
||||
self.lockIconInitialFrame = lockIconInitialFrame
|
||||
self.cancel = cancel
|
||||
}
|
||||
}
|
||||
|
||||
public enum PasscodeEntryControllerBiometricsMode {
|
||||
case none
|
||||
case enabled(Data?)
|
||||
}
|
||||
|
||||
public final class PasscodeEntryController: ViewController {
|
||||
private var controllerNode: PasscodeEntryControllerNode {
|
||||
return self.displayNode as! PasscodeEntryControllerNode
|
||||
}
|
||||
|
||||
private let context: AccountContext
|
||||
private var presentationData: PresentationData
|
||||
private var presentationDataDisposable: Disposable?
|
||||
|
||||
private let challengeData: PostboxAccessChallengeData
|
||||
private let biometrics: PasscodeEntryControllerBiometricsMode
|
||||
private let arguments: PasscodeEntryControllerPresentationArguments
|
||||
|
||||
public var presentationCompleted: (() -> Void)?
|
||||
public var completed: (() -> Void)?
|
||||
|
||||
private let biometricsDisposable = MetaDisposable()
|
||||
private var hasOngoingBiometricsRequest = false
|
||||
private var skipNextBiometricsRequest = false
|
||||
|
||||
private var inBackground: Bool = false
|
||||
private var inBackgroundDisposable: Disposable?
|
||||
|
||||
public init(context: AccountContext, challengeData: PostboxAccessChallengeData, biometrics: PasscodeEntryControllerBiometricsMode, arguments: PasscodeEntryControllerPresentationArguments) {
|
||||
self.context = context
|
||||
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
self.challengeData = challengeData
|
||||
self.biometrics = biometrics
|
||||
self.arguments = arguments
|
||||
|
||||
super.init(navigationBarPresentationData: nil)
|
||||
|
||||
self.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait)
|
||||
self.statusBar.statusBarStyle = .White
|
||||
|
||||
self.presentationDataDisposable = (context.sharedContext.presentationData
|
||||
|> deliverOnMainQueue).start(next: { [weak self] presentationData in
|
||||
if let strongSelf = self, strongSelf.isNodeLoaded {
|
||||
strongSelf.controllerNode.updatePresentationData(presentationData)
|
||||
}
|
||||
})
|
||||
|
||||
self.inBackgroundDisposable = (context.sharedContext.applicationBindings.applicationInForeground
|
||||
|> deliverOnMainQueue).start(next: { [weak self] value in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.inBackground = !value
|
||||
if !value {
|
||||
strongSelf.skipNextBiometricsRequest = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
deinit {
|
||||
self.presentationDataDisposable?.dispose()
|
||||
self.biometricsDisposable.dispose()
|
||||
self.inBackgroundDisposable?.dispose()
|
||||
}
|
||||
|
||||
required public init(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override public func loadDisplayNode() {
|
||||
let passcodeType: PasscodeEntryFieldType
|
||||
switch self.challengeData {
|
||||
case let .numericalPassword(value, _, _):
|
||||
passcodeType = value.count == 6 ? .digits6 : .digits4
|
||||
default:
|
||||
passcodeType = .alphanumeric
|
||||
}
|
||||
let biometricsType: LocalAuthBiometricAuthentication?
|
||||
if case let .enabled(data) = self.biometrics {
|
||||
if #available(iOSApplicationExtension 9.0, iOS 9.0, *) {
|
||||
if data == LocalAuth.evaluatedPolicyDomainState || (data == nil && !self.context.sharedContext.applicationBindings.isMainApp) {
|
||||
biometricsType = LocalAuth.biometricAuthentication
|
||||
} else {
|
||||
biometricsType = nil
|
||||
}
|
||||
} else {
|
||||
biometricsType = LocalAuth.biometricAuthentication
|
||||
}
|
||||
} else {
|
||||
biometricsType = nil
|
||||
}
|
||||
self.displayNode = PasscodeEntryControllerNode(context: self.context, theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, passcodeType: passcodeType, biometricsType: biometricsType, arguments: self.arguments, statusBar: self.statusBar)
|
||||
self.displayNodeDidLoad()
|
||||
|
||||
let _ = (self.context.sharedContext.accountManager.transaction({ transaction -> AccessChallengeAttempts? in
|
||||
return transaction.getAccessChallengeData().attempts
|
||||
}) |> deliverOnMainQueue).start(next: { [weak self] attempts in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.controllerNode.updateInvalidAttempts(attempts)
|
||||
})
|
||||
|
||||
self.controllerNode.checkPasscode = { [weak self] passcode in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
var succeed = false
|
||||
switch strongSelf.challengeData {
|
||||
case .none:
|
||||
succeed = true
|
||||
case let .numericalPassword(code, _, _):
|
||||
succeed = passcode == code
|
||||
if !succeed {
|
||||
succeed = convertToArabicNumeralString(passcode) == code
|
||||
}
|
||||
case let .plaintextPassword(code, _, _):
|
||||
succeed = passcode == code
|
||||
}
|
||||
|
||||
if succeed {
|
||||
if let completed = strongSelf.completed {
|
||||
completed()
|
||||
} else {
|
||||
let _ = (strongSelf.context.sharedContext.accountManager.transaction { transaction -> Void in
|
||||
var data = transaction.getAccessChallengeData().withUpdatedAutolockDeadline(nil)
|
||||
switch data {
|
||||
case .none:
|
||||
break
|
||||
case let .numericalPassword(value, timeout, _):
|
||||
data = .numericalPassword(value: value, timeout: timeout, attempts: nil)
|
||||
case let .plaintextPassword(value, timeout, _):
|
||||
data = .plaintextPassword(value: value, timeout: timeout, attempts: nil)
|
||||
}
|
||||
transaction.setAccessChallengeData(data)
|
||||
}).start()
|
||||
}
|
||||
|
||||
let isMainApp = strongSelf.context.sharedContext.applicationBindings.isMainApp
|
||||
let _ = updatePresentationPasscodeSettingsInteractively(accountManager: strongSelf.context.sharedContext.accountManager, { settings in
|
||||
if isMainApp {
|
||||
return settings.withUpdatedBiometricsDomainState(LocalAuth.evaluatedPolicyDomainState)
|
||||
} else {
|
||||
return settings.withUpdatedShareBiometricsDomainState(LocalAuth.evaluatedPolicyDomainState)
|
||||
}
|
||||
}).start()
|
||||
} else {
|
||||
let _ = (strongSelf.context.sharedContext.accountManager.transaction({ transaction -> AccessChallengeAttempts in
|
||||
var data = transaction.getAccessChallengeData()
|
||||
let updatedAttempts: AccessChallengeAttempts
|
||||
if let attempts = data.attempts {
|
||||
var count = attempts.count + 1
|
||||
if count > 6 {
|
||||
count = 1
|
||||
}
|
||||
updatedAttempts = AccessChallengeAttempts(count: count, timestamp: Int32(CFAbsoluteTimeGetCurrent()))
|
||||
} else {
|
||||
updatedAttempts = AccessChallengeAttempts(count: 1, timestamp: Int32(CFAbsoluteTimeGetCurrent()))
|
||||
}
|
||||
switch data {
|
||||
case .none:
|
||||
break
|
||||
case let .numericalPassword(value, timeout, _):
|
||||
data = .numericalPassword(value: value, timeout: timeout, attempts: updatedAttempts)
|
||||
case let .plaintextPassword(value, timeout, _):
|
||||
data = .plaintextPassword(value: value, timeout: timeout, attempts: updatedAttempts)
|
||||
}
|
||||
transaction.setAccessChallengeData(data)
|
||||
|
||||
return updatedAttempts
|
||||
})
|
||||
|> deliverOnMainQueue).start(next: { [weak self] attempts in
|
||||
if let strongSelf = self {
|
||||
strongSelf.controllerNode.updateInvalidAttempts(attempts, animated: true)
|
||||
}
|
||||
})
|
||||
|
||||
strongSelf.controllerNode.animateError()
|
||||
}
|
||||
}
|
||||
self.controllerNode.requestBiometrics = { [weak self] in
|
||||
if let strongSelf = self {
|
||||
strongSelf.requestBiometrics(force: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override public func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
|
||||
self.view.disablesInteractiveTransitionGestureRecognizer = true
|
||||
|
||||
self.controllerNode.activateInput()
|
||||
if self.arguments.animated {
|
||||
self.controllerNode.animateIn(iconFrame: self.arguments.lockIconInitialFrame(), completion: { [weak self] in
|
||||
self?.presentationCompleted?()
|
||||
})
|
||||
} else {
|
||||
self.controllerNode.initialAppearance(fadeIn: self.arguments.fadeIn)
|
||||
self.presentationCompleted?()
|
||||
}
|
||||
}
|
||||
|
||||
public func requestBiometrics(force: Bool = false) {
|
||||
guard case let .enabled(data) = self.biometrics, let _ = LocalAuth.biometricAuthentication else {
|
||||
return
|
||||
}
|
||||
|
||||
if #available(iOSApplicationExtension 9.0, iOS 9.0, *) {
|
||||
if data == nil && self.context.sharedContext.applicationBindings.isMainApp {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if self.skipNextBiometricsRequest {
|
||||
self.skipNextBiometricsRequest = false
|
||||
if !force {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if self.hasOngoingBiometricsRequest {
|
||||
if !force {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
self.hasOngoingBiometricsRequest = true
|
||||
|
||||
self.biometricsDisposable.set((LocalAuth.auth(reason: self.presentationData.strings.EnterPasscode_TouchId) |> deliverOnMainQueue).start(next: { [weak self] result, evaluatedPolicyDomainState in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
if #available(iOSApplicationExtension 9.0, iOS 9.0, *) {
|
||||
if case let .enabled(storedDomainState) = strongSelf.biometrics, evaluatedPolicyDomainState != nil {
|
||||
if !strongSelf.context.sharedContext.applicationBindings.isMainApp && storedDomainState == nil {
|
||||
let _ = updatePresentationPasscodeSettingsInteractively(accountManager: strongSelf.context.sharedContext.accountManager, { settings in
|
||||
return settings.withUpdatedShareBiometricsDomainState(LocalAuth.evaluatedPolicyDomainState)
|
||||
}).start()
|
||||
} else if storedDomainState != evaluatedPolicyDomainState {
|
||||
strongSelf.controllerNode.hideBiometrics()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if result {
|
||||
strongSelf.controllerNode.animateSuccess()
|
||||
|
||||
if let completed = strongSelf.completed {
|
||||
Queue.mainQueue().after(1.5) {
|
||||
completed()
|
||||
}
|
||||
strongSelf.hasOngoingBiometricsRequest = false
|
||||
} else {
|
||||
let _ = (strongSelf.context.sharedContext.accountManager.transaction { transaction -> Void in
|
||||
let data = transaction.getAccessChallengeData().withUpdatedAutolockDeadline(nil)
|
||||
transaction.setAccessChallengeData(data)
|
||||
}).start(completed: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
strongSelf.hasOngoingBiometricsRequest = false
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
strongSelf.hasOngoingBiometricsRequest = false
|
||||
strongSelf.skipNextBiometricsRequest = true
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||
super.containerLayoutUpdated(layout, transition: transition)
|
||||
|
||||
self.controllerNode.containerLayoutUpdated(layout, navigationBarHeight: self.navigationHeight, transition: transition)
|
||||
}
|
||||
|
||||
public override func dismiss(completion: (() -> Void)? = nil) {
|
||||
self.view.endEditing(true)
|
||||
self.controllerNode.animateOut { [weak self] in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.view.endEditing(true)
|
||||
strongSelf.presentingViewController?.dismiss(animated: false, completion: completion)
|
||||
}
|
||||
}
|
||||
}
|
||||
396
submodules/PasscodeUI/Sources/PasscodeEntryControllerNode.swift
Normal file
396
submodules/PasscodeUI/Sources/PasscodeEntryControllerNode.swift
Normal file
@@ -0,0 +1,396 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import AccountContext
|
||||
import LocalAuth
|
||||
|
||||
private let titleFont = Font.regular(20.0)
|
||||
private let subtitleFont = Font.regular(15.0)
|
||||
private let buttonFont = Font.regular(17.0)
|
||||
|
||||
final class PasscodeEntryControllerNode: ASDisplayNode {
|
||||
private let context: AccountContext
|
||||
private var theme: PresentationTheme
|
||||
private var strings: PresentationStrings
|
||||
private var wallpaper: TelegramWallpaper
|
||||
private let passcodeType: PasscodeEntryFieldType
|
||||
private let biometricsType: LocalAuthBiometricAuthentication?
|
||||
private let arguments: PasscodeEntryControllerPresentationArguments
|
||||
private var background: PasscodeBackground?
|
||||
|
||||
private let statusBar: StatusBar
|
||||
|
||||
private let backgroundNode: ASImageNode
|
||||
private let iconNode: PasscodeLockIconNode
|
||||
private let titleNode: PasscodeEntryLabelNode
|
||||
private let inputFieldNode: PasscodeEntryInputFieldNode
|
||||
private let subtitleNode: PasscodeEntryLabelNode
|
||||
private let keyboardNode: PasscodeEntryKeyboardNode
|
||||
private let cancelButtonNode: HighlightableButtonNode
|
||||
private let deleteButtonNode: HighlightableButtonNode
|
||||
private let biometricButtonNode: HighlightableButtonNode
|
||||
private let effectView: UIVisualEffectView
|
||||
|
||||
private var invalidAttempts: AccessChallengeAttempts?
|
||||
private var timer: SwiftSignalKit.Timer?
|
||||
|
||||
private let hapticFeedback = HapticFeedback()
|
||||
|
||||
private var validLayout: ContainerViewLayout?
|
||||
|
||||
var checkPasscode: ((String) -> Void)?
|
||||
var requestBiometrics: (() -> Void)?
|
||||
|
||||
init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, passcodeType: PasscodeEntryFieldType, biometricsType: LocalAuthBiometricAuthentication?, arguments: PasscodeEntryControllerPresentationArguments, statusBar: StatusBar) {
|
||||
self.context = context
|
||||
self.theme = theme
|
||||
self.strings = strings
|
||||
self.wallpaper = wallpaper
|
||||
self.passcodeType = passcodeType
|
||||
self.biometricsType = biometricsType
|
||||
self.arguments = arguments
|
||||
self.statusBar = statusBar
|
||||
|
||||
self.backgroundNode = ASImageNode()
|
||||
self.backgroundNode.contentMode = .scaleToFill
|
||||
|
||||
self.iconNode = PasscodeLockIconNode()
|
||||
self.titleNode = PasscodeEntryLabelNode()
|
||||
self.inputFieldNode = PasscodeEntryInputFieldNode(color: .white, accentColor: .white, fieldType: passcodeType, keyboardAppearance: .dark, useCustomNumpad: true)
|
||||
self.subtitleNode = PasscodeEntryLabelNode()
|
||||
self.keyboardNode = PasscodeEntryKeyboardNode()
|
||||
self.cancelButtonNode = HighlightableButtonNode()
|
||||
self.deleteButtonNode = HighlightableButtonNode()
|
||||
self.biometricButtonNode = HighlightableButtonNode()
|
||||
self.effectView = UIVisualEffectView(effect: nil)
|
||||
|
||||
super.init()
|
||||
|
||||
self.setViewBlock({
|
||||
return UITracingLayerView()
|
||||
})
|
||||
|
||||
self.backgroundColor = .clear
|
||||
self.iconNode.unlockedColor = theme.rootController.navigationBar.primaryTextColor
|
||||
|
||||
self.keyboardNode.charactedEntered = { [weak self] character in
|
||||
self?.inputFieldNode.append(character)
|
||||
}
|
||||
self.inputFieldNode.complete = { [weak self] passcode in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
if strongSelf.shouldWaitBeforeNextAttempt() {
|
||||
strongSelf.animateError()
|
||||
} else {
|
||||
strongSelf.checkPasscode?(passcode)
|
||||
}
|
||||
}
|
||||
|
||||
self.cancelButtonNode.setTitle(strings.Common_Cancel, with: buttonFont, with: .white, for: .normal)
|
||||
self.deleteButtonNode.setTitle(strings.Common_Delete, with: buttonFont, with: .white, for: .normal)
|
||||
|
||||
if let biometricsType = self.biometricsType {
|
||||
switch biometricsType {
|
||||
case .touchId:
|
||||
self.biometricButtonNode.setImage(generateTintedImage(image: UIImage(bundleImageName: "Settings/PasscodeTouchId"), color: .white), for: .normal)
|
||||
case .faceId:
|
||||
self.biometricButtonNode.setImage(generateTintedImage(image: UIImage(bundleImageName: "Settings/PasscodeFaceId"), color: .white), for: .normal)
|
||||
}
|
||||
}
|
||||
|
||||
self.addSubnode(self.backgroundNode)
|
||||
self.addSubnode(self.iconNode)
|
||||
self.addSubnode(self.titleNode)
|
||||
self.addSubnode(self.inputFieldNode)
|
||||
self.addSubnode(self.subtitleNode)
|
||||
self.addSubnode(self.keyboardNode)
|
||||
self.addSubnode(self.deleteButtonNode)
|
||||
self.addSubnode(self.biometricButtonNode)
|
||||
|
||||
if self.arguments.cancel != nil {
|
||||
self.addSubnode(self.cancelButtonNode)
|
||||
}
|
||||
}
|
||||
|
||||
override func didLoad() {
|
||||
super.didLoad()
|
||||
|
||||
self.view.insertSubview(self.effectView, at: 0)
|
||||
|
||||
if self.arguments.cancel != nil {
|
||||
self.cancelButtonNode.addTarget(self, action: #selector(self.cancelPressed), forControlEvents: .touchUpInside)
|
||||
}
|
||||
self.deleteButtonNode.addTarget(self, action: #selector(self.deletePressed), forControlEvents: .touchUpInside)
|
||||
self.biometricButtonNode.addTarget(self, action: #selector(self.biometricsPressed), forControlEvents: .touchUpInside)
|
||||
}
|
||||
|
||||
@objc private func cancelPressed() {
|
||||
self.animateOut(down: true)
|
||||
self.arguments.cancel?()
|
||||
}
|
||||
|
||||
@objc private func deletePressed() {
|
||||
self.hapticFeedback.tap()
|
||||
self.inputFieldNode.delete()
|
||||
}
|
||||
|
||||
@objc private func biometricsPressed() {
|
||||
self.requestBiometrics?()
|
||||
}
|
||||
|
||||
func activateInput() {
|
||||
self.inputFieldNode.activateInput()
|
||||
}
|
||||
|
||||
func updatePresentationData(_ presentationData: PresentationData) {
|
||||
self.theme = presentationData.theme
|
||||
self.strings = presentationData.strings
|
||||
self.wallpaper = presentationData.chatWallpaper
|
||||
|
||||
self.deleteButtonNode.setTitle(self.strings.Common_Delete, with: buttonFont, with: .white, for: .normal)
|
||||
if let validLayout = self.validLayout {
|
||||
self.containerLayoutUpdated(validLayout, navigationBarHeight: 0.0, transition: .immediate)
|
||||
}
|
||||
}
|
||||
|
||||
func updateBackground() {
|
||||
guard let validLayout = self.validLayout else {
|
||||
return
|
||||
}
|
||||
|
||||
var size = validLayout.size
|
||||
if case .compact = validLayout.metrics.widthClass, size.width > size.height {
|
||||
size = CGSize(width: size.height, height: size.width)
|
||||
}
|
||||
|
||||
if let background = self.background, background.size == size {
|
||||
return
|
||||
}
|
||||
|
||||
switch self.wallpaper {
|
||||
case .image, .file:
|
||||
if let image = chatControllerBackgroundImage(theme: self.theme, wallpaper: self.wallpaper, mediaBox: self.context.sharedContext.accountManager.mediaBox, composed: false, knockoutMode: false) {
|
||||
self.background = ImageBasedPasscodeBackground(image: image, size: size)
|
||||
} else {
|
||||
self.background = GradientPasscodeBackground(size: size, backgroundColors: self.theme.passcode.backgroundColors.colors, buttonColor: self.theme.passcode.buttonColor)
|
||||
}
|
||||
default:
|
||||
self.background = GradientPasscodeBackground(size: size, backgroundColors: self.theme.passcode.backgroundColors.colors, buttonColor: self.theme.passcode.buttonColor)
|
||||
}
|
||||
|
||||
if let background = self.background {
|
||||
self.backgroundNode.image = background.backgroundImage
|
||||
self.keyboardNode.updateBackground(background)
|
||||
self.inputFieldNode.updateBackground(background)
|
||||
}
|
||||
}
|
||||
|
||||
private let waitInterval: Int32 = 60
|
||||
private func shouldWaitBeforeNextAttempt() -> Bool {
|
||||
if let attempts = self.invalidAttempts {
|
||||
if attempts.count >= 6 {
|
||||
if Int32(CFAbsoluteTimeGetCurrent()) - attempts.timestamp < waitInterval {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func updateInvalidAttempts(_ attempts: AccessChallengeAttempts?, animated: Bool = false) {
|
||||
self.invalidAttempts = attempts
|
||||
if let attempts = attempts {
|
||||
var text = NSAttributedString(string: "")
|
||||
if attempts.count >= 6 && self.shouldWaitBeforeNextAttempt() {
|
||||
text = NSAttributedString(string: self.strings.PasscodeSettings_TryAgainIn1Minute, font: subtitleFont, textColor: .white)
|
||||
|
||||
self.timer?.invalidate()
|
||||
let timer = SwiftSignalKit.Timer(timeout: Double(attempts.timestamp + waitInterval - Int32(CFAbsoluteTimeGetCurrent())), repeat: false, completion: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
strongSelf.timer = nil
|
||||
strongSelf.updateInvalidAttempts(strongSelf.invalidAttempts, animated: true)
|
||||
}
|
||||
}, queue: Queue.mainQueue())
|
||||
self.timer = timer
|
||||
timer.start()
|
||||
}
|
||||
self.subtitleNode.setAttributedText(text, animation: animated ? .crossFade : .none, completion: {})
|
||||
} else {
|
||||
self.subtitleNode.setAttributedText(NSAttributedString(string: ""), animation: animated ? .crossFade : .none, completion: {})
|
||||
}
|
||||
}
|
||||
|
||||
func hideBiometrics() {
|
||||
self.biometricButtonNode.layer.animateScale(from: 1.0, to: 0.00001, duration: 0.25, delay: 0.0, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, completion: { [weak self] _ in
|
||||
self?.biometricButtonNode.isHidden = true
|
||||
})
|
||||
self.animateError()
|
||||
}
|
||||
|
||||
func initialAppearance(fadeIn: Bool = false) {
|
||||
if fadeIn {
|
||||
let effect = self.theme.overallDarkAppearance ? UIBlurEffect(style: .dark) : UIBlurEffect(style: .light)
|
||||
UIView.animate(withDuration: 0.3, animations: {
|
||||
if #available(iOS 9.0, *) {
|
||||
self.effectView.effect = effect
|
||||
} else {
|
||||
self.effectView.alpha = 1.0
|
||||
}
|
||||
})
|
||||
self.backgroundNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||
}
|
||||
self.titleNode.setAttributedText(NSAttributedString(string: self.strings.EnterPasscode_EnterPasscode, font: titleFont, textColor: .white), animation: .none)
|
||||
}
|
||||
|
||||
func animateIn(iconFrame: CGRect, completion: @escaping () -> Void = {}) {
|
||||
let effect = self.theme.overallDarkAppearance ? UIBlurEffect(style: .dark) : UIBlurEffect(style: .light)
|
||||
UIView.animate(withDuration: 0.3, animations: {
|
||||
if #available(iOS 9.0, *) {
|
||||
self.effectView.effect = effect
|
||||
} else {
|
||||
self.effectView.alpha = 1.0
|
||||
}
|
||||
})
|
||||
self.backgroundNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||
if !iconFrame.isEmpty {
|
||||
self.iconNode.animateIn(fromScale: 0.416)
|
||||
self.iconNode.layer.animatePosition(from: iconFrame.center.offsetBy(dx: 6.0, dy: 6.0), to: self.iconNode.layer.position, duration: 0.45)
|
||||
}
|
||||
|
||||
self.statusBar.layer.removeAnimation(forKey: "opacity")
|
||||
self.statusBar.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||
|
||||
self.subtitleNode.isHidden = true
|
||||
self.inputFieldNode.isHidden = true
|
||||
self.keyboardNode.isHidden = true
|
||||
self.cancelButtonNode.isHidden = true
|
||||
self.deleteButtonNode.isHidden = true
|
||||
self.biometricButtonNode.isHidden = true
|
||||
|
||||
self.titleNode.setAttributedText(NSAttributedString(string: self.strings.Passcode_AppLockedAlert.replacingOccurrences(of: "\n", with: " "), font: titleFont, textColor: .white), animation: .slideIn, completion: {
|
||||
self.subtitleNode.isHidden = false
|
||||
self.inputFieldNode.isHidden = false
|
||||
self.keyboardNode.isHidden = false
|
||||
self.cancelButtonNode.isHidden = false
|
||||
self.deleteButtonNode.isHidden = false
|
||||
self.biometricButtonNode.isHidden = false
|
||||
|
||||
self.subtitleNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25)
|
||||
|
||||
self.inputFieldNode.animateIn()
|
||||
self.keyboardNode.animateIn()
|
||||
var biometricDelay = 0.3
|
||||
if case .alphanumeric = self.passcodeType {
|
||||
biometricDelay = 0.0
|
||||
} else {
|
||||
self.cancelButtonNode.layer.animateScale(from: 0.0001, to: 1.0, duration: 0.25, delay: 0.15, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue)
|
||||
self.deleteButtonNode.layer.animateScale(from: 0.0001, to: 1.0, duration: 0.25, delay: 0.15, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue)
|
||||
}
|
||||
self.biometricButtonNode.layer.animateScale(from: 0.0001, to: 1.0, duration: 0.25, delay: biometricDelay, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue)
|
||||
|
||||
Queue.mainQueue().after(1.5, {
|
||||
self.titleNode.setAttributedText(NSAttributedString(string: self.strings.EnterPasscode_EnterPasscode, font: titleFont, textColor: .white), animation: .crossFade)
|
||||
})
|
||||
|
||||
completion()
|
||||
})
|
||||
}
|
||||
|
||||
func animateOut(down: Bool = false, completion: @escaping () -> Void = {}) {
|
||||
self.statusBar.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false)
|
||||
self.layer.animatePosition(from: CGPoint(), to: CGPoint(x: 0.0, y: down ? self.bounds.size.height : -self.bounds.size.height), duration: 0.2, removeOnCompletion: false, additive: true, completion: { _ in
|
||||
completion()
|
||||
})
|
||||
}
|
||||
|
||||
func animateSuccess() {
|
||||
self.iconNode.animateUnlock()
|
||||
self.inputFieldNode.animateSuccess()
|
||||
}
|
||||
|
||||
func animateError() {
|
||||
self.inputFieldNode.reset()
|
||||
self.inputFieldNode.layer.addShakeAnimation(amplitude: -30.0, duration: 0.5, count: 6, decay: true)
|
||||
self.iconNode.layer.addShakeAnimation(amplitude: -8.0, duration: 0.5, count: 6, decay: true)
|
||||
|
||||
self.hapticFeedback.error()
|
||||
}
|
||||
|
||||
func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||
self.validLayout = layout
|
||||
|
||||
self.updateBackground()
|
||||
|
||||
if layout.size.width == 320.0 {
|
||||
self.iconNode.alpha = 0.0
|
||||
}
|
||||
|
||||
let bounds = CGRect(origin: CGPoint(), size: layout.size)
|
||||
transition.updateFrame(node: self.backgroundNode, frame: bounds)
|
||||
transition.updateFrame(view: self.effectView, frame: bounds)
|
||||
|
||||
let iconSize = CGSize(width: 35.0, height: 37.0)
|
||||
transition.updateFrame(node: self.iconNode, frame: CGRect(origin: CGPoint(x: floor((layout.size.width - iconSize.width) / 2.0) + 6.0, y: layout.insets(options: .statusBar).top + 15.0), size: iconSize))
|
||||
|
||||
let passcodeLayout = PasscodeLayout(layout: layout)
|
||||
|
||||
let inputFieldFrame = self.inputFieldNode.updateLayout(layout: passcodeLayout, transition: transition)
|
||||
transition.updateFrame(node: self.inputFieldNode, frame: CGRect(origin: CGPoint(), size: layout.size))
|
||||
|
||||
let titleSize = self.titleNode.updateLayout(layout: layout, transition: transition)
|
||||
transition.updateFrame(node: self.titleNode, frame: CGRect(origin: CGPoint(x: 0.0, y: passcodeLayout.titleOffset), size: titleSize))
|
||||
|
||||
var subtitleOffset = passcodeLayout.subtitleOffset
|
||||
if case .alphanumeric = self.passcodeType {
|
||||
subtitleOffset = 16.0
|
||||
}
|
||||
let subtitleSize = self.subtitleNode.updateLayout(layout: layout, transition: transition)
|
||||
transition.updateFrame(node: self.subtitleNode, frame: CGRect(origin: CGPoint(x: 0.0, y: inputFieldFrame.maxY + subtitleOffset), size: subtitleSize))
|
||||
|
||||
let (keyboardFrame, keyboardButtonSize) = self.keyboardNode.updateLayout(layout: passcodeLayout, transition: transition)
|
||||
transition.updateFrame(node: self.keyboardNode, frame: CGRect(origin: CGPoint(), size: layout.size))
|
||||
|
||||
switch self.passcodeType {
|
||||
case .digits6, .digits4:
|
||||
self.keyboardNode.alpha = 1.0
|
||||
self.deleteButtonNode.alpha = 1.0
|
||||
case .alphanumeric:
|
||||
self.keyboardNode.alpha = 0.0
|
||||
self.deleteButtonNode.alpha = 0.0
|
||||
}
|
||||
|
||||
let bottomInset = layout.inputHeight ?? 0.0
|
||||
|
||||
let cancelSize = self.cancelButtonNode.measure(layout.size)
|
||||
var cancelY: CGFloat = layout.size.height - layout.intrinsicInsets.bottom - cancelSize.height - passcodeLayout.keyboard.deleteOffset
|
||||
if bottomInset > 0 && self.keyboardNode.alpha < 1.0 {
|
||||
cancelY = layout.size.height - bottomInset - cancelSize.height - 20.0
|
||||
}
|
||||
|
||||
transition.updateFrame(node: self.cancelButtonNode, frame: CGRect(origin: CGPoint(x: floor(keyboardFrame.minX + keyboardButtonSize.width / 2.0 - cancelSize.width / 2.0), y: cancelY), size: cancelSize))
|
||||
|
||||
let deleteSize = self.deleteButtonNode.measure(layout.size)
|
||||
transition.updateFrame(node: self.deleteButtonNode, frame: CGRect(origin: CGPoint(x: floor(keyboardFrame.maxX - keyboardButtonSize.width / 2.0 - deleteSize.width / 2.0), y: layout.size.height - layout.intrinsicInsets.bottom - deleteSize.height - passcodeLayout.keyboard.deleteOffset), size: deleteSize))
|
||||
|
||||
if let biometricIcon = self.biometricButtonNode.image(for: .normal) {
|
||||
var biometricY: CGFloat = 0.0
|
||||
if bottomInset > 0 && self.keyboardNode.alpha < 1.0 {
|
||||
biometricY = inputFieldFrame.maxY + floor((layout.size.height - bottomInset - inputFieldFrame.maxY - biometricIcon.size.height) / 2.0)
|
||||
} else {
|
||||
biometricY = keyboardFrame.maxY + passcodeLayout.keyboard.biometricsOffset
|
||||
}
|
||||
transition.updateFrame(node: self.biometricButtonNode, frame: CGRect(origin: CGPoint(x: floor((layout.size.width - biometricIcon.size.width) / 2.0), y: biometricY), size: biometricIcon.size))
|
||||
}
|
||||
}
|
||||
}
|
||||
381
submodules/PasscodeUI/Sources/PasscodeEntryInputFieldNode.swift
Normal file
381
submodules/PasscodeUI/Sources/PasscodeEntryInputFieldNode.swift
Normal file
@@ -0,0 +1,381 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
|
||||
private let dotDiameter: CGFloat = 13.0
|
||||
private let dotSpacing: CGFloat = 24.0
|
||||
private let fieldHeight: CGFloat = 38.0
|
||||
|
||||
private func generateDotImage(color: UIColor, filled: Bool) -> UIImage? {
|
||||
return generateImage(CGSize(width: dotDiameter, height: dotDiameter), contextGenerator: { size, context in
|
||||
let bounds = CGRect(origin: CGPoint(), size: size)
|
||||
context.clear(bounds)
|
||||
|
||||
if filled {
|
||||
context.setFillColor(color.cgColor)
|
||||
context.fillEllipse(in: bounds)
|
||||
} else {
|
||||
context.setStrokeColor(color.cgColor)
|
||||
context.setLineWidth(1.0)
|
||||
context.strokeEllipse(in: bounds.insetBy(dx: 0.5, dy: 0.5))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private func generateFieldBackgroundImage(background: PasscodeBackground, frame: CGRect) -> UIImage? {
|
||||
return generateImage(frame.size, contextGenerator: { size, context in
|
||||
let bounds = CGRect(origin: CGPoint(), size: size)
|
||||
context.clear(bounds)
|
||||
|
||||
let relativeFrame = CGRect(x: -frame.minX, y: frame.minY - background.size.height + frame.size.height
|
||||
, width: background.size.width, height: background.size.height)
|
||||
|
||||
let path = UIBezierPath(roundedRect: CGRect(x: 0.0, y: 0.0, width: size.width, height: size.height), cornerRadius: 6.0)
|
||||
context.addPath(path.cgPath)
|
||||
context.clip()
|
||||
|
||||
context.draw(background.foregroundImage.cgImage!, in: relativeFrame)
|
||||
|
||||
context.setBlendMode(.clear)
|
||||
context.setFillColor(UIColor.clear.cgColor)
|
||||
|
||||
let innerPath = UIBezierPath(roundedRect: CGRect(x: 1.0, y: 1.0, width: size.width - 2.0, height: size.height - 2.0), cornerRadius: 6.0)
|
||||
context.addPath(innerPath.cgPath)
|
||||
context.fillPath()
|
||||
})
|
||||
}
|
||||
|
||||
private let validDigitsSet: CharacterSet = {
|
||||
return CharacterSet(charactersIn: "0".unicodeScalars.first! ... "9".unicodeScalars.first!)
|
||||
}()
|
||||
|
||||
public enum PasscodeEntryFieldType {
|
||||
case digits6
|
||||
case digits4
|
||||
case alphanumeric
|
||||
|
||||
public var maxLength: Int? {
|
||||
switch self {
|
||||
case .digits6:
|
||||
return 6
|
||||
case .digits4:
|
||||
return 4
|
||||
case .alphanumeric:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
public var allowedCharacters: CharacterSet? {
|
||||
switch self {
|
||||
case .digits6, .digits4:
|
||||
return validDigitsSet
|
||||
case .alphanumeric:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
public var keyboardType: UIKeyboardType {
|
||||
switch self {
|
||||
case .digits6, .digits4:
|
||||
if #available(iOS 10.0, *) {
|
||||
return .asciiCapableNumberPad
|
||||
} else {
|
||||
return .numberPad
|
||||
}
|
||||
case .alphanumeric:
|
||||
return .default
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PasscodeEntryInputView: UIView {
|
||||
|
||||
}
|
||||
|
||||
private class PasscodeEntryDotNode: ASImageNode {
|
||||
private let regularImage: UIImage
|
||||
private let filledImage: UIImage
|
||||
private var currentImage: UIImage
|
||||
|
||||
init(color: UIColor) {
|
||||
self.regularImage = generateDotImage(color: color, filled: false)!
|
||||
self.filledImage = generateDotImage(color: color, filled: true)!
|
||||
self.currentImage = self.regularImage
|
||||
|
||||
super.init()
|
||||
|
||||
self.image = self.currentImage
|
||||
}
|
||||
|
||||
func updateState(filled: Bool, animated: Bool = false, delay: Double = 0.0) {
|
||||
let image = filled ? self.filledImage : self.regularImage
|
||||
if self.currentImage !== image {
|
||||
let currentContents = self.layer.contents
|
||||
self.layer.removeAnimation(forKey: "contents")
|
||||
if let currentContents = currentContents, animated {
|
||||
self.layer.animate(from: currentContents as AnyObject, to: image.cgImage!, keyPath: "contents", timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, duration: image === self.regularImage ? 0.25 : 0.05, delay: delay, removeOnCompletion: false, completion: { finished in
|
||||
if finished {
|
||||
self.image = image
|
||||
}
|
||||
})
|
||||
} else {
|
||||
self.image = image
|
||||
}
|
||||
self.currentImage = image
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final class PasscodeEntryInputFieldNode: ASDisplayNode, UITextFieldDelegate {
|
||||
private var background: PasscodeBackground?
|
||||
private var color: UIColor
|
||||
private var accentColor: UIColor
|
||||
private var fieldType: PasscodeEntryFieldType
|
||||
private let useCustomNumpad: Bool
|
||||
|
||||
private let textFieldNode: TextFieldNode
|
||||
private let borderNode: ASImageNode
|
||||
private let dotNodes: [PasscodeEntryDotNode]
|
||||
|
||||
private var validLayout: PasscodeLayout?
|
||||
|
||||
var complete: ((String) -> Void)?
|
||||
|
||||
var text: String {
|
||||
return self.textFieldNode.textField.text ?? ""
|
||||
}
|
||||
|
||||
var keyboardAppearance: UIKeyboardAppearance {
|
||||
didSet {
|
||||
self.textFieldNode.textField.keyboardAppearance = self.keyboardAppearance
|
||||
}
|
||||
}
|
||||
|
||||
init(color: UIColor, accentColor: UIColor, fieldType: PasscodeEntryFieldType, keyboardAppearance: UIKeyboardAppearance, useCustomNumpad: Bool = false) {
|
||||
self.color = color
|
||||
self.accentColor = accentColor
|
||||
self.fieldType = fieldType
|
||||
self.keyboardAppearance = keyboardAppearance
|
||||
self.useCustomNumpad = useCustomNumpad
|
||||
|
||||
self.textFieldNode = TextFieldNode()
|
||||
self.borderNode = ASImageNode()
|
||||
self.dotNodes = (0 ..< 6).map { _ in PasscodeEntryDotNode(color: color) }
|
||||
|
||||
super.init()
|
||||
|
||||
self.isUserInteractionEnabled = false
|
||||
|
||||
for node in self.dotNodes {
|
||||
self.addSubnode(node)
|
||||
}
|
||||
self.addSubnode(self.textFieldNode)
|
||||
self.addSubnode(self.borderNode)
|
||||
}
|
||||
|
||||
override func didLoad() {
|
||||
super.didLoad()
|
||||
|
||||
self.textFieldNode.textField.isSecureTextEntry = true
|
||||
self.textFieldNode.textField.textColor = self.color
|
||||
self.textFieldNode.textField.delegate = self
|
||||
self.textFieldNode.textField.returnKeyType = .done
|
||||
self.textFieldNode.textField.tintColor = self.accentColor
|
||||
self.textFieldNode.textField.keyboardAppearance = self.keyboardAppearance
|
||||
self.textFieldNode.textField.keyboardType = self.fieldType.keyboardType
|
||||
|
||||
if self.useCustomNumpad {
|
||||
switch self.fieldType {
|
||||
case .digits6, .digits4:
|
||||
self.textFieldNode.textField.inputView = PasscodeEntryInputView()
|
||||
case .alphanumeric:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func updateFieldType(_ fieldType: PasscodeEntryFieldType, animated: Bool) {
|
||||
self.fieldType = fieldType
|
||||
|
||||
self.textFieldNode.textField.keyboardType = self.fieldType.keyboardType
|
||||
|
||||
if let validLayout = self.validLayout {
|
||||
let _ = self.updateLayout(layout: validLayout, transition: animated ? .animated(duration: 0.25, curve: .easeInOut) : .immediate)
|
||||
}
|
||||
}
|
||||
|
||||
func updateBackground(_ background: PasscodeBackground) {
|
||||
self.background = background
|
||||
if let validLayout = self.validLayout {
|
||||
let _ = self.updateLayout(layout: validLayout, transition: .immediate)
|
||||
}
|
||||
}
|
||||
|
||||
func activateInput() {
|
||||
self.textFieldNode.textField.becomeFirstResponder()
|
||||
}
|
||||
|
||||
func animateIn() {
|
||||
switch self.fieldType {
|
||||
case .digits6, .digits4:
|
||||
for node in self.dotNodes {
|
||||
node.layer.animateScale(from: 0.0001, to: 1.0, duration: 0.25, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue)
|
||||
}
|
||||
case .alphanumeric:
|
||||
self.textFieldNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue)
|
||||
self.borderNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue)
|
||||
}
|
||||
}
|
||||
|
||||
func animateSuccess() {
|
||||
switch self.fieldType {
|
||||
case .digits6, .digits4:
|
||||
var delay: Double = 0.0
|
||||
for node in self.dotNodes {
|
||||
node.updateState(filled: true, animated: true, delay: delay)
|
||||
delay += 0.01
|
||||
}
|
||||
case .alphanumeric:
|
||||
if (self.textFieldNode.textField.text ?? "").isEmpty {
|
||||
self.textFieldNode.textField.text = "passwordpassword"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func reset(animated: Bool = true) {
|
||||
var delay: Double = 0.0
|
||||
for node in self.dotNodes.reversed() {
|
||||
if node.alpha < 1.0 {
|
||||
continue
|
||||
}
|
||||
|
||||
node.updateState(filled: false, animated: animated, delay: delay)
|
||||
delay += 0.05
|
||||
}
|
||||
self.textFieldNode.textField.text = ""
|
||||
}
|
||||
|
||||
func append(_ string: String) {
|
||||
var text = (self.textFieldNode.textField.text ?? "") + string
|
||||
let maxLength = self.fieldType.maxLength
|
||||
if let maxLength = maxLength, text.count > maxLength {
|
||||
return
|
||||
}
|
||||
self.textFieldNode.textField.text = text
|
||||
|
||||
text = self.textFieldNode.textField.text ?? "" + string
|
||||
self.updateDots(count: text.count, animated: false)
|
||||
|
||||
if let maxLength = maxLength, text.count == maxLength {
|
||||
Queue.mainQueue().after(0.2) {
|
||||
self.complete?(text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func delete() {
|
||||
var text = self.textFieldNode.textField.text ?? ""
|
||||
guard !text.isEmpty else {
|
||||
return
|
||||
}
|
||||
text = String(text[text.startIndex ..< text.index(text.endIndex, offsetBy: -1)])
|
||||
self.textFieldNode.textField.text = text
|
||||
self.updateDots(count: text.count, animated: true)
|
||||
}
|
||||
|
||||
func updateDots(count: Int, animated: Bool) {
|
||||
var i = -1
|
||||
for node in self.dotNodes {
|
||||
if node.alpha < 1.0 {
|
||||
continue
|
||||
}
|
||||
i += 1
|
||||
node.updateState(filled: i < count, animated: animated)
|
||||
}
|
||||
}
|
||||
|
||||
func update(fieldType: PasscodeEntryFieldType) {
|
||||
if fieldType != self.fieldType {
|
||||
self.textFieldNode.textField.text = ""
|
||||
}
|
||||
self.fieldType = fieldType
|
||||
if let validLayout = self.validLayout {
|
||||
let _ = self.updateLayout(layout: validLayout, transition: .immediate)
|
||||
}
|
||||
}
|
||||
|
||||
func updateLayout(layout: PasscodeLayout, transition: ContainedViewLayoutTransition) -> CGRect {
|
||||
self.validLayout = layout
|
||||
|
||||
let fieldAlpha: CGFloat
|
||||
switch self.fieldType {
|
||||
case .digits6, .digits4:
|
||||
fieldAlpha = 0.0
|
||||
case .alphanumeric:
|
||||
fieldAlpha = 1.0
|
||||
}
|
||||
|
||||
transition.updateAlpha(node: self.textFieldNode, alpha: fieldAlpha)
|
||||
transition.updateAlpha(node: self.borderNode, alpha: fieldAlpha)
|
||||
|
||||
let origin = CGPoint(x: floor((layout.layout.size.width - dotDiameter * 6 - dotSpacing * 5) / 2.0), y: layout.inputFieldOffset)
|
||||
for i in 0 ..< self.dotNodes.count {
|
||||
let node = self.dotNodes[i]
|
||||
let dotAlpha: CGFloat
|
||||
switch self.fieldType {
|
||||
case .digits6:
|
||||
dotAlpha = 1.0
|
||||
case .digits4:
|
||||
dotAlpha = (i > 0 && i < self.dotNodes.count - 1) ? 1.0 : 0.0
|
||||
case .alphanumeric:
|
||||
dotAlpha = 0.0
|
||||
}
|
||||
transition.updateAlpha(node: node, alpha: dotAlpha)
|
||||
|
||||
let dotFrame = CGRect(x: origin.x + CGFloat(i) * (dotDiameter + dotSpacing), y: origin.y, width: dotDiameter, height: dotDiameter)
|
||||
transition.updateFrame(node: node, frame: dotFrame)
|
||||
}
|
||||
|
||||
var inset: CGFloat = 50.0
|
||||
if !self.useCustomNumpad {
|
||||
inset = 16.0
|
||||
}
|
||||
let fieldFrame = CGRect(x: inset, y: origin.y, width: layout.layout.size.width - inset * 2.0, height: fieldHeight)
|
||||
transition.updateFrame(node: self.borderNode, frame: fieldFrame)
|
||||
transition.updateFrame(node: self.textFieldNode, frame: fieldFrame.insetBy(dx: 13.0, dy: 0.0))
|
||||
if let background = self.background {
|
||||
self.borderNode.image = generateFieldBackgroundImage(background: background, frame: fieldFrame)
|
||||
}
|
||||
|
||||
return fieldFrame
|
||||
}
|
||||
|
||||
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
|
||||
let currentText = textField.text ?? ""
|
||||
let text = (currentText as NSString).replacingCharacters(in: range, with: string)
|
||||
if let maxLength = self.fieldType.maxLength, text.count > maxLength {
|
||||
return false
|
||||
}
|
||||
if let allowedCharacters = self.fieldType.allowedCharacters, let _ = text.rangeOfCharacter(from: allowedCharacters.inverted) {
|
||||
return false
|
||||
}
|
||||
self.updateDots(count: text.count, animated: text.count < currentText.count)
|
||||
|
||||
if string == "\n" {
|
||||
Queue.mainQueue().after(0.2) {
|
||||
self.complete?(currentText)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
if let maxLength = self.fieldType.maxLength, text.count == maxLength {
|
||||
Queue.mainQueue().after(0.2) {
|
||||
self.complete?(text)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
278
submodules/PasscodeUI/Sources/PasscodeEntryKeyboardNode.swift
Normal file
278
submodules/PasscodeUI/Sources/PasscodeEntryKeyboardNode.swift
Normal file
@@ -0,0 +1,278 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
|
||||
private let regularTitleFont = Font.regular(36.0)
|
||||
private let regularSubtitleFont: UIFont = {
|
||||
if #available(iOS 8.2, *) {
|
||||
return UIFont.systemFont(ofSize: 10.0, weight: UIFont.Weight.bold)
|
||||
} else {
|
||||
return CTFontCreateWithName("HelveticaNeue-Bold" as CFString, 10.0, nil)
|
||||
}
|
||||
}()
|
||||
|
||||
private let largeTitleFont = Font.regular(40.0)
|
||||
private let largeSubtitleFont: UIFont = {
|
||||
if #available(iOS 8.2, *) {
|
||||
return UIFont.systemFont(ofSize: 12.0, weight: UIFont.Weight.bold)
|
||||
} else {
|
||||
return CTFontCreateWithName("HelveticaNeue-Bold" as CFString, 12.0, nil)
|
||||
}
|
||||
}()
|
||||
|
||||
private func generateButtonImage(background: PasscodeBackground, frame: CGRect, title: String, subtitle: String, highlighted: Bool) -> UIImage? {
|
||||
return generateImage(frame.size, contextGenerator: { size, context in
|
||||
let bounds = CGRect(origin: CGPoint(), size: size)
|
||||
context.clear(bounds)
|
||||
|
||||
let relativeFrame = CGRect(x: -frame.minX, y: frame.minY - background.size.height + frame.size.height
|
||||
, width: background.size.width, height: background.size.height)
|
||||
|
||||
context.beginPath()
|
||||
context.addEllipse(in: bounds)
|
||||
context.clip()
|
||||
|
||||
context.setAlpha(0.8)
|
||||
context.draw(background.foregroundImage.cgImage!, in: relativeFrame)
|
||||
|
||||
if highlighted {
|
||||
context.setFillColor(UIColor(white: 1.0, alpha: 0.65).cgColor)
|
||||
context.fillEllipse(in: bounds)
|
||||
}
|
||||
|
||||
context.setAlpha(1.0)
|
||||
context.textMatrix = .identity
|
||||
|
||||
let titleFont: UIFont
|
||||
let subtitleFont: UIFont
|
||||
let titleOffset: CGFloat
|
||||
let subtitleOffset: CGFloat
|
||||
if size.width > 80.0 {
|
||||
titleFont = largeTitleFont
|
||||
subtitleFont = largeSubtitleFont
|
||||
if subtitle.isEmpty {
|
||||
titleOffset = -18.0
|
||||
} else {
|
||||
titleOffset = -11.0
|
||||
}
|
||||
subtitleOffset = -54.0
|
||||
} else {
|
||||
titleFont = regularTitleFont
|
||||
subtitleFont = regularSubtitleFont
|
||||
if subtitle.isEmpty {
|
||||
titleOffset = -17.0
|
||||
} else {
|
||||
titleOffset = -10.0
|
||||
}
|
||||
subtitleOffset = -48.0
|
||||
}
|
||||
|
||||
let titlePath = CGMutablePath()
|
||||
titlePath.addRect(bounds.offsetBy(dx: 0.0, dy: titleOffset))
|
||||
let titleString = NSAttributedString(string: title, font: titleFont, textColor: .white, paragraphAlignment: .center)
|
||||
let titleFramesetter = CTFramesetterCreateWithAttributedString(titleString as CFAttributedString)
|
||||
let titleFrame = CTFramesetterCreateFrame(titleFramesetter, CFRangeMake(0, titleString.length), titlePath, nil)
|
||||
CTFrameDraw(titleFrame, context)
|
||||
|
||||
if !subtitle.isEmpty {
|
||||
let subtitlePath = CGMutablePath()
|
||||
subtitlePath.addRect(bounds.offsetBy(dx: 0.0, dy: subtitleOffset))
|
||||
let subtitleString = NSAttributedString(string: subtitle, font: subtitleFont, textColor: .white, paragraphAlignment: .center)
|
||||
let subtitleFramesetter = CTFramesetterCreateWithAttributedString(subtitleString as CFAttributedString)
|
||||
let subtitleFrame = CTFramesetterCreateFrame(subtitleFramesetter, CFRangeMake(0, subtitleString.length), subtitlePath, nil)
|
||||
CTFrameDraw(subtitleFrame, context)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
final class PasscodeEntryButtonNode: HighlightTrackingButtonNode {
|
||||
private var background: PasscodeBackground
|
||||
let title: String
|
||||
private let subtitle: String
|
||||
|
||||
private var currentImage: UIImage?
|
||||
private var regularImage: UIImage?
|
||||
private var highlightedImage: UIImage?
|
||||
|
||||
private let backgroundNode: ASImageNode
|
||||
|
||||
var action: (() -> Void)?
|
||||
|
||||
init(background: PasscodeBackground, title: String, subtitle: String) {
|
||||
self.background = background
|
||||
self.title = title
|
||||
self.subtitle = subtitle
|
||||
|
||||
self.backgroundNode = ASImageNode()
|
||||
self.backgroundNode.isUserInteractionEnabled = false
|
||||
|
||||
super.init()
|
||||
|
||||
self.addSubnode(self.backgroundNode)
|
||||
|
||||
self.highligthedChanged = { [weak self] highlighted in
|
||||
if let strongSelf = self {
|
||||
strongSelf.updateState(highlighted: highlighted)
|
||||
}
|
||||
}
|
||||
|
||||
self.addTarget(self, action: #selector(self.nop), forControlEvents: .touchUpInside)
|
||||
}
|
||||
|
||||
@objc private func nop() {
|
||||
}
|
||||
|
||||
override var frame: CGRect {
|
||||
get {
|
||||
return super.frame
|
||||
}
|
||||
set {
|
||||
super.frame = newValue
|
||||
self.updateGraphics()
|
||||
}
|
||||
}
|
||||
|
||||
func updateBackground(_ background: PasscodeBackground) {
|
||||
self.background = background
|
||||
self.updateGraphics()
|
||||
}
|
||||
|
||||
private func updateGraphics() {
|
||||
self.regularImage = generateButtonImage(background: self.background, frame: self.frame, title: self.title, subtitle: self.subtitle, highlighted: false)
|
||||
self.highlightedImage = generateButtonImage(background: self.background, frame: self.frame, title: self.title, subtitle: self.subtitle, highlighted: true)
|
||||
self.updateState(highlighted: self.isHighlighted)
|
||||
}
|
||||
|
||||
private func updateState(highlighted: Bool) {
|
||||
let image = highlighted ? self.highlightedImage : self.regularImage
|
||||
if self.currentImage !== image {
|
||||
let currentContents = self.backgroundNode.layer.contents
|
||||
self.backgroundNode.layer.removeAnimation(forKey: "contents")
|
||||
if let currentContents = currentContents, let image = image {
|
||||
self.backgroundNode.image = image
|
||||
self.backgroundNode.layer.animate(from: currentContents as AnyObject, to: image.cgImage!, keyPath: "contents", timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, duration: image === self.regularImage ? 0.45 : 0.05)
|
||||
} else {
|
||||
self.backgroundNode.image = image
|
||||
}
|
||||
self.currentImage = image
|
||||
}
|
||||
}
|
||||
|
||||
override func layout() {
|
||||
super.layout()
|
||||
|
||||
self.backgroundNode.frame = self.bounds
|
||||
}
|
||||
|
||||
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||
super.touchesBegan(touches, with: event)
|
||||
|
||||
self.action?()
|
||||
}
|
||||
}
|
||||
|
||||
private let buttonsData = [
|
||||
("1", " "),
|
||||
("2", "A B C"),
|
||||
("3", "D E F"),
|
||||
("4", "G H I"),
|
||||
("5", "J K L"),
|
||||
("6", "M N O"),
|
||||
("7", "P Q R S"),
|
||||
("8", "T U V"),
|
||||
("9", "W X Y Z"),
|
||||
("0", "")
|
||||
]
|
||||
|
||||
final class PasscodeEntryKeyboardNode: ASDisplayNode {
|
||||
private var background: PasscodeBackground?
|
||||
|
||||
var charactedEntered: ((String) -> Void)?
|
||||
|
||||
private func updateButtons() {
|
||||
guard let background = self.background else {
|
||||
return
|
||||
}
|
||||
|
||||
if let subnodes = self.subnodes, !subnodes.isEmpty {
|
||||
for case let button as PasscodeEntryButtonNode in subnodes {
|
||||
button.updateBackground(background)
|
||||
}
|
||||
} else {
|
||||
for (title, subtitle) in buttonsData {
|
||||
let buttonNode = PasscodeEntryButtonNode(background: background, title: title, subtitle: subtitle)
|
||||
buttonNode.action = { [weak self] in
|
||||
self?.charactedEntered?(title)
|
||||
}
|
||||
self.addSubnode(buttonNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func updateBackground(_ background: PasscodeBackground) {
|
||||
self.background = background
|
||||
self.updateButtons()
|
||||
}
|
||||
|
||||
func animateIn() {
|
||||
if let subnodes = self.subnodes {
|
||||
for i in 0 ..< subnodes.count {
|
||||
let subnode = subnodes[i]
|
||||
var delay: Double = 0.0
|
||||
if i / 3 == 1 {
|
||||
delay = 0.05
|
||||
}
|
||||
else if i / 3 == 2 {
|
||||
delay = 0.1
|
||||
}
|
||||
else if i / 3 == 3 {
|
||||
delay = 0.15
|
||||
}
|
||||
subnode.layer.animateScale(from: 0.0001, to: 1.0, duration: 0.25, delay: delay, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func updateLayout(layout: PasscodeLayout, transition: ContainedViewLayoutTransition) -> (CGRect, CGSize) {
|
||||
let origin = CGPoint(x: floor((layout.layout.size.width - layout.keyboard.size.width) / 2.0), y: layout.keyboard.topOffset)
|
||||
if let subnodes = self.subnodes {
|
||||
for i in 0 ..< subnodes.count {
|
||||
var origin = origin
|
||||
if i % 3 == 0 {
|
||||
origin.x += 0.0
|
||||
} else if (i % 3 == 1) {
|
||||
origin.x += layout.keyboard.horizontalSecond
|
||||
}
|
||||
else {
|
||||
origin.x += layout.keyboard.horizontalThird
|
||||
}
|
||||
|
||||
if i / 3 == 0 {
|
||||
origin.y += 0.0
|
||||
}
|
||||
else if i / 3 == 1 {
|
||||
origin.y += layout.keyboard.verticalSecond
|
||||
}
|
||||
else if i / 3 == 2 {
|
||||
origin.y += layout.keyboard.verticalThird
|
||||
}
|
||||
else if i / 3 == 3 {
|
||||
origin.x += layout.keyboard.horizontalSecond
|
||||
origin.y += layout.keyboard.verticalFourth
|
||||
}
|
||||
transition.updateFrame(node: subnodes[i], frame: CGRect(origin: origin, size: CGSize(width: layout.keyboard.buttonSize, height: layout.keyboard.buttonSize)))
|
||||
}
|
||||
}
|
||||
return (CGRect(origin: origin, size: layout.keyboard.size), CGSize(width: layout.keyboard.buttonSize, height: layout.keyboard.buttonSize))
|
||||
}
|
||||
|
||||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||
let result = super.hitTest(point, with: event)
|
||||
if let result = result, result.isDescendant(of: self.view) {
|
||||
return result
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
89
submodules/PasscodeUI/Sources/PasscodeEntryLabelNode.swift
Normal file
89
submodules/PasscodeUI/Sources/PasscodeEntryLabelNode.swift
Normal file
@@ -0,0 +1,89 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
|
||||
enum PasscodeEntryTitleAnimation {
|
||||
case none
|
||||
case slideIn
|
||||
case crossFade
|
||||
}
|
||||
|
||||
final class PasscodeEntryLabelNode: ASDisplayNode {
|
||||
private let wrapperNode: ASDisplayNode
|
||||
private let textNode: ASTextNode
|
||||
|
||||
private var validLayout: ContainerViewLayout?
|
||||
|
||||
override init() {
|
||||
self.wrapperNode = ASDisplayNode()
|
||||
self.wrapperNode.clipsToBounds = true
|
||||
|
||||
self.textNode = ASTextNode()
|
||||
self.textNode.isLayerBacked = false
|
||||
|
||||
super.init()
|
||||
|
||||
self.addSubnode(self.wrapperNode)
|
||||
self.wrapperNode.addSubnode(self.textNode)
|
||||
}
|
||||
|
||||
func setAttributedText(_ text: NSAttributedString, animation: PasscodeEntryTitleAnimation = .none, completion: @escaping () -> Void = {}) {
|
||||
switch animation {
|
||||
case .none:
|
||||
self.textNode.attributedText = text
|
||||
completion()
|
||||
|
||||
if let validLayout = self.validLayout {
|
||||
let _ = self.updateLayout(layout: validLayout, transition: .immediate)
|
||||
}
|
||||
case .slideIn:
|
||||
self.textNode.attributedText = text
|
||||
if let validLayout = self.validLayout {
|
||||
let _ = self.updateLayout(layout: validLayout, transition: .immediate)
|
||||
}
|
||||
|
||||
let offset = self.wrapperNode.bounds.width / 2.0
|
||||
self.wrapperNode.layer.animatePosition(from: CGPoint(x: -offset, y: 0.0), to: CGPoint(), duration: 0.45, additive: true)
|
||||
self.textNode.layer.animatePosition(from: CGPoint(x: offset * 2.0, y: 0.0), to: CGPoint(), duration: 0.45, additive: true, completion: { _ in
|
||||
completion()
|
||||
})
|
||||
self.textNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25)
|
||||
case .crossFade:
|
||||
if let snapshotView = self.textNode.view.snapshotContentTree() {
|
||||
snapshotView.frame = self.textNode.frame
|
||||
self.textNode.view.superview?.insertSubview(snapshotView, aboveSubview: self.textNode.view)
|
||||
self.textNode.alpha = 0.0
|
||||
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak snapshotView] _ in
|
||||
snapshotView?.removeFromSuperview()
|
||||
self.textNode.attributedText = text
|
||||
self.textNode.alpha = 1.0
|
||||
self.textNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3, completion: { _ in
|
||||
completion()
|
||||
})
|
||||
if let validLayout = self.validLayout {
|
||||
let _ = self.updateLayout(layout: validLayout, transition: .immediate)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
self.textNode.attributedText = text
|
||||
self.textNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||
completion()
|
||||
if let validLayout = self.validLayout {
|
||||
let _ = self.updateLayout(layout: validLayout, transition: .immediate)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func updateLayout(layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) -> CGSize {
|
||||
self.validLayout = layout
|
||||
|
||||
let textSize = self.textNode.measure(layout.size)
|
||||
let textFrame = CGRect(x: floor((layout.size.width - textSize.width) / 2.0), y: 0.0, width: textSize.width, height: textSize.height)
|
||||
transition.updateFrame(node: self.wrapperNode, frame: textFrame)
|
||||
transition.updateFrame(node: self.textNode, frame: CGRect(origin: CGPoint(), size: textSize))
|
||||
|
||||
return CGSize(width: layout.size.width, height: 25.0)
|
||||
}
|
||||
}
|
||||
172
submodules/PasscodeUI/Sources/PasscodeLayout.swift
Normal file
172
submodules/PasscodeUI/Sources/PasscodeLayout.swift
Normal file
@@ -0,0 +1,172 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
|
||||
struct PasscodeKeyboardLayout {
|
||||
let buttonSize: CGFloat
|
||||
let horizontalSecond: CGFloat
|
||||
let horizontalThird: CGFloat
|
||||
let verticalSecond: CGFloat
|
||||
let verticalThird: CGFloat
|
||||
let verticalFourth: CGFloat
|
||||
let size: CGSize
|
||||
let topOffset: CGFloat
|
||||
let biometricsOffset: CGFloat
|
||||
let deleteOffset: CGFloat
|
||||
|
||||
fileprivate init(layout: ContainerViewLayout, metrics: DeviceMetrics?) {
|
||||
if let metrics = metrics {
|
||||
switch metrics {
|
||||
case .iPhone4:
|
||||
self.buttonSize = 75.0
|
||||
self.horizontalSecond = 95.0
|
||||
self.horizontalThird = 190.0
|
||||
self.verticalSecond = 88.0
|
||||
self.verticalThird = 176.0
|
||||
self.verticalFourth = 264.0
|
||||
self.size = CGSize(width: 265.0, height: 339.0)
|
||||
self.topOffset = 122.0
|
||||
self.biometricsOffset = 0.0
|
||||
self.deleteOffset = 45.0
|
||||
case .iPhone5:
|
||||
self.buttonSize = 75.0
|
||||
self.horizontalSecond = 95.0
|
||||
self.horizontalThird = 190.0
|
||||
self.verticalSecond = 88.0
|
||||
self.verticalThird = 176.0
|
||||
self.verticalFourth = 264.0
|
||||
self.size = CGSize(width: 265.0, height: 339.0)
|
||||
self.topOffset = 155.0
|
||||
self.biometricsOffset = 23.0
|
||||
self.deleteOffset = 20.0
|
||||
case .iPhone6:
|
||||
self.buttonSize = 75.0
|
||||
self.horizontalSecond = 103.0
|
||||
self.horizontalThird = 206.0
|
||||
self.verticalSecond = 90.0
|
||||
self.verticalThird = 180.0
|
||||
self.verticalFourth = 270.0
|
||||
self.size = CGSize(width: 281.0, height: 348.0)
|
||||
self.topOffset = 221.0
|
||||
self.biometricsOffset = 30.0
|
||||
self.deleteOffset = 20.0
|
||||
case .iPhone6Plus:
|
||||
self.buttonSize = 85.0
|
||||
self.horizontalSecond = 115.0
|
||||
self.horizontalThird = 230.0
|
||||
self.verticalSecond = 100.0
|
||||
self.verticalThird = 200.0
|
||||
self.verticalFourth = 300.0
|
||||
self.size = CGSize(width: 315.0, height: 385.0)
|
||||
self.topOffset = 226.0
|
||||
self.biometricsOffset = 30.0
|
||||
self.deleteOffset = 20.0
|
||||
case .iPhoneX:
|
||||
self.buttonSize = 75.0
|
||||
self.horizontalSecond = 103.0
|
||||
self.horizontalThird = 206.0
|
||||
self.verticalSecond = 91.0
|
||||
self.verticalThird = 182.0
|
||||
self.verticalFourth = 273.0
|
||||
self.size = CGSize(width: 281.0, height: 348.0)
|
||||
self.topOffset = 294.0
|
||||
self.biometricsOffset = 30.0
|
||||
self.deleteOffset = 20.0
|
||||
case .iPhoneXSMax:
|
||||
self.buttonSize = 85.0
|
||||
self.horizontalSecond = 115.0
|
||||
self.horizontalThird = 230.0
|
||||
self.verticalSecond = 100.0
|
||||
self.verticalThird = 200.0
|
||||
self.verticalFourth = 300.0
|
||||
self.size = CGSize(width: 315.0, height: 385.0)
|
||||
self.topOffset = 329.0
|
||||
self.biometricsOffset = 30.0
|
||||
self.deleteOffset = 20.0
|
||||
case .iPad, .iPadPro10Inch, .iPadPro11Inch, .iPadPro, .iPadPro3rdGen:
|
||||
self.buttonSize = 81.0
|
||||
self.horizontalSecond = 106.0
|
||||
self.horizontalThird = 212.0
|
||||
self.verticalSecond = 101.0
|
||||
self.verticalThird = 202.0
|
||||
self.verticalFourth = 303.0
|
||||
self.size = CGSize(width: 293.0, height: 384.0)
|
||||
self.topOffset = 120.0 + (layout.size.height - self.size.height - 120.0) / 2.0
|
||||
self.biometricsOffset = 30.0
|
||||
self.deleteOffset = 80.0
|
||||
}
|
||||
} else {
|
||||
self.buttonSize = 75.0
|
||||
self.horizontalSecond = 95.0
|
||||
self.horizontalThird = 190.0
|
||||
self.verticalSecond = 88.0
|
||||
self.verticalThird = 176.0
|
||||
self.verticalFourth = 264.0
|
||||
self.size = CGSize(width: 265.0, height: 339.0)
|
||||
self.topOffset = 0.0
|
||||
self.biometricsOffset = 30.0
|
||||
self.deleteOffset = 20.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct PasscodeLayout {
|
||||
let layout: ContainerViewLayout
|
||||
let keyboard: PasscodeKeyboardLayout
|
||||
let titleOffset: CGFloat
|
||||
let subtitleOffset: CGFloat
|
||||
let inputFieldOffset: CGFloat
|
||||
|
||||
init(layout: ContainerViewLayout) {
|
||||
self.layout = layout
|
||||
|
||||
let metrics = DeviceMetrics.forScreenSize(layout.size)
|
||||
self.keyboard = PasscodeKeyboardLayout(layout: layout, metrics: metrics)
|
||||
if let metrics = metrics {
|
||||
switch metrics {
|
||||
case .iPhone4:
|
||||
self.titleOffset = 30.0
|
||||
self.subtitleOffset = -13.0
|
||||
self.inputFieldOffset = 70.0
|
||||
case .iPhone5:
|
||||
self.titleOffset = 50.0
|
||||
self.subtitleOffset = -7.0
|
||||
self.inputFieldOffset = 90.0
|
||||
case .iPhone6:
|
||||
self.titleOffset = 100.0
|
||||
self.subtitleOffset = -3.0
|
||||
self.inputFieldOffset = 144.0
|
||||
case .iPhone6Plus:
|
||||
self.titleOffset = 112.0
|
||||
self.subtitleOffset = -6.0
|
||||
self.inputFieldOffset = 156.0
|
||||
case .iPhoneX:
|
||||
self.titleOffset = 162.0
|
||||
self.subtitleOffset = 0.0
|
||||
self.inputFieldOffset = 206.0
|
||||
case .iPhoneXSMax:
|
||||
self.titleOffset = 180.0
|
||||
self.subtitleOffset = 0.0
|
||||
self.inputFieldOffset = 226.0
|
||||
case .iPad, .iPadPro10Inch, .iPadPro11Inch, .iPadPro, .iPadPro3rdGen:
|
||||
self.titleOffset = self.keyboard.topOffset - 120.0
|
||||
self.subtitleOffset = -2.0
|
||||
self.inputFieldOffset = self.keyboard.topOffset - 76.0
|
||||
}
|
||||
} else {
|
||||
self.titleOffset = 100.0
|
||||
self.subtitleOffset = 0.0
|
||||
self.inputFieldOffset = 140.0
|
||||
}
|
||||
}
|
||||
|
||||
init(layout: ContainerViewLayout, titleOffset: CGFloat, subtitleOffset: CGFloat, inputFieldOffset: CGFloat) {
|
||||
self.layout = layout
|
||||
|
||||
let metrics = DeviceMetrics.forScreenSize(layout.size)
|
||||
self.keyboard = PasscodeKeyboardLayout(layout: layout, metrics: metrics)
|
||||
self.titleOffset = titleOffset
|
||||
self.subtitleOffset = subtitleOffset
|
||||
self.inputFieldOffset = inputFieldOffset
|
||||
}
|
||||
}
|
||||
169
submodules/PasscodeUI/Sources/PasscodeLockIconNode.swift
Normal file
169
submodules/PasscodeUI/Sources/PasscodeLockIconNode.swift
Normal file
@@ -0,0 +1,169 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import LegacyComponents
|
||||
|
||||
private final class PasscodeLockIconNodeParameters: NSObject {
|
||||
let unlockedColor: UIColor
|
||||
let lockedColor: UIColor
|
||||
let progress: CGFloat
|
||||
let fromScale: CGFloat
|
||||
let keepLockedColor: Bool
|
||||
|
||||
init(unlockedColor: UIColor, lockedColor: UIColor, progress: CGFloat, fromScale: CGFloat, keepLockedColor: Bool) {
|
||||
self.unlockedColor = unlockedColor
|
||||
self.lockedColor = lockedColor
|
||||
self.progress = progress
|
||||
self.fromScale = fromScale
|
||||
self.keepLockedColor = keepLockedColor
|
||||
super.init()
|
||||
}
|
||||
}
|
||||
|
||||
final class PasscodeLockIconNode: ASDisplayNode {
|
||||
var unlockedColor: UIColor = .black {
|
||||
didSet {
|
||||
self.setNeedsDisplay()
|
||||
}
|
||||
}
|
||||
|
||||
private var effectiveProgress: CGFloat = 1.0 {
|
||||
didSet {
|
||||
self.setNeedsDisplay()
|
||||
}
|
||||
}
|
||||
|
||||
private var fromScale: CGFloat = 1.0
|
||||
|
||||
private var keepLockedColor = false
|
||||
|
||||
override init() {
|
||||
super.init()
|
||||
|
||||
self.isOpaque = false
|
||||
self.backgroundColor = .clear
|
||||
}
|
||||
|
||||
func animateIn(fromScale: CGFloat = 1.0) {
|
||||
self.fromScale = fromScale
|
||||
|
||||
self.pop_removeAllAnimations()
|
||||
|
||||
let animation = POPBasicAnimation()
|
||||
animation.property = (POPAnimatableProperty.property(withName: "progress", initializer: { property in
|
||||
property?.readBlock = { node, values in
|
||||
values?.pointee = (node as! PasscodeLockIconNode).effectiveProgress
|
||||
}
|
||||
property?.writeBlock = { node, values in
|
||||
(node as! PasscodeLockIconNode).effectiveProgress = values!.pointee
|
||||
}
|
||||
property?.threshold = 0.01
|
||||
}) as! POPAnimatableProperty)
|
||||
animation.fromValue = 0.0 as NSNumber
|
||||
animation.toValue = 1.0 as NSNumber
|
||||
animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear)
|
||||
animation.duration = 0.55
|
||||
self.pop_add(animation, forKey: "progress")
|
||||
}
|
||||
|
||||
func animateUnlock() {
|
||||
self.fromScale = 1.0
|
||||
self.keepLockedColor = true
|
||||
self.pop_removeAllAnimations()
|
||||
|
||||
let animation = POPBasicAnimation()
|
||||
animation.property = (POPAnimatableProperty.property(withName: "progress", initializer: { property in
|
||||
property?.readBlock = { node, values in
|
||||
values?.pointee = (node as! PasscodeLockIconNode).effectiveProgress
|
||||
}
|
||||
property?.writeBlock = { node, values in
|
||||
(node as! PasscodeLockIconNode).effectiveProgress = values!.pointee
|
||||
}
|
||||
property?.threshold = 0.01
|
||||
}) as! POPAnimatableProperty)
|
||||
animation.fromValue = 1.0 as NSNumber
|
||||
animation.toValue = 0.0 as NSNumber
|
||||
animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear)
|
||||
animation.duration = 0.75
|
||||
self.pop_add(animation, forKey: "progress")
|
||||
}
|
||||
|
||||
override func drawParameters(forAsyncLayer layer: _ASDisplayLayer) -> NSObjectProtocol? {
|
||||
return PasscodeLockIconNodeParameters(unlockedColor: self.unlockedColor, lockedColor: .white, progress: self.effectiveProgress, fromScale: self.fromScale, keepLockedColor: self.keepLockedColor)
|
||||
}
|
||||
|
||||
@objc override class func draw(_ bounds: CGRect, withParameters parameters: Any?, isCancelled: () -> Bool, isRasterizing: Bool) {
|
||||
let context = UIGraphicsGetCurrentContext()!
|
||||
|
||||
if !isRasterizing {
|
||||
context.setBlendMode(.copy)
|
||||
context.setFillColor(UIColor.clear.cgColor)
|
||||
context.fill(bounds)
|
||||
}
|
||||
|
||||
guard let parameters = parameters as? PasscodeLockIconNodeParameters else {
|
||||
return
|
||||
}
|
||||
|
||||
let progress = parameters.progress
|
||||
let fromScale = parameters.fromScale
|
||||
let lockSpan: CGFloat = parameters.keepLockedColor ? 0.5 : 0.85
|
||||
let lockProgress = min(1.0, progress / lockSpan)
|
||||
|
||||
context.translateBy(x: bounds.width / 2.0, y: bounds.height / 2.0)
|
||||
context.scaleBy(x: fromScale + (1.0 - fromScale) * lockProgress, y: fromScale + (1.0 - fromScale) * lockProgress)
|
||||
context.translateBy(x: -bounds.width / 2.0, y: -bounds.height / 2.0)
|
||||
|
||||
let color = parameters.keepLockedColor ? parameters.lockedColor : parameters.unlockedColor.mixedWith(parameters.lockedColor, alpha: progress)
|
||||
|
||||
context.setStrokeColor(color.cgColor)
|
||||
|
||||
let lineWidth: CGFloat = 3.0
|
||||
context.setLineWidth(lineWidth)
|
||||
|
||||
var topRect: CGRect
|
||||
var topRadius: CGFloat
|
||||
var offset: CGFloat = 0.0
|
||||
if lockProgress < 0.5 {
|
||||
topRect = CGRect(x: 19.0, y: lineWidth / 2.0 + 1.0, width: 14.0 * (0.5 - lockProgress) / 0.5, height: 22.0)
|
||||
topRadius = 6.0 * (0.5 - lockProgress) * 2.0
|
||||
} else {
|
||||
let width = 14.0 * (lockProgress - 0.5) * 2.0
|
||||
topRect = CGRect(x: 19.0 - width, y: lineWidth / 2.0 + 1.0, width: width, height: 22.0)
|
||||
topRadius = 6.0 * (lockProgress - 0.5) * 2.0
|
||||
}
|
||||
if progress > lockSpan {
|
||||
let innerProgress = (progress - lockSpan) / (1.0 - lockSpan)
|
||||
if !parameters.keepLockedColor {
|
||||
if innerProgress < 0.6 {
|
||||
offset = 2.0 * min(1.0, innerProgress / 0.6)
|
||||
} else {
|
||||
offset = 2.0 * min(1.0, max(0.0, (1.0 - innerProgress) / 0.4))
|
||||
}
|
||||
}
|
||||
|
||||
topRect.origin.y += 4.0 * min(1.0, max(0.0, innerProgress / 0.6)) + offset
|
||||
}
|
||||
let topPath = UIBezierPath(roundedRect: topRect, cornerRadius: topRadius)
|
||||
context.addPath(topPath.cgPath)
|
||||
context.strokePath()
|
||||
|
||||
var clearRect: CGRect
|
||||
if lockProgress < 0.5 {
|
||||
clearRect = CGRect(x: topRect.minX + lineWidth, y: topRect.minY + 11.0, width: 14.0, height: 22.0)
|
||||
} else {
|
||||
clearRect = CGRect(x: topRect.maxX - 14.0 - lineWidth, y: topRect.minY + 11.0, width: 14.0, height: 22.0)
|
||||
}
|
||||
|
||||
context.setBlendMode(.clear)
|
||||
context.clear(clearRect)
|
||||
context.setBlendMode(.normal)
|
||||
|
||||
context.setFillColor(color.cgColor)
|
||||
|
||||
let basePath = UIBezierPath(roundedRect: CGRect(x: 0.0, y: bounds.height - 21.0 + offset, width: 24.0, height: 19.0), cornerRadius: 3.5)
|
||||
context.addPath(basePath.cgPath)
|
||||
context.fillPath()
|
||||
}
|
||||
}
|
||||
151
submodules/PasscodeUI/Sources/PasscodeSetupController.swift
Normal file
151
submodules/PasscodeUI/Sources/PasscodeSetupController.swift
Normal file
@@ -0,0 +1,151 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import AsyncDisplayKit
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import AccountContext
|
||||
|
||||
public enum PasscodeSetupControllerMode {
|
||||
case setup(change: Bool, PasscodeEntryFieldType)
|
||||
case entry(PostboxAccessChallengeData)
|
||||
}
|
||||
|
||||
public final class PasscodeSetupController: ViewController {
|
||||
private var controllerNode: PasscodeSetupControllerNode {
|
||||
return self.displayNode as! PasscodeSetupControllerNode
|
||||
}
|
||||
|
||||
private let context: AccountContext
|
||||
private var mode: PasscodeSetupControllerMode
|
||||
|
||||
public var complete: ((String, Bool) -> Void)?
|
||||
public var check: ((String) -> Bool)?
|
||||
|
||||
private let hapticFeedback = HapticFeedback()
|
||||
|
||||
private var presentationData: PresentationData
|
||||
|
||||
private var nextAction: UIBarButtonItem?
|
||||
|
||||
public init(context: AccountContext, mode: PasscodeSetupControllerMode) {
|
||||
self.context = context
|
||||
self.mode = mode
|
||||
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
|
||||
super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationData: self.presentationData))
|
||||
|
||||
self.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait)
|
||||
self.statusBar.statusBarStyle = self.presentationData.theme.rootController.statusBarStyle.style
|
||||
|
||||
self.nextAction = UIBarButtonItem(title: self.presentationData.strings.Common_Next, style: .done, target: self, action: #selector(self.nextPressed))
|
||||
|
||||
self.title = self.presentationData.strings.PasscodeSettings_Title
|
||||
}
|
||||
|
||||
required public init(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override public func loadDisplayNode() {
|
||||
self.displayNode = PasscodeSetupControllerNode(presentationData: self.presentationData, mode: self.mode)
|
||||
self.displayNodeDidLoad()
|
||||
|
||||
self.controllerNode.selectPasscodeMode = { [weak self] in
|
||||
guard let strongSelf = self, case let .setup(change, type) = strongSelf.mode else {
|
||||
return
|
||||
}
|
||||
|
||||
let controller = ActionSheetController(presentationTheme: strongSelf.presentationData.theme)
|
||||
let dismissAction: () -> Void = { [weak controller] in
|
||||
self?.controllerNode.activateInput()
|
||||
controller?.dismissAnimated()
|
||||
}
|
||||
|
||||
var items: [ActionSheetButtonItem] = []
|
||||
if case .digits6 = type {
|
||||
} else {
|
||||
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.PasscodeSettings_6DigitCode, action: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
strongSelf.mode = .setup(change: change, .digits6)
|
||||
strongSelf.controllerNode.updateMode(strongSelf.mode)
|
||||
}
|
||||
dismissAction()
|
||||
}))
|
||||
}
|
||||
if case .digits4 = type {
|
||||
} else {
|
||||
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.PasscodeSettings_4DigitCode, action: {
|
||||
if let strongSelf = self {
|
||||
strongSelf.mode = .setup(change: change, .digits4)
|
||||
strongSelf.controllerNode.updateMode(strongSelf.mode)
|
||||
}
|
||||
dismissAction()
|
||||
}))
|
||||
}
|
||||
if case .alphanumeric = type {
|
||||
} else {
|
||||
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.PasscodeSettings_AlphanumericCode, action: {
|
||||
if let strongSelf = self {
|
||||
strongSelf.mode = .setup(change: change, .alphanumeric)
|
||||
strongSelf.controllerNode.updateMode(strongSelf.mode)
|
||||
}
|
||||
dismissAction()
|
||||
}))
|
||||
}
|
||||
controller.setItemGroups([
|
||||
ActionSheetItemGroup(items: items),
|
||||
ActionSheetItemGroup(items: [ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Cancel, action: { dismissAction() })])
|
||||
])
|
||||
controller.dismissed = { _ in
|
||||
self?.controllerNode.activateInput()
|
||||
}
|
||||
strongSelf.view.endEditing(true)
|
||||
strongSelf.present(controller, in: .window(.root))
|
||||
}
|
||||
self.controllerNode.updateNextAction = { [weak self] visible in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
if visible {
|
||||
strongSelf.navigationItem.rightBarButtonItem = strongSelf.nextAction
|
||||
} else {
|
||||
strongSelf.navigationItem.rightBarButtonItem = nil
|
||||
}
|
||||
}
|
||||
self.controllerNode.complete = { [weak self] passcode, numerical in
|
||||
if let strongSelf = self {
|
||||
strongSelf.complete?(passcode, numerical)
|
||||
}
|
||||
}
|
||||
self.controllerNode.checkPasscode = { [weak self] passcode in
|
||||
return self?.check?(passcode) ?? false
|
||||
}
|
||||
}
|
||||
|
||||
override public func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
self.controllerNode.activateInput()
|
||||
}
|
||||
|
||||
override public func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
self.view.disablesInteractiveTransitionGestureRecognizer = true
|
||||
|
||||
self.controllerNode.activateInput()
|
||||
}
|
||||
|
||||
override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||
super.containerLayoutUpdated(layout, transition: transition)
|
||||
|
||||
self.controllerNode.containerLayoutUpdated(layout, navigationBarHeight: self.navigationHeight, transition: transition)
|
||||
}
|
||||
|
||||
@objc private func nextPressed() {
|
||||
self.controllerNode.activateNext()
|
||||
}
|
||||
}
|
||||
275
submodules/PasscodeUI/Sources/PasscodeSetupControllerNode.swift
Normal file
275
submodules/PasscodeUI/Sources/PasscodeSetupControllerNode.swift
Normal file
@@ -0,0 +1,275 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
|
||||
enum PasscodeSetupInitialState {
|
||||
case createPasscode
|
||||
case changePassword(current: String, hasRecoveryEmail: Bool, hasSecureValues: Bool)
|
||||
}
|
||||
|
||||
enum PasscodeSetupStateKind: Int32 {
|
||||
case enterPasscode
|
||||
case confirmPasscode
|
||||
}
|
||||
|
||||
private func generateFieldBackground(backgroundColor: UIColor, borderColor: UIColor) -> UIImage? {
|
||||
return generateImage(CGSize(width: 1.0, height: 48.0), contextGenerator: { size, context in
|
||||
let bounds = CGRect(origin: CGPoint(), size: size)
|
||||
|
||||
context.setFillColor(backgroundColor.cgColor)
|
||||
context.fill(bounds)
|
||||
|
||||
context.setFillColor(borderColor.cgColor)
|
||||
context.fill(CGRect(origin: CGPoint(), size: CGSize(width: 1.0, height: UIScreenPixel)))
|
||||
context.fill(CGRect(origin: CGPoint(x: 0.0, y: size.height - UIScreenPixel), size: CGSize(width: 1.0, height: UIScreenPixel)))
|
||||
})
|
||||
}
|
||||
|
||||
final class PasscodeSetupControllerNode: ASDisplayNode {
|
||||
private var presentationData: PresentationData
|
||||
private var mode: PasscodeSetupControllerMode
|
||||
|
||||
private let wrapperNode: ASDisplayNode
|
||||
|
||||
private let titleNode: ASTextNode
|
||||
private let subtitleNode: ASTextNode
|
||||
private let inputFieldNode: PasscodeEntryInputFieldNode
|
||||
private let inputFieldBackgroundNode: ASImageNode
|
||||
private let modeButtonNode: HighlightableButtonNode
|
||||
|
||||
var previousPasscode: String?
|
||||
var currentPasscode: String {
|
||||
return self.inputFieldNode.text
|
||||
}
|
||||
|
||||
var selectPasscodeMode: (() -> Void)?
|
||||
var checkPasscode: ((String) -> Bool)?
|
||||
var complete: ((String, Bool) -> Void)?
|
||||
var updateNextAction: ((Bool) -> Void)?
|
||||
|
||||
private let hapticFeedback = HapticFeedback()
|
||||
|
||||
private var validLayout: (ContainerViewLayout, CGFloat)?
|
||||
private var maxBottomInset: CGFloat?
|
||||
|
||||
init(presentationData: PresentationData, mode: PasscodeSetupControllerMode) {
|
||||
self.presentationData = presentationData
|
||||
self.mode = mode
|
||||
|
||||
self.wrapperNode = ASDisplayNode()
|
||||
|
||||
self.titleNode = ASTextNode()
|
||||
self.titleNode.isUserInteractionEnabled = false
|
||||
self.titleNode.displaysAsynchronously = false
|
||||
|
||||
self.subtitleNode = ASTextNode()
|
||||
self.subtitleNode.isUserInteractionEnabled = false
|
||||
self.subtitleNode.displaysAsynchronously = false
|
||||
|
||||
let passcodeType: PasscodeEntryFieldType
|
||||
switch self.mode {
|
||||
case let .entry(challenge):
|
||||
switch challenge {
|
||||
case let .numericalPassword(value, _, _):
|
||||
passcodeType = value.count == 6 ? .digits6 : .digits4
|
||||
default:
|
||||
passcodeType = .alphanumeric
|
||||
}
|
||||
case .setup:
|
||||
passcodeType = .digits6
|
||||
}
|
||||
|
||||
self.inputFieldNode = PasscodeEntryInputFieldNode(color: self.presentationData.theme.list.itemPrimaryTextColor, accentColor: self.presentationData.theme.list.itemAccentColor, fieldType: passcodeType, keyboardAppearance: self.presentationData.theme.chatList.searchBarKeyboardColor.keyboardAppearance)
|
||||
self.inputFieldBackgroundNode = ASImageNode()
|
||||
self.inputFieldBackgroundNode.alpha = passcodeType == .alphanumeric ? 1.0 : 0.0
|
||||
self.inputFieldBackgroundNode.contentMode = .scaleToFill
|
||||
self.inputFieldBackgroundNode.image = generateFieldBackground(backgroundColor: self.presentationData.theme.list.itemBlocksBackgroundColor, borderColor: self.presentationData.theme.list.itemBlocksSeparatorColor)
|
||||
|
||||
self.modeButtonNode = HighlightableButtonNode()
|
||||
self.modeButtonNode.setTitle(self.presentationData.strings.PasscodeSettings_PasscodeOptions, with: Font.regular(17.0), with: self.presentationData.theme.list.itemAccentColor, for: .normal)
|
||||
|
||||
super.init()
|
||||
|
||||
self.setViewBlock({
|
||||
return UITracingLayerView()
|
||||
})
|
||||
|
||||
self.backgroundColor = self.presentationData.theme.list.blocksBackgroundColor
|
||||
|
||||
self.addSubnode(self.wrapperNode)
|
||||
|
||||
self.wrapperNode.addSubnode(self.titleNode)
|
||||
self.wrapperNode.addSubnode(self.subtitleNode)
|
||||
self.wrapperNode.addSubnode(self.inputFieldBackgroundNode)
|
||||
self.wrapperNode.addSubnode(self.inputFieldNode)
|
||||
self.wrapperNode.addSubnode(self.modeButtonNode)
|
||||
|
||||
let text: String
|
||||
switch self.mode {
|
||||
case .entry:
|
||||
self.modeButtonNode.isHidden = true
|
||||
self.modeButtonNode.isAccessibilityElement = false
|
||||
text = self.presentationData.strings.EnterPasscode_EnterPasscode
|
||||
case let .setup(change, _):
|
||||
if change {
|
||||
text = self.presentationData.strings.EnterPasscode_EnterNewPasscodeChange
|
||||
} else {
|
||||
text = self.presentationData.strings.EnterPasscode_EnterNewPasscodeNew
|
||||
}
|
||||
}
|
||||
self.titleNode.attributedText = NSAttributedString(string: text, font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
||||
|
||||
self.inputFieldNode.complete = { [weak self] passcode in
|
||||
self?.activateNext()
|
||||
}
|
||||
|
||||
self.modeButtonNode.addTarget(self, action: #selector(self.modePressed), forControlEvents: .touchUpInside)
|
||||
}
|
||||
|
||||
func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||
self.validLayout = (layout, navigationBarHeight)
|
||||
|
||||
var insets = layout.insets(options: [.statusBar, .input])
|
||||
if let maxBottomInset = self.maxBottomInset {
|
||||
if maxBottomInset > insets.bottom {
|
||||
insets.bottom = maxBottomInset
|
||||
} else {
|
||||
self.maxBottomInset = insets.bottom
|
||||
}
|
||||
} else {
|
||||
self.maxBottomInset = insets.bottom
|
||||
}
|
||||
|
||||
self.wrapperNode.frame = CGRect(x: 0.0, y: 0.0, width: layout.size.width, height: layout.size.height)
|
||||
|
||||
let passcodeLayout = PasscodeLayout(layout: layout, titleOffset: 0.0, subtitleOffset: 0.0, inputFieldOffset: floor(insets.top + navigationBarHeight + (layout.size.height - navigationBarHeight - insets.top - insets.bottom - 24.0) / 2.0))
|
||||
let inputFieldFrame = self.inputFieldNode.updateLayout(layout: passcodeLayout, transition: transition)
|
||||
transition.updateFrame(node: self.inputFieldNode, frame: CGRect(origin: CGPoint(), size: layout.size))
|
||||
|
||||
transition.updateFrame(node: self.inputFieldBackgroundNode, frame: CGRect(x: 0.0, y: inputFieldFrame.minY - 6.0, width: layout.size.width, height: 48.0))
|
||||
|
||||
let titleSize = self.titleNode.measure(CGSize(width: layout.size.width - 28.0, height: CGFloat.greatestFiniteMagnitude))
|
||||
transition.updateFrame(node: self.titleNode, frame: CGRect(origin: CGPoint(x: floor((layout.size.width - titleSize.width) / 2.0), y: inputFieldFrame.minY - titleSize.height - 20.0), size: titleSize))
|
||||
|
||||
let subtitleSize = self.subtitleNode.measure(CGSize(width: layout.size.width - 28.0, height: CGFloat.greatestFiniteMagnitude))
|
||||
transition.updateFrame(node: self.subtitleNode, frame: CGRect(origin: CGPoint(x: floor((layout.size.width - subtitleSize.width) / 2.0), y: inputFieldFrame.maxY + 20.0), size: subtitleSize))
|
||||
|
||||
transition.updateFrame(node: self.modeButtonNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - insets.bottom - 53.0), size: CGSize(width: layout.size.width, height: 44.0)))
|
||||
}
|
||||
|
||||
func updateMode(_ mode: PasscodeSetupControllerMode) {
|
||||
self.mode = mode
|
||||
self.inputFieldNode.reset()
|
||||
|
||||
if case let .setup(_, type) = mode {
|
||||
self.inputFieldNode.updateFieldType(type, animated: true)
|
||||
|
||||
let fieldBackgroundAlpha: CGFloat
|
||||
if case .alphanumeric = type {
|
||||
fieldBackgroundAlpha = 1.0
|
||||
self.updateNextAction?(true)
|
||||
} else {
|
||||
fieldBackgroundAlpha = 0.0
|
||||
self.updateNextAction?(false)
|
||||
}
|
||||
let previousAlpha = self.inputFieldBackgroundNode.alpha
|
||||
self.inputFieldBackgroundNode.alpha = fieldBackgroundAlpha
|
||||
self.inputFieldBackgroundNode.layer.animateAlpha(from: previousAlpha, to: fieldBackgroundAlpha, duration: 0.25)
|
||||
self.subtitleNode.isHidden = true
|
||||
}
|
||||
}
|
||||
|
||||
func activateNext() {
|
||||
guard !self.currentPasscode.isEmpty else {
|
||||
self.animateError()
|
||||
return
|
||||
}
|
||||
|
||||
switch self.mode {
|
||||
case .entry:
|
||||
if !(self.checkPasscode?(self.currentPasscode) ?? false) {
|
||||
self.animateError()
|
||||
}
|
||||
case .setup:
|
||||
if let previousPasscode = self.previousPasscode {
|
||||
if self.currentPasscode == previousPasscode {
|
||||
var numerical = false
|
||||
if case let .setup(_, type) = mode {
|
||||
if case .alphanumeric = type {
|
||||
} else {
|
||||
numerical = true
|
||||
}
|
||||
}
|
||||
self.complete?(self.currentPasscode, numerical)
|
||||
} else {
|
||||
self.previousPasscode = nil
|
||||
|
||||
if let snapshotView = self.wrapperNode.view.snapshotContentTree() {
|
||||
snapshotView.frame = self.wrapperNode.frame
|
||||
self.wrapperNode.view.superview?.insertSubview(snapshotView, aboveSubview: self.wrapperNode.view)
|
||||
snapshotView.layer.animatePosition(from: CGPoint(), to: CGPoint(x: self.wrapperNode.bounds.width, y: 0.0), duration: 0.25, removeOnCompletion: false, additive: true, completion : { [weak snapshotView] _ in
|
||||
snapshotView?.removeFromSuperview()
|
||||
})
|
||||
self.wrapperNode.layer.animatePosition(from: CGPoint(x: -self.wrapperNode.bounds.width, y: 0.0), to: CGPoint(), duration: 0.25, additive: true)
|
||||
|
||||
self.inputFieldNode.reset(animated: false)
|
||||
self.titleNode.attributedText = NSAttributedString(string: self.presentationData.strings.EnterPasscode_EnterNewPasscodeChange, font: Font.regular(16.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
||||
self.subtitleNode.isHidden = false
|
||||
self.subtitleNode.attributedText = NSAttributedString(string: self.presentationData.strings.PasscodeSettings_DoNotMatch, font: Font.regular(16.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
||||
self.modeButtonNode.isHidden = false
|
||||
self.modeButtonNode.isAccessibilityElement = true
|
||||
|
||||
UIAccessibility.post(notification: UIAccessibility.Notification.announcement, argument: self.presentationData.strings.PasscodeSettings_DoNotMatch)
|
||||
|
||||
if let validLayout = self.validLayout {
|
||||
self.containerLayoutUpdated(validLayout.0, navigationBarHeight: validLayout.1, transition: .immediate)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.previousPasscode = self.currentPasscode
|
||||
|
||||
if let snapshotView = self.wrapperNode.view.snapshotContentTree() {
|
||||
snapshotView.frame = self.wrapperNode.frame
|
||||
self.wrapperNode.view.superview?.insertSubview(snapshotView, aboveSubview: self.wrapperNode.view)
|
||||
snapshotView.layer.animatePosition(from: CGPoint(), to: CGPoint(x: -self.wrapperNode.bounds.width, y: 0.0), duration: 0.25, removeOnCompletion: false, additive: true, completion : { [weak snapshotView] _ in
|
||||
snapshotView?.removeFromSuperview()
|
||||
})
|
||||
self.wrapperNode.layer.animatePosition(from: CGPoint(x: self.wrapperNode.bounds.width, y: 0.0), to: CGPoint(), duration: 0.25, additive: true)
|
||||
|
||||
self.inputFieldNode.reset(animated: false)
|
||||
self.titleNode.attributedText = NSAttributedString(string: self.presentationData.strings.EnterPasscode_RepeatNewPasscode, font: Font.regular(16.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
||||
self.subtitleNode.isHidden = true
|
||||
self.modeButtonNode.isHidden = true
|
||||
self.modeButtonNode.isAccessibilityElement = false
|
||||
|
||||
UIAccessibility.post(notification: UIAccessibility.Notification.announcement, argument: self.presentationData.strings.EnterPasscode_RepeatNewPasscode)
|
||||
|
||||
if let validLayout = self.validLayout {
|
||||
self.containerLayoutUpdated(validLayout.0, navigationBarHeight: validLayout.1, transition: .immediate)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func activateInput() {
|
||||
self.inputFieldNode.activateInput()
|
||||
|
||||
UIAccessibility.post(notification: UIAccessibility.Notification.announcement, argument: self.titleNode.attributedText?.string)
|
||||
}
|
||||
|
||||
func animateError() {
|
||||
self.inputFieldNode.reset()
|
||||
self.inputFieldNode.layer.addShakeAnimation(amplitude: -30.0, duration: 0.5, count: 6, decay: true)
|
||||
|
||||
self.hapticFeedback.error()
|
||||
}
|
||||
|
||||
@objc func modePressed() {
|
||||
self.selectPasscodeMode?()
|
||||
}
|
||||
}
|
||||
19
submodules/PasscodeUI/Sources/PasscodeUI.h
Normal file
19
submodules/PasscodeUI/Sources/PasscodeUI.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// PasscodeUI.h
|
||||
// PasscodeUI
|
||||
//
|
||||
// Created by Peter on 8/13/19.
|
||||
// Copyright © 2019 Telegram Messenger LLP. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
//! Project version number for PasscodeUI.
|
||||
FOUNDATION_EXPORT double PasscodeUIVersionNumber;
|
||||
|
||||
//! Project version string for PasscodeUI.
|
||||
FOUNDATION_EXPORT const unsigned char PasscodeUIVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <PasscodeUI/PublicHeader.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user