Skip to content

Commit 44500f6

Browse files
authored
Merge pull request #7 from codeRIT/peter
Clean start, basic login (non-native)
2 parents 0d3fcf4 + 3d51db7 commit 44500f6

24 files changed

Lines changed: 878 additions & 1280 deletions

BrickHack-Mobile.xcodeproj/project.pbxproj

Lines changed: 54 additions & 148 deletions
Large diffs are not rendered by default.

BrickHack-Mobile.xcworkspace/contents.xcworkspacedata

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
//
2+
// AlertMessage.swift
3+
// BrickHack-Mobile
4+
//
5+
// Created by Peter Kos on 10/4/19.
6+
// Copyright © 2019 codeRIT. All rights reserved.
7+
//
8+
9+
import SwiftMessages
10+
11+
12+
class MessageHandler {
13+
14+
// A set of common message types
15+
// @TODO: Flesh these out as needed (error=red, warning=yellow, info=blue styles)
16+
// For now, only error is supported.
17+
enum MessageType {
18+
case error, warning, info
19+
}
20+
21+
// Wrapper for SwiftMessages that configures standard properties for this project.
22+
// Precondition: must be called on the main thread
23+
static func showAlertMessage(withTitle title: String, body: String, type: MessageType ) {
24+
25+
let view = MessageView.viewFromNib(layout: .tabView)
26+
view.configureTheme(.error)
27+
view.button?.isHidden = true
28+
view.configureContent(title: title,
29+
body: body,
30+
iconText: "⚠️")
31+
32+
// Tapping message will hide view
33+
view.tapHandler = { _ in SwiftMessages.hide() }
34+
35+
// Configure view properties
36+
// @TODO: Add progress bar timer, à-la Discord?
37+
var config = SwiftMessages.Config()
38+
config.presentationStyle = .center
39+
config.dimMode = .color(color: UIColor.black.withAlphaComponent(0.5), interactive: true)
40+
config.preferredStatusBarStyle = .lightContent
41+
config.duration = .automatic
42+
43+
44+
SwiftMessages.show(config: config, view: view)
45+
46+
}
47+
48+
static func showConnectionError() {
49+
print("ERROR: Connection Error")
50+
showAlertMessage(withTitle: "Unable To Connect",
51+
body: "Make sure you're connected to the internet.",
52+
type: .error)
53+
}
54+
55+
static func showAuthorizationDeniedError(withText error: Error) {
56+
print("ERROR: Authorization Denied")
57+
print(error.localizedDescription)
58+
showAlertMessage(withTitle: "Authorization Denied",
59+
body: "Please try again.",
60+
type: .error)
61+
}
62+
63+
static func showInvalidUserError() {
64+
print("ERROR: Invalid user")
65+
showAlertMessage(withTitle: "Invalid User",
66+
body: "Please log in again.",
67+
type: .error)
68+
}
69+
70+
static func showAuthSigningError() {
71+
print("ERROR: Auth signing error")
72+
showAlertMessage(withTitle: "Authentication Error",
73+
body: "Please try logging in again.",
74+
type: .error)
75+
}
76+
77+
static func showNetworkError(withText errorText: String) {
78+
print("ERROR: Network Error")
79+
print(errorText)
80+
showAlertMessage(withTitle: "Networking Error",
81+
body: "Error grabbing user info from server.",
82+
type: .error)
83+
}
84+
85+
static func showUserDataParsingError(withText errorText: String = "") {
86+
print("ERROR: User Data Parsing Error")
87+
print(errorText)
88+
showAlertMessage(withTitle: "Parsing Error",
89+
body: "Error parsing user info from server.",
90+
type: .error)
91+
92+
}
93+
}

BrickHack-Mobile/AppDelegate.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1313

1414
var window: UIWindow?
1515

16-
1716
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1817
// Override point for customization after application launch.
1918
return true
2019
}
2120

2221
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
23-
if "brickhack-ios" == url.scheme{
22+
23+
if "brickhack-ios" == url.scheme {
2424
if let vc = window?.rootViewController as? LoginViewController {
25-
vc.oauth2.handleRedirectURL(url)
25+
vc.oauthGrant.handleRedirectURL(url)
2626
return true
2727
}
2828
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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" : "0.216",
13+
"alpha" : "1.000",
14+
"blue" : "0.345",
15+
"green" : "0.278"
16+
}
17+
}
18+
}
19+
]
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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" : "0x36",
13+
"alpha" : "1.000",
14+
"blue" : "0x58",
15+
"green" : "0x47"
16+
}
17+
}
18+
}
19+
]
20+
}

BrickHack-Mobile/Authentication.swift

Lines changed: 0 additions & 125 deletions
This file was deleted.

0 commit comments

Comments
 (0)