Skip to content

Commit 865b628

Browse files
committed
0.1.5
1 parent 5598c01 commit 865b628

4 files changed

Lines changed: 111 additions & 20 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44

55
+ (May) lookup baseline reset issue with overflowing text
66

7-
* Feature/Label_Styles/0.1.3
7+
* Feature/Label_Styles/0.1.5
8+
9+
+ Moved constants into `UI`
10+
+ Added `MockupViewController`
11+
12+
13+
* Feature/Label_Styles/0.1.3 - 0.1.4
814

915
+ Added scroll view to `PlanetViewController`
1016
+ Matched inspection border to Figma

UILabel_Typography_Extensions.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
5501DB9727D8240E009E0FDA /* UIButton+Styles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5501DB9627D8240E009E0FDA /* UIButton+Styles.swift */; };
1414
551B425F259BCE40001310A9 /* UIFont+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 551B425E259BCE40001310A9 /* UIFont+Extensions.swift */; };
1515
554AF31825961B6200A23E41 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 554AF31725961B6200A23E41 /* README.md */; };
16+
5558DA4627DA1FA900A4A178 /* MockupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5558DA4527DA1FA900A4A178 /* MockupViewController.swift */; };
1617
559795E525A259E400A757A3 /* UIColor+Styles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 559795E425A259E400A757A3 /* UIColor+Styles.swift */; };
1718
559E70FD27D90D0E00C00AD7 /* PlanetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 559E70FC27D90D0E00C00AD7 /* PlanetViewController.swift */; };
1819
559FB34E25A4B1A200CE795D /* LineHeightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 559FB34D25A4B1A200CE795D /* LineHeightViewController.swift */; };
@@ -43,6 +44,7 @@
4344
551B425E259BCE40001310A9 /* UIFont+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIFont+Extensions.swift"; sourceTree = "<group>"; };
4445
554A2DCF27D67B66008A4AE4 /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = "<group>"; };
4546
554AF31725961B6200A23E41 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
47+
5558DA4527DA1FA900A4A178 /* MockupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockupViewController.swift; sourceTree = "<group>"; };
4648
559795E425A259E400A757A3 /* UIColor+Styles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Styles.swift"; sourceTree = "<group>"; };
4749
559E70FC27D90D0E00C00AD7 /* PlanetViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlanetViewController.swift; sourceTree = "<group>"; };
4850
559FB34D25A4B1A200CE795D /* LineHeightViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineHeightViewController.swift; sourceTree = "<group>"; };
@@ -106,6 +108,7 @@
106108
559E70FE27D90D1200C00AD7 /* Planet */ = {
107109
isa = PBXGroup;
108110
children = (
111+
5558DA4527DA1FA900A4A178 /* MockupViewController.swift */,
109112
559E70FC27D90D0E00C00AD7 /* PlanetViewController.swift */,
110113
55BB9AD027D9685700599A5E /* Styles.swift */,
111114
);
@@ -263,6 +266,7 @@
263266
55F7E34125A0A91E00E7F48B /* LoremIpsumViewController.swift in Sources */,
264267
559795E525A259E400A757A3 /* UIColor+Styles.swift in Sources */,
265268
55BB9AD127D9685700599A5E /* Styles.swift in Sources */,
269+
5558DA4627DA1FA900A4A178 /* MockupViewController.swift in Sources */,
266270
55F7E34825A0AD7F00E7F48B /* AttributesViewController.swift in Sources */,
267271
55F236B725912BF20007BC69 /* MenuViewController.swift in Sources */,
268272
55F7E33E25A051FE00E7F48B /* UILabel+Grid.swift in Sources */,
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
//
2+
// MockupViewController.swift
3+
// UILabel_Typography_Extensions
4+
//
5+
// Created by Geri Borbás on 10/03/2022.
6+
//
7+
8+
import UIKit
9+
import SwiftUI
10+
11+
12+
class MockupViewController: UIViewController {
13+
14+
lazy var stackView = UIStackView()
15+
.vertical(spacing: 5)
16+
.views(
17+
UILabel()
18+
.withHeroStyle
19+
.with(text: "Mars"),
20+
UILabel()
21+
.withSubtitleStyle
22+
.with(text: "Martian (/ˈmɑːrʃən/)"),
23+
UIImageView(image: .init(named: "Placeholder")),
24+
UILabel()
25+
.withIntroStyle
26+
.with(text: "Mars is the fourth planet from the Sun and the second-smallest planet in the Solar System, being larger than only Mercury. In English, Mars carries the name of the Roman god of war and is often referred to as the \"Red Planet\". The latter refers to the effect of the iron oxide prevalent on Mars's surface.".uppercased()),
27+
UILabel()
28+
.withTitleStyle
29+
.with(text: "History"),
30+
UILabel()
31+
.withParagraphStyle
32+
.with(text: "The days and seasons are comparable to those of Earth, because the rotation period as well as the tilt of the rotational axis relative to the ecliptic plane are similar. Mars is the site of Olympus Mons, the largest volcano and highest known mountain on any planet in the Solar System, and of Valles Marineris, one of the largest canyons in the Solar System. The smooth Borealis basin in the Northern Hemisphere covers 40% of the planet and may be a giant impact feature. Mars has two moons, Phobos and Deimos, which are small and irregularly shaped.\n\nMars has been explored by several uncrewed spacecraft. Mariner 4 was the first spacecraft to visit Mars; launched by NASA on 28 November 1964, it made its closest approach to the planet on 15 July 1965. Mariner 4 detected the weak Martian radiation belt, measured at about 0.1% that of Earth, and captured the first images of another planet from deep space. The latest spacecraft to successfully land on Mars are CNSA's Tianwen-1 lander and Zhurong rover, landed on 14 May 2021.")
33+
)
34+
.with {
35+
$0.setCustomSpacing(30, after: $0.subviews[3])
36+
$0.setCustomSpacing(30, after: $0.subviews[5])
37+
}
38+
39+
lazy var scrollView = UIScrollView()
40+
.with {
41+
$0.clipsToBounds = false
42+
}
43+
44+
override func viewDidLoad() {
45+
super.viewDidLoad()
46+
47+
// Colors.
48+
view.backgroundColor = UI.Color.background
49+
50+
// Hierarchy.
51+
view.addSubview(scrollView)
52+
scrollView.addSubview(stackView)
53+
scrollView.pin(
54+
to: view.safeAreaLayoutGuide,
55+
insets: .zero
56+
)
57+
stackView.pin(
58+
to: scrollView,
59+
insets: UI.padding
60+
)
61+
62+
// Vertical scrolling.
63+
stackView.widthAnchor.constraint(
64+
equalTo: scrollView.widthAnchor,
65+
constant: -UI.padding.left - UI.padding.right
66+
).isActive = true
67+
}
68+
}
69+
70+
71+
struct MockupViewController_Previews: PreviewProvider {
72+
static var previews: some View {
73+
Group {
74+
PreviewView(for: MockupViewController())
75+
.environment(\.colorScheme, .light)
76+
.edgesIgnoringSafeArea(.all)
77+
}
78+
}
79+
}

UILabel_Typography_Extensions/Menu/Planet/PlanetViewController.swift

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@ import SwiftUI
1111

1212
class PlanetViewController: UIViewController {
1313

14-
lazy var heroLabel = UILabel().withHeroStyle.inspect
15-
lazy var subtitleLabel = UILabel().withSubtitleStyle.inspect
16-
lazy var image = UIImageView().inspect
17-
lazy var introLabel = UILabel().withIntroStyle.inspect
18-
lazy var titleLabel = UILabel().withTitleStyle.inspect
19-
lazy var paragraphLabel = UILabel().withParagraphStyle.inspect
14+
lazy var heroLabel = UILabel().withHeroStyle
15+
lazy var subtitleLabel = UILabel().withSubtitleStyle
16+
lazy var image = UIImageView()
17+
lazy var introLabel = UILabel().withIntroStyle
18+
lazy var titleLabel = UILabel().withTitleStyle
19+
lazy var paragraphLabel = UILabel().withParagraphStyle
2020

2121
lazy var stackView = UIStackView()
2222
.vertical(spacing: UI.StackView.spacing)
2323
.views(
24-
heroLabel,
25-
subtitleLabel,
26-
image,
27-
introLabel,
28-
titleLabel,
29-
paragraphLabel
24+
heroLabel.inspect,
25+
subtitleLabel.inspect,
26+
image.inspect,
27+
introLabel.inspect,
28+
titleLabel.inspect,
29+
paragraphLabel.inspect
3030
)
3131
.with {
32-
$0.setCustomSpacing(20 + 2 * UI.StackView.spacing, after: introLabel)
33-
$0.setCustomSpacing(20 + 2 * UI.StackView.spacing, after: titleLabel)
32+
$0.setCustomSpacing(UI.StackView.spacer + 2 * UI.StackView.spacing, after: introLabel)
33+
$0.setCustomSpacing(UI.StackView.spacer + 2 * UI.StackView.spacing, after: titleLabel)
3434
}
3535

3636
lazy var scrollView = UIScrollView()
@@ -42,7 +42,7 @@ class PlanetViewController: UIViewController {
4242
super.viewDidLoad()
4343

4444
// Colors.
45-
view.backgroundColor = .background
45+
view.backgroundColor = UI.Color.background
4646
overrideUserInterfaceStyle = .dark
4747

4848
// Hierarchy.
@@ -69,9 +69,9 @@ class PlanetViewController: UIViewController {
6969

7070
// Data.
7171
heroLabel.text = "Mars"
72-
heroLabel.textColor = .mars
72+
heroLabel.textColor = UI.Color.mars
7373
subtitleLabel.text = "Martian (/ˈmɑːrʃən/)"
74-
image.image = .init(named: "Mars")
74+
image.image = UI.Asset.mars
7575
introLabel.text = "Mars is the fourth planet from the Sun and the second-smallest planet in the Solar System, being larger than only Mercury. In English, Mars carries the name of the Roman god of war and is often referred to as the \"Red Planet\". The latter refers to the effect of the iron oxide prevalent on Mars's surface.".uppercased()
7676
titleLabel.text = "History"
7777
paragraphLabel.text = """
@@ -85,8 +85,10 @@ class PlanetViewController: UIViewController {
8585

8686
struct PlanetViewController_Previews: PreviewProvider {
8787
static var previews: some View {
88-
PreviewView(for: PlanetViewController())
89-
.environment(\.colorScheme, .dark)
88+
Group {
89+
PreviewView(for: PlanetViewController())
90+
.environment(\.colorScheme, .dark)
9091
.edgesIgnoringSafeArea(.all)
92+
}
9193
}
9294
}

0 commit comments

Comments
 (0)