Skip to content

Commit

Permalink
Merge pull request #17 from jeantimex/remove-main-storyboard-in-example
Browse files Browse the repository at this point in the history
Removed main storyboard.
  • Loading branch information
jeantimex authored Jul 23, 2017
2 parents b26f006 + 0378f5d commit c3d669a
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 147 deletions.
2 changes: 1 addition & 1 deletion CollapsibleTableSectionViewController.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "CollapsibleTableSectionViewController"
s.version = "0.0.7"
s.version = "0.0.8"
s.summary = "Swift 3.0 library to support collapsible sections in a table view."

# This description is used to generate tags and improve search results.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,29 @@ class CollapsibleTableViewHeader: UITableViewHeaderFooterView {
override init(reuseIdentifier: String?) {
super.init(reuseIdentifier: reuseIdentifier)

//
// Constraint the size of arrow label for auto layout
//
arrowLabel.widthAnchor.constraint(equalToConstant: 12).isActive = true
// Content View
contentView.backgroundColor = UIColor(hex: 0x2E3944)

titleLabel.translatesAutoresizingMaskIntoConstraints = false

let marginGuide = contentView.layoutMarginsGuide

// Arrow label
contentView.addSubview(arrowLabel)
arrowLabel.textColor = UIColor.white
arrowLabel.translatesAutoresizingMaskIntoConstraints = false
arrowLabel.widthAnchor.constraint(equalToConstant: 12).isActive = true
arrowLabel.topAnchor.constraint(equalTo: marginGuide.topAnchor).isActive = true
arrowLabel.trailingAnchor.constraint(equalTo: marginGuide.trailingAnchor).isActive = true
arrowLabel.bottomAnchor.constraint(equalTo: marginGuide.bottomAnchor).isActive = true

// Title label
contentView.addSubview(titleLabel)
contentView.addSubview(arrowLabel)
titleLabel.textColor = UIColor.white
titleLabel.translatesAutoresizingMaskIntoConstraints = false
titleLabel.topAnchor.constraint(equalTo: marginGuide.topAnchor).isActive = true
titleLabel.trailingAnchor.constraint(equalTo: marginGuide.trailingAnchor).isActive = true
titleLabel.bottomAnchor.constraint(equalTo: marginGuide.bottomAnchor).isActive = true
titleLabel.leadingAnchor.constraint(equalTo: marginGuide.leadingAnchor).isActive = true

//
// Call tapHeader when tapping on this header
Expand All @@ -44,44 +57,6 @@ class CollapsibleTableViewHeader: UITableViewHeaderFooterView {
fatalError("init(coder:) has not been implemented")
}

override func layoutSubviews() {
super.layoutSubviews()

contentView.backgroundColor = UIColor(hex: 0x2E3944)

titleLabel.textColor = UIColor.white
arrowLabel.textColor = UIColor.white

//
// Autolayout the lables
//
let views = [
"titleLabel" : titleLabel,
"arrowLabel" : arrowLabel,
]

contentView.addConstraints(NSLayoutConstraint.constraints(
withVisualFormat: "H:|-20-[titleLabel]-[arrowLabel]-20-|",
options: [],
metrics: nil,
views: views
))

contentView.addConstraints(NSLayoutConstraint.constraints(
withVisualFormat: "V:|-[titleLabel]-|",
options: [],
metrics: nil,
views: views
))

contentView.addConstraints(NSLayoutConstraint.constraints(
withVisualFormat: "V:|-[arrowLabel]-|",
options: [],
metrics: nil,
views: views
))
}

//
// Trigger toggle section when tapping on the header
//
Expand Down
12 changes: 0 additions & 12 deletions Examples/Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/* Begin PBXBuildFile section */
0AC886DF1F226627007E4E2F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AC886DE1F226627007E4E2F /* AppDelegate.swift */; };
0AC886E11F226627007E4E2F /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AC886E01F226627007E4E2F /* ViewController.swift */; };
0AC886E41F226627007E4E2F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0AC886E21F226627007E4E2F /* Main.storyboard */; };
0AC886E61F226627007E4E2F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0AC886E51F226627007E4E2F /* Assets.xcassets */; };
0AC886E91F226627007E4E2F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0AC886E71F226627007E4E2F /* LaunchScreen.storyboard */; };
1954D61128E2AEA6960297AB /* Pods_Examples.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 540185A9FAB3B385AE8ED8A6 /* Pods_Examples.framework */; };
Expand All @@ -19,7 +18,6 @@
0AC886DB1F226627007E4E2F /* Examples.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Examples.app; sourceTree = BUILT_PRODUCTS_DIR; };
0AC886DE1F226627007E4E2F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
0AC886E01F226627007E4E2F /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
0AC886E31F226627007E4E2F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
0AC886E51F226627007E4E2F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
0AC886E81F226627007E4E2F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
0AC886EA1F226627007E4E2F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -63,7 +61,6 @@
children = (
0AC886DE1F226627007E4E2F /* AppDelegate.swift */,
0AC886E01F226627007E4E2F /* ViewController.swift */,
0AC886E21F226627007E4E2F /* Main.storyboard */,
0AC886E51F226627007E4E2F /* Assets.xcassets */,
0AC886E71F226627007E4E2F /* LaunchScreen.storyboard */,
0AC886EA1F226627007E4E2F /* Info.plist */,
Expand Down Expand Up @@ -153,7 +150,6 @@
files = (
0AC886E91F226627007E4E2F /* LaunchScreen.storyboard in Resources */,
0AC886E61F226627007E4E2F /* Assets.xcassets in Resources */,
0AC886E41F226627007E4E2F /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -220,14 +216,6 @@
/* End PBXSourcesBuildPhase section */

/* Begin PBXVariantGroup section */
0AC886E21F226627007E4E2F /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
0AC886E31F226627007E4E2F /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
0AC886E71F226627007E4E2F /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
Expand Down
29 changes: 5 additions & 24 deletions Examples/Examples/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
self.window = UIWindow(frame:UIScreen.main.bounds)
self.window?.backgroundColor = UIColor.white
self.window?.rootViewController = UINavigationController(rootViewController: ViewController())
self.window?.makeKeyAndVisible()

return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

49 changes: 0 additions & 49 deletions Examples/Examples/Base.lproj/Main.storyboard

This file was deleted.

2 changes: 0 additions & 2 deletions Examples/Examples/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
Expand Down
17 changes: 2 additions & 15 deletions Examples/Examples/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@
import UIKit
import CollapsibleTableSectionViewController

class ViewController: UIViewController {

var sections = [Section]()
class ViewController: CollapsibleTableSectionViewController {

override func viewDidLoad() {
super.viewDidLoad()

self.title = "Apple Products"

let controller: CollapsibleTableSectionViewController = CollapsibleTableSectionViewController()

controller.sections = [
self.sections = [
Section(name: "Mac", items: [
Item(name: "MacBook", detail: "Apple's ultraportable laptop, trading portability for speed and connectivity."),
Item(name: "MacBook Air", detail: "While the screen could be sharper, the updated 11-inch MacBook Air is a very light ultraportable that offers great performance and battery life for the price."),
Expand All @@ -44,15 +40,6 @@ class ViewController: UIViewController {
Item(name: "Accessories", detail: "")
])
]

let tableView: UITableView = controller.tableView

var frame = self.view.bounds
frame.origin.y = (navigationController?.navigationBar.frame.maxY)!

tableView.frame = frame

view.addSubview(tableView)
}

}
Expand Down

0 comments on commit c3d669a

Please sign in to comment.