Skip to content

Commit 82c4210

Browse files
committed
New TabBar swipe style UI
1 parent 269c7d0 commit 82c4210

10 files changed

Lines changed: 217 additions & 66 deletions

File tree

BrickHack-Mobile.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
31C5F546219B29CD00E3E1AF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 31C5F544219B29CD00E3E1AF /* Main.storyboard */; };
1616
31C5F548219B29CF00E3E1AF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 31C5F547219B29CF00E3E1AF /* Assets.xcassets */; };
1717
D706937323E8F86B004FA788 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = D706937223E8F86B004FA788 /* User.swift */; };
18+
D706937523E905FF004FA788 /* TabViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D706937423E905FF004FA788 /* TabViewController.swift */; };
1819
D750E81823DF67360075C639 /* FavoriteButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = D750E81723DF67360075C639 /* FavoriteButton.swift */; };
1920
D772876C23DFF92800C2D541 /* ScheduleParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = D772876B23DFF92800C2D541 /* ScheduleParser.swift */; };
2021
D789978223D652ED0058060A /* ScheduleTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D789978123D652ED0058060A /* ScheduleTableViewController.swift */; };
@@ -53,6 +54,7 @@
5354
31E39209219F765E00F7A3BE /* BrickHack-Mobile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "BrickHack-Mobile.entitlements"; sourceTree = "<group>"; };
5455
C029FC28202ED2177D811FF7 /* Pods-BrickHack-Mobile.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BrickHack-Mobile.debug.xcconfig"; path = "Pods/Target Support Files/Pods-BrickHack-Mobile/Pods-BrickHack-Mobile.debug.xcconfig"; sourceTree = "<group>"; };
5556
D706937223E8F86B004FA788 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
57+
D706937423E905FF004FA788 /* TabViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabViewController.swift; sourceTree = "<group>"; };
5658
D750E81723DF67360075C639 /* FavoriteButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = FavoriteButton.swift; path = "BrickHack-Mobile/Views/FavoriteButton.swift"; sourceTree = SOURCE_ROOT; };
5759
D772876B23DFF92800C2D541 /* ScheduleParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScheduleParser.swift; sourceTree = "<group>"; };
5860
D789978123D652ED0058060A /* ScheduleTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScheduleTableViewController.swift; sourceTree = "<group>"; };
@@ -129,6 +131,7 @@
129131
isa = PBXGroup;
130132
children = (
131133
D7C07884233EDBA300089193 /* LoginViewController.swift */,
134+
D706937423E905FF004FA788 /* TabViewController.swift */,
132135
D7C41E2423637D650091C480 /* MainTabBarController.swift */,
133136
31602384220A116000F73F58 /* EventsViewController.swift */,
134137
D789978123D652ED0058060A /* ScheduleTableViewController.swift */,
@@ -295,6 +298,7 @@
295298
D772876C23DFF92800C2D541 /* ScheduleParser.swift in Sources */,
296299
D7C07885233EDBA300089193 /* LoginViewController.swift in Sources */,
297300
D7C41E2523637D650091C480 /* MainTabBarController.swift in Sources */,
301+
D706937523E905FF004FA788 /* TabViewController.swift in Sources */,
298302
D750E81823DF67360075C639 /* FavoriteButton.swift in Sources */,
299303
D7D4B037234813A70001DFC5 /* AlertMessage.swift in Sources */,
300304
D7C41E27236383300091C480 /* ResourcesViewController.swift in Sources */,

BrickHack-Mobile/Base.lproj/Main.storyboard

Lines changed: 75 additions & 34 deletions
Large diffs are not rendered by default.

BrickHack-Mobile/Controllers/EventsViewController.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import TimelineTableViewCell
1111

1212
class EventsViewController: UIViewController { //UserDataHandler {
1313

14-
1514
// MARK: UI
1615

1716
// General properties
@@ -28,22 +27,6 @@ class EventsViewController: UIViewController { //UserDataHandler {
2827
loginVC.logout()
2928
}
3029

31-
// TableViewController segue
32-
// This is the main way to reference the ProfileTableViewCotroller
33-
// that is contained within this view via an Embed segue.
34-
if let tableVC = segue.destination as? ProfileTableViewController {
35-
36-
// May just set properties as Strings;
37-
// this approach calls viewDidLoad() before this data is set,
38-
// which may lead to odd behavior down the road.
39-
tableVC.loadViewIfNeeded()
40-
41-
// @FIXME: Fill using user data once login is working
42-
// (either here or in helper function or in previous VC)
43-
tableVC.nameLabel.text = currentUser.firstName + " " + currentUser.lastName
44-
tableVC.schoolLabel.text = "Unknown School"
45-
46-
}
4730
}
4831

4932
}

BrickHack-Mobile/Controllers/LoginViewController.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ import SafariServices
1818
// as it needs a computed property to get/set the userID, while all other classes do not require
1919
// this functionality.
2020
protocol UserDataHandler {
21-
var userID: Int! { get set }
22-
var oauthGrant: OAuth2ImplicitGrant! { get set }
23-
// @TODO: Add user data info upon backend implementation
24-
// let userData: [String, Any] { get set }
21+
var currentUser: User! { get set }
22+
// var userID: Int! { get set }
23+
// var oauthGrant: OAuth2ImplicitGrant! { get set }
2524
}
2625

2726

@@ -128,14 +127,15 @@ class LoginViewController: UIViewController {
128127
segue.destination.modalPresentationStyle = .fullScreen
129128

130129
// Pass data forward (temp to main screen)
131-
if let eventsVC = segue.destination as? EventsViewController {
130+
if let eventsVC = segue.destination as? TabViewController {
132131
print("passed user object")
133132
eventsVC.currentUser = self.currentUser
134133
}
135134

136135

137136
// Check for MainTabBarController (skip through nav controller)
138137
// Note: not used!
138+
/*
139139
if let tabVC = segue.destination.children.first as? MainTabBarController {
140140

141141
// Check if valid user (on error, user will reauth)
@@ -147,7 +147,7 @@ class LoginViewController: UIViewController {
147147
// Pass data to the tab bar controller, which will handle passing its own children
148148
tabVC.userID = userID
149149
tabVC.oauthGrant = oauthGrant
150-
}
150+
} */
151151
}
152152
}
153153

BrickHack-Mobile/Controllers/MainTabBarController.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
import UIKit
1010
import p2_OAuth2
1111

12-
class MainTabBarController: UITabBarController, UserDataHandler {
12+
/*
13+
OLD CLASS
14+
Currently not using. Code is left here if last-minute switch is needed.
15+
class MainTabBarController: UITabBarController { // , UserDataHandler {
1316

1417
var userID: Int!
1518
var oauthGrant: OAuth2ImplicitGrant!
@@ -34,3 +37,4 @@ class MainTabBarController: UITabBarController, UserDataHandler {
3437
}
3538
}
3639
}
40+
*/

BrickHack-Mobile/Controllers/ResourcesViewController.swift

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,31 @@
77
//
88

99
import UIKit
10-
import p2_OAuth2
1110

12-
class ResourcesViewController: UIViewController, UserDataHandler {
13-
14-
var userID: Int!
15-
var oauthGrant: OAuth2ImplicitGrant!
11+
class ResourcesViewController: UIViewController {
1612

13+
var currentUser: User!
1714

1815
override func viewDidLoad() {
1916
super.viewDidLoad()
17+
18+
}
19+
20+
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
21+
22+
// Embedded TableViewController segue
23+
// This is the main way to reference the ProfileTableViewCotroller
24+
// that is contained within this view via an Embed segue.
25+
if let tableVC = segue.destination as? ProfileTableViewController {
26+
27+
// May just set properties as Strings;
28+
// this approach calls viewDidLoad() before this data is set,
29+
// which may lead to odd behavior down the road.
30+
tableVC.loadViewIfNeeded()
31+
32+
tableVC.nameLabel.text = currentUser.firstName + " " + currentUser.lastName
33+
tableVC.schoolLabel.text = "Unknown School"
34+
35+
}
2036
}
2137
}

BrickHack-Mobile/Controllers/ScheduleTableViewController.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class ScheduleTableViewController: UITableViewController {
6666
// which runs each minute (while the screen is visible) and updates the timeline view if necessary.
6767
// @TODO: Change from 60s to change on every hour, effectively caching the result
6868
// (or maybe don't bother with cache and do it every time the view is loaded / minimal persistance)
69-
scheduleTimer = Timer.scheduledTimer(timeInterval: 60.0, target: self, selector: #selector(refreshTimeline), userInfo: nil, repeats: true)
69+
scheduleTimer = Timer.scheduledTimer(timeInterval: 10.0, target: self, selector: #selector(refreshTimeline), userInfo: nil, repeats: true)
7070
scheduleTimer.fire()
7171
}
7272

@@ -253,7 +253,12 @@ class ScheduleTableViewController: UITableViewController {
253253

254254
// Defined height for the time header slot (e.g., "9am")
255255
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
256-
return 60.0
256+
// If first element, set its header height to 0
257+
// (to make "Schedule" view text not seem too far away)
258+
if section == 0 {
259+
return tableView.sectionHeaderHeight
260+
}
261+
return 50.0
257262
}
258263

259264
// Remove margin between sections
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//
2+
// TabViewController.swift
3+
// BrickHack-Mobile
4+
//
5+
// Created by Peter Kos on 2/3/20.
6+
// Copyright © 2020 codeRIT. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import Pageboy
11+
import Tabman
12+
13+
14+
class TabViewController: TabmanViewController, PageboyViewControllerDataSource, TMBarDataSource {
15+
16+
var currentUser: User!
17+
private var viewControllers = [UIViewController]()
18+
19+
override func viewDidLoad() {
20+
super.viewDidLoad()
21+
22+
// Set PageboyViewControllerDataSource
23+
dataSource = self
24+
25+
// Instantiate our view controller from the storyboard
26+
let storyboard = UIStoryboard(name: "Main", bundle: nil)
27+
28+
// Even though delegate methods are polymorphic,
29+
// we need cast to properly set the user data.
30+
let eventsVC = storyboard.instantiateViewController(withIdentifier: "eventsVC") as! EventsViewController
31+
let resourcesVC = storyboard.instantiateViewController(withIdentifier: "resourcesVC") as! ResourcesViewController
32+
33+
// Pass our user object forward
34+
eventsVC.currentUser = self.currentUser
35+
resourcesVC.currentUser = self.currentUser
36+
37+
self.viewControllers.append(eventsVC)
38+
self.viewControllers.append(resourcesVC)
39+
40+
self.reloadData()
41+
42+
// Create bar
43+
// @TODO: Dark Mode
44+
let bar = TMBar.LineBar()
45+
bar.layout.contentInset.top = 30.0
46+
bar.layout.transitionStyle = .progressive
47+
bar.backgroundColor = .white
48+
bar.indicator.cornerStyle = .rounded
49+
if self.traitCollection.userInterfaceStyle == .dark {
50+
bar.indicator.tintColor = UIColor.init(named: "quadColor")
51+
} else {
52+
bar.indicator.tintColor = UIColor.init(named: "tertiaryColor")
53+
}
54+
55+
56+
// Add to view
57+
self.addBar(bar, dataSource: self, at: .top)
58+
59+
}
60+
61+
62+
// MARK: PageboyViewControllerSource
63+
64+
func numberOfViewControllers(in pageboyViewController: PageboyViewController) -> Int {
65+
return viewControllers.count
66+
}
67+
68+
func viewController(for pageboyViewController: PageboyViewController, at index: PageboyViewController.PageIndex) -> UIViewController? {
69+
return viewControllers[index]
70+
}
71+
72+
func defaultPage(for pageboyViewController: PageboyViewController) -> PageboyViewController.Page? {
73+
return .first
74+
}
75+
76+
// MARK: TMBarDataSource
77+
func barItem(for bar: TMBar, at index: Int) -> TMBarItemable {
78+
print("indexed at \(index)")
79+
if index == 0 {
80+
return TMBarItem(title: "Schedule")
81+
} else if index == 2 {
82+
return TMBarItem(title: "Resources")
83+
} else {
84+
return TMBarItem(title: "Unknown")
85+
}
86+
}
87+
}
88+
89+

Podfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ target 'BrickHack-Mobile' do
1414
pod 'PromiseKit/Foundation', '~> 6.0'
1515
pod 'TimelineTableViewCell', :git=>'https://github.com/peterkos/TimelineTableViewCell.git'
1616
#pod 'TimelineTableViewCell', :path=>'~/Code/Github/TimelineTableViewCell'
17+
pod 'Tabman', '~> 2.6'
1718
end
1819

1920

Podfile.lock

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ PODS:
55
- Apollo/Core (0.16.0)
66
- Keys (1.0.1)
77
- p2.OAuth2 (4.2.0)
8+
- Pageboy (3.5.0)
89
- PromiseKit (6.11.0):
910
- PromiseKit/CorePromise (= 6.11.0)
1011
- PromiseKit/Foundation (= 6.11.0)
@@ -19,6 +20,8 @@ PODS:
1920
- SwiftMessages/App (= 7.0.1)
2021
- SwiftMessages/App (7.0.1)
2122
- SwiftyJSON (5.0.0)
23+
- Tabman (2.8.0):
24+
- Pageboy (~> 3.5.0)
2225
- TimelineTableViewCell (2.2.1)
2326
- VYNFCKit (0.3.2)
2427

@@ -32,6 +35,7 @@ DEPENDENCIES:
3235
- SVProgressHUD
3336
- SwiftMessages
3437
- SwiftyJSON
38+
- Tabman (~> 2.6)
3539
- TimelineTableViewCell (from `https://github.com/peterkos/TimelineTableViewCell.git`)
3640
- VYNFCKit
3741

@@ -42,10 +46,12 @@ SPEC REPOS:
4246
trunk:
4347
- Apollo
4448
- p2.OAuth2
49+
- Pageboy
4550
- PromiseKit
4651
- SVProgressHUD
4752
- SwiftMessages
4853
- SwiftyJSON
54+
- Tabman
4955

5056
EXTERNAL SOURCES:
5157
Keys:
@@ -63,13 +69,15 @@ SPEC CHECKSUMS:
6369
Apollo: ad9ce2008f88fce57c062aa4853364b7927355c8
6470
Keys: a576f4c9c1c641ca913a959a9c62ed3f215a8de9
6571
p2.OAuth2: d5ea9b928fc5d10d088d419db6f3380578b6f866
72+
Pageboy: 3794c578aae5fcce06e90b3ed4a0ad6b807d75bb
6673
PromiseKit: e4863d06976e7dee5e41c04fc7371c16b3600292
6774
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
6875
SwiftMessages: b577dc7043be8b299857ab35bb663dbff6483bd0
6976
SwiftyJSON: 36413e04c44ee145039d332b4f4e2d3e8d6c4db7
77+
Tabman: f62ad94ee54a7d96e3fbab34f677d9ea4d38ece6
7078
TimelineTableViewCell: b2721a3c1f17c4a4950ae442f45cd4e8669a2750
7179
VYNFCKit: 86a9b711fd1f34f6f7128a2a883cd58dbd781b9d
7280

73-
PODFILE CHECKSUM: 72789a355e215b22714d7bd9ab0ec3292b700001
81+
PODFILE CHECKSUM: 329820a5a13a6b82a678097cfb99449bc03b70f5
7482

7583
COCOAPODS: 1.8.4

0 commit comments

Comments
 (0)