Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar Apeland committed Oct 23, 2017
1 parent 4999579 commit 0f594a2
Show file tree
Hide file tree
Showing 18 changed files with 820 additions and 99 deletions.
18 changes: 18 additions & 0 deletions SwipingViewController.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Pod::Spec.new do |s|
s.name = 'SwipeableViewController'
s.version = '0.1.0'
s.summary = 'A small UI component to build UIPageViewController-y views in your app.'

s.description = <<-DESC
A segmented header and a UIPageViewController all in one convenient package.
DESC

s.homepage = 'https://github.com/tiseoslo/SwipeableViewController'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Oscar Apeland' => 'oscar@tiseit.com' }
s.source = { :git => 'https://github.com/tiseoslo/SwipeableViewController.git', :tag => s.version.to_s }

s.ios.deployment_target = '10.0'
s.source_files = 'SwipeableViewController/Source/*.swift'

end
90 changes: 70 additions & 20 deletions SwipingViewController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,36 @@

/* Begin PBXBuildFile section */
08254DD81F8E9EDA006DD969 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08254DD71F8E9EDA006DD969 /* AppDelegate.swift */; };
08254DDA1F8E9EDA006DD969 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08254DD91F8E9EDA006DD969 /* ViewController.swift */; };
08254DDD1F8E9EDA006DD969 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 08254DDB1F8E9EDA006DD969 /* Main.storyboard */; };
08254DDF1F8E9EDA006DD969 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 08254DDE1F8E9EDA006DD969 /* Assets.xcassets */; };
08254DE21F8E9EDA006DD969 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 08254DE01F8E9EDA006DD969 /* LaunchScreen.storyboard */; };
087E9B1C1F90C336007DCB8F /* ExampleSwipeableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 087E9B1B1F90C336007DCB8F /* ExampleSwipeableViewController.swift */; };
08A9E2DB1F9E2FF8000B2729 /* SwipeableNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08A9E2D31F9E2FF8000B2729 /* SwipeableNavigationBar.swift */; };
08A9E2DC1F9E2FF8000B2729 /* SwipeableItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08A9E2D41F9E2FF8000B2729 /* SwipeableItem.swift */; };
08A9E2DD1F9E2FF8000B2729 /* SwipeableCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08A9E2D51F9E2FF8000B2729 /* SwipeableCollectionView.swift */; };
08A9E2DE1F9E2FF8000B2729 /* SwipeableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08A9E2D61F9E2FF8000B2729 /* SwipeableCell.swift */; };
08A9E2DF1F9E2FF8000B2729 /* SwipeableNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08A9E2D71F9E2FF8000B2729 /* SwipeableNavigationController.swift */; };
08A9E2E01F9E2FF8000B2729 /* SwipeableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08A9E2D81F9E2FF8000B2729 /* SwipeableViewController.swift */; };
08A9E2E11F9E2FF8000B2729 /* SwipeableCollectionViewFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08A9E2D91F9E2FF8000B2729 /* SwipeableCollectionViewFlowLayout.swift */; };
08A9E2E21F9E2FF8000B2729 /* SwipeableCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 08A9E2DA1F9E2FF8000B2729 /* SwipeableCell.xib */; };
08D04A631F8F959100982B4C /* ExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08D04A621F8F959100982B4C /* ExampleViewController.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
08254DD41F8E9EDA006DD969 /* SwipingViewController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwipingViewController.app; sourceTree = BUILT_PRODUCTS_DIR; };
08254DD71F8E9EDA006DD969 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
08254DD91F8E9EDA006DD969 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
08254DDC1F8E9EDA006DD969 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
08254DDE1F8E9EDA006DD969 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
08254DE11F8E9EDA006DD969 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
08254DE31F8E9EDA006DD969 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
087E9B1B1F90C336007DCB8F /* ExampleSwipeableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleSwipeableViewController.swift; sourceTree = "<group>"; };
08A9E2D31F9E2FF8000B2729 /* SwipeableNavigationBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeableNavigationBar.swift; sourceTree = "<group>"; };
08A9E2D41F9E2FF8000B2729 /* SwipeableItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeableItem.swift; sourceTree = "<group>"; };
08A9E2D51F9E2FF8000B2729 /* SwipeableCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeableCollectionView.swift; sourceTree = "<group>"; };
08A9E2D61F9E2FF8000B2729 /* SwipeableCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeableCell.swift; sourceTree = "<group>"; };
08A9E2D71F9E2FF8000B2729 /* SwipeableNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeableNavigationController.swift; sourceTree = "<group>"; };
08A9E2D81F9E2FF8000B2729 /* SwipeableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeableViewController.swift; sourceTree = "<group>"; };
08A9E2D91F9E2FF8000B2729 /* SwipeableCollectionViewFlowLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeableCollectionViewFlowLayout.swift; sourceTree = "<group>"; };
08A9E2DA1F9E2FF8000B2729 /* SwipeableCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SwipeableCell.xib; sourceTree = "<group>"; };
08D04A621F8F959100982B4C /* ExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -35,6 +51,26 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
080FFF321F9797BE00DF7612 /* Junk */ = {
isa = PBXGroup;
children = (
08254DDE1F8E9EDA006DD969 /* Assets.xcassets */,
08254DE01F8E9EDA006DD969 /* LaunchScreen.storyboard */,
08254DE31F8E9EDA006DD969 /* Info.plist */,
08254DD71F8E9EDA006DD969 /* AppDelegate.swift */,
);
name = Junk;
sourceTree = "<group>";
};
080FFF331F9797CB00DF7612 /* Example */ = {
isa = PBXGroup;
children = (
08D04A621F8F959100982B4C /* ExampleViewController.swift */,
087E9B1B1F90C336007DCB8F /* ExampleSwipeableViewController.swift */,
);
name = Example;
sourceTree = "<group>";
};
08254DCB1F8E9EDA006DD969 = {
isa = PBXGroup;
children = (
Expand All @@ -54,16 +90,28 @@
08254DD61F8E9EDA006DD969 /* SwipingViewController */ = {
isa = PBXGroup;
children = (
08254DD71F8E9EDA006DD969 /* AppDelegate.swift */,
08254DD91F8E9EDA006DD969 /* ViewController.swift */,
08254DDB1F8E9EDA006DD969 /* Main.storyboard */,
08254DDE1F8E9EDA006DD969 /* Assets.xcassets */,
08254DE01F8E9EDA006DD969 /* LaunchScreen.storyboard */,
08254DE31F8E9EDA006DD969 /* Info.plist */,
08A9E2D21F9E2FF8000B2729 /* Source */,
080FFF321F9797BE00DF7612 /* Junk */,
080FFF331F9797CB00DF7612 /* Example */,
);
path = SwipingViewController;
sourceTree = "<group>";
};
08A9E2D21F9E2FF8000B2729 /* Source */ = {
isa = PBXGroup;
children = (
08A9E2D31F9E2FF8000B2729 /* SwipeableNavigationBar.swift */,
08A9E2D41F9E2FF8000B2729 /* SwipeableItem.swift */,
08A9E2D51F9E2FF8000B2729 /* SwipeableCollectionView.swift */,
08A9E2D61F9E2FF8000B2729 /* SwipeableCell.swift */,
08A9E2D71F9E2FF8000B2729 /* SwipeableNavigationController.swift */,
08A9E2D81F9E2FF8000B2729 /* SwipeableViewController.swift */,
08A9E2D91F9E2FF8000B2729 /* SwipeableCollectionViewFlowLayout.swift */,
08A9E2DA1F9E2FF8000B2729 /* SwipeableCell.xib */,
);
path = Source;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -124,8 +172,8 @@
buildActionMask = 2147483647;
files = (
08254DE21F8E9EDA006DD969 /* LaunchScreen.storyboard in Resources */,
08A9E2E21F9E2FF8000B2729 /* SwipeableCell.xib in Resources */,
08254DDF1F8E9EDA006DD969 /* Assets.xcassets in Resources */,
08254DDD1F8E9EDA006DD969 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -136,22 +184,22 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
08254DDA1F8E9EDA006DD969 /* ViewController.swift in Sources */,
08A9E2DE1F9E2FF8000B2729 /* SwipeableCell.swift in Sources */,
08A9E2DC1F9E2FF8000B2729 /* SwipeableItem.swift in Sources */,
08A9E2E01F9E2FF8000B2729 /* SwipeableViewController.swift in Sources */,
08A9E2DD1F9E2FF8000B2729 /* SwipeableCollectionView.swift in Sources */,
08A9E2DF1F9E2FF8000B2729 /* SwipeableNavigationController.swift in Sources */,
08A9E2E11F9E2FF8000B2729 /* SwipeableCollectionViewFlowLayout.swift in Sources */,
08A9E2DB1F9E2FF8000B2729 /* SwipeableNavigationBar.swift in Sources */,
08254DD81F8E9EDA006DD969 /* AppDelegate.swift in Sources */,
08D04A631F8F959100982B4C /* ExampleViewController.swift in Sources */,
087E9B1C1F90C336007DCB8F /* ExampleSwipeableViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXVariantGroup section */
08254DDB1F8E9EDA006DD969 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
08254DDC1F8E9EDA006DD969 /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
08254DE01F8E9EDA006DD969 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
Expand Down Expand Up @@ -277,6 +325,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 88F3596FP2;
INFOPLIST_FILE = SwipingViewController/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Tise.SwipingViewController;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -292,6 +341,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 88F3596FP2;
INFOPLIST_FILE = SwipingViewController/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Tise.SwipingViewController;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.SwiftErrorBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
scope = "0"
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
42 changes: 14 additions & 28 deletions SwipingViewController/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

//
// AppDelegate.swift
// SwipingViewController
Expand All @@ -10,37 +11,22 @@ import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
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.
}
window = UIWindow(frame: UIScreen.main.bounds)

let navigationController = SwipeableNavigationController(navigationBarClass: SwipeableNavigationBar.self, toolbarClass: nil)
let viewController = ExampleSwipeableViewController()
viewController.swipeableItems = [SwipeableItem(title: "Recent", viewController: ExampleViewController()),
SwipeableItem(title: "Explore", viewController: ExampleViewController()),
SwipeableItem(title: "Browse", viewController: ExampleViewController())]
viewController.selectedIndex = 1
navigationController.setViewControllers([viewController], animated: false)

window?.rootViewController = navigationController
window?.makeKeyAndVisible()

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:.
return true
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
24 changes: 0 additions & 24 deletions SwipingViewController/Base.lproj/Main.storyboard

This file was deleted.

26 changes: 26 additions & 0 deletions SwipingViewController/ExampleSwipeableViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// ExampleSwipeableViewController.swift
// SwipingViewController
//
// Created by Oscar Apeland on 13.10.2017.
// Copyright © 2017 Tise. All rights reserved.
//

import UIKit

class ExampleSwipeableViewController: SwipeableViewController {
lazy var searchController = UISearchController(searchResultsController: {
$0.view.backgroundColor = .red
return $0
}(UIViewController()))

override func viewDidLoad() {
super.viewDidLoad()
if #available(iOS 11.0, *) {
navigationItem.searchController = searchController
} else {
navigationItem.titleView = searchController.searchBar
}
definesPresentationContext = true
}
}
66 changes: 66 additions & 0 deletions SwipingViewController/ExampleViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// ExampleViewController.swift
// SwipingViewController
//
// Created by Oscar Apeland on 12.10.2017.
// Copyright © 2017 Tise. All rights reserved.
//

import UIKit

class ExampleViewController: UIViewController {
lazy var collectionView: UICollectionView = {
$0.backgroundColor = .white
$0.alwaysBounceVertical = true
$0.delegate = self
$0.dataSource = self
$0.autoresizingMask = [.flexibleHeight, .flexibleWidth]
($0.collectionViewLayout as? UICollectionViewFlowLayout)?.sectionInset = UIEdgeInsets(top: 20, left: 0, bottom: 0, right: 0)

return $0
}(UICollectionView(frame: view.bounds, collectionViewLayout: UICollectionViewFlowLayout()))

let cellColor = UIColor.random

override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(collectionView)
if #available(iOS 11.0, *) {
collectionView.contentInsetAdjustmentBehavior = .always
}
}
}

extension ExampleViewController: UICollectionViewDataSource, UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 100
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "cell")
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)
cell.backgroundColor = cellColor

return cell
}

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let vc = UICollectionViewController(collectionViewLayout: UICollectionViewFlowLayout())

vc.collectionView?.backgroundColor = .white
vc.collectionView?.dataSource = self
vc.collectionView?.delegate = self

navigationController?.pushViewController(vc, animated: true)
}
}

extension UIColor {
class var random: UIColor {
func random() -> CGFloat {
return CGFloat(arc4random()) / CGFloat(UInt32.max)
}

return UIColor(red: random(), green: random(), blue: random(), alpha: 1.0)
}
}
Loading

0 comments on commit 0f594a2

Please sign in to comment.