Skip to content

Commit

Permalink
Created models, cell, headerView.
Browse files Browse the repository at this point in the history
  • Loading branch information
alicanbatur committed Dec 15, 2017
1 parent 9582666 commit f240fee
Show file tree
Hide file tree
Showing 15 changed files with 440 additions and 28 deletions.
59 changes: 44 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# OS X
.DS_Store

# Created by https://www.gitignore.io/api/swift

### Swift ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
Expand All @@ -12,22 +20,43 @@ build/
*.perspectivev3
!default.perspectivev3
xcuserdata/
*.xccheckout
profile

## Other
*.moved-aside
DerivedData
*.xccheckout
*.xcscmblueprint

## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

# Bundler
.bundle
## Playgrounds
timeline.xctimeline
playground.xcworkspace

Carthage
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
# Note: if you ignore the Pods directory, make sure to uncomment
# `pod install` in .travis.yml
# Swift Package Manager
#
# Pods/
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
.build/

# CocoaPods - Refactored to standalone file

# Carthage - Refactored to standalone file

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

# fastlane/report.xml
# fastlane/Preview.html
# fastlane/screenshots
# fastlane/test_output

# End of https://www.gitignore.io/api/swift
13 changes: 13 additions & 0 deletions ABExpandableView/Classes/Models/RowItem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// RowItem.swift
// ABExpandableView
//
// Created by Ali Can Batur on 15/12/2017.
//

import Foundation

protocol RowItem {
var identifier: String! { get }
var name: String! { get }
}
46 changes: 46 additions & 0 deletions ABExpandableView/Classes/Models/SectionItem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// SectionItem.swift
// ABExpandableView
//
// Created by Ali Can Batur on 15/12/2017.
//

import Foundation

protocol SectionItem: RowItem {
var expanded: Bool { get set }
var rows: [RowItem] { get set }
var rawRows: [RowItem] { get set }
var selectedRows: [RowItem] { get set }
var numberOfSelectedItems: Int { get }
}

/*
SectionItem extension manages the selection of objects using id comparison.
*/

extension SectionItem {

mutating func select(row: RowItem) {
if !selectedRows.contains(where: { $0.identifier == row.identifier }) {
selectedRows.append(row)
}
}

mutating func deselect(row: RowItem) {
selectedRows = selectedRows.filter({ $0.identifier != row.identifier })
}

func isSelected(row: RowItem) -> Bool {
return selectedRows.contains(where: { $0.identifier == row.identifier })
}

mutating func filterRows(inputText: String) -> [RowItem] {
rows = rawRows.filter({( item: RowItem) -> Bool in
if inputText == "" { return true }
return item.name.lowercased().range(of: inputText.lowercased()) != nil
})
return rows
}

}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "arrowDown.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions ABExpandableView/Classes/View/Cells/SelectionCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// SelectionCell.swift
// ABExpandableView
//
// Created by Ali Can Batur on 15/12/2017.
//

import Foundation

class SelectionCell: UITableViewCell {

// MARK: - Reuse identifier

class var reuseIdentifier: String {
return String(describing: self)
}

// MARK: - Public helper

func populateCell(_ text: String) {
textLabel?.text = text
}

}
80 changes: 80 additions & 0 deletions ABExpandableView/Classes/View/Expandable.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="xHk-oO-F64">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Expandable Sections View Controller-->
<scene sceneID="HC4-nK-Vly">
<objects>
<viewController id="xHk-oO-F64" customClass="ExpandableSectionsViewController" customModule="ABExpandableView" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="IDF-h4-IoM">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Nothing has been found with the typed text." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ISB-86-p0e" userLabel="Warning Label">
<rect key="frame" x="25" y="80" width="325" height="19.5"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="19.5" id="PVe-sN-nmP"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="7Rj-f3-tVI">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<searchBar key="tableHeaderView" contentMode="redraw" placeholder="All" id="PLj-lo-qOZ">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="pzs-9W-lcm"/>
</constraints>
<color key="barTintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<textInputTraits key="textInputTraits" returnKeyType="done" enablesReturnKeyAutomatically="YES"/>
</searchBar>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="checkmark" indentationWidth="10" reuseIdentifier="SelectionCell" textLabel="Fyy-Kv-Ega" style="IBUITableViewCellStyleDefault" id="6f2-NU-LRH" customClass="SelectionCell">
<rect key="frame" x="0.0" y="72" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="6f2-NU-LRH" id="FAC-EF-nAE">
<rect key="frame" x="0.0" y="0.0" width="336" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Fyy-Kv-Ega">
<rect key="frame" x="15" y="0.0" width="321" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="7Rj-f3-tVI" firstAttribute="leading" secondItem="LMV-hv-XHQ" secondAttribute="leading" id="2YY-6I-i3L"/>
<constraint firstItem="7Rj-f3-tVI" firstAttribute="bottom" secondItem="LMV-hv-XHQ" secondAttribute="bottom" id="3As-xv-ga7"/>
<constraint firstItem="ISB-86-p0e" firstAttribute="leading" secondItem="LMV-hv-XHQ" secondAttribute="leading" constant="25" id="EpN-2G-VDN"/>
<constraint firstItem="ISB-86-p0e" firstAttribute="top" secondItem="LMV-hv-XHQ" secondAttribute="top" constant="60" id="Rhx-21-bOz"/>
<constraint firstItem="LMV-hv-XHQ" firstAttribute="trailing" secondItem="ISB-86-p0e" secondAttribute="trailing" constant="25" id="TSN-OO-gHF"/>
<constraint firstItem="7Rj-f3-tVI" firstAttribute="trailing" secondItem="LMV-hv-XHQ" secondAttribute="trailing" id="hLv-no-IRD"/>
<constraint firstItem="7Rj-f3-tVI" firstAttribute="top" secondItem="IDF-h4-IoM" secondAttribute="top" id="jjj-t0-EIj"/>
</constraints>
<viewLayoutGuide key="safeArea" id="LMV-hv-XHQ"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Ydk-i0-Kjz" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="152.80000000000001" y="169.56521739130437"/>
</scene>
</scenes>
</document>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// ExpandableSectionsViewController.swift
// ABExpandableView
//
// Created by Ali Can Batur on 14/12/2017.
//

import UIKit

class ExpandableSectionsViewController: UIViewController {

// MARK: - View Lifecycle

override func viewDidLoad() {
super.viewDidLoad()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// ExpandableHeaderView.swift
// ABExpandableView
//
// Created by Ali Can Batur on 15/12/2017.
//

import Foundation

class ExpandableHeaderView: UITableViewHeaderFooterView {

}
86 changes: 86 additions & 0 deletions ABExpandableView/Classes/View/HeaderView/ExpandableHeaderView.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<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"/>
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="ExpandableHeaderView" customModule="ABExpandableView">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="f2q-mw-0Da">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yW7-3c-FvD">
<rect key="frame" x="0.0" y="43" width="375" height="1"/>
<color key="backgroundColor" red="0.80000000000000004" green="0.80000000000000004" blue="0.80000000000000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="EDF-eI-r6G"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vNS-3o-Oy3">
<rect key="frame" x="16" y="12" width="281" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="4ZS-ad-RqO"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hRG-zo-2yf">
<rect key="frame" x="305" y="10" width="24" height="24"/>
<color key="backgroundColor" red="0.90980392160000001" green="0.1647058824" blue="0.23529411759999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="24" id="Gly-Vf-2yO"/>
<constraint firstAttribute="width" constant="24" id="zoh-uy-0E6"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="arrow_down" translatesAutoresizingMaskIntoConstraints="NO" id="6fP-2q-h2B">
<rect key="frame" x="345" y="18" width="14" height="9"/>
<constraints>
<constraint firstAttribute="width" constant="14" id="3c8-dd-35P"/>
<constraint firstAttribute="height" constant="9" id="gvX-fE-1fj"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" red="0.87058823529999996" green="0.96862745100000003" blue="0.98431372549999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="hRG-zo-2yf" firstAttribute="centerY" secondItem="f2q-mw-0Da" secondAttribute="centerY" id="7oh-Xg-CQi"/>
<constraint firstItem="hRG-zo-2yf" firstAttribute="leading" secondItem="vNS-3o-Oy3" secondAttribute="trailing" constant="8" id="AYg-Ml-Eab"/>
<constraint firstAttribute="bottom" secondItem="yW7-3c-FvD" secondAttribute="bottom" id="JXk-qB-nje"/>
<constraint firstItem="6fP-2q-h2B" firstAttribute="centerY" secondItem="f2q-mw-0Da" secondAttribute="centerY" id="JsQ-sb-Lfd"/>
<constraint firstItem="6fP-2q-h2B" firstAttribute="leading" secondItem="hRG-zo-2yf" secondAttribute="trailing" constant="16" id="Mth-AH-8Yj"/>
<constraint firstAttribute="trailing" secondItem="6fP-2q-h2B" secondAttribute="trailing" constant="16" id="QoQ-yo-9ah"/>
<constraint firstItem="vNS-3o-Oy3" firstAttribute="centerY" secondItem="f2q-mw-0Da" secondAttribute="centerY" id="cJo-Fd-ISt"/>
<constraint firstItem="yW7-3c-FvD" firstAttribute="leading" secondItem="f2q-mw-0Da" secondAttribute="leading" id="daY-Rb-yMZ"/>
<constraint firstItem="vNS-3o-Oy3" firstAttribute="leading" secondItem="f2q-mw-0Da" secondAttribute="leading" constant="16" id="r2z-a2-AK8"/>
<constraint firstAttribute="trailing" secondItem="yW7-3c-FvD" secondAttribute="trailing" id="xZh-Ef-LoD"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="f2q-mw-0Da" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="LUs-mR-uMT"/>
<constraint firstItem="f2q-mw-0Da" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="QDU-XT-TXy"/>
<constraint firstAttribute="trailing" secondItem="f2q-mw-0Da" secondAttribute="trailing" id="Ut7-YS-x6D"/>
<constraint firstAttribute="bottom" secondItem="f2q-mw-0Da" secondAttribute="bottom" id="Whj-eZ-EOJ"/>
</constraints>
<nil key="simulatedTopBarMetrics"/>
<nil key="simulatedBottomBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="25.5" y="52"/>
</view>
</objects>
<resources>
<image name="arrow_down" width="22" height="13"/>
</resources>
</document>
Loading

0 comments on commit f240fee

Please sign in to comment.