Skip to content

Commit 8a43b33

Browse files
committed
First commit🍻
1 parent 506e848 commit 8a43b33

File tree

11 files changed

+410
-33
lines changed

11 files changed

+410
-33
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Carthage
2626
# We recommend against adding the Pods directory to your .gitignore. However
2727
# you should judge for yourself, the pros and cons are mentioned at:
2828
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
29-
#
29+
#
3030
# Note: if you ignore the Pods directory, make sure to uncomment
3131
# `pod install` in .travis.yml
3232
#
33-
# Pods/
33+
Pods/

Example/Podfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ use_frameworks!
22

33
target 'StackScrollView_Example' do
44
pod 'StackScrollView', :path => '../'
5+
pod 'Then'
56

67
target 'StackScrollView_Tests' do
78
inherit! :search_paths
89

9-
10+
1011
end
1112
end

Example/Podfile.lock

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
PODS:
2+
- EasyPeasy (1.2.1)
3+
- StackScrollView (0.1.0):
4+
- EasyPeasy
5+
- Then (1.0.3)
6+
7+
DEPENDENCIES:
8+
- StackScrollView (from `../`)
9+
- Then
10+
11+
EXTERNAL SOURCES:
12+
StackScrollView:
13+
:path: "../"
14+
15+
SPEC CHECKSUMS:
16+
EasyPeasy: b39f8cb9619fd248f8b65654e38eafb07efaf675
17+
StackScrollView: d07492b72960139b86bf68814dbe3bea7eddf76d
18+
Then: c2502b763132c80dfa64d325065d70c45e2d48ca
19+
20+
PODFILE CHECKSUM: b8bc53110533220a13033fe6bdaf6079d8e487a7
21+
22+
COCOAPODS: 1.0.1

Example/StackScrollView.xcworkspace/contents.xcworkspacedata

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,42 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
4+
<deployment identifier="iOS"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
56
</dependencies>
67
<scenes>
78
<!--View Controller-->
89
<scene sceneID="ufC-wZ-h7g">
910
<objects>
10-
<viewController id="vXZ-lx-hvc" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
11+
<viewController id="vXZ-lx-hvc" customClass="ViewController" customModule="StackScrollView_Example" customModuleProvider="target" sceneMemberID="viewController">
1112
<layoutGuides>
1213
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
1314
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
1415
</layoutGuides>
1516
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
1617
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
1718
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
19+
<subviews>
20+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BfU-Zd-xR3" customClass="StackScrollView" customModule="StackScrollView">
21+
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
22+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
23+
</view>
24+
</subviews>
1825
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
26+
<constraints>
27+
<constraint firstItem="BfU-Zd-xR3" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leading" id="9Zj-cx-vbj"/>
28+
<constraint firstAttribute="trailing" secondItem="BfU-Zd-xR3" secondAttribute="trailing" id="GbH-pB-f1K"/>
29+
<constraint firstItem="BfU-Zd-xR3" firstAttribute="top" secondItem="kh9-bI-dsS" secondAttribute="top" id="IRJ-IU-zKj"/>
30+
<constraint firstItem="2fi-mo-0CV" firstAttribute="top" secondItem="BfU-Zd-xR3" secondAttribute="bottom" id="Tdl-PA-Ley"/>
31+
</constraints>
1932
</view>
33+
<connections>
34+
<outlet property="stackScrollView" destination="BfU-Zd-xR3" id="bcs-XD-fGv"/>
35+
</connections>
2036
</viewController>
2137
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
2238
</objects>
39+
<point key="canvasLocation" x="325" y="358"/>
2340
</scene>
2441
</scenes>
2542
</document>

Example/StackScrollView/ViewController.swift

Lines changed: 164 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,180 @@
88

99
import UIKit
1010

11+
import StackScrollView
12+
import EasyPeasy
13+
14+
import Then
15+
1116
class ViewController: UIViewController {
1217

1318
override func viewDidLoad() {
1419
super.viewDidLoad()
15-
// Do any additional setup after loading the view, typically from a nib.
20+
21+
let colorA = UIColor(white: 0.9, alpha: 1)
22+
let colorB = UIColor(white: 0.8, alpha: 1)
23+
24+
25+
let labelCell = LabelStackViewCell().then { cell in
26+
cell.backgroundColor = colorA
27+
cell.titleLabel.text = "Hiroshi"
28+
cell.detailLabel.text = "Kimura"
29+
}
30+
31+
let switchCell = SwitchStackViewCell().then { cell in
32+
cell.backgroundColor = colorB
33+
cell.titleLabel.text = "Hiroshi"
34+
cell.valueChanged = { on in
35+
36+
}
37+
}
38+
39+
let labelFromTextCell = LabelStackViewCell().then { cell in
40+
cell.backgroundColor = colorA
41+
cell.titleLabel.text = "Hiroshi"
42+
cell.detailLabel.text = "Kimura"
43+
}
44+
45+
let textFieldCell = TextFieldStackViewCell().then { cell in
46+
cell.backgroundColor = colorB
47+
cell.titleLabel.text = "Hiroshi"
48+
cell.valueChanged = { string in
49+
50+
labelFromTextCell.titleLabel.text = string
51+
}
52+
}
53+
54+
stackScrollView.append(
55+
views: [
56+
labelCell,
57+
switchCell,
58+
labelFromTextCell,
59+
textFieldCell,
60+
],
61+
animated: true)
1662
}
1763

1864
override func didReceiveMemoryWarning() {
1965
super.didReceiveMemoryWarning()
2066
// Dispose of any resources that can be recreated.
2167
}
2268

69+
@IBOutlet weak var stackScrollView: StackScrollView!
70+
}
71+
72+
class LabelStackViewCell: UIView {
73+
74+
init() {
75+
super.init(frame: .zero)
76+
77+
addSubview(titleLabel)
78+
addSubview(detailLabel)
79+
80+
titleLabel <- [
81+
Left(8),
82+
CenterY(),
83+
]
84+
85+
detailLabel <- [
86+
Right(8),
87+
CenterY(),
88+
]
89+
}
90+
91+
override func intrinsicContentSize() -> CGSize {
92+
return CGSize(width: UIViewNoIntrinsicMetric, height: 60)
93+
}
94+
95+
required init?(coder aDecoder: NSCoder) {
96+
fatalError("init(coder:) has not been implemented")
97+
}
98+
99+
let titleLabel = UILabel()
100+
let detailLabel = UILabel()
101+
}
102+
103+
class SwitchStackViewCell: UIView {
104+
105+
var valueChanged: (Bool) -> Void = { _ in }
106+
107+
init() {
108+
super.init(frame: .zero)
109+
110+
addSubview(titleLabel)
111+
addSubview(switchView)
112+
113+
titleLabel <- [
114+
Left(8),
115+
CenterY(),
116+
]
117+
118+
switchView <- [
119+
Right(8),
120+
CenterY(),
121+
]
122+
123+
switchView.addTarget(self, action: #selector(switchValueChanged), forControlEvents: .ValueChanged)
124+
}
125+
126+
override func intrinsicContentSize() -> CGSize {
127+
return CGSize(width: UIViewNoIntrinsicMetric, height: 60)
128+
}
129+
130+
required init?(coder aDecoder: NSCoder) {
131+
fatalError("init(coder:) has not been implemented")
132+
}
133+
134+
let titleLabel = UILabel()
135+
136+
let switchView = UISwitch()
137+
138+
@objc private func switchValueChanged() {
139+
140+
valueChanged(switchView.on)
141+
}
23142
}
24143

144+
class TextFieldStackViewCell: UIView {
145+
146+
var valueChanged: (String) -> Void = { _ in }
147+
148+
init() {
149+
super.init(frame: .zero)
150+
151+
addSubview(titleLabel)
152+
addSubview(textField)
153+
154+
titleLabel.setContentHuggingPriority(950, forAxis: .Horizontal)
155+
titleLabel <- [
156+
Left(8),
157+
CenterY(),
158+
]
159+
160+
textField <- [
161+
Left(8).to(titleLabel, .Right),
162+
Right(8),
163+
CenterY(),
164+
]
165+
166+
textField.backgroundColor = UIColor(white: 0, alpha: 0.5)
167+
168+
textField.addTarget(self, action: #selector(textChanged), forControlEvents: .EditingChanged)
169+
}
170+
171+
override func intrinsicContentSize() -> CGSize {
172+
return CGSize(width: UIViewNoIntrinsicMetric, height: 60)
173+
}
174+
175+
required init?(coder aDecoder: NSCoder) {
176+
fatalError("init(coder:) has not been implemented")
177+
}
178+
179+
let titleLabel = UILabel()
180+
181+
let textField = UITextField()
182+
183+
@objc private func textChanged() {
184+
185+
valueChanged(textField.text ?? "")
186+
}
187+
}

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@
55
[![License](https://img.shields.io/cocoapods/l/StackScrollView.svg?style=flat)](http://cocoapods.org/pods/StackScrollView)
66
[![Platform](https://img.shields.io/cocoapods/p/StackScrollView.svg?style=flat)](http://cocoapods.org/pods/StackScrollView)
77

8-
## Example
8+
**Very Scalable** iOS form builder with **UIScrollView**
99

10-
To run the example project, clone the repo, and run `pod install` from the Example directory first.
10+
**Work in progress**
11+
12+
- StackScrollView (Core) this repository
13+
- UI Components (Other repository)
14+
15+
sample screenshot
16+
17+
![](shot.png)
1118

1219
## Requirements
1320

StackScrollView.podspec

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,15 @@
99
Pod::Spec.new do |s|
1010
s.name = 'StackScrollView'
1111
s.version = '0.1.0'
12-
s.summary = 'A short description of StackScrollView.'
13-
14-
# This description is used to generate tags and improve search results.
15-
# * Think: What does it do? Why did you write it? What is the focus?
16-
# * Try to keep it short, snappy and to the point.
17-
# * Write the description between the DESC delimiters below.
18-
# * Finally, don't worry about the indent, CocoaPods strips it!
19-
20-
s.description = <<-DESC
21-
TODO: Add long description of the pod here.
22-
DESC
23-
24-
s.homepage = 'https://github.com/<GITHUB_USERNAME>/StackScrollView'
25-
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
12+
s.summary = 'Scalable form builder with UIScrollView'
13+
s.homepage = 'https://github.com/muukii/StackScrollView'
2614
s.license = { :type => 'MIT', :file => 'LICENSE' }
2715
s.author = { 'muukii' => '[email protected]' }
28-
s.source = { :git => 'https://github.com/<GITHUB_USERNAME>/StackScrollView.git', :tag => s.version.to_s }
29-
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
16+
s.source = { :git => 'https://github.com/muukii/StackScrollView.git', :tag => s.version.to_s }
17+
s.social_media_url = 'https://twitter.com/muukii0803'
3018

3119
s.ios.deployment_target = '8.0'
32-
3320
s.source_files = 'StackScrollView/Classes/**/*'
34-
35-
# s.resource_bundles = {
36-
# 'StackScrollView' => ['StackScrollView/Assets/*.png']
37-
# }
21+
s.dependency 'EasyPeasy'
3822

39-
# s.public_header_files = 'Pod/Classes/**/*.h'
40-
# s.frameworks = 'UIKit', 'MapKit'
41-
# s.dependency 'AFNetworking', '~> 2.3'
4223
end

StackScrollView/Classes/ReplaceMe.swift

Whitespace-only changes.

0 commit comments

Comments
 (0)