Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
#1 feat: 뷰 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
Makeeyaf committed Jan 16, 2021
1 parent a8111e7 commit 5b0b95f
Show file tree
Hide file tree
Showing 10 changed files with 522 additions and 7 deletions.
65 changes: 64 additions & 1 deletion BindingWithCell.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 52;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -13,6 +13,14 @@
7E4056E725B19F0500DCBBF2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7E4056E525B19F0500DCBBF2 /* Main.storyboard */; };
7E4056E925B19F0500DCBBF2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7E4056E825B19F0500DCBBF2 /* Assets.xcassets */; };
7E4056EC25B19F0500DCBBF2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7E4056EA25B19F0500DCBBF2 /* LaunchScreen.storyboard */; };
7E41A71025B27CC800012AAB /* CombineViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E41A70F25B27CC800012AAB /* CombineViewController.swift */; };
7E46AEDB25B1CB7D0074A278 /* DataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E46AEDA25B1CB7D0074A278 /* DataSource.swift */; };
7E46AEDE25B1D0960074A278 /* SwiftUIListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E46AEDD25B1D0960074A278 /* SwiftUIListView.swift */; };
7E690BBC25B19F65002FBF80 /* RxSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 7E690BBB25B19F65002FBF80 /* RxSwift */; };
7E690BBE25B19F65002FBF80 /* RxCocoa in Frameworks */ = {isa = PBXBuildFile; productRef = 7E690BBD25B19F65002FBF80 /* RxCocoa */; };
7E690BC025B19F65002FBF80 /* RxRelay in Frameworks */ = {isa = PBXBuildFile; productRef = 7E690BBF25B19F65002FBF80 /* RxRelay */; };
7E690BC625B1A107002FBF80 /* RxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E690BC525B1A107002FBF80 /* RxViewController.swift */; };
7E690BCF25B1C075002FBF80 /* Cell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E690BCE25B1C075002FBF80 /* Cell.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -24,13 +32,21 @@
7E4056E825B19F0500DCBBF2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
7E4056EB25B19F0500DCBBF2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
7E4056ED25B19F0500DCBBF2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7E41A70F25B27CC800012AAB /* CombineViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CombineViewController.swift; sourceTree = "<group>"; };
7E46AEDA25B1CB7D0074A278 /* DataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataSource.swift; sourceTree = "<group>"; };
7E46AEDD25B1D0960074A278 /* SwiftUIListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIListView.swift; sourceTree = "<group>"; };
7E690BC525B1A107002FBF80 /* RxViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RxViewController.swift; sourceTree = "<group>"; };
7E690BCE25B1C075002FBF80 /* Cell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Cell.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
7E4056D925B19F0500DCBBF2 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
7E690BC025B19F65002FBF80 /* RxRelay in Frameworks */,
7E690BBE25B19F65002FBF80 /* RxCocoa in Frameworks */,
7E690BBC25B19F65002FBF80 /* RxSwift in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -63,6 +79,11 @@
7E4056E825B19F0500DCBBF2 /* Assets.xcassets */,
7E4056EA25B19F0500DCBBF2 /* LaunchScreen.storyboard */,
7E4056ED25B19F0500DCBBF2 /* Info.plist */,
7E690BC525B1A107002FBF80 /* RxViewController.swift */,
7E690BCE25B1C075002FBF80 /* Cell.swift */,
7E46AEDA25B1CB7D0074A278 /* DataSource.swift */,
7E46AEDD25B1D0960074A278 /* SwiftUIListView.swift */,
7E41A70F25B27CC800012AAB /* CombineViewController.swift */,
);
path = BindingWithCell;
sourceTree = "<group>";
Expand All @@ -83,6 +104,11 @@
dependencies = (
);
name = BindingWithCell;
packageProductDependencies = (
7E690BBB25B19F65002FBF80 /* RxSwift */,
7E690BBD25B19F65002FBF80 /* RxCocoa */,
7E690BBF25B19F65002FBF80 /* RxRelay */,
);
productName = BindingWithCell;
productReference = 7E4056DC25B19F0500DCBBF2 /* BindingWithCell.app */;
productType = "com.apple.product-type.application";
Expand Down Expand Up @@ -110,6 +136,9 @@
Base,
);
mainGroup = 7E4056D325B19F0500DCBBF2;
packageReferences = (
7E690BBA25B19F65002FBF80 /* XCRemoteSwiftPackageReference "RxSwift" */,
);
productRefGroup = 7E4056DD25B19F0500DCBBF2 /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -137,9 +166,14 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7E46AEDB25B1CB7D0074A278 /* DataSource.swift in Sources */,
7E41A71025B27CC800012AAB /* CombineViewController.swift in Sources */,
7E4056E425B19F0500DCBBF2 /* ViewController.swift in Sources */,
7E4056E025B19F0500DCBBF2 /* AppDelegate.swift in Sources */,
7E4056E225B19F0500DCBBF2 /* SceneDelegate.swift in Sources */,
7E46AEDE25B1D0960074A278 /* SwiftUIListView.swift in Sources */,
7E690BC625B1A107002FBF80 /* RxViewController.swift in Sources */,
7E690BCF25B1C075002FBF80 /* Cell.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -341,6 +375,35 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
7E690BBA25B19F65002FBF80 /* XCRemoteSwiftPackageReference "RxSwift" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/ReactiveX/RxSwift.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 6.0.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
7E690BBB25B19F65002FBF80 /* RxSwift */ = {
isa = XCSwiftPackageProductDependency;
package = 7E690BBA25B19F65002FBF80 /* XCRemoteSwiftPackageReference "RxSwift" */;
productName = RxSwift;
};
7E690BBD25B19F65002FBF80 /* RxCocoa */ = {
isa = XCSwiftPackageProductDependency;
package = 7E690BBA25B19F65002FBF80 /* XCRemoteSwiftPackageReference "RxSwift" */;
productName = RxCocoa;
};
7E690BBF25B19F65002FBF80 /* RxRelay */ = {
isa = XCSwiftPackageProductDependency;
package = 7E690BBA25B19F65002FBF80 /* XCRemoteSwiftPackageReference "RxSwift" */;
productName = RxRelay;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 7E4056D425B19F0500DCBBF2 /* Project object */;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "RxSwift",
"repositoryURL": "https://github.com/ReactiveX/RxSwift.git",
"state": {
"branch": null,
"revision": "c8742ed97fc2f0c015a5ea5eddefb064cd7532d2",
"version": "6.0.0"
}
}
]
},
"version": 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>Rx (Playground) 1.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>2</integer>
</dict>
<key>Rx (Playground) 2.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>3</integer>
</dict>
<key>Rx (Playground).xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
37 changes: 32 additions & 5 deletions BindingWithCell/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,24 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="tGI-gf-1Bq">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="BindingWithCell" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<navigationItem key="navigationItem" id="lVp-S8-Bw7"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1047.8260869565217" y="118.52678571428571"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="gmI-bW-m3U">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="tGI-gf-1Bq" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="TzB-sS-KPY">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="Opf-Gk-SPz"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="XFx-7Z-UI4" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="137.68115942028987" y="118.52678571428571"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
125 changes: 125 additions & 0 deletions BindingWithCell/Cell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
//
// Cell.swift
// BindingWithCell
//
// Created by Makeeyaf on 2021/01/15.
//

import UIKit

final class RxCell: UITableViewCell {
static let reuseID = String(describing: self)

// MARK: Views

lazy var titleLabel: UILabel = {
let view = UILabel()
view.numberOfLines = 1
view.font = .systemFont(ofSize: 16, weight: .semibold)
return view
}()

lazy var toggleSwitch = UISwitch()

// MARK: Lifecycles

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
addViews()
setConstraints()
}

required init?(coder: NSCoder) {
super.init(coder: coder)
addViews()
setConstraints()
}

private func addViews() {
[titleLabel, toggleSwitch].forEach {
contentView.addSubview($0)
}
}

private func setConstraints() {
[titleLabel, toggleSwitch].forEach {
$0.translatesAutoresizingMaskIntoConstraints = false
}

NSLayoutConstraint.activate([
titleLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 15),
titleLabel.centerYAnchor.constraint(equalTo: contentView.centerYAnchor),
titleLabel.trailingAnchor.constraint(lessThanOrEqualTo: toggleSwitch.leadingAnchor),
])

NSLayoutConstraint.activate([
toggleSwitch.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -15),
toggleSwitch.centerYAnchor.constraint(equalTo: contentView.centerYAnchor),
])
}
}


final class CombineCell: UITableViewCell {
static let reuseID = String(describing: self)

@Published var isOn: Bool = false

// MARK: Views

lazy var titleLabel: UILabel = {
let view = UILabel()
view.numberOfLines = 1
view.font = .systemFont(ofSize: 16, weight: .semibold)
return view
}()

lazy var toggleSwitch: UISwitch = {
let view = UISwitch()
view.addTarget(self, action: #selector(switchValueChanged(_:)), for: .valueChanged)
return view
}()

// MARK: Lifecycles

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
addViews()
setConstraints()
}

required init?(coder: NSCoder) {
super.init(coder: coder)
addViews()
setConstraints()
}

private func addViews() {
[titleLabel, toggleSwitch].forEach {
contentView.addSubview($0)
}
}

private func setConstraints() {
[titleLabel, toggleSwitch].forEach {
$0.translatesAutoresizingMaskIntoConstraints = false
}

NSLayoutConstraint.activate([
titleLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 15),
titleLabel.centerYAnchor.constraint(equalTo: contentView.centerYAnchor),
titleLabel.trailingAnchor.constraint(lessThanOrEqualTo: toggleSwitch.leadingAnchor),
])

NSLayoutConstraint.activate([
toggleSwitch.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -15),
toggleSwitch.centerYAnchor.constraint(equalTo: contentView.centerYAnchor),
])
}

// MARK: Actions

@objc private func switchValueChanged(_ sender: UISwitch) {
isOn = sender.isOn
}
}

0 comments on commit 5b0b95f

Please sign in to comment.