Return examples

This commit is contained in:
mrustaa
2021-11-16 15:08:55 +03:00
parent f2e8d4411f
commit 3993d4d003
159 changed files with 12320 additions and 2 deletions
@@ -0,0 +1,94 @@
import UIKit
import ContainerControllerSwift
// MARK: - Item
class ExampleSwitchCellItem: TableAdapterItem {
init(height: CGFloat? = nil,
delegate: ExampleCellDelegate? = nil,
type: ExampleCell.Style = .default,
title: String = "",
value: Bool = false,
callback: ((Int) -> Void)? = nil) {
let cellData = ExampleSwitchCellData(type, title, value, height, delegate, callback)
super.init(cellClass: ExampleSwitchCell.self, cellData: cellData)
}
}
// MARK: - Data
class ExampleSwitchCellData: ExampleCellData {
// MARK: Properties
var value: Bool
// MARK: Inits
init(_ type: ExampleCell.Style,
_ title: String,
_ value: Bool,
_ cellHeight: CGFloat?,
_ delegate: ExampleCellDelegate?,
_ callback: ((Int) -> Void)?) {
self.value = value
super.init(type, title, cellHeight, delegate, callback)
}
override public func cellHeight() -> CGFloat {
return cellSizeHeight ?? 51.0
}
}
// MARK: - Cell
class ExampleSwitchCell: TableAdapterCell {
// MARK: Properties
public var data: ExampleSwitchCellData?
// MARK: Outlets
@IBOutlet override var selectedView: UIView? {
didSet { }
}
@IBOutlet private weak var switchButton: UISwitch?
@IBOutlet private weak var titleLabel: UILabel?
// MARK: Load
override func awakeFromNib() {
}
// MARK: Initialize
override func fill(data: TableAdapterCellData?) {
guard let data = data as? ExampleSwitchCellData else { return }
self.data = data
titleLabel?.text = data.title
switchButton?.setOn(data.value, animated: false)
}
@IBAction func switchAction(_ sender: UISwitch) {
guard let data = data else { return }
let value = sender.isOn
data.value = value
data.callback?((value ? 1 : 0))
data.delegate?.exampleCell(self, type: data.type, value: (value ? 1 : 0), endEditing: true)
}
}
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" id="ADc-Wu-299" customClass="ExampleSwitchCell" customModule="ContainerController" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="351" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="ADc-Wu-299" id="Qrk-n6-aPT">
<rect key="frame" x="0.0" y="0.0" width="351" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="SwitchText" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aYC-50-jqf">
<rect key="frame" x="10" y="9.5" width="272" height="32"/>
<constraints>
<constraint firstAttribute="height" constant="32" id="ygQ-Ul-8eS"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="13"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="BxP-OS-4Mu">
<rect key="frame" x="292" y="10" width="51" height="31"/>
<color key="onTintColor" systemColor="systemBlueColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<action selector="switchAction:" destination="ADc-Wu-299" eventType="valueChanged" id="tC8-YJ-2yF"/>
</connections>
</switch>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="BxP-OS-4Mu" firstAttribute="leading" secondItem="aYC-50-jqf" secondAttribute="trailing" constant="10" id="Nor-jw-6Vp"/>
<constraint firstItem="BxP-OS-4Mu" firstAttribute="centerY" secondItem="Qrk-n6-aPT" secondAttribute="centerY" id="OC2-nT-sr6"/>
<constraint firstAttribute="trailing" secondItem="BxP-OS-4Mu" secondAttribute="trailing" constant="10" id="iXi-S4-icf"/>
<constraint firstItem="aYC-50-jqf" firstAttribute="centerY" secondItem="Qrk-n6-aPT" secondAttribute="centerY" id="mME-6L-435"/>
<constraint firstItem="aYC-50-jqf" firstAttribute="leading" secondItem="Qrk-n6-aPT" secondAttribute="leading" constant="10" id="tNY-fx-JmB"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="switchButton" destination="BxP-OS-4Mu" id="Fzu-VA-frU"/>
<outlet property="titleLabel" destination="aYC-50-jqf" id="lUq-rA-0RO"/>
</connections>
<point key="canvasLocation" x="108" y="99.850074962518747"/>
</tableViewCell>
</objects>
</document>