Skip to content

Commit 92fd09a

Browse files
committed
Implement a base class for tabbarcontroller that conforms to protocol
1 parent 6c1d1d9 commit 92fd09a

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

SampleSporify/MainTabBarController.swift

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Created by Emre Havan on 20.03.20.
66
// Copyright © 2020 Emre Havan. All rights reserved.
77
//
8+
import UIKit
89

910
public protocol StickyViewControllerSupporting: UITabBarController {
1011
var collapsableVCFlow: ExpandableViewController? { get set }
@@ -15,9 +16,12 @@ public protocol StickyViewControllerSupporting: UITabBarController {
1516
func collapseCollapsibleVC(duration: TimeInterval)
1617
}
1718

18-
extension StickyViewControllerSupporting {
19+
public class StickyViewControllerSupportingTabBarController: UITabBarController, StickyViewControllerSupporting {
20+
public var collapsableVCFlow: ExpandableViewController?
21+
public var collapsedHeight: CGFloat = 50.0
22+
public var animationDuration: TimeInterval = 0.5
1923

20-
func configureCollapsedTrainingView(withChildViewController childViewController: Expandable) {
24+
public func configureCollapsedTrainingView(withChildViewController childViewController: Expandable) {
2125
guard collapsableVCFlow == nil else {
2226
return
2327
}
@@ -42,7 +46,7 @@ extension StickyViewControllerSupporting {
4246
collapsableVCFlow!.didMove(toParent: self)
4347
}
4448

45-
func removeCollapsibleView(withAnimation: Bool, duration: TimeInterval) {
49+
public func removeCollapsibleView(withAnimation: Bool, duration: TimeInterval) {
4650
guard let collapsableVCFlow = collapsableVCFlow else {
4751
return
4852
}
@@ -66,23 +70,16 @@ extension StickyViewControllerSupporting {
6670
}
6771
}
6872

69-
func collapseCollapsibleVC(duration: TimeInterval) {
73+
public func collapseCollapsibleVC(duration: TimeInterval) {
7074
guard let collapsableVCFlow = collapsableVCFlow else {
7175
return
7276
}
7377
collapsableVCFlow.collapse()
7478
}
7579
}
7680

77-
import UIKit
81+
class MainTabBarController: StickyViewControllerSupportingTabBarController {
7882

79-
class MainTabBarController: UITabBarController, StickyViewControllerSupporting {
80-
var animationDuration: TimeInterval = 0.5
81-
82-
var collapsedHeight: CGFloat = 60.0
83-
84-
var collapsableVCFlow: ExpandableViewController?
85-
8683
override func viewDidLoad() {
8784
super.viewDidLoad()
8885
}

SampleSporify/SampleChildViewController.xib

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@
3737
<nil key="highlightedColor"/>
3838
</label>
3939
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BiF-D1-eME">
40-
<rect key="frame" x="0.0" y="44" width="414" height="60"/>
40+
<rect key="frame" x="0.0" y="44" width="414" height="50"/>
4141
<color key="backgroundColor" systemColor="systemGreenColor" red="0.20392156859999999" green="0.78039215689999997" blue="0.34901960780000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
4242
<constraints>
43-
<constraint firstAttribute="height" constant="60" id="d8e-J2-U8u"/>
43+
<constraint firstAttribute="height" constant="50" id="d8e-J2-U8u"/>
4444
</constraints>
4545
</view>
4646
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="A3p-MX-5B5">

0 commit comments

Comments
 (0)