mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Refactor PasswordSetupUI, PassportUI, GalleryUI and related modules
This commit is contained in:
22
submodules/PhoneInputNode/Info.plist
Normal file
22
submodules/PhoneInputNode/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>
|
||||
@@ -0,0 +1,559 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 50;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
D0C9C26923009F2300FAB518 /* PhoneInputNode.h in Headers */ = {isa = PBXBuildFile; fileRef = D0C9C26723009F2300FAB518 /* PhoneInputNode.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D0C9C2742300A01A00FAB518 /* PhoneInputNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0C9C2732300A01A00FAB518 /* PhoneInputNode.swift */; };
|
||||
D0C9C2772300A02A00FAB518 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9C2762300A02A00FAB518 /* Foundation.framework */; };
|
||||
D0C9C2792300A02D00FAB518 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9C2782300A02D00FAB518 /* UIKit.framework */; };
|
||||
D0C9C27B2300A03000FAB518 /* AsyncDisplayKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9C27A2300A03000FAB518 /* AsyncDisplayKit.framework */; };
|
||||
D0C9C27D2300A03500FAB518 /* Display.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9C27C2300A03500FAB518 /* Display.framework */; };
|
||||
D0C9C27F2300A03A00FAB518 /* TelegramPresentationData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C9C27E2300A03A00FAB518 /* TelegramPresentationData.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
D0C9C26423009F2300FAB518 /* PhoneInputNode.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PhoneInputNode.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D0C9C26723009F2300FAB518 /* PhoneInputNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PhoneInputNode.h; sourceTree = "<group>"; };
|
||||
D0C9C26823009F2300FAB518 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
D0C9C2732300A01A00FAB518 /* PhoneInputNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhoneInputNode.swift; sourceTree = "<group>"; };
|
||||
D0C9C2762300A02A00FAB518 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
D0C9C2782300A02D00FAB518 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||
D0C9C27A2300A03000FAB518 /* AsyncDisplayKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = AsyncDisplayKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D0C9C27C2300A03500FAB518 /* Display.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Display.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D0C9C27E2300A03A00FAB518 /* TelegramPresentationData.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = TelegramPresentationData.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
D0C9C26123009F2300FAB518 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D0C9C27F2300A03A00FAB518 /* TelegramPresentationData.framework in Frameworks */,
|
||||
D0C9C27D2300A03500FAB518 /* Display.framework in Frameworks */,
|
||||
D0C9C27B2300A03000FAB518 /* AsyncDisplayKit.framework in Frameworks */,
|
||||
D0C9C2792300A02D00FAB518 /* UIKit.framework in Frameworks */,
|
||||
D0C9C2772300A02A00FAB518 /* Foundation.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
D0C9C25A23009F2300FAB518 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D0C9C26823009F2300FAB518 /* Info.plist */,
|
||||
D0C9C26623009F2300FAB518 /* Sources */,
|
||||
D0C9C26523009F2300FAB518 /* Products */,
|
||||
D0C9C2752300A02A00FAB518 /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D0C9C26523009F2300FAB518 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D0C9C26423009F2300FAB518 /* PhoneInputNode.framework */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D0C9C26623009F2300FAB518 /* Sources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D0C9C2732300A01A00FAB518 /* PhoneInputNode.swift */,
|
||||
D0C9C26723009F2300FAB518 /* PhoneInputNode.h */,
|
||||
);
|
||||
path = Sources;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D0C9C2752300A02A00FAB518 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D0C9C27E2300A03A00FAB518 /* TelegramPresentationData.framework */,
|
||||
D0C9C27C2300A03500FAB518 /* Display.framework */,
|
||||
D0C9C27A2300A03000FAB518 /* AsyncDisplayKit.framework */,
|
||||
D0C9C2782300A02D00FAB518 /* UIKit.framework */,
|
||||
D0C9C2762300A02A00FAB518 /* Foundation.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
D0C9C25F23009F2300FAB518 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D0C9C26923009F2300FAB518 /* PhoneInputNode.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
D0C9C26323009F2300FAB518 /* PhoneInputNode */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = D0C9C26C23009F2300FAB518 /* Build configuration list for PBXNativeTarget "PhoneInputNode" */;
|
||||
buildPhases = (
|
||||
D0C9C25F23009F2300FAB518 /* Headers */,
|
||||
D0C9C26023009F2300FAB518 /* Sources */,
|
||||
D0C9C26123009F2300FAB518 /* Frameworks */,
|
||||
D0C9C26223009F2300FAB518 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = PhoneInputNode;
|
||||
productName = PhoneInputNode;
|
||||
productReference = D0C9C26423009F2300FAB518 /* PhoneInputNode.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
D0C9C25B23009F2300FAB518 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
DefaultBuildSystemTypeForWorkspace = Latest;
|
||||
LastUpgradeCheck = 1030;
|
||||
ORGANIZATIONNAME = "Telegram Messenger LLP";
|
||||
TargetAttributes = {
|
||||
D0C9C26323009F2300FAB518 = {
|
||||
CreatedOnToolsVersion = 10.3;
|
||||
LastSwiftMigration = 1030;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = D0C9C25E23009F2300FAB518 /* Build configuration list for PBXProject "PhoneInputNode_Xcode" */;
|
||||
compatibilityVersion = "Xcode 9.3";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = D0C9C25A23009F2300FAB518;
|
||||
productRefGroup = D0C9C26523009F2300FAB518 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
D0C9C26323009F2300FAB518 /* PhoneInputNode */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
D0C9C26223009F2300FAB518 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
D0C9C26023009F2300FAB518 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D0C9C2742300A01A00FAB518 /* PhoneInputNode.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
D0C9C26A23009F2300FAB518 /* 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;
|
||||
};
|
||||
D0C9C26B23009F2300FAB518 /* 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;
|
||||
};
|
||||
D0C9C26D23009F2300FAB518 /* 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.PhoneInputNode;
|
||||
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;
|
||||
};
|
||||
D0C9C26E23009F2300FAB518 /* 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.PhoneInputNode;
|
||||
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = ReleaseAppStoreLLC;
|
||||
};
|
||||
D0C9C26F23009FA700FAB518 /* 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;
|
||||
};
|
||||
D0C9C27023009FA700FAB518 /* 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.PhoneInputNode;
|
||||
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;
|
||||
};
|
||||
D0C9C27123009FB300FAB518 /* 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;
|
||||
};
|
||||
D0C9C27223009FB300FAB518 /* 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.PhoneInputNode;
|
||||
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 */
|
||||
D0C9C25E23009F2300FAB518 /* Build configuration list for PBXProject "PhoneInputNode_Xcode" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
D0C9C26A23009F2300FAB518 /* DebugAppStoreLLC */,
|
||||
D0C9C26F23009FA700FAB518 /* DebugHockeyapp */,
|
||||
D0C9C26B23009F2300FAB518 /* ReleaseAppStoreLLC */,
|
||||
D0C9C27123009FB300FAB518 /* ReleaseHockeyappInternal */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = ReleaseAppStoreLLC;
|
||||
};
|
||||
D0C9C26C23009F2300FAB518 /* Build configuration list for PBXNativeTarget "PhoneInputNode" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
D0C9C26D23009F2300FAB518 /* DebugAppStoreLLC */,
|
||||
D0C9C27023009FA700FAB518 /* DebugHockeyapp */,
|
||||
D0C9C26E23009F2300FAB518 /* ReleaseAppStoreLLC */,
|
||||
D0C9C27223009FB300FAB518 /* ReleaseHockeyappInternal */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = ReleaseAppStoreLLC;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = D0C9C25B23009F2300FAB518 /* Project object */;
|
||||
}
|
||||
19
submodules/PhoneInputNode/Sources/PhoneInputNode.h
Normal file
19
submodules/PhoneInputNode/Sources/PhoneInputNode.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// PhoneInputNode.h
|
||||
// PhoneInputNode
|
||||
//
|
||||
// Created by Peter on 8/11/19.
|
||||
// Copyright © 2019 Telegram Messenger LLP. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
//! Project version number for PhoneInputNode.
|
||||
FOUNDATION_EXPORT double PhoneInputNodeVersionNumber;
|
||||
|
||||
//! Project version string for PhoneInputNode.
|
||||
FOUNDATION_EXPORT const unsigned char PhoneInputNodeVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <PhoneInputNode/PublicHeader.h>
|
||||
|
||||
|
||||
296
submodules/PhoneInputNode/Sources/PhoneInputNode.swift
Normal file
296
submodules/PhoneInputNode/Sources/PhoneInputNode.swift
Normal file
@@ -0,0 +1,296 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import TelegramCore
|
||||
|
||||
private func removeDuplicatedPlus(_ text: String?) -> String {
|
||||
var result = ""
|
||||
if let text = text {
|
||||
for c in text {
|
||||
if c == "+" {
|
||||
if result.isEmpty {
|
||||
result += String(c)
|
||||
}
|
||||
} else {
|
||||
result += String(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private func removePlus(_ text: String?) -> String {
|
||||
var result = ""
|
||||
if let text = text {
|
||||
for c in text {
|
||||
if c != "+" {
|
||||
result += String(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private func cleanPhoneNumber(_ text: String?) -> String {
|
||||
var cleanNumber = ""
|
||||
if let text = text {
|
||||
for c in text {
|
||||
if c == "+" {
|
||||
if cleanNumber.isEmpty {
|
||||
cleanNumber += String(c)
|
||||
}
|
||||
} else if c >= "0" && c <= "9" {
|
||||
cleanNumber += String(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
return cleanNumber
|
||||
}
|
||||
|
||||
private func cleanPrefix(_ text: String) -> String {
|
||||
var result = ""
|
||||
var checked = false
|
||||
for c in text {
|
||||
if c != " " {
|
||||
checked = true
|
||||
}
|
||||
if checked {
|
||||
result += String(c)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private func cleanSuffix(_ text: String) -> String {
|
||||
var result = ""
|
||||
var checked = false
|
||||
for c in text.reversed() {
|
||||
if c != " " {
|
||||
checked = true
|
||||
}
|
||||
if checked {
|
||||
result = String(c) + result
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
public final class PhoneInputNode: ASDisplayNode, UITextFieldDelegate {
|
||||
public let countryCodeField: TextFieldNode
|
||||
public let numberField: TextFieldNode
|
||||
|
||||
public var previousCountryCodeText = "+"
|
||||
public var previousNumberText = ""
|
||||
public var enableEditing: Bool = true
|
||||
|
||||
public var number: String {
|
||||
get {
|
||||
return cleanPhoneNumber((self.countryCodeField.textField.text ?? "") + (self.numberField.textField.text ?? ""))
|
||||
} set(value) {
|
||||
self.updateNumber(value)
|
||||
}
|
||||
}
|
||||
|
||||
public var countryCodeText: String {
|
||||
get {
|
||||
return self.countryCodeField.textField.text ?? ""
|
||||
} set(value) {
|
||||
if self.countryCodeField.textField.text != value {
|
||||
self.countryCodeField.textField.text = value
|
||||
self.countryCodeTextChanged(self.countryCodeField.textField)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public var numberText: String {
|
||||
get {
|
||||
return self.numberField.textField.text ?? ""
|
||||
} set(value) {
|
||||
if self.numberField.textField.text != value {
|
||||
self.numberField.textField.text = value
|
||||
self.numberTextChanged(self.numberField.textField)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var countryNameForCode: (Int32, String)?
|
||||
|
||||
public var codeAndNumber: (Int32?, String?, String) {
|
||||
get {
|
||||
var code: Int32?
|
||||
if let text = self.countryCodeField.textField.text, text.count <= 4, let number = Int(removePlus(text)) {
|
||||
code = Int32(number)
|
||||
var countryName: String?
|
||||
if self.countryNameForCode?.0 == code {
|
||||
countryName = self.countryNameForCode?.1
|
||||
}
|
||||
return (code, countryName, cleanPhoneNumber(self.numberField.textField.text))
|
||||
} else if let text = self.countryCodeField.textField.text {
|
||||
return (nil, nil, cleanPhoneNumber(text + (self.numberField.textField.text ?? "")))
|
||||
} else {
|
||||
return (nil, nil, "")
|
||||
}
|
||||
} set(value) {
|
||||
let updatedCountryName = self.countryNameForCode?.0 != value.0 || self.countryNameForCode?.1 != value.1
|
||||
if let code = value.0, let name = value.1 {
|
||||
self.countryNameForCode = (code, name)
|
||||
} else {
|
||||
self.countryNameForCode = nil
|
||||
}
|
||||
self.updateNumber("+" + (value.0 == nil ? "" : "\(value.0!)") + value.2, forceNotifyCountryCodeUpdated: updatedCountryName)
|
||||
}
|
||||
}
|
||||
|
||||
public var countryCodeUpdated: ((String, String?) -> Void)?
|
||||
|
||||
public var countryCodeTextUpdated: ((String) -> Void)?
|
||||
public var numberTextUpdated: ((String) -> Void)?
|
||||
|
||||
public var returnAction: (() -> Void)?
|
||||
|
||||
private let phoneFormatter = InteractivePhoneFormatter()
|
||||
|
||||
private let fontSize: CGFloat
|
||||
|
||||
public init(fontSize: CGFloat = 20.0) {
|
||||
self.fontSize = fontSize
|
||||
|
||||
self.countryCodeField = TextFieldNode()
|
||||
self.countryCodeField.textField.font = Font.regular(fontSize)
|
||||
self.countryCodeField.textField.textAlignment = .center
|
||||
self.countryCodeField.textField.keyboardType = .numberPad
|
||||
self.countryCodeField.textField.returnKeyType = .next
|
||||
if #available(iOSApplicationExtension 10.0, iOS 10.0, *) {
|
||||
self.countryCodeField.textField.textContentType = .telephoneNumber
|
||||
}
|
||||
|
||||
self.numberField = TextFieldNode()
|
||||
self.numberField.textField.font = Font.regular(fontSize)
|
||||
self.numberField.textField.keyboardType = .numberPad
|
||||
if #available(iOSApplicationExtension 10.0, iOS 10.0, *) {
|
||||
self.numberField.textField.textContentType = .telephoneNumber
|
||||
}
|
||||
|
||||
super.init()
|
||||
|
||||
self.addSubnode(self.countryCodeField)
|
||||
self.addSubnode(self.numberField)
|
||||
|
||||
self.numberField.textField.didDeleteBackwardWhileEmpty = { [weak self] in
|
||||
self?.countryCodeField.textField.becomeFirstResponder()
|
||||
}
|
||||
self.countryCodeField.textField.addTarget(self, action: #selector(self.countryCodeTextChanged(_:)), for: .editingChanged)
|
||||
self.numberField.textField.addTarget(self, action: #selector(self.numberTextChanged(_:)), for: .editingChanged)
|
||||
self.countryCodeField.textField.delegate = self
|
||||
self.numberField.textField.delegate = self
|
||||
}
|
||||
|
||||
@objc private func countryCodeTextChanged(_ textField: UITextField) {
|
||||
self.updateNumberFromTextFields()
|
||||
}
|
||||
|
||||
@objc private func numberTextChanged(_ textField: UITextField) {
|
||||
self.updateNumberFromTextFields()
|
||||
}
|
||||
|
||||
public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
|
||||
if !self.enableEditing {
|
||||
return false
|
||||
}
|
||||
if range.length == 0, string.count > 1 {
|
||||
self.updateNumber(cleanPhoneNumber(string), tryRestoringInputPosition: false)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
if textField == self.numberField.textField {
|
||||
self.returnAction?()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private func updateNumberFromTextFields() {
|
||||
let inputText = removeDuplicatedPlus(cleanPhoneNumber(self.countryCodeField.textField.text) + cleanPhoneNumber(self.numberField.textField.text))
|
||||
self.updateNumber(inputText)
|
||||
}
|
||||
|
||||
private func updateNumber(_ inputText: String, tryRestoringInputPosition: Bool = true, forceNotifyCountryCodeUpdated: Bool = false) {
|
||||
let (regionPrefix, text) = self.phoneFormatter.updateText(inputText)
|
||||
var realRegionPrefix: String
|
||||
let numberText: String
|
||||
if let regionPrefix = regionPrefix, !regionPrefix.isEmpty, regionPrefix != "+" {
|
||||
realRegionPrefix = cleanSuffix(regionPrefix)
|
||||
if !realRegionPrefix.hasPrefix("+") {
|
||||
realRegionPrefix = "+" + realRegionPrefix
|
||||
}
|
||||
numberText = cleanPrefix(String(text[realRegionPrefix.endIndex...]))
|
||||
} else {
|
||||
realRegionPrefix = text
|
||||
if !realRegionPrefix.hasPrefix("+") {
|
||||
realRegionPrefix = "+" + realRegionPrefix
|
||||
}
|
||||
numberText = ""
|
||||
}
|
||||
|
||||
var focusOnNumber = false
|
||||
if realRegionPrefix != self.countryCodeField.textField.text {
|
||||
self.countryCodeField.textField.text = realRegionPrefix
|
||||
}
|
||||
if self.previousCountryCodeText != realRegionPrefix || forceNotifyCountryCodeUpdated {
|
||||
self.previousCountryCodeText = realRegionPrefix
|
||||
let code = removePlus(realRegionPrefix).trimmingCharacters(in: .whitespaces)
|
||||
var countryName: String?
|
||||
if self.countryNameForCode?.0 == Int32(code) {
|
||||
countryName = self.countryNameForCode?.1
|
||||
}
|
||||
self.countryCodeUpdated?(code, countryName)
|
||||
}
|
||||
self.countryCodeTextUpdated?(realRegionPrefix)
|
||||
|
||||
if numberText != self.numberField.textField.text {
|
||||
var restorePosition: Int?
|
||||
if let text = self.numberField.textField.text, let selectedTextRange = self.numberField.textField.selectedTextRange {
|
||||
let initialOffset = self.numberField.textField.offset(from: self.numberField.textField.beginningOfDocument, to: selectedTextRange.start)
|
||||
var significantIndex = 0
|
||||
for i in 0 ..< min(initialOffset, text.count) {
|
||||
let unicodeScalars = String(text[text.index(text.startIndex, offsetBy: i)]).unicodeScalars
|
||||
if unicodeScalars.count == 1 && CharacterSet.decimalDigits.contains(unicodeScalars[unicodeScalars.startIndex]) {
|
||||
significantIndex += 1
|
||||
}
|
||||
}
|
||||
var restoreIndex = 0
|
||||
for i in 0 ..< numberText.count {
|
||||
if significantIndex <= 0 {
|
||||
break
|
||||
}
|
||||
let unicodeScalars = String(numberText[numberText.index(numberText.startIndex, offsetBy: i)]).unicodeScalars
|
||||
if unicodeScalars.count == 1 && CharacterSet.decimalDigits.contains(unicodeScalars[unicodeScalars.startIndex]) {
|
||||
significantIndex -= 1
|
||||
}
|
||||
restoreIndex += 1
|
||||
}
|
||||
restorePosition = restoreIndex
|
||||
}
|
||||
self.numberField.textField.text = numberText
|
||||
if tryRestoringInputPosition, let restorePosition = restorePosition {
|
||||
if let startPosition = self.numberField.textField.position(from: self.numberField.textField.beginningOfDocument, offset: restorePosition) {
|
||||
let selectionRange = self.numberField.textField.textRange(from: startPosition, to: startPosition)
|
||||
self.numberField.textField.selectedTextRange = selectionRange
|
||||
}
|
||||
}
|
||||
}
|
||||
self.numberTextUpdated?(numberText)
|
||||
|
||||
if self.previousNumberText.isEmpty && !numberText.isEmpty {
|
||||
focusOnNumber = true
|
||||
}
|
||||
self.previousNumberText = numberText
|
||||
|
||||
if focusOnNumber && !self.numberField.textField.isFirstResponder {
|
||||
self.numberField.textField.becomeFirstResponder()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user