Skip to content

Commit f98cbff

Browse files
committed
Added navigation controller. Moved mimicrated tool bar to native navigation.
1 parent 490d103 commit f98cbff

File tree

7 files changed

+90
-49
lines changed

7 files changed

+90
-49
lines changed

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,46 @@
5454
debugDocumentVersioning = "YES"
5555
debugServiceExtension = "internal"
5656
allowLocationSimulation = "YES">
57-
<BuildableProductRunnable
58-
runnableDebuggingMode = "0">
57+
<RemoteRunnable
58+
runnableDebuggingMode = "2"
59+
BundleIdentifier = "com.apple.Carousel"
60+
RemotePath = "/(null)">
5961
<BuildableReference
6062
BuildableIdentifier = "primary"
6163
BlueprintIdentifier = "F4C33E2F26C932C8001A28B1"
6264
BuildableName = "watchOS Example.app"
6365
BlueprintName = "watchOS Example"
6466
ReferencedContainer = "container:NativeUIKit.xcodeproj">
6567
</BuildableReference>
66-
</BuildableProductRunnable>
68+
</RemoteRunnable>
6769
</LaunchAction>
6870
<ProfileAction
6971
buildConfiguration = "Release"
7072
shouldUseLaunchSchemeArgsEnv = "YES"
7173
savedToolIdentifier = ""
7274
useCustomWorkingDirectory = "NO"
7375
debugDocumentVersioning = "YES">
74-
<BuildableProductRunnable
75-
runnableDebuggingMode = "0">
76+
<RemoteRunnable
77+
runnableDebuggingMode = "2"
78+
BundleIdentifier = "com.apple.Carousel"
79+
RemotePath = "/(null)">
7680
<BuildableReference
7781
BuildableIdentifier = "primary"
7882
BlueprintIdentifier = "F4C33E2F26C932C8001A28B1"
7983
BuildableName = "watchOS Example.app"
8084
BlueprintName = "watchOS Example"
8185
ReferencedContainer = "container:NativeUIKit.xcodeproj">
8286
</BuildableReference>
83-
</BuildableProductRunnable>
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>
8497
</ProfileAction>
8598
<AnalyzeAction
8699
buildConfiguration = "Debug">

Example App/iOS Example/App/AppDelegate.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@
2121

2222
import UIKit
2323
import SparrowKit
24+
import NativeUIKit
2425

2526
@UIApplicationMain
2627
class AppDelegate: SPAppWindowDelegate {
2728

2829
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
29-
let rootController = RootController().wrapToNavigationController(prefersLargeTitles: false)
30-
makeKeyAndVisible(viewController: rootController, tint: .systemBlue)
30+
let rootController = RootController()
31+
let navigationController = NativeNavigationController(rootViewController: rootController)
32+
makeKeyAndVisible(viewController: navigationController, tint: .systemBlue)
3133
return true
3234
}
3335
}
36+

Example App/iOS Example/Scenes/RootController.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,18 @@ import NativeUIKit
2525

2626
class RootController: NativeScrollController {
2727

28-
let authToolBarView = NativeAppleAuthToolBarView().do {
28+
let actionToolBarView = NativeLargeActionToolBarView().do {
29+
$0.actionButton.setTitle("Action Button")
2930
$0.footerLabel.text = "Here footer text and it provided my developer and maybe some lines even."
3031
}
3132

3233
override func viewDidLoad() {
3334
super.viewDidLoad()
34-
self.toolBarView = authToolBarView
3535

36+
if let navigationController = self.navigationController as? NativeNavigationController {
37+
navigationController.mimicrateToolBarView = actionToolBarView
38+
}
39+
40+
scrollView.contentSize = .init(width: view.frame.width, height: 1000)
3641
}
3742
}

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.7'
4+
s.version = '1.0.8'
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 }
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// The MIT License (MIT)
2+
// Copyright © 2021 Ivan Vorobei ([email protected])
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in all
12+
// copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
// SOFTWARE.
21+
22+
#if canImport(UIKit) && (os(iOS))
23+
import UIKit
24+
import SparrowKit
25+
26+
open class NativeNavigationController: SPNavigationController {
27+
28+
// MARK: - Views
29+
30+
open var mimicrateToolBarView: NativeMimicrateToolBarView? = nil {
31+
willSet {
32+
if let toolBarView = mimicrateToolBarView {
33+
toolBarView.removeFromSuperview()
34+
}
35+
}
36+
didSet {
37+
if let toolBarView = mimicrateToolBarView {
38+
view.addSubview(toolBarView)
39+
}
40+
}
41+
}
42+
43+
// MARK: - Layout
44+
45+
open override func viewDidLayoutSubviews() {
46+
super.viewDidLayoutSubviews()
47+
if let toolBarView = mimicrateToolBarView {
48+
toolBarView.layoutMargins.bottom = systemSafeAreaInsets.bottom + 16
49+
toolBarView.setWidthAndFit(width: view.frame.width)
50+
toolBarView.frame.setMaxY(view.frame.height)
51+
let toolBarFrameFitHeight = toolBarView.frame.height - systemSafeAreaInsets.bottom
52+
if additionalSafeAreaInsets.bottom != toolBarFrameFitHeight {
53+
additionalSafeAreaInsets.bottom = toolBarFrameFitHeight
54+
}
55+
}
56+
}
57+
}
58+
#endif

Sources/NativeUIKit/Controllers/NativeScrollController.swift

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,6 @@ open class NativeScrollController: SPScrollController {
4646
}
4747
}
4848

49-
// MARK: - Views
50-
51-
open var toolBarView: NativeMimicrateToolBarView? = nil {
52-
willSet {
53-
if let toolBarView = toolBarView {
54-
toolBarView.removeFromSuperview()
55-
}
56-
}
57-
didSet {
58-
if let toolBarView = toolBarView {
59-
view.addSubview(toolBarView)
60-
}
61-
}
62-
}
63-
6449
// MARK: - Init
6550

6651
public override init() {
@@ -88,29 +73,6 @@ open class NativeScrollController: SPScrollController {
8873
}
8974
}
9075

91-
// MARK: - Lifecycle
92-
93-
open override func viewDidLoad() {
94-
super.viewDidLoad()
95-
96-
}
97-
98-
// MARK: - Layout
99-
100-
open override func viewDidLayoutSubviews() {
101-
super.viewDidLayoutSubviews()
102-
if let toolBarView = toolBarView {
103-
toolBarView.layoutMargins.bottom = systemSafeAreaInsets.bottom + 16
104-
toolBarView.setWidthAndFit(width: view.frame.width)
105-
toolBarView.frame.setMaxY(view.frame.height)
106-
let toolBarFrameFitHeight = toolBarView.frame.height - systemSafeAreaInsets.bottom
107-
if additionalSafeAreaInsets.bottom != toolBarFrameFitHeight {
108-
additionalSafeAreaInsets.bottom = toolBarFrameFitHeight
109-
}
110-
}
111-
112-
}
113-
11476
// MARK: - Models
11577

11678
public enum NavigationScrollBehavior {

0 commit comments

Comments
 (0)