Skip to content

Commit 6147cd6

Browse files
committed
Almost fully implemented Resources page
Yes I know the two embeds are strange but I was planning to have a pinned/scrolling design that didn’t work out. It was faster to leave it as it is now rather than refactor
1 parent c9eb944 commit 6147cd6

8 files changed

Lines changed: 377 additions & 74 deletions

File tree

BrickHack-Mobile.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
D706937323E8F86B004FA788 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = D706937223E8F86B004FA788 /* User.swift */; };
1818
D706937523E905FF004FA788 /* TabViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D706937423E905FF004FA788 /* TabViewController.swift */; };
1919
D750E81823DF67360075C639 /* FavoriteButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = D750E81723DF67360075C639 /* FavoriteButton.swift */; };
20+
D757301223EA236900343DDE /* ResourcesTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D757301123EA236900343DDE /* ResourcesTableViewController.swift */; };
2021
D772876C23DFF92800C2D541 /* ScheduleParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = D772876B23DFF92800C2D541 /* ScheduleParser.swift */; };
2122
D789978223D652ED0058060A /* ScheduleTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D789978123D652ED0058060A /* ScheduleTableViewController.swift */; };
2223
D789978523D6A4DC0058060A /* ProfileTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D789978423D6A4DC0058060A /* ProfileTableViewController.swift */; };
@@ -56,6 +57,7 @@
5657
D706937223E8F86B004FA788 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
5758
D706937423E905FF004FA788 /* TabViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabViewController.swift; sourceTree = "<group>"; };
5859
D750E81723DF67360075C639 /* FavoriteButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = FavoriteButton.swift; path = "BrickHack-Mobile/Views/FavoriteButton.swift"; sourceTree = SOURCE_ROOT; };
60+
D757301123EA236900343DDE /* ResourcesTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResourcesTableViewController.swift; sourceTree = "<group>"; };
5961
D772876B23DFF92800C2D541 /* ScheduleParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScheduleParser.swift; sourceTree = "<group>"; };
6062
D789978123D652ED0058060A /* ScheduleTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScheduleTableViewController.swift; sourceTree = "<group>"; };
6163
D789978423D6A4DC0058060A /* ProfileTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ProfileTableViewController.swift; path = "/Users/peterkos/Code/Github/brickhack-mobile-ios/BrickHack-Mobile/Controllers/ProfileTableViewController.swift"; sourceTree = "<absolute>"; };
@@ -137,6 +139,7 @@
137139
D789978123D652ED0058060A /* ScheduleTableViewController.swift */,
138140
D789978423D6A4DC0058060A /* ProfileTableViewController.swift */,
139141
D7C41E26236383300091C480 /* ResourcesViewController.swift */,
142+
D757301123EA236900343DDE /* ResourcesTableViewController.swift */,
140143
);
141144
path = Controllers;
142145
sourceTree = "<group>";
@@ -297,6 +300,7 @@
297300
D789978223D652ED0058060A /* ScheduleTableViewController.swift in Sources */,
298301
D772876C23DFF92800C2D541 /* ScheduleParser.swift in Sources */,
299302
D7C07885233EDBA300089193 /* LoginViewController.swift in Sources */,
303+
D757301223EA236900343DDE /* ResourcesTableViewController.swift in Sources */,
300304
D7C41E2523637D650091C480 /* MainTabBarController.swift in Sources */,
301305
D706937523E905FF004FA788 /* TabViewController.swift in Sources */,
302306
D750E81823DF67360075C639 /* FavoriteButton.swift in Sources */,

BrickHack-Mobile/AlertMessage.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,11 @@ class MessageHandler {
9696
body: "Please try again later.",
9797
type: .error)
9898
}
99+
100+
static func showUnableToOpenURLError(url: URL) {
101+
print("ERROR: URL \(url.absoluteString) cannot be opened.")
102+
showAlertMessage(withTitle: "URL cannot be opened.",
103+
body: "Please try again later.",
104+
type: .error)
105+
}
99106
}

BrickHack-Mobile/Assets.xcassets/timelineBackColor.colorset/Contents.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
"color" : {
2828
"color-space" : "srgb",
2929
"components" : {
30-
"red" : "0.754",
30+
"red" : "0xC0",
3131
"alpha" : "1.000",
32-
"blue" : "0.754",
33-
"green" : "0.754"
32+
"blue" : "0xC0",
33+
"green" : "0xC0"
3434
}
3535
}
3636
}

BrickHack-Mobile/Base.lproj/Main.storyboard

Lines changed: 264 additions & 33 deletions
Large diffs are not rendered by default.

BrickHack-Mobile/Controllers/ProfileTableViewController.swift

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,35 @@ import UIKit
1414
class ProfileTableViewController: UITableViewController {
1515

1616
// MARK: IBOutlets
17+
// These are set in the prepareForSegue in ResourcesViewController
1718
@IBOutlet weak var nameLabel: UILabel!
18-
@IBOutlet weak var schoolLabel: UILabel!
19+
@IBOutlet weak var infoLabel: UILabel!
20+
21+
// MARK: Properties
22+
var nameText: String?
23+
var infoText: String?
1924

2025
override func viewDidLoad() {
2126
super.viewDidLoad()
2227

23-
// Uncomment the following line to preserve selection between presentations
24-
// self.clearsSelectionOnViewWillAppear = false
25-
}
28+
// Fill properites
29+
self.nameLabel.text = nameText ?? "Unknown Name"
30+
self.infoLabel.text = infoText ?? "Unknown Major"
2631

27-
// MARK: - Table view data source
32+
// Fix header issue
33+
let view = UIView()
34+
view.frame.size.height = .leastNormalMagnitude
35+
self.tableView.tableHeaderView = view
2836

29-
override func numberOfSections(in tableView: UITableView) -> Int {
30-
return 1
37+
self.tableView.separatorStyle = .singleLine
3138
}
3239

33-
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
34-
return 1
35-
}
36-
37-
/*
38-
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
39-
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
40-
41-
// Configure the cell...
42-
43-
return cell
44-
}
45-
*/
46-
47-
/*
48-
// MARK: - Navigation
49-
50-
// In a storyboard-based application, you will often want to do a little preparation before navigation
51-
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
52-
// Get the new view controller using segue.destination.
53-
// Pass the selected object to the new view controller.
40+
// This doesn't work!
41+
// When a header is not defined, iOS creates a default one with a default height.
42+
// See the viewForHeaderInSection method for the real fix.
43+
// src: https://stackoverflow.com/a/22185534/1431900
44+
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
45+
return 0.0
5446
}
55-
*/
5647

5748
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
//
2+
// ResourcesTableViewController.swift
3+
// BrickHack-Mobile
4+
//
5+
// Created by Peter Kos on 2/4/20.
6+
// Copyright © 2020 codeRIT. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class ResourcesTableViewController: UITableViewController {
12+
13+
// MARK: IBStuff
14+
15+
@IBAction func callEmergency(_ sender: Any) {
16+
17+
let emergencyURL = URL(string: "tel://\(emergencyNumber)")!
18+
openURL(url: emergencyURL)
19+
}
20+
21+
@IBAction func callNonEmergency(_ sender: Any) {
22+
23+
let nonEmergencyURL = URL(string: "tel://\(emergencyNumber)")!
24+
openURL(url: nonEmergencyURL)
25+
}
26+
27+
@IBAction func openDevpost(_ sender: Any) {
28+
openURL(url: URL(string: devpostURL)!)
29+
}
30+
31+
@IBAction func openSlack(_ sender: Any) {
32+
openURL(url: URL(string: slackURL)!)
33+
}
34+
35+
36+
// MARK: Properties
37+
38+
let emergencyNumber = "585_475_3333"
39+
let nonEmergencyNumber = "585_475_2853"
40+
let devpostURL = "https://brickhack6.devpost.com"
41+
let slackURL = "https://brickhack6.slack.com"
42+
43+
override func viewDidLoad() {
44+
super.viewDidLoad()
45+
46+
// Fix header issue
47+
let view = UIView()
48+
view.frame.size.height = .leastNormalMagnitude
49+
self.tableView.tableHeaderView = view
50+
}
51+
52+
private func openURL(url: URL) {
53+
54+
guard UIApplication.shared.canOpenURL(url) else {
55+
MessageHandler.showUnableToOpenURLError(url: url)
56+
return
57+
}
58+
59+
UIApplication.shared.open(url, options: [:], completionHandler: nil)
60+
}
61+
62+
// This doesn't work!
63+
// When a header is not defined, iOS creates a default one with a default height.
64+
// See the viewForHeaderInSection method for the real fix.
65+
// src: https://stackoverflow.com/a/22185534/1431900
66+
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
67+
return 0.0
68+
}
69+
70+
}

BrickHack-Mobile/Controllers/ResourcesViewController.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
import UIKit
1010

11+
/**
12+
Acts as a dummy intermediate to pass properties HERE instead of in whatever class attempts to instantiate it.
13+
Yay for last minute decisions.
14+
*/
1115
class ResourcesViewController: UIViewController {
1216

1317
var currentUser: User!
@@ -24,13 +28,9 @@ class ResourcesViewController: UIViewController {
2428
// that is contained within this view via an Embed segue.
2529
if let tableVC = segue.destination as? ProfileTableViewController {
2630

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"
31+
// @TODO: Impement thanks
32+
tableVC.nameText = currentUser.firstName + " " + currentUser.lastName
33+
tableVC.infoText = "Majoring in X"// + currentUser.major
3434

3535
}
3636
}

BrickHack-Mobile/Launch Screen.storyboard

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
<rect key="frame" x="0.0" y="0.0" width="375" height="487"/>
2222
<subviews>
2323
<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"/>
24+
<rect key="frame" x="36" y="104" width="296" height="279"/>
2525
</imageView>
2626
<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"/>
27+
<rect key="frame" x="-47" y="-105.5" width="422" height="698"/>
2828
</imageView>
2929
</subviews>
3030
<color key="backgroundColor" name="primaryColor"/>

0 commit comments

Comments
 (0)