Skip to content

Commit

Permalink
Modify example
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Zonov committed Nov 8, 2017
1 parent 2387cd7 commit f1fc557
Show file tree
Hide file tree
Showing 11 changed files with 344 additions and 177 deletions.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,21 @@ playground.xcworkspace

# Carthage
Carthage/Build
ExpandableCell.xcworkspace/contents.xcworkspacedata
Pods/Manifest.lock
Pods/Target Support Files/AZExpandable/AZExpandable-dummy.m
Pods/Target Support Files/AZExpandable/AZExpandable-prefix.pch
Pods/Target Support Files/AZExpandable/AZExpandable-umbrella.h
Pods/Target Support Files/AZExpandable/AZExpandable.modulemap
Pods/Target Support Files/AZExpandable/AZExpandable.xcconfig
Pods/Target Support Files/AZExpandable/Info.plist
Pods/Target Support Files/Pods-ExpandableCell/Info.plist
Pods/Target Support Files/Pods-ExpandableCell/Pods-ExpandableCell-acknowledgements.markdown
Pods/Target Support Files/Pods-ExpandableCell/Pods-ExpandableCell-acknowledgements.plist
Pods/Target Support Files/Pods-ExpandableCell/Pods-ExpandableCell-dummy.m
Pods/Target Support Files/Pods-ExpandableCell/Pods-ExpandableCell-frameworks.sh
Pods/Target Support Files/Pods-ExpandableCell/Pods-ExpandableCell-resources.sh
Pods/Target Support Files/Pods-ExpandableCell/Pods-ExpandableCell-umbrella.h
Pods/Target Support Files/Pods-ExpandableCell/Pods-ExpandableCell.debug.xcconfig
Pods/Target Support Files/Pods-ExpandableCell/Pods-ExpandableCell.modulemap
Pods/Target Support Files/Pods-ExpandableCell/Pods-ExpandableCell.release.xcconfig
62 changes: 51 additions & 11 deletions ExpandableCell.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,25 @@

/* Begin PBXBuildFile section */
544BBBECEC7CBA6DC12582BA /* Pods_ExpandableCell.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CAEC0521AA1804F5AD4A219 /* Pods_ExpandableCell.framework */; };
5759872B1FA39FE200239B5E /* TableViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5759872A1FA39FE200239B5E /* TableViewModel.swift */; };
579732361F971A43006DB071 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 579732351F971A43006DB071 /* AppDelegate.swift */; };
579732381F971A43006DB071 /* DemoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 579732371F971A43006DB071 /* DemoViewController.swift */; };
5797323B1F971A43006DB071 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 579732391F971A43006DB071 /* Main.storyboard */; };
5797323B1F971A43006DB071 /* Demo.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 579732391F971A43006DB071 /* Demo.storyboard */; };
5797323D1F971A43006DB071 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5797323C1F971A43006DB071 /* Assets.xcassets */; };
579732401F971A43006DB071 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5797323E1F971A43006DB071 /* LaunchScreen.storyboard */; };
57FF07FF1FB2CBC2008C0958 /* TableViewModelFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57FF07FE1FB2CBC2008C0958 /* TableViewModelFactory.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
5759872A1FA39FE200239B5E /* TableViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewModel.swift; sourceTree = "<group>"; };
579732321F971A43006DB071 /* ExpandableCell.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExpandableCell.app; sourceTree = BUILT_PRODUCTS_DIR; };
579732351F971A43006DB071 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
579732371F971A43006DB071 /* DemoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoViewController.swift; sourceTree = "<group>"; };
5797323A1F971A43006DB071 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
5797323A1F971A43006DB071 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Demo.storyboard; sourceTree = "<group>"; };
5797323C1F971A43006DB071 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
5797323F1F971A43006DB071 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
579732411F971A43006DB071 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
57FF07FE1FB2CBC2008C0958 /* TableViewModelFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewModelFactory.swift; sourceTree = "<group>"; };
5B9DB0A27CB6D3B14B4FA504 /* Pods-ExpandableCell.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExpandableCell.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ExpandableCell/Pods-ExpandableCell.debug.xcconfig"; sourceTree = "<group>"; };
8A984765D95495A0BB3DFE38 /* Pods-ExpandableCell.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExpandableCell.release.xcconfig"; path = "Pods/Target Support Files/Pods-ExpandableCell/Pods-ExpandableCell.release.xcconfig"; sourceTree = "<group>"; };
9CAEC0521AA1804F5AD4A219 /* Pods_ExpandableCell.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ExpandableCell.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -78,14 +82,48 @@
579732341F971A43006DB071 /* ExpandableCell */ = {
isa = PBXGroup;
children = (
579732351F971A43006DB071 /* AppDelegate.swift */,
579732371F971A43006DB071 /* DemoViewController.swift */,
579732391F971A43006DB071 /* Main.storyboard */,
57FF08031FB2CEDF008C0958 /* ViewModels */,
57FF08021FB2CED3008C0958 /* Views */,
57FF08011FB2CEB8008C0958 /* View Controller */,
57FF08001FB2CE51008C0958 /* Supporting Files */,
);
path = ExpandableCell;
sourceTree = "<group>";
};
57FF08001FB2CE51008C0958 /* Supporting Files */ = {
isa = PBXGroup;
children = (
5797323C1F971A43006DB071 /* Assets.xcassets */,
5797323E1F971A43006DB071 /* LaunchScreen.storyboard */,
579732411F971A43006DB071 /* Info.plist */,
579732351F971A43006DB071 /* AppDelegate.swift */,
);
path = ExpandableCell;
path = "Supporting Files";
sourceTree = "<group>";
};
57FF08011FB2CEB8008C0958 /* View Controller */ = {
isa = PBXGroup;
children = (
579732371F971A43006DB071 /* DemoViewController.swift */,
);
path = "View Controller";
sourceTree = "<group>";
};
57FF08021FB2CED3008C0958 /* Views */ = {
isa = PBXGroup;
children = (
579732391F971A43006DB071 /* Demo.storyboard */,
);
path = Views;
sourceTree = "<group>";
};
57FF08031FB2CEDF008C0958 /* ViewModels */ = {
isa = PBXGroup;
children = (
5759872A1FA39FE200239B5E /* TableViewModel.swift */,
57FF07FE1FB2CBC2008C0958 /* TableViewModelFactory.swift */,
);
path = ViewModels;
sourceTree = "<group>";
};
/* End PBXGroup section */
Expand Down Expand Up @@ -153,7 +191,7 @@
files = (
579732401F971A43006DB071 /* LaunchScreen.storyboard in Resources */,
5797323D1F971A43006DB071 /* Assets.xcassets in Resources */,
5797323B1F971A43006DB071 /* Main.storyboard in Resources */,
5797323B1F971A43006DB071 /* Demo.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -218,20 +256,22 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5759872B1FA39FE200239B5E /* TableViewModel.swift in Sources */,
579732381F971A43006DB071 /* DemoViewController.swift in Sources */,
57FF07FF1FB2CBC2008C0958 /* TableViewModelFactory.swift in Sources */,
579732361F971A43006DB071 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXVariantGroup section */
579732391F971A43006DB071 /* Main.storyboard */ = {
579732391F971A43006DB071 /* Demo.storyboard */ = {
isa = PBXVariantGroup;
children = (
5797323A1F971A43006DB071 /* Base */,
);
name = Main.storyboard;
name = Demo.storyboard;
sourceTree = "<group>";
};
5797323E1F971A43006DB071 /* LaunchScreen.storyboard */ = {
Expand Down Expand Up @@ -359,7 +399,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = ExpandableCell/Info.plist;
INFOPLIST_FILE = "ExpandableCell/Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.azonov.ExpandableCell;
Expand All @@ -378,7 +418,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = ExpandableCell/Info.plist;
INFOPLIST_FILE = "ExpandableCell/Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.azonov.ExpandableCell;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<string>Demo</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ViewController.swift
// DemoViewController.swift
// ExpandableCell
//
// Created by Andrey Zonov on 18/10/2017.
Expand All @@ -17,28 +17,29 @@ class DemoViewController: UIViewController {
// MARK: Private properties
private var expandableTable: ExpandableTable!
private var expandedCell: ExpandedCellInfo?

private var tableViewModel = TableViewModelFactory.staticExpandableTable

// MARK: Lifecycle

override func viewDidLoad() {
super.viewDidLoad()

expandableTable = ExpandableTable(with: tableView, infoProvider: self)
}

}

// MARK: - UITableViewDataSource
extension DemoViewController: UITableViewDataSource {

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 100
return tableViewModel.sections[section].cells.count
}

func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: .default, reuseIdentifier: "s")
cell.textLabel?.text = "\(indexPath.row)"
let cellModel = tableViewModel.sections[indexPath.section].cells[indexPath.row]
let cell = UITableViewCell(style: .default, reuseIdentifier: "staticCell")
cell.textLabel?.text = cellModel.title

return cell
}
}
Expand Down
31 changes: 31 additions & 0 deletions ExpandableCell/ViewModels/TableViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// TableViewModel.swift
// ExpandableCell
//
// Created by Andrey Zonov on 27/10/2017.
// Copyright © 2017 Andrey Zonov. All rights reserved.
//

import Foundation

enum ExpandingType {
case date
case picker
case custom
}

struct TableViewModel {

struct Section {

struct Cell {
var title: String
var expandingType: ExpandingType?
}

var cells: [Cell]
}

static var expandable = TableViewModel(sections: [])
var sections: [Section]
}
22 changes: 22 additions & 0 deletions ExpandableCell/ViewModels/TableViewModelFactory.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// TableViewModelFactory.swift
// ExpandableCell
//
// Created by Andrey Zonov on 08/11/2017.
// Copyright © 2017 Andrey Zonov. All rights reserved.
//

import Foundation

struct TableViewModelFactory {

static var staticExpandableTable: TableViewModel {
let helpCell = TableViewModel.Section.Cell(title: "Help", expandingType: .custom)
let dateCell = TableViewModel.Section.Cell(title: "Date", expandingType: .date)
let pickerCell = TableViewModel.Section.Cell(title: "Picker", expandingType: .picker)

let section = TableViewModel.Section(cells: [helpCell, dateCell, pickerCell])

return TableViewModel(sections: [section])
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13174"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand All @@ -11,11 +15,11 @@
<objects>
<viewController id="BYZ-38-t0r" customClass="DemoViewController" customModule="ExpandableCell" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="VAF-Vr-Iar">
<rect key="frame" x="0.0" y="20" width="600" height="580"/>
<rect key="frame" x="0.0" y="20" width="375" height="647"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tableView>
</subviews>
Expand Down
Loading

0 comments on commit f1fc557

Please sign in to comment.