This repository has been archived by the owner on Jan 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Makeeyaf
committed
Jan 16, 2021
1 parent
a8111e7
commit 5b0b95f
Showing
10 changed files
with
522 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
BindingWithCell.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Oops, something went wrong.