Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

.DS_Store
499 changes: 499 additions & 0 deletions ITGlueContacts/ITGlueContacts.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>ITGlueContacts.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
55 changes: 55 additions & 0 deletions ITGlueContacts/ITGlueContacts/Controllers/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// AppDelegate.swift
// ITGlueContacts
//
// Created by Michael Page on 14/6/19.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let viewController: UIViewController

if UserDefaults.standard.displayedAppIntro() {
// Welcome screen has been previously displayed.
viewController = storyboard.instantiateInitialViewController()!
} else {
// User has not been shown the welcome screen.
viewController = storyboard.instantiateViewController(withIdentifier: "WelcomeViewController")
}

window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = viewController

return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Date+CurrentTimeZoneDateString.swift
// ITGlueContacts
//
// Created by Michael Page on 25/6/19.
//

import Foundation

extension Date {
// Output a date string, based on the user's current time zone. Example: "26 Jun 2019 at 3:19 pm"
func currentTimeZoneDateString() -> String {
let format = DateFormatter()
format.timeZone = .current
format.dateStyle = .medium
format.timeStyle = .short
return format.string(from: self)
}
}
15 changes: 15 additions & 0 deletions ITGlueContacts/ITGlueContacts/Extensions/String+FullRange.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// String+FullRange.swift
// ITGlueContacts
//
// Created by Michael Page on 16/6/19.
//

import Foundation

extension String {
// Returns NSRange of a string.
func fullRange() -> NSRange {
return NSMakeRange(0, count)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// UIViewController+Alert.swift
// ITGlueContacts
//
// Created by Michael Page on 26/6/19.
//

import UIKit

extension UIViewController {
// Display a basic alert on the main thread.
func alert(title: String?, message: String?) {
DispatchQueue.main.async {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
let dismissAction = UIAlertAction(title: "Close", style: .default)
alert.addAction(dismissAction)
self.present(alert, animated: true)
}
}
}
33 changes: 33 additions & 0 deletions ITGlueContacts/ITGlueContacts/Extensions/UserDefaults.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// UserDefaults.swift
// ITGlueContacts
//
// Created by Michael Page on 22/6/19.
//

import Foundation

// UserDefaults is used for storing app settings.
enum UserDefaultsKeys: String {
case displayedAppIntro, connectToEuropeanUnionEndpoint
}

extension UserDefaults {
func setDisplayedAppIntro(_ value: Bool) {
set(value, forKey: UserDefaultsKeys.displayedAppIntro.rawValue)
}

// Has the user been shown the welcome screen yet?
func displayedAppIntro() -> Bool {
return bool(forKey: UserDefaultsKeys.displayedAppIntro.rawValue)
}

func setConnectToEuropeanUnionEndpoint(_ value: Bool) {
set(value, forKey: UserDefaultsKeys.connectToEuropeanUnionEndpoint.rawValue)
}

// Should the app use the EU API endpoint?
func connectToEuropeanUnionEndpoint() -> Bool {
return bool(forKey: UserDefaultsKeys.connectToEuropeanUnionEndpoint.rawValue)
}
}
Loading