Skip to content

Commit 490d103

Browse files
committed
Added toolbar for apple auth.
1 parent 26e89f1 commit 490d103

File tree

6 files changed

+59
-59
lines changed

6 files changed

+59
-59
lines changed

Example App/NativeUIKit.xcodeproj/xcshareddata/xcschemes/watchOS Example.xcscheme

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,46 +54,33 @@
5454
debugDocumentVersioning = "YES"
5555
debugServiceExtension = "internal"
5656
allowLocationSimulation = "YES">
57-
<RemoteRunnable
58-
runnableDebuggingMode = "2"
59-
BundleIdentifier = "com.apple.Carousel"
60-
RemotePath = "/(null)">
57+
<BuildableProductRunnable
58+
runnableDebuggingMode = "0">
6159
<BuildableReference
6260
BuildableIdentifier = "primary"
6361
BlueprintIdentifier = "F4C33E2F26C932C8001A28B1"
6462
BuildableName = "watchOS Example.app"
6563
BlueprintName = "watchOS Example"
6664
ReferencedContainer = "container:NativeUIKit.xcodeproj">
6765
</BuildableReference>
68-
</RemoteRunnable>
66+
</BuildableProductRunnable>
6967
</LaunchAction>
7068
<ProfileAction
7169
buildConfiguration = "Release"
7270
shouldUseLaunchSchemeArgsEnv = "YES"
7371
savedToolIdentifier = ""
7472
useCustomWorkingDirectory = "NO"
7573
debugDocumentVersioning = "YES">
76-
<RemoteRunnable
77-
runnableDebuggingMode = "2"
78-
BundleIdentifier = "com.apple.Carousel"
79-
RemotePath = "/(null)">
74+
<BuildableProductRunnable
75+
runnableDebuggingMode = "0">
8076
<BuildableReference
8177
BuildableIdentifier = "primary"
8278
BlueprintIdentifier = "F4C33E2F26C932C8001A28B1"
8379
BuildableName = "watchOS Example.app"
8480
BlueprintName = "watchOS Example"
8581
ReferencedContainer = "container:NativeUIKit.xcodeproj">
8682
</BuildableReference>
87-
</RemoteRunnable>
88-
<MacroExpansion>
89-
<BuildableReference
90-
BuildableIdentifier = "primary"
91-
BlueprintIdentifier = "F4C33E2F26C932C8001A28B1"
92-
BuildableName = "watchOS Example.app"
93-
BlueprintName = "watchOS Example"
94-
ReferencedContainer = "container:NativeUIKit.xcodeproj">
95-
</BuildableReference>
96-
</MacroExpansion>
83+
</BuildableProductRunnable>
9784
</ProfileAction>
9885
<AnalyzeAction
9986
buildConfiguration = "Debug">

Example App/iOS Example/Scenes/RootController.swift

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,15 @@ import UIKit
2323
import SparrowKit
2424
import NativeUIKit
2525

26-
class RootController: SPController {
26+
class RootController: NativeScrollController {
2727

28+
let authToolBarView = NativeAppleAuthToolBarView().do {
29+
$0.footerLabel.text = "Here footer text and it provided my developer and maybe some lines even."
30+
}
2831

29-
let promoView = NativePromoView()
30-
3132
override func viewDidLoad() {
3233
super.viewDidLoad()
33-
view.backgroundColor = .secondarySystemBackground
34-
35-
promoView.button.setTitle("Example")
36-
promoView.descriptionLabel.text = "fdsfs"
37-
promoView.titleLabel.text = "fsdfdsfs"
38-
view.addSubview(promoView)
39-
40-
delay(2, closure: {
41-
print("call")
42-
UIApplication.shared.windows.forEach({ $0.tintColor = UIColor.systemColorfulColors.randomElement()! })
43-
})
34+
self.toolBarView = authToolBarView
4435

45-
delay(4, closure: {
46-
print("call")
47-
UIApplication.shared.windows.forEach({ $0.tintColor = UIColor.systemColorfulColors.randomElement()! })
48-
})
49-
50-
delay(6, closure: {
51-
print("call")
52-
UIApplication.shared.windows.forEach({ $0.tintColor = UIColor.systemColorfulColors.randomElement()! })
53-
})
54-
}
55-
56-
override func viewDidLayoutSubviews() {
57-
super.viewDidLayoutSubviews()
58-
promoView.layout(y: 100)
5936
}
6037
}

NativeUIKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = 'NativeUIKit'
4-
s.version = '1.0.6'
4+
s.version = '1.0.7'
55
s.summary = 'Mimicrated views and controls to native Apple appearance.'
66
s.homepage = 'https://github.com/ivanvorobei/NativeUIKit'
77
s.source = { :git => 'https://github.com/ivanvorobei/NativeUIKit.git', :tag => s.version }

Sources/NativeUIKit/Bars/ToolBar/NativeLargeActionFooterToolBarView.swift renamed to Sources/NativeUIKit/Bars/ToolBar/NativeAppleAuthToolBarView.swift

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,57 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
// SOFTWARE.
2121

22-
#if canImport(UIKit) && (os(iOS))
22+
#if canImport(UIKit) && canImport(AuthenticationServices) && (os(iOS))
2323
import UIKit
2424
import SparrowKit
25+
import AuthenticationServices
2526

26-
open class NativeLargeActionFooterToolBarView: NativeLargeActionToolBarView {
27+
@available(iOS 13.0, *)
28+
open class NativeAppleAuthToolBarView: NativeMimicrateToolBarView {
2729

2830
// MARK: - Views
2931

32+
public let authButton = ASAuthorizationAppleIDButton()
33+
3034
public let footerLabel = SPLabel().do {
3135
$0.font = .preferredFont(forTextStyle: .footnote)
32-
if #available(iOS 13.0, *) {
33-
$0.textColor = .secondaryLabel
34-
} else {
35-
$0.textColor = .black.alpha(0.5)
36-
}
36+
$0.numberOfLines = .zero
37+
$0.textColor = .secondaryLabel
3738
}
3839

3940
// MARK: - Init
4041

4142
open override func commonInit() {
4243
super.commonInit()
44+
addSubview(authButton)
4345
addSubview(footerLabel)
4446
}
4547

4648
// MARK: - Layout
4749

50+
internal let footerLeftInset: CGFloat = 20
51+
4852
open override func layoutSubviews() {
4953
super.layoutSubviews()
50-
let inset: CGFloat = 16
51-
footerLabel.layoutDynamicHeight(x: layoutMargins.left + inset, y: actionButton.frame.maxY + 12, width: layoutWidth - inset)
54+
55+
let authButtonWidth = min(readableWidth, NativeLayout.Sizes.actionable_area_maximum_width)
56+
authButton.frame.setWidth(authButtonWidth)
57+
authButton.frame.setHeight(52)
58+
authButton.setXCenter()
59+
authButton.frame.origin.y = layoutMargins.top
60+
61+
if footerLabel.text != nil {
62+
footerLabel.layoutDynamicHeight(x: layoutMargins.left + footerLeftInset, y: authButton.frame.maxY + 12, width: layoutWidth - footerLeftInset)
63+
}
5264
}
5365

5466
open override func sizeThatFits(_ size: CGSize) -> CGSize {
5567
layoutSubviews()
56-
return .init(width: size.width, height: footerLabel.frame.maxY + layoutMargins.bottom)
68+
if footerLabel.text == nil {
69+
return .init(width: size.width, height: authButton.frame.maxY + layoutMargins.bottom)
70+
} else {
71+
return .init(width: size.width, height: footerLabel.frame.maxY + layoutMargins.bottom)
72+
}
5773
}
5874
}
5975
#endif

Sources/NativeUIKit/Bars/ToolBar/NativeLargeActionToolBarView.swift

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,43 @@ open class NativeLargeActionToolBarView: NativeMimicrateToolBarView {
3131
$0.applyDefaultAppearance(with: .init(content: .white, background: .tint))
3232
}
3333

34+
public let footerLabel = SPLabel().do {
35+
$0.font = .preferredFont(forTextStyle: .footnote)
36+
$0.numberOfLines = .zero
37+
if #available(iOS 13.0, *) {
38+
$0.textColor = .secondaryLabel
39+
} else {
40+
$0.textColor = .black.alpha(0.5)
41+
}
42+
}
43+
3444
// MARK: - Init
3545

3646
open override func commonInit() {
3747
super.commonInit()
3848
addSubview(actionButton)
49+
addSubview(footerLabel)
3950
}
4051

4152
// MARK: - Layout
4253

54+
internal let footerLeftInset: CGFloat = 20
55+
4356
open override func layoutSubviews() {
4457
super.layoutSubviews()
4558
actionButton.layout(y: layoutMargins.top)
59+
if footerLabel.text != nil {
60+
footerLabel.layoutDynamicHeight(x: layoutMargins.left + footerLeftInset, y: actionButton.frame.maxY + 12, width: layoutWidth - footerLeftInset)
61+
}
4662
}
4763

4864
open override func sizeThatFits(_ size: CGSize) -> CGSize {
4965
layoutSubviews()
50-
return .init(width: size.width, height: actionButton.frame.maxY + layoutMargins.bottom)
66+
if footerLabel.text == nil {
67+
return .init(width: size.width, height: actionButton.frame.maxY + layoutMargins.bottom)
68+
} else {
69+
return .init(width: size.width, height: footerLabel.frame.maxY + layoutMargins.bottom)
70+
}
5171
}
5272
}
5373
#endif

0 commit comments

Comments
 (0)