Skip to content

Commit 202a593

Browse files
author
Морозов Денис Сергеевич
committed
Merge pull request #20 in UPCMC/ftctextentryformatting from demo-and-readme to master
* commit 'f90edf0fd9b65f9e948ba842c60d888d5aeea067': Demo and readme
2 parents a5be627 + f90edf0 commit 202a593

18 files changed

Lines changed: 1278 additions & 13 deletions

FTCTextEntryFormattingDemo/FTCTextEntryFormattingDemo.xcodeproj/project.pbxproj

Lines changed: 584 additions & 0 deletions
Large diffs are not rendered by default.

FTCTextEntryFormattingDemo/FTCTextEntryFormattingDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) 2017 CFT
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in all
11+
// copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
// SOFTWARE.
20+
21+
import UIKit
22+
23+
@UIApplicationMain
24+
class AppDelegate: UIResponder, UIApplicationDelegate {
25+
26+
var window: UIWindow?
27+
28+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
29+
{
30+
return true
31+
}
32+
}
33+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "20x20",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "20x20",
11+
"scale" : "3x"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"size" : "29x29",
16+
"scale" : "2x"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"size" : "29x29",
21+
"scale" : "3x"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"size" : "40x40",
26+
"scale" : "2x"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"size" : "40x40",
31+
"scale" : "3x"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"size" : "60x60",
36+
"scale" : "2x"
37+
},
38+
{
39+
"idiom" : "iphone",
40+
"size" : "60x60",
41+
"scale" : "3x"
42+
}
43+
],
44+
"info" : {
45+
"version" : 1,
46+
"author" : "xcode"
47+
}
48+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
5+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
6+
</dependencies>
7+
<scenes>
8+
<!--View Controller-->
9+
<scene sceneID="EHf-IW-A2E">
10+
<objects>
11+
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
12+
<layoutGuides>
13+
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
14+
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
15+
</layoutGuides>
16+
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
17+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
18+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
19+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
20+
</view>
21+
</viewController>
22+
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
23+
</objects>
24+
<point key="canvasLocation" x="53" y="375"/>
25+
</scene>
26+
</scenes>
27+
</document>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina4_0" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
6+
<dependencies>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
9+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
10+
</dependencies>
11+
<scenes>
12+
<!--View Controller-->
13+
<scene sceneID="tne-QT-ifu">
14+
<objects>
15+
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="FTCTextEntryFormattingDemo" customModuleProvider="target" sceneMemberID="viewController">
16+
<layoutGuides>
17+
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
18+
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
19+
</layoutGuides>
20+
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
21+
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
22+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
23+
<subviews>
24+
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="Q2e-Gp-TIW">
25+
<rect key="frame" x="0.0" y="20" width="320" height="548"/>
26+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
27+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
28+
<connections>
29+
<outlet property="dataSource" destination="BYZ-38-t0r" id="BOu-Gp-8t9"/>
30+
<outlet property="delegate" destination="BYZ-38-t0r" id="5tH-rf-XoT"/>
31+
</connections>
32+
</tableView>
33+
</subviews>
34+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
35+
</view>
36+
<connections>
37+
<outlet property="tableView" destination="Q2e-Gp-TIW" id="ePA-wZ-ien"/>
38+
</connections>
39+
</viewController>
40+
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
41+
</objects>
42+
<point key="canvasLocation" x="150" y="80"/>
43+
</scene>
44+
<!--Entry View Controller-->
45+
<scene sceneID="ZKK-YJ-WKj">
46+
<objects>
47+
<viewController storyboardIdentifier="EntryViewController" id="aaw-bw-vdr" customClass="EntryViewController" customModule="FTCTextEntryFormattingDemo" customModuleProvider="target" sceneMemberID="viewController">
48+
<layoutGuides>
49+
<viewControllerLayoutGuide type="top" id="tLn-oy-1Oc"/>
50+
<viewControllerLayoutGuide type="bottom" id="cTg-ma-L9U"/>
51+
</layoutGuides>
52+
<view key="view" contentMode="scaleToFill" id="8gG-dg-dUT">
53+
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
54+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
55+
<subviews>
56+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="e9o-0Q-avT">
57+
<rect key="frame" x="240" y="20" width="64" height="30"/>
58+
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
59+
<state key="normal" title="Закрыть"/>
60+
<connections>
61+
<action selector="close:" destination="aaw-bw-vdr" eventType="touchUpInside" id="sEN-0K-l4M"/>
62+
</connections>
63+
</button>
64+
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="ZXP-Ce-X2g">
65+
<rect key="frame" x="16" y="58" width="288" height="30"/>
66+
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
67+
<nil key="textColor"/>
68+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
69+
<textInputTraits key="textInputTraits"/>
70+
</textField>
71+
</subviews>
72+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
73+
</view>
74+
<connections>
75+
<outlet property="textField" destination="ZXP-Ce-X2g" id="UT2-ma-4qm"/>
76+
</connections>
77+
</viewController>
78+
<placeholder placeholderIdentifier="IBFirstResponder" id="Oav-pX-Ok8" userLabel="First Responder" sceneMemberID="firstResponder"/>
79+
</objects>
80+
<point key="canvasLocation" x="966" y="79"/>
81+
</scene>
82+
</scenes>
83+
</document>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) 2017 CFT
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in all
11+
// copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
// SOFTWARE.
20+
21+
#ifndef Bridging_Header_h
22+
#define Bridging_Header_h
23+
24+
#import "FTCTextEntryFormatting.h"
25+
26+
#endif /* Bridging_Header_h */
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
// Copyright (c) 2017 CFT
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in all
11+
// copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
// SOFTWARE.
20+
21+
struct FormattingExampleItem
22+
{
23+
let text: String
24+
let detailText: String?
25+
let config: FTCTextEntryFormattingConfig
26+
let keyboard: UIKeyboardType
27+
}
28+
29+
extension FormattingExampleItem
30+
{
31+
static func makeItems() -> [FormattingExampleItem]
32+
{
33+
34+
return [
35+
self.makeCellPhoneItem(),
36+
self.makeMoneyItem(),
37+
self.makeCreditCardPANItem(),
38+
self.makeDriverLicenseModernItem(),
39+
self.makeDriverLicenseOutdatedItem(),
40+
]
41+
}
42+
43+
static func makeCellPhoneItem() -> FormattingExampleItem
44+
{
45+
let config = FTCTextEntryFormattingConfigFactory.mobilePhoneConfig(with: "+7 (___) ___ __ __", maskChar: "_")
46+
47+
return FormattingExampleItem(text: "Cell phone",
48+
detailText: nil,
49+
config: config,
50+
keyboard: .phonePad)
51+
}
52+
53+
static func makeMoneyItem() -> FormattingExampleItem
54+
{
55+
let config = FTCTextEntryFormattingConfigFactory.moneyConfig(with: nil, onlyIntegral: false)
56+
57+
return FormattingExampleItem(text: "Money",
58+
detailText: nil,
59+
config: config,
60+
keyboard: .decimalPad)
61+
}
62+
63+
static func makeCreditCardPANItem() -> FormattingExampleItem
64+
{
65+
let maskConfig = FTCMaskFormatterGenericConfig(mask: "XXXX XXXX XXXX XXXX XXX", maskCharacter: "X")
66+
maskConfig.cutTail = true
67+
68+
let maskFormatter = FTCMaskFormatter(config: maskConfig)
69+
let inputFilter = FTCDigitsValueFilter(maxLength: maskConfig.countMaskCharacters)
70+
71+
let config = FTCTextEntryFormattingConfig(formatter: maskFormatter, inputFilter: inputFilter)
72+
73+
return FormattingExampleItem(text: "Credit Card PAN",
74+
detailText: nil,
75+
config: config,
76+
keyboard: .numberPad)
77+
}
78+
79+
static func makeDriverLicenseModernItem() -> FormattingExampleItem
80+
{
81+
let maskConfig = FTCMaskFormatterGenericConfig(mask: "__ __ ______", maskCharacter: "_")
82+
maskConfig.cutTail = false
83+
84+
let maskFormatter = FTCMaskFormatter(config: maskConfig)
85+
let inputFilter = FTCDigitsValueFilter(maxLength: maskConfig.countMaskCharacters)
86+
87+
let config = FTCTextEntryFormattingConfig(formatter: maskFormatter, inputFilter: inputFilter)
88+
89+
return FormattingExampleItem(text: "Driver's license",
90+
detailText: "modern",
91+
config: config,
92+
keyboard: .numberPad)
93+
}
94+
95+
static func makeDriverLicenseOutdatedItem() -> FormattingExampleItem
96+
{
97+
let maskConfig = FTCMaskFormatterGenericConfig(mask: "__ __ № ______", maskCharacter: "_")
98+
maskConfig.cutTail = false
99+
100+
let maskFormatter = FTCMaskFormatter(config: maskConfig)
101+
let inputFilter = FTCToUpperCaseInputFilter()
102+
103+
let config = FTCTextEntryFormattingConfig(formatter: maskFormatter, inputFilter: inputFilter)
104+
105+
return FormattingExampleItem(text: "Driver's license",
106+
detailText: "outdated",
107+
config: config,
108+
keyboard: .default)
109+
}
110+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>APPL</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>1</string>
21+
<key>LSRequiresIPhoneOS</key>
22+
<true/>
23+
<key>UILaunchStoryboardName</key>
24+
<string>LaunchScreen</string>
25+
<key>UIMainStoryboardFile</key>
26+
<string>Main</string>
27+
<key>UIRequiredDeviceCapabilities</key>
28+
<array>
29+
<string>armv7</string>
30+
</array>
31+
<key>UISupportedInterfaceOrientations</key>
32+
<array>
33+
<string>UIInterfaceOrientationPortrait</string>
34+
<string>UIInterfaceOrientationLandscapeLeft</string>
35+
<string>UIInterfaceOrientationLandscapeRight</string>
36+
</array>
37+
</dict>
38+
</plist>

0 commit comments

Comments
 (0)