Skip to content

Commit

Permalink
Initial commit, starting at version 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rickybloomfield committed Sep 11, 2014
0 parents commit c819d4f
Show file tree
Hide file tree
Showing 103 changed files with 8,744 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
41 changes: 41 additions & 0 deletions Classes/Controllers/MCMainViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// MCMainViewController.swift
// Duke Medicine Mobile Companion
//
// Created by Ricky Bloomfield on 6/12/14.
// Copyright (c) 2014 Duke Medicine
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

import UIKit

class MCMainViewController: UIViewController {

// Open Haiku or Canto if installed, otherwise just open the Duke Medicine website
@IBAction func mainViewButton(sender:AnyObject) {
if (HaikuOrCanto()? != nil) {
openHaikuOrCanto()
} else {
let webViewController = MCModalWebViewController(address: "http://www.dukemedicine.org", tintColor: DUKE_BLUE())
webViewController.modalTransitionStyle = UIModalTransitionStyle.CrossDissolve
self.presentViewController(webViewController, animated: true, completion: nil)
}
}
}
93 changes: 93 additions & 0 deletions Classes/Controllers/MCModalWebViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//
// MCModalWebViewController.swift
// Duke Medicine Mobile Companion
//
// Created by Ricky Bloomfield on 6/29/14.
// Copyright (c) 2014 Duke Medicine
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

import UIKit

class MCModalWebViewController: UINavigationController {
var webViewController: TOWebViewController = TOWebViewController()

// With Swift, we now need to override all initializers used (i.e., they're not automatically assumed to exist from super)
override init(nibName nibNameOrNil: String!, bundle nibBundleOrNil: NSBundle!) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}

convenience init(address urlString: String!, tintColor: UIColor!) {
self.init(URL: NSURL.URLWithString(urlString), tintColor: tintColor)
}

required init(coder aDecoder: NSCoder)
{
super.init(coder: aDecoder)
}

init(URL url: NSURL!, tintColor: UIColor!) {
self.webViewController = TOWebViewController(URL: url)

// Make all UIBarButtonItems have bold text (so Haiku/Canto button matches the 'Done' button)
let barButtonAppearanceDict = [NSFontAttributeName : UIFont.boldSystemFontOfSize(17.0)]
UIBarButtonItem.appearance().setTitleTextAttributes(barButtonAppearanceDict, forState: UIControlState.Normal)

// Create Return button
let title = "\(HaikuOrCanto())"
var returnButton: UIBarButtonItem = UIBarButtonItem(title: title, style: UIBarButtonItemStyle.Plain, target: self.webViewController, action: Selector("returnToHaikuOrCanto"))

// Show the Haiku or Canto button on the left if one or both are installed
if HaikuOrCanto() != nil {
self.webViewController.navigationItem.leftBarButtonItem = returnButton
}

// In Swift, we have to call super.init after we initialize (but before we call any class methods)
super.init(rootViewController: self.webViewController)

// Set color for UINavigationController navigationBar - any method called on 'self' must happen after super.init called
self.view.tintColor = tintColor
}
}

// Add required functionality to SVWebViewController via an extension (new to Swift)
extension TOWebViewController {

/**
Return to the appropriate app. If on iPad, close the webview when leaving since there isn't a 'Done' button there
*/
func returnToHaikuOrCanto() {
if HaikuOrCanto() == "Haiku" {
openHaiku()
if IPAD() {
dispatch_after(1, dispatch_get_main_queue(), {
self.dismissViewControllerAnimated(true, completion: nil)
})
}
} else if HaikuOrCanto() == "Canto" {
openCanto()
if IPAD() {
dispatch_after(1, dispatch_get_main_queue(), {
self.dismissViewControllerAnimated(true, completion: nil)
})
}
}
}
}
124 changes: 124 additions & 0 deletions Classes/Controllers/MCSettingsViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
//
// MCSettingsViewController.swift
// Duke Medicine Mobile Companion
//
// Created by Ricky Bloomfield on 6/15/14.
// Copyright (c) 2014 Duke Medicine
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

import UIKit

class MCSettingsViewController: IASKAppSettingsViewController, IASKSettingsDelegate {

override init() {
super.init()
}

override init(nibName nibNameOrNil: String!, bundle nibBundleOrNil: NSBundle!) {
super.init(nibName: nibName, bundle: nil)
}

override init(style: UITableViewStyle) {
if style != UITableViewStyle.Grouped {
println("Only UITableViewStyleGrouped style is supported, forcing it.")
}

super.init(style: style)
}

required init(coder aDecoder: NSCoder)
{
super.init(coder: aDecoder)
}

override func viewDidLoad() {
super.viewDidLoad()

// Set self as delegate for IASK delegate methods
delegate = self
title = "Settings"

// Run the function used to determine whether or not to show the "Return to:" option in Settings
determineHiddenKeys()
}

// Remove appropriate settings depending whether Haiku and/or Canto are installed
func determineHiddenKeys() {
let HaikuInstalled = UIApplication.sharedApplication().canOpenURL(NSURL.URLWithString("epichaiku://"))
let CantoInstalled = UIApplication.sharedApplication().canOpenURL(NSURL.URLWithString("epiccanto://"))

var set = NSMutableSet()

// Hide the "Return to" button if neither app is installed
if !(HaikuInstalled && CantoInstalled) {
set.addObject("returnTo")
}

// Hide the "Open Haiku" button if Haiku is not installed, otherwise, hide the "Download Haiku" button
if !HaikuInstalled {
set.addObject("openHaiku")
} else {
set.addObject("downloadHaiku")
}

// Hide the "Open Canto" button if Canto is not installed, otherwise, hide the "Download Canto" button
if !CantoInstalled {
set.addObject("openCanto")
} else {
set.addObject("downloadCanto")
}

// Hide both "Open Canto" and "Download Canto" if this is not an iPad
if !IPAD() {
set.addObject("openCanto")
set.addObject("downloadCanto")
}

hiddenKeys = set
}

// Open a webview to the Duke Medicine home page
func showDukeMedicine() {
let webViewController = MCModalWebViewController(address: "http://www.dukemedicine.org", tintColor: DUKE_BLUE())
webViewController.modalTransitionStyle = UIModalTransitionStyle.CrossDissolve
self.presentViewController(webViewController, animated: true, completion: nil)
}

// Allow specific actions when tapping buttons
func settingsViewController(sender: IASKAppSettingsViewController!, buttonTappedForSpecifier specifier: IASKSpecifier!) {
if specifier.key() == "openCanto" {
openCanto()
} else if specifier.key() == "openHaiku" {
openHaiku()
} else if specifier.key() == "downloadCanto" {
downloadCanto()
} else if specifier.key() == "downloadHaiku" {
downloadHaiku()
} else if specifier.key() == "DukeMedicine" {
showDukeMedicine()
}
}

// This is a required delegate method
func settingsViewControllerDidEnd(sender: IASKAppSettingsViewController!) {

}
}
64 changes: 64 additions & 0 deletions Classes/Controllers/MCWebViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// MCWebViewController.swift
// Maestro Care Mobile Companion
//
// Created by Ricky Bloomfield on 6/25/14.
// Copyright (c) 2014 Duke Medicine. All rights reserved.
//

import UIKit

class MCWebViewController: UIViewController, UIAlertViewDelegate {

/*var webViewController: SVWebViewController?
var barsTintColor: UIColor?
var viewTintColor: UIColor?

init(nibName nibNameOrNil: String!, bundle nibBundleOrNil: NSBundle!) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}

init(address urlString: String!, andTintColor color: UIColor!) {
let url: NSURL = NSURL.URLWithString(urlString)
self.webViewController = SVWebViewController(URL: url)
super.init(rootViewController: self.webViewController)

let doneButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Done, target: self.webViewController, action: Selector("doneButtonClicked:"))

self.viewTintColor = color

// Make all UIBarButtonItems have bold text (so Haiku/Canto button matches the 'Done' button)
let barButtonAppearanceDict = [NSFontAttributeName : UIFont.boldSystemFontOfSize(17.0)]
UIBarButtonItem.appearance().setTitleTextAttributes(barButtonAppearanceDict, forState: UIControlState.Normal)

let title = "❮ \(HaikuOrCanto)"
var returnButton: UIBarButtonItem?

if IPAD() {
returnButton = UIBarButtonItem(title: title, style: UIBarButtonItemStyle.Plain, target: self, action: Selector("touchesBegan:withEvent:"))
} else {
returnButton = UIBarButtonItem(title: title, style: UIBarButtonItemStyle.Plain, target: self, action: Selector("returnToHaikuCanto"))
}

if IPAD() {
self.navigationItem.leftBarButtonItem = returnButton
} else {
self.navigationItem.rightBarButtonItem = doneButton
print("Done button added")

// Show the Haiku/Canto button on if one or both are installed
if self.HaikuOrCanto() != nil {
self.navigationItem.leftBarButtonItem = returnButton
}
}
}

override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)

//self.webViewController!.title = self.title;
self.navigationBar.tintColor = self.viewTintColor;
}*/


}
Loading

0 comments on commit c819d4f

Please sign in to comment.