Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions DiffableDataSource.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
RUN_CLANG_STATIC_ANALYZER = NO;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand Down Expand Up @@ -423,6 +424,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 12.3;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
RUN_CLANG_STATIC_ANALYZER = NO;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
Expand Down
30 changes: 30 additions & 0 deletions DiffableDataSource/Assets.xcassets/person.imageset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,42 @@
"scale" : "1x"
},
{
"appearances" : [
{
"appearance" : "contrast",
"value" : "high"
}
],
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"appearances" : [
{
"appearance" : "contrast",
"value" : "high"
}
],
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
},
{
"appearances" : [
{
"appearance" : "contrast",
"value" : "high"
}
],
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
Expand Down
13 changes: 7 additions & 6 deletions DiffableDataSource/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17132" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="6v2-tY-Ega">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19150" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="uef-HM-AQr">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17105"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19134"/>
<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"/>
Expand Down Expand Up @@ -32,7 +33,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="CVi-DT-KZz">
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="CVi-DT-KZz">
<rect key="frame" x="100" y="142" width="150" height="72"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Table View"/>
Expand Down Expand Up @@ -67,18 +68,18 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<searchBar contentMode="redraw" translatesAutoresizingMaskIntoConstraints="NO" id="KNd-5W-LO2">
<rect key="frame" x="0.0" y="44" width="375" height="56"/>
<rect key="frame" x="0.0" y="44" width="375" height="51"/>
<textInputTraits key="textInputTraits"/>
<connections>
<outlet property="delegate" destination="Fbt-MR-IKF" id="R6S-e8-nGA"/>
</connections>
</searchBar>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="oEe-4b-6UT">
<rect key="frame" x="0.0" y="100" width="375" height="567"/>
<rect key="frame" x="0.0" y="95" width="375" height="572"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" id="jQD-cz-tNQ">
<rect key="frame" x="0.0" y="28" width="375" height="43.5"/>
<rect key="frame" x="0.0" y="44.5" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="jQD-cz-tNQ" id="auq-rH-RmY">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class MyCellCollectionViewListCell: UICollectionViewListCell {

let label = UILabel()

var item: Item?

static let reuseIdentifier = "list-cell"

enum Constants {
Expand All @@ -30,6 +32,7 @@ class MyCellCollectionViewListCell: UICollectionViewListCell {
let imageView = UIImageView(frame: .zero)
imageView.image = UIImage(named: "person")
imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.isHidden = true
addSubview(imageView)

NSLayoutConstraint.activate([
Expand All @@ -49,5 +52,24 @@ class MyCellCollectionViewListCell: UICollectionViewListCell {
fatalError("init(coder:) has not been implemented")
}

override func updateConfiguration(using state: UICellConfigurationState) {
var content = self.defaultContentConfiguration().updated(for: state)
content.imageProperties.reservedLayoutSize = CGSize(width: 10, height: 44)
let content1 = UIBackgroundConfiguration.listSidebarCell()
//var content = UIListContentConfiguration.sidebarCell()

content.text = item?.name
content.image = item?.image

if state.isHighlighted || state.isSelected {
content.imageProperties.tintColor = .orange
content.textProperties.color = .yellow
}

self.contentConfiguration = content
self.backgroundConfiguration = content1
}

}


Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

import UIKit

struct Item {
let name: String
let image: UIImage
}

final class CollectionViewController: UIViewController {

enum Constants {
Expand Down Expand Up @@ -60,14 +65,27 @@ final class CollectionViewController: UIViewController {
fatalError("Cannot create new cell") }

cell.accessories = [
.outlineDisclosure(displayed: .always, options: .init(style: .automatic), actionHandler: {
.outlineDisclosure(displayed: .whenEditing, options: .init(style: .automatic), actionHandler: {
print("Handling Disclosure Tap")
print("How event")
}),
.delete(displayed: .always, actionHandler: {
.delete(displayed: .whenNotEditing, actionHandler: {
print("Handling Delete action")
})
]
cell.label.text = "\(number)"
// This is done
var x = 100
var y = 200
//cell.label.text = "\(number)"

// var content = cell.defaultContentConfiguration()
//
// content.text = String(number)
// content.image = UIImage(systemName: "star")
// cell.contentConfiguration = content

cell.item = Item(name: String(number), image: UIImage(systemName: "star")!)

return cell
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ final class TableViewController: UIViewController {
(tableView: UITableView, indexPath: IndexPath,
country: Country) -> UITableViewCell? in
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = country.name
var content = cell.defaultContentConfiguration()
content.text = country.name
content.image = UIImage(systemName: "star")
content.secondaryText = country.name
cell.contentConfiguration = content
return cell
}
dataSource.defaultRowAnimation = .fade
Expand Down