Skip to content

Commit 0f8a6a1

Browse files
committed
Clean tinted. Added header controllers. Added NativeFooterView. Added menu diffable system.
1 parent ccb60f5 commit 0f8a6a1

27 files changed

Lines changed: 707 additions & 93 deletions

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let package = Package(
1515
dependencies: [
1616
.package(name: "SparrowKit", url: "https://github.com/ivanvorobei/SparrowKit", .exact("3.4.8")),
1717
.package(name: "SPPerspective", url: "https://github.com/ivanvorobei/SPPerspective", .exact("1.4.1")),
18-
.package(name: "SPDiffable", url: "https://github.com/ivanvorobei/SPDiffable", .exactItem("2.2.0"))
18+
.package(name: "SPDiffable", url: "https://github.com/ivanvorobei/SPDiffable", .exactItem("3.0.0"))
1919
],
2020
targets: [
2121
.target(

Sources/NativeUIKit/Bars/ToolBar/LargeAction/NativeLargeActionToolBarView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ open class NativeLargeActionToolBarView: NativeMimicrateToolBarView {
3030
public let activityIndicatorView = UIActivityIndicatorView()
3131

3232
public let actionButton = NativeLargeActionButton().do {
33-
$0.applyDefaultAppearance(with: .init(content: .white, background: .tint))
33+
$0.applyDefaultAppearance(with: .tintedColorful)
3434
}
3535

3636
public let footerLabel = SPLabel().do {

Sources/NativeUIKit/Bars/ToolBar/LargeAction/NativeLargeSmallActionToolBarView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ open class NativeLargeSmallActionToolBarView: NativeLargeActionToolBarView {
2828
// MARK: - Views
2929

3030
public let secondActionButton = SPDimmedButton().do {
31-
$0.applyDefaultAppearance(with: .init(content: .tint, background: .clear))
31+
$0.applyDefaultAppearance(with: .tintedContent)
3232
$0.titleLabel?.font = UIFont.preferredFont(forTextStyle: .headline, addPoints: -1)
3333
}
3434

Sources/NativeUIKit/Bars/ToolBar/NativeSmallActionToolBarView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import SparrowKit
2626
open class NativeSmallActionToolBarView: NativeMimicrateToolBarView {
2727

2828
public let actionButton = SPDimmedButton().do {
29-
$0.applyDefaultAppearance(with: .init(content: .tint, background: .clear))
29+
$0.applyDefaultAppearance(with: .tintedContent)
3030
$0.titleLabel?.font = UIFont.preferredFont(forTextStyle: .title3, weight: .semibold)
3131
}
3232

Sources/NativeUIKit/Controllers/Complex/Profile/NativeProfileController.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,5 @@ open class NativeProfileController: NativeHeaderTableController {
4747
super.viewDidLoad()
4848
navigationItem.title = .empty
4949
}
50-
51-
// MARK: - Public
52-
53-
open func setSpaceBetweenHeaderAndCells(_ value: CGFloat) {
54-
headerContainerView.layoutMargins.bottom = value
55-
}
5650
}
5751
#endif

Sources/NativeUIKit/Controllers/Scroll/NativeHeaderController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ open class NativeHeaderController: SPScrollController {
4949

5050
open override func viewDidLayoutSubviews() {
5151
super.viewDidLayoutSubviews()
52-
headerView.layout(y: .zero)
52+
headerView.layout(y: NativeLayout.Spaces.default)
5353
scrollView.contentSize = .init(width: view.frame.width, height: headerView.frame.maxY)
5454
}
5555
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// The MIT License (MIT)
2+
// Copyright © 2021 Ivan Vorobei (hello@ivanvorobei.by)
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+
@available(iOS 13.0, *)
27+
open class NativeHeaderFullWidthImageController: SPScrollController {
28+
29+
// MARK: - Views
30+
31+
public let headerImageView = SPImageView().do {
32+
$0.backgroundColor = .systemGray.alpha(0.1)
33+
$0.contentMode = .scaleAspectFill
34+
}
35+
36+
public let titlesView = NativeModalHeaderView()
37+
38+
// MARK: - Lifecycle
39+
40+
open override func viewDidLoad() {
41+
super.viewDidLoad()
42+
view.backgroundColor = .secondarySystemBackground
43+
scrollView.showsVerticalScrollIndicator = false
44+
scrollView.addSubviews([headerImageView, titlesView])
45+
navigationController?.navigationBar.setAppearance(.transparentAlways)
46+
}
47+
48+
// MARK: - Layout
49+
50+
open override func viewDidLayoutSubviews() {
51+
super.viewDidLayoutSubviews()
52+
headerImageView.frame = .init(x: .zero, y: -scrollView.layoutMargins.top, width: view.frame.width, height: view.frame.height * 0.45)
53+
titlesView.layout(y: headerImageView.frame.maxY + NativeLayout.Spaces.default_double)
54+
scrollView.contentSize = .init(
55+
width: view.frame.width,
56+
height: titlesView.frame.maxY + NativeLayout.Spaces.default_double
57+
)
58+
}
59+
}
60+
#endif

Sources/NativeUIKit/Controllers/Scroll/NativeHeaderTextFieldController.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,28 @@ open class NativeHeaderTextFieldController: NativeHeaderController {
3232
$0.autocapitalizationType = .words
3333
}
3434

35+
public let footerView = NativeFooterView()
36+
3537
// MARK: - Lifecycle
3638

3739
open override func viewDidLoad() {
3840
super.viewDidLoad()
3941
if #available(iOS 13.0, *) {
4042
view.backgroundColor = .systemBackground
4143
}
42-
view.addSubview(scrollView)
43-
scrollView.addSubview(textField)
44+
scrollView.addSubviews(textField, footerView)
45+
dismissKeyboardWhenTappedAround()
4446
}
4547

4648
// MARK: - Layout
4749

4850
open override func viewDidLayoutSubviews() {
4951
super.viewDidLayoutSubviews()
50-
textField.layout(y: headerView.frame.maxY + 24)
51-
scrollView.contentSize = .init(width: view.frame.width, height: textField.frame.maxY)
52+
textField.layout(y: headerView.frame.maxY + NativeLayout.Spaces.default + NativeLayout.Spaces.default_half)
53+
footerView.setWidthAndFit(width: textField.frame.width)
54+
footerView.frame.origin.x = textField.frame.origin.x
55+
footerView.frame.origin.y = textField.frame.maxY
56+
scrollView.contentSize = .init(width: view.frame.width, height: footerView.frame.maxY)
5257
}
5358
}
5459
#endif

Sources/NativeUIKit/Controllers/Table/Header/NativeHeaderTableController+HeaderContainerView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ extension NativeHeaderTableController {
4747
public override func commonInit() {
4848
super.commonInit()
4949
insetsLayoutMarginsFromSafeArea = false
50+
contentView.insetsLayoutMarginsFromSafeArea = false
5051
layoutMargins = .zero
5152
addSubview(contentView)
5253
}

Sources/NativeUIKit/Controllers/Table/Header/NativeHeaderTableController.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ open class NativeHeaderTableController: SPDiffableTableController {
4949

5050
open override func viewDidLayoutSubviews() {
5151
super.viewDidLayoutSubviews()
52+
headerContainerView.contentView.layoutMargins.left = tableView.layoutMargins.left
53+
headerContainerView.contentView.layoutMargins.right = tableView.layoutMargins.right
5254
headerContainerView.setWidthAndFit(width: view.frame.width)
5355
if cachedHeaderHeight != headerContainerView.frame.height {
5456
cachedHeaderHeight = headerContainerView.frame.height
@@ -61,5 +63,11 @@ open class NativeHeaderTableController: SPDiffableTableController {
6163
}
6264

6365
private var cachedHeaderHeight: CGFloat? = nil
66+
67+
// MARK: - Public
68+
69+
open func setSpaceBetweenHeaderAndCells(_ value: CGFloat) {
70+
headerContainerView.layoutMargins.bottom = value
71+
}
6472
}
6573
#endif

0 commit comments

Comments
 (0)