Skip to content

Commit 7947562

Browse files
committed
examples in progress; experement with github actions
1 parent a6763c2 commit 7947562

12 files changed

+50
-21
lines changed

.github/workflows/swift.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@ name: Swift
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [ main, paddings_for_formatting_tf ]
66
pull_request:
77
branches: [ main ]
88

99
jobs:
1010
build:
11-
1211
runs-on: macos-latest
13-
1412
steps:
1513
- uses: actions/checkout@v2
16-
# - name: Build
17-
# run: xcodebuild build -scheme AGInputControls -verbose
1814
- name: Run tests
19-
run: xcodebuild -scheme AGInputControlsTests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone SE (2nd generation),OS=16.2' test
15+
run: release.sh
16+
# run: xcodebuild -scheme AGInputControlsTests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone SE (2nd generation),OS=16.2' test

AGInputControls.xcodeproj/project.pbxproj

+14-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
D6ABBDF4272AE0220064473E /* DefaultFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6ABBDF3272AE0220064473E /* DefaultFormatter.swift */; };
3434
D6ABBDF6272AE1C60064473E /* DefaultFormatterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6ABBDF5272AE1C60064473E /* DefaultFormatterTests.swift */; };
3535
D6ABBDFC272D7F860064473E /* AGFormatter+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6ABBDFB272D7F860064473E /* AGFormatter+Extension.swift */; };
36+
D6B1E49B2BAE3F2F00DD8301 /* OTPViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6B1E49A2BAE3F2F00DD8301 /* OTPViewController.swift */; };
3637
D6C9B7D22684DE9A00F08CAA /* AGInputControls.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6A6F5B92684BC9700157970 /* AGInputControls.framework */; };
3738
D6C9B7D32684DE9A00F08CAA /* AGInputControls.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D6A6F5B92684BC9700157970 /* AGInputControls.framework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
3839
D6C9B7DC2685F65600F08CAA /* PhoneTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C9B7DB2685F65600F08CAA /* PhoneTextField.swift */; };
@@ -105,6 +106,7 @@
105106
D6ABBDF3272AE0220064473E /* DefaultFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultFormatter.swift; sourceTree = "<group>"; };
106107
D6ABBDF5272AE1C60064473E /* DefaultFormatterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultFormatterTests.swift; sourceTree = "<group>"; };
107108
D6ABBDFB272D7F860064473E /* AGFormatter+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AGFormatter+Extension.swift"; sourceTree = "<group>"; };
109+
D6B1E49A2BAE3F2F00DD8301 /* OTPViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OTPViewController.swift; sourceTree = "<group>"; };
108110
D6C9B7DB2685F65600F08CAA /* PhoneTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhoneTextField.swift; sourceTree = "<group>"; };
109111
D6EC7C0F2B97A58400190184 /* PaddingTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaddingTextField.swift; sourceTree = "<group>"; };
110112
D6EC7C112B97C96200190184 /* MenuViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuViewController.swift; sourceTree = "<group>"; };
@@ -222,18 +224,27 @@
222224
D6A6F5E02684BD9900157970 /* Examples */ = {
223225
isa = PBXGroup;
224226
children = (
225-
D6306F242BA319B300A8B54C /* Base */,
227+
D6B1E4992BAE3E1600DD8301 /* ViewControllers */,
226228
D6306F232BA24AD500A8B54C /* App */,
227229
D6A6F5E52684BD9A00157970 /* ViewController.swift */,
228230
D6A6F5E72684BD9A00157970 /* Main.storyboard */,
229231
D6A6F5EA2684BD9B00157970 /* Assets.xcassets */,
230232
D6A6F5EC2684BD9B00157970 /* LaunchScreen.storyboard */,
231233
D6A6F5EF2684BD9B00157970 /* Info.plist */,
234+
);
235+
path = Examples;
236+
sourceTree = "<group>";
237+
};
238+
D6B1E4992BAE3E1600DD8301 /* ViewControllers */ = {
239+
isa = PBXGroup;
240+
children = (
232241
D6EC7C112B97C96200190184 /* MenuViewController.swift */,
242+
D6B1E49A2BAE3F2F00DD8301 /* OTPViewController.swift */,
233243
D6EC7C132B97CC4400190184 /* FloatingLabelViewController.swift */,
234244
D6493E472B9875580076841F /* PhoneFieldViewController.swift */,
245+
D6306F242BA319B300A8B54C /* Base */,
235246
);
236-
path = Examples;
247+
path = ViewControllers;
237248
sourceTree = "<group>";
238249
};
239250
D6C9B7D12684DE9A00F08CAA /* Frameworks */ = {
@@ -420,6 +431,7 @@
420431
D6306F282BA319E400A8B54C /* Entry.swift in Sources */,
421432
D6493E482B9875580076841F /* PhoneFieldViewController.swift in Sources */,
422433
D6A6F5E62684BD9A00157970 /* ViewController.swift in Sources */,
434+
D6B1E49B2BAE3F2F00DD8301 /* OTPViewController.swift in Sources */,
423435
D6EC7C142B97CC4400190184 /* FloatingLabelViewController.swift in Sources */,
424436
D6306F262BA319C100A8B54C /* StackViewController.swift in Sources */,
425437
D6A6F5E22684BD9900157970 /* AppDelegate.swift in Sources */,

AGInputControls/Source/FloatingLabelTextField.swift

+5-8
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ open class FloatingLabelTextField : FormattingTextField {
3838
open var errorTintColor: UIColor = .red
3939

4040
/// Indicates, is textfield is in error state or not.
41-
open var isError: Bool = false {
41+
open var hasError: Bool = false {
4242
didSet {
43-
if isError {
43+
if hasError {
4444
if nonErrorTintColor == nil {
4545
nonErrorTintColor = tintColor
4646
}
@@ -114,7 +114,7 @@ open class FloatingLabelTextField : FormattingTextField {
114114
let lineHeight = font!.lineHeight
115115
let paddings: CGFloat = textPadding.top + textPadding.bottom
116116
let topLabelHeight = lineHeight * floatingLabelScaleFactor
117-
height = lineHeight + paddings + 1 + topLabelHeight + floatingLabelBottomPadding
117+
height = lineHeight + paddings + underlineHeight + topLabelHeight + floatingLabelBottomPadding
118118
let bottomHeight: CGFloat = hasBottomText ? bottomLabelHeight + bottomTextTopPadding : 0
119119
return CGSize(width: UIScreen.main.bounds.width * 0.75, height: height + bottomHeight)
120120
}
@@ -223,7 +223,7 @@ open class FloatingLabelTextField : FormattingTextField {
223223

224224
var color: UIColor?
225225

226-
if isError {
226+
if hasError {
227227
color = errorTintColor
228228
} else if isFirstResponder && highlightsWhenActive {
229229
color = tintColor
@@ -287,7 +287,7 @@ open class FloatingLabelTextField : FormattingTextField {
287287
let path = UIBezierPath(roundedRect: borderRect, cornerRadius: cornerRadius)
288288

289289
var color: UIColor?
290-
if isError {
290+
if hasError {
291291
color = errorTintColor
292292
} else {
293293
color = isFirstResponder && highlightsWhenActive ? tintColor : placeholderColor
@@ -315,8 +315,6 @@ open class FloatingLabelTextField : FormattingTextField {
315315
guard formatter is PhoneNumberFormatter else { return }
316316
if isFirstResponder && text.isEmptyOrTrue {
317317
super.drawExampleMask(rect: rect)
318-
} else {
319-
320318
}
321319
}
322320

@@ -384,7 +382,6 @@ open class FloatingLabelTextField : FormattingTextField {
384382
}
385383

386384
open override func resignFirstResponder() -> Bool {
387-
388385
let value = super.resignFirstResponder()
389386

390387
if value {

AGInputControls/Source/FormattingTextField.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ open class FormattingTextField: PaddingTextField {
273273
}
274274

275275
open func drawExampleMask(rect: CGRect) {
276-
assertForExampleMasksAndPrefix()
276+
// assertForExampleMasksAndPrefix()
277277
let text = text ?? ""
278278

279279
guard let mask = exampleMask,

Examples/App/SceneDelegate.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
1313

1414

1515
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
16-
guard let _ = (scene as? UIWindowScene) else { return }
16+
guard let scene = (scene as? UIWindowScene) else { return }
17+
window = scene.windows.first
18+
window?.rootViewController = UINavigationController(
19+
rootViewController: MenuViewController(style: .insetGrouped)
20+
)
21+
window?.makeKeyAndVisible()
1722
}
1823
}
1924

Examples/ViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class ViewController: UIViewController {
131131
guard let tf = textField as? FloatingLabelTextField else { return }
132132
let isError = tf.text!.count % 2 == 0
133133
tf.bottomText = isError ? "Incorrect card format" : nil
134-
tf.isError = isError
134+
tf.hasError = isError
135135
}
136136

137137
@objc func didTapClear() {
File renamed without changes.

Examples/FloatingLabelViewController.swift Examples/ViewControllers/FloatingLabelViewController.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ final class FloatingLabelViewController: StackViewController {
6565
floatingPhoneTextField.formatter = PhoneNumberFormatter(mask: "+7 (###) ### ##-##")
6666
floatingPhoneTextField.exampleMask = "+7 (123) 456 78-90"
6767
// floatingPhoneTextField.exampleMask = "+7 (___) ___ __-__"
68+
floatingPhoneTextField.exampleMask = "+7 ("
6869
floatingPhoneTextField.font = .systemFont(ofSize: 24)
6970

70-
stackView.addArrangedSubview(Entry(title: "No formatting", targetView: floatingFieldNoFormatting))
71+
stackView.addArrangedSubview(Entry(title: "No formatting", targetView: floatingFieldNoFormatting, needsTrailingConstraint: true))
7172
stackView.addArrangedSubview(Entry(title: "Regular formatting", targetView: floatTextField))
7273
stackView.addArrangedSubview(Entry(title: "Phone floating textfield", targetView: floatingPhoneTextField))
7374
}
@@ -77,7 +78,7 @@ final class FloatingLabelViewController: StackViewController {
7778
guard let tf = textField as? FloatingLabelTextField else { return }
7879
let isError = tf.text!.count % 2 == 0
7980
tf.bottomText = isError ? "Incorrect card format" : nil
80-
tf.isError = isError
81+
tf.hasError = isError
8182
}
8283

8384
@objc func didTapClear() {

Examples/MenuViewController.swift Examples/ViewControllers/MenuViewController.swift

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ final class MenuViewController: UITableViewController {
1313
super.viewDidLoad()
1414
title = "AGInputControls"
1515
tableView.backgroundColor = .systemGroupedBackground
16+
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
1617
}
1718

1819

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// OTPViewController.swift
3+
// Examples
4+
//
5+
// Created by Igor Vedeneev on 22/03/2024.
6+
//
7+
8+
import UIKit
9+
import AGInputControls
10+
11+
final class OTPViewController: StackViewController {
12+
13+
override func viewDidLoad() {
14+
super.viewDidLoad()
15+
}
16+
}

0 commit comments

Comments
 (0)