Skip to content

Commit 6e7f906

Browse files
committed
Fix *LayerWrapperView bugs, add *LayerWrapperDemo
1 parent db1e7c5 commit 6e7f906

13 files changed

Lines changed: 321 additions & 89 deletions

File tree

Demo/Demo.xcodeproj/project.pbxproj

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
/* Begin PBXBuildFile section */
1010
080677C628BE7D8B00000E16 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 080677C528BE7D8B00000E16 /* ViewController.swift */; };
1111
080677C828BE7DA400000E16 /* WrapStackDemoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 080677C728BE7DA400000E16 /* WrapStackDemoViewController.swift */; };
12+
08A24B8428E49A9600CDD7E2 /* LookinServer in Frameworks */ = {isa = PBXBuildFile; productRef = 08A24B8328E49A9600CDD7E2 /* LookinServer */; };
13+
08A24B8628E49C7A00CDD7E2 /* HVStackWrapperViewDemoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08A24B8528E49C7A00CDD7E2 /* HVStackWrapperViewDemoViewController.swift */; };
1214
08E16CD9289ABA1C0019D7CB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08E16CD8289ABA1C0019D7CB /* AppDelegate.swift */; };
1315
08E16CDB289ABA1C0019D7CB /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08E16CDA289ABA1C0019D7CB /* SceneDelegate.swift */; };
1416
08E16CDD289ABA1C0019D7CB /* HVStackDemoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08E16CDC289ABA1C0019D7CB /* HVStackDemoViewController.swift */; };
@@ -22,6 +24,7 @@
2224
/* Begin PBXFileReference section */
2325
080677C528BE7D8B00000E16 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
2426
080677C728BE7DA400000E16 /* WrapStackDemoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WrapStackDemoViewController.swift; sourceTree = "<group>"; };
27+
08A24B8528E49C7A00CDD7E2 /* HVStackWrapperViewDemoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HVStackWrapperViewDemoViewController.swift; sourceTree = "<group>"; };
2528
08E16CD5289ABA1C0019D7CB /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; };
2629
08E16CD8289ABA1C0019D7CB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
2730
08E16CDA289ABA1C0019D7CB /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
@@ -39,6 +42,7 @@
3942
buildActionMask = 2147483647;
4043
files = (
4144
08F2594E28BD06150098174B /* PinLayout in Frameworks */,
45+
08A24B8428E49A9600CDD7E2 /* LookinServer in Frameworks */,
4246
08F2594C28BD060D0098174B /* StackKit in Frameworks */,
4347
);
4448
runOnlyForDeploymentPostprocessing = 0;
@@ -71,6 +75,7 @@
7175
08E16CDA289ABA1C0019D7CB /* SceneDelegate.swift */,
7276
080677C528BE7D8B00000E16 /* ViewController.swift */,
7377
08E16CDC289ABA1C0019D7CB /* HVStackDemoViewController.swift */,
78+
08A24B8528E49C7A00CDD7E2 /* HVStackWrapperViewDemoViewController.swift */,
7479
080677C728BE7DA400000E16 /* WrapStackDemoViewController.swift */,
7580
08E16CDE289ABA1C0019D7CB /* Main.storyboard */,
7681
08E16CE1289ABA1D0019D7CB /* Assets.xcassets */,
@@ -114,6 +119,7 @@
114119
packageProductDependencies = (
115120
08F2594B28BD060D0098174B /* StackKit */,
116121
08F2594D28BD06150098174B /* PinLayout */,
122+
08A24B8328E49A9600CDD7E2 /* LookinServer */,
117123
);
118124
productName = TestStackKit;
119125
productReference = 08E16CD5289ABA1C0019D7CB /* Demo.app */;
@@ -145,6 +151,7 @@
145151
mainGroup = 08E16CCC289ABA1C0019D7CB;
146152
packageReferences = (
147153
085CA41F28BD0521000E74CD /* XCRemoteSwiftPackageReference "pinlayout" */,
154+
08A24B8228E49A9600CDD7E2 /* XCRemoteSwiftPackageReference "LookinServer" */,
148155
);
149156
productRefGroup = 08E16CD6289ABA1C0019D7CB /* Products */;
150157
projectDirPath = "";
@@ -176,6 +183,7 @@
176183
080677C628BE7D8B00000E16 /* ViewController.swift in Sources */,
177184
08E16CDD289ABA1C0019D7CB /* HVStackDemoViewController.swift in Sources */,
178185
080677C828BE7DA400000E16 /* WrapStackDemoViewController.swift in Sources */,
186+
08A24B8628E49C7A00CDD7E2 /* HVStackWrapperViewDemoViewController.swift in Sources */,
179187
08E16CD9289ABA1C0019D7CB /* AppDelegate.swift in Sources */,
180188
08E16CDB289ABA1C0019D7CB /* SceneDelegate.swift in Sources */,
181189
);
@@ -405,9 +413,22 @@
405413
minimumVersion = 1.0.0;
406414
};
407415
};
416+
08A24B8228E49A9600CDD7E2 /* XCRemoteSwiftPackageReference "LookinServer" */ = {
417+
isa = XCRemoteSwiftPackageReference;
418+
repositoryURL = "https://github.com/QMUI/LookinServer/";
419+
requirement = {
420+
branch = develop;
421+
kind = branch;
422+
};
423+
};
408424
/* End XCRemoteSwiftPackageReference section */
409425

410426
/* Begin XCSwiftPackageProductDependency section */
427+
08A24B8328E49A9600CDD7E2 /* LookinServer */ = {
428+
isa = XCSwiftPackageProductDependency;
429+
package = 08A24B8228E49A9600CDD7E2 /* XCRemoteSwiftPackageReference "LookinServer" */;
430+
productName = LookinServer;
431+
};
411432
08F2594B28BD060D0098174B /* StackKit */ = {
412433
isa = XCSwiftPackageProductDependency;
413434
productName = StackKit;

Demo/Demo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Demo/Demo/Base.lproj/Main.storyboard

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="9VV-h8-9cl">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21225" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="9VV-h8-9cl">
33
<device id="retina6_1" orientation="portrait" appearance="light"/>
44
<dependencies>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
67
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
78
<capability name="System colors in document resources" minToolsVersion="11.0"/>
89
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -17,18 +18,26 @@
1718
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1819
<subviews>
1920
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="21" translatesAutoresizingMaskIntoConstraints="NO" id="M84-Lf-Gfo">
20-
<rect key="frame" x="144.5" y="406.5" width="125.5" height="83"/>
21+
<rect key="frame" x="87.5" y="375.5" width="239" height="145.5"/>
2122
<subviews>
2223
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="06f-Ws-ezl">
23-
<rect key="frame" x="0.0" y="0.0" width="125.5" height="31"/>
24+
<rect key="frame" x="0.0" y="0.0" width="239" height="34.5"/>
2425
<state key="normal" title="Button"/>
2526
<buttonConfiguration key="configuration" style="filled" title="H/VStackView"/>
2627
<connections>
2728
<segue destination="hGA-TO-DpM" kind="show" id="CVz-1t-QBY"/>
2829
</connections>
2930
</button>
31+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="iYP-HX-gHv">
32+
<rect key="frame" x="0.0" y="55.5" width="239" height="34.5"/>
33+
<state key="normal" title="Button"/>
34+
<buttonConfiguration key="configuration" style="filled" title="H/VStackLayerWrapperView"/>
35+
<connections>
36+
<segue destination="5WQ-Nd-2jr" kind="show" id="Knm-qG-ruH"/>
37+
</connections>
38+
</button>
3039
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Dpb-UY-wFq">
31-
<rect key="frame" x="0.0" y="52" width="125.5" height="31"/>
40+
<rect key="frame" x="0.0" y="111" width="239" height="34.5"/>
3241
<state key="normal" title="Button"/>
3342
<buttonConfiguration key="configuration" style="filled" title="WrapStackView"/>
3443
<connections>
@@ -73,7 +82,7 @@
7382
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="9VV-h8-9cl" sceneMemberID="viewController">
7483
<toolbarItems/>
7584
<navigationBar key="navigationBar" contentMode="scaleToFill" id="yVL-2F-E2I">
76-
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
85+
<rect key="frame" x="0.0" y="48" width="414" height="44"/>
7786
<autoresizingMask key="autoresizingMask"/>
7887
</navigationBar>
7988
<nil name="viewControllers"/>
@@ -101,6 +110,22 @@
101110
</objects>
102111
<point key="canvasLocation" x="2077" y="555"/>
103112
</scene>
113+
<!--H/VStackLayerWrapperView-->
114+
<scene sceneID="9vs-48-r50">
115+
<objects>
116+
<viewController id="5WQ-Nd-2jr" customClass="HVStackWrapperViewDemoViewController" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
117+
<view key="view" contentMode="scaleToFill" id="UXA-yy-xad">
118+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
119+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
120+
<viewLayoutGuide key="safeArea" id="S0H-ab-HM3"/>
121+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
122+
</view>
123+
<navigationItem key="navigationItem" title="H/VStackLayerWrapperView" id="lcg-7o-MOp"/>
124+
</viewController>
125+
<placeholder placeholderIdentifier="IBFirstResponder" id="eb2-QC-Y1T" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
126+
</objects>
127+
<point key="canvasLocation" x="2077" y="-790"/>
128+
</scene>
104129
</scenes>
105130
<resources>
106131
<systemColor name="systemBackgroundColor">
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
//
2+
// HVStackWrapperViewDemoViewController.swift
3+
// Demo
4+
//
5+
// Created by i on 2022/9/28.
6+
//
7+
8+
import UIKit
9+
import StackKit
10+
11+
let contentWidth: CGFloat = UIScreen.main.bounds.width - 32
12+
13+
class HVStackWrapperViewDemoViewController: UIViewController {
14+
15+
let content = VStackLayerWrapperView {
16+
HStackLayerWrapperView() {
17+
VStackLayerWrapperView(alignment: .left) {
18+
UILabel().stack.then {
19+
$0.text = "Good Morning."
20+
$0.font = .systemFont(ofSize: 16, weight: .medium)
21+
$0.textColor = .gray
22+
}
23+
24+
UILabel().stack.then {
25+
$0.text = "Kukuh Sanjaya"
26+
$0.font = .systemFont(ofSize: 20, weight: .bold)
27+
$0.textColor = .black
28+
}
29+
}
30+
31+
Spacer()
32+
33+
// ICON
34+
HStackLayerWrapperView(distribution: .spacing(10)) {
35+
UIView().stack.size(34).then {
36+
$0.backgroundColor = .systemPink
37+
$0.layer.cornerRadius = 8
38+
}
39+
40+
UIView().stack.size(34).then {
41+
$0.backgroundColor = .systemPink
42+
$0.layer.cornerRadius = 8
43+
}
44+
}
45+
46+
// wrapper in other view, need set width and sizeToFit
47+
}.stack.width(contentWidth).sizeToFit(.width)
48+
49+
Spacer(length: 20)
50+
51+
HStackLayerWrapperView {
52+
HStackLayerWrapperView(distribution: .spacing(6)) {
53+
UIView().stack.size(60).then {
54+
$0.backgroundColor = .systemPink
55+
$0.layer.cornerRadius = 8
56+
}
57+
VStackLayerWrapperView(alignment: .left) {
58+
UILabel().stack.then {
59+
$0.text = "Spending"
60+
$0.font = .systemFont(ofSize: 18)
61+
$0.textColor = .gray
62+
}
63+
UILabel().stack.then {
64+
$0.text = "$980"
65+
$0.font = .systemFont(ofSize: 22, weight: .medium)
66+
$0.textColor = .black
67+
}
68+
}
69+
}
70+
Spacer()
71+
HStackLayerWrapperView(distribution: .spacing(6)) {
72+
UIView().stack.size(60).then {
73+
$0.backgroundColor = .systemPink
74+
$0.layer.cornerRadius = 8
75+
}
76+
VStackLayerWrapperView(alignment: .left) {
77+
UILabel().stack.then {
78+
$0.text = "Income"
79+
$0.font = .systemFont(ofSize: 18)
80+
$0.textColor = .gray
81+
}
82+
UILabel().stack.then {
83+
$0.text = "$2,860"
84+
$0.font = .systemFont(ofSize: 22, weight: .medium)
85+
$0.textColor = .black
86+
}
87+
}
88+
}
89+
}.stack.width(contentWidth).sizeToFit(.width)
90+
91+
Spacer(length: 30)
92+
HStackLayerWrapperView(alignment: .bottom) {
93+
UILabel().stack.then {
94+
$0.text = "Transactions"
95+
$0.font = .systemFont(ofSize: 24, weight: .bold)
96+
$0.textColor = .black
97+
}
98+
Spacer()
99+
UILabel().stack.then {
100+
$0.text = "See All"
101+
$0.font = .systemFont(ofSize: 18, weight: .medium)
102+
$0.textColor = .blue
103+
}
104+
}.stack.width(contentWidth).sizeToFit(.width)
105+
106+
Spacer(length: 20)
107+
VStackLayerWrapperView(alignment: .left) {
108+
109+
HStackLayerWrapperView {
110+
UIView().stack.size(40).then {
111+
$0.backgroundColor = .systemPink
112+
$0.layer.cornerRadius = 12
113+
}
114+
Spacer(length: 10)
115+
VStackLayerWrapperView(alignment: .left) {
116+
UILabel().stack.then {
117+
$0.text = "Freelance Work"
118+
$0.textColor = .black
119+
$0.font = .systemFont(ofSize: 16)
120+
}
121+
UILabel().stack.then {
122+
$0.text = "Apr 26"
123+
$0.textColor = .gray
124+
$0.font = .systemFont(ofSize: 14)
125+
}
126+
}
127+
Spacer()
128+
UILabel().stack.then {
129+
$0.text = "+$2,600"
130+
$0.textColor = .black
131+
$0.font = .systemFont(ofSize: 18, weight: .medium)
132+
}
133+
}.stack.width(contentWidth).sizeToFit(.width)
134+
}
135+
}
136+
137+
override func viewDidLoad() {
138+
super.viewDidLoad()
139+
140+
// Do any additional setup after loading the view.
141+
142+
self.view.addSubview(content)
143+
}
144+
145+
override func viewDidLayoutSubviews() {
146+
super.viewDidLayoutSubviews()
147+
148+
content.pin.top(view.pin.safeArea).horizontally(16).sizeToFit()
149+
}
150+
151+
/*
152+
// MARK: - Navigation
153+
154+
// In a storyboard-based application, you will often want to do a little preparation before navigation
155+
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
156+
// Get the new view controller using segue.destination.
157+
// Pass the selected object to the new view controller.
158+
}
159+
*/
160+
161+
}

0 commit comments

Comments
 (0)