Skip to content

Commit 94311cb

Browse files
authored
Merge pull request #12 from codeRIT/peter-navigation
[merge profile PR first] Navigation
2 parents bbde934 + c9eb944 commit 94311cb

12 files changed

Lines changed: 298 additions & 79 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 */,
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
},
6+
"colors" : [
7+
{
8+
"idiom" : "universal",
9+
"color" : {
10+
"color-space" : "srgb",
11+
"components" : {
12+
"red" : "0x38",
13+
"alpha" : "1.000",
14+
"blue" : "0x59",
15+
"green" : "0x48"
16+
}
17+
}
18+
},
19+
{
20+
"idiom" : "universal",
21+
"appearances" : [
22+
{
23+
"appearance" : "luminosity",
24+
"value" : "dark"
25+
}
26+
],
27+
"color" : {
28+
"color-space" : "srgb",
29+
"components" : {
30+
"red" : "1.000",
31+
"alpha" : "1.000",
32+
"blue" : "1.000",
33+
"green" : "1.000"
34+
}
35+
}
36+
}
37+
]
38+
}

BrickHack-Mobile/Base.lproj/Main.storyboard

Lines changed: 80 additions & 39 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: 4 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

@@ -148,6 +148,8 @@ class ScheduleTableViewController: UITableViewController {
148148
// Set images
149149
favButton.addTarget(self, action: #selector(favoriteTapped(sender:)), for: .touchUpInside)
150150
cell.accessoryView = favButton
151+
// Make "favorite" star a bit bigger
152+
cell.accessoryView?.transform = CGAffineTransform(scaleX: 1.1, y: 1.1)
151153
// Set custom properties
152154
favButton.section = indexPath.section
153155
favButton.row = indexPath.row
@@ -253,7 +255,7 @@ class ScheduleTableViewController: UITableViewController {
253255

254256
// Defined height for the time header slot (e.g., "9am")
255257
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
256-
return 60.0
258+
return 40.0
257259
}
258260

259261
// 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+
let bar = TMBar.ButtonBar()
44+
// bar.layout.contentInset.top = 30.0
45+
bar.layout.interButtonSpacing = 20.0
46+
bar.layout.contentInset.left = 20.0
47+
bar.layout.transitionStyle = .progressive
48+
bar.indicator.cornerStyle = .rounded
49+
bar.indicator.tintColor = UIColor.init(named: "tabBarIndicatorColor")
50+
if #available(iOS 13.0, *) {
51+
bar.backgroundView.style = .flat(color: .systemBackground)
52+
} else {
53+
bar.backgroundView.style = .flat(color: .white)
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 == 1 {
82+
return TMBarItem(title: "Resources")
83+
} else {
84+
return TMBarItem(title: "Unknown")
85+
}
86+
}
87+
}
88+
89+
Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="zNB-F1-Vze">
3-
<device id="retina4_7" orientation="portrait">
4-
<adaptation id="fullscreen"/>
5-
</device>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="zNB-F1-Vze">
3+
<device id="retina4_7" orientation="portrait" appearance="light"/>
64
<dependencies>
75
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
7+
<capability name="Named colors" minToolsVersion="9.0"/>
98
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
109
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1110
</dependencies>
@@ -17,14 +16,48 @@
1716
<view key="view" contentMode="scaleToFill" id="hIc-I3-XMI">
1817
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1918
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
20-
<color key="backgroundColor" red="0.21747174859999999" green="0.27733260389999997" blue="0.34390062090000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
19+
<subviews>
20+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="W8h-cH-efN">
21+
<rect key="frame" x="0.0" y="0.0" width="375" height="487"/>
22+
<subviews>
23+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="brickHack6Logo" translatesAutoresizingMaskIntoConstraints="NO" id="baO-lg-ues">
24+
<rect key="frame" x="36" y="174" width="148" height="139.5"/>
25+
</imageView>
26+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="loginShapes" translatesAutoresizingMaskIntoConstraints="NO" id="Vz7-XO-8iH">
27+
<rect key="frame" x="164" y="69" width="211" height="349"/>
28+
</imageView>
29+
</subviews>
30+
<color key="backgroundColor" name="primaryColor"/>
31+
<constraints>
32+
<constraint firstAttribute="trailing" secondItem="Vz7-XO-8iH" secondAttribute="trailing" id="74V-Xn-Byc"/>
33+
<constraint firstAttribute="trailing" secondItem="Vz7-XO-8iH" secondAttribute="trailing" id="7OA-4e-nHn"/>
34+
<constraint firstItem="baO-lg-ues" firstAttribute="leading" secondItem="W8h-cH-efN" secondAttribute="leading" constant="36" id="hd4-Zv-X8h"/>
35+
<constraint firstItem="baO-lg-ues" firstAttribute="centerY" secondItem="W8h-cH-efN" secondAttribute="centerY" id="kFR-BP-ydw"/>
36+
<constraint firstItem="Vz7-XO-8iH" firstAttribute="centerY" secondItem="W8h-cH-efN" secondAttribute="centerY" id="lMu-ws-dg6"/>
37+
</constraints>
38+
</view>
39+
</subviews>
40+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
41+
<constraints>
42+
<constraint firstItem="4bi-QB-vgu" firstAttribute="bottom" secondItem="W8h-cH-efN" secondAttribute="bottom" constant="180" id="C9d-xx-mM5"/>
43+
<constraint firstItem="4bi-QB-vgu" firstAttribute="trailing" secondItem="W8h-cH-efN" secondAttribute="trailing" id="Q01-OU-a8Z"/>
44+
<constraint firstItem="W8h-cH-efN" firstAttribute="leading" secondItem="4bi-QB-vgu" secondAttribute="leading" id="W4n-x5-hM4"/>
45+
<constraint firstItem="W8h-cH-efN" firstAttribute="top" secondItem="hIc-I3-XMI" secondAttribute="top" id="jJ4-es-EWb"/>
46+
</constraints>
2147
<viewLayoutGuide key="safeArea" id="4bi-QB-vgu"/>
2248
</view>
2349
<nil key="simulatedTopBarMetrics"/>
2450
</viewController>
2551
<placeholder placeholderIdentifier="IBFirstResponder" id="n08-hQ-RY1" sceneMemberID="firstResponder"/>
2652
</objects>
27-
<point key="canvasLocation" x="947.82608695652186" y="132.58928571428572"/>
53+
<point key="canvasLocation" x="946.39999999999998" y="131.78410794602701"/>
2854
</scene>
2955
</scenes>
56+
<resources>
57+
<image name="brickHack6Logo" width="148" height="139.5"/>
58+
<image name="loginShapes" width="211" height="349"/>
59+
<namedColor name="primaryColor">
60+
<color red="0.96078431372549022" green="0.52549019607843139" blue="0.14509803921568629" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
61+
</namedColor>
62+
</resources>
3063
</document>

0 commit comments

Comments
 (0)