Skip to content

Commit

Permalink
nate/feature/LOOP-309/plugin-colours (#23)
Browse files Browse the repository at this point in the history
* color palette available to plugin

* adding colours to the rileylink app
  • Loading branch information
nhamming authored Aug 10, 2020
1 parent 54a51ce commit 1042f10
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
7 changes: 4 additions & 3 deletions MinimedKitUI/MinimedPumpManager+UI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Copyright © 2018 LoopKit Authors. All rights reserved.
//

import SwiftUI
import UIKit
import LoopKit
import LoopKitUI
Expand All @@ -13,11 +14,11 @@ import MinimedKit

extension MinimedPumpManager: PumpManagerUI {

static public func setupViewController() -> (UIViewController & PumpManagerSetupViewController & CompletionNotifying) {
static public func setupViewController(insulinTintColor: Color, guidanceColors: GuidanceColors) -> (UIViewController & PumpManagerSetupViewController & CompletionNotifying) {
return MinimedPumpManagerSetupViewController.instantiateFromStoryboard()
}

public func settingsViewController() -> (UIViewController & CompletionNotifying) {
public func settingsViewController(insulinTintColor: Color, guidanceColors: GuidanceColors) -> (UIViewController & CompletionNotifying) {
let settings = MinimedPumpSettingsViewController(pumpManager: self)
let nav = SettingsNavigationViewController(rootViewController: settings)
return nav
Expand All @@ -27,7 +28,7 @@ extension MinimedPumpManager: PumpManagerUI {
return state.smallPumpImage
}

public func hudProvider() -> HUDProvider? {
public func hudProvider(insulinTintColor: Color, guidanceColors: GuidanceColors) -> HUDProvider? {
return MinimedHUDProvider(pumpManager: self)
}

Expand Down
10 changes: 5 additions & 5 deletions OmniKitUI/PumpManager/OmniPodPumpManager+UI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
//

import Foundation

import SwiftUI
import UIKit
import LoopKit
import LoopKitUI
import OmniKit

extension OmnipodPumpManager: PumpManagerUI {

static public func setupViewController() -> (UIViewController & PumpManagerSetupViewController & CompletionNotifying) {
static public func setupViewController(insulinTintColor: Color, guidanceColors: GuidanceColors) -> (UIViewController & PumpManagerSetupViewController & CompletionNotifying) {
return OmnipodPumpManagerSetupViewController.instantiateFromStoryboard()
}

public func settingsViewController() -> (UIViewController & CompletionNotifying) {
public func settingsViewController(insulinTintColor: Color, guidanceColors: GuidanceColors) -> (UIViewController & CompletionNotifying) {
let settings = OmnipodSettingsViewController(pumpManager: self)
let nav = SettingsNavigationViewController(rootViewController: settings)
return nav
Expand All @@ -29,8 +29,8 @@ extension OmnipodPumpManager: PumpManagerUI {
return UIImage(named: "Pod", in: Bundle(for: OmnipodSettingsViewController.self), compatibleWith: nil)!
}

public func hudProvider() -> HUDProvider? {
return OmnipodHUDProvider(pumpManager: self)
public func hudProvider(insulinTintColor: Color, guidanceColors: GuidanceColors) -> HUDProvider? {
return OmnipodHUDProvider(pumpManager: self, insulinTintColor: insulinTintColor, guidanceColors: guidanceColors)
}

public static func createHUDView(rawValue: HUDProvider.HUDViewRawState) -> LevelHUDView? {
Expand Down
11 changes: 9 additions & 2 deletions OmniKitUI/PumpManager/OmnipodHUDProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import UIKit
import SwiftUI
import LoopKit
import LoopKitUI
import OmniKit
Expand Down Expand Up @@ -48,9 +49,15 @@ internal class OmnipodHUDProvider: NSObject, HUDProvider, PodStateObserver {
}
}

public init(pumpManager: OmnipodPumpManager) {
private let insulinTintColor: Color

private let guidanceColors: GuidanceColors

public init(pumpManager: OmnipodPumpManager, insulinTintColor: Color, guidanceColors: GuidanceColors) {
self.pumpManager = pumpManager
self.podState = pumpManager.state.podState
self.insulinTintColor = insulinTintColor
self.guidanceColors = guidanceColors
super.init()
self.pumpManager.addPodStateObserver(self, queue: .main)
}
Expand Down Expand Up @@ -87,7 +94,7 @@ internal class OmnipodHUDProvider: NSObject, HUDProvider, PodStateObserver {
if podState?.fault != nil {
return HUDTapAction.presentViewController(PodReplacementNavigationController.instantiatePodReplacementFlow(pumpManager))
} else {
return HUDTapAction.presentViewController(pumpManager.settingsViewController())
return HUDTapAction.presentViewController(pumpManager.settingsViewController(insulinTintColor: insulinTintColor, guidanceColors: guidanceColors))
}
}

Expand Down
4 changes: 3 additions & 1 deletion RileyLink/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
//

import UIKit
import SwiftUI
import CoreData
import LoopKitUI
import RileyLinkKit


Expand All @@ -21,7 +23,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

if let navController = self.window?.rootViewController as? UINavigationController {
let mainViewController = MainViewController(deviceDataManager: deviceDataManager)
let mainViewController = MainViewController(deviceDataManager: deviceDataManager, insulinTintColor: .orange, guidanceColors: GuidanceColors(acceptable: .primary, warning: .yellow, critical: .red))
navController.pushViewController(mainViewController, animated: false)
}

Expand Down
13 changes: 10 additions & 3 deletions RileyLink/View Controllers/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2016 Pete Schwamb. All rights reserved.
//
import UIKit
import SwiftUI
import MinimedKit
import MinimedKitUI
import RileyLinkBLEKit
Expand All @@ -18,9 +19,15 @@ import OmniKitUI
class MainViewController: RileyLinkSettingsViewController {

let deviceDataManager: DeviceDataManager

let insulinTintColor: Color

let guidanceColors: GuidanceColors

init(deviceDataManager: DeviceDataManager) {
init(deviceDataManager: DeviceDataManager, insulinTintColor: Color, guidanceColors: GuidanceColors) {
self.deviceDataManager = deviceDataManager
self.insulinTintColor = insulinTintColor
self.guidanceColors = guidanceColors
let rileyLinkPumpManager = RileyLinkPumpManager(rileyLinkDeviceProvider: deviceDataManager.rileyLinkConnectionManager.deviceProvider, rileyLinkConnectionManager: deviceDataManager.rileyLinkConnectionManager)

super.init(rileyLinkPumpManager: rileyLinkPumpManager, devicesSectionIndex: Section.rileyLinks.rawValue, style: .grouped)
Expand Down Expand Up @@ -173,7 +180,7 @@ class MainViewController: RileyLinkSettingsViewController {
show(vc, sender: indexPath)
case .pump:
if let pumpManager = deviceDataManager.pumpManager {
var settings = pumpManager.settingsViewController()
var settings = pumpManager.settingsViewController(insulinTintColor: insulinTintColor, guidanceColors: guidanceColors)
settings.completionDelegate = self
present(settings, animated: true)
} else {
Expand Down Expand Up @@ -217,7 +224,7 @@ extension MainViewController: CompletionDelegate {
extension MainViewController: PumpManagerSetupViewControllerDelegate {
func pumpManagerSetupViewController(_ pumpManagerSetupViewController: PumpManagerSetupViewController, didSetUpPumpManager pumpManager: PumpManagerUI) {
deviceDataManager.pumpManager = pumpManager
show(pumpManager.settingsViewController(), sender: nil)
show(pumpManager.settingsViewController(insulinTintColor: insulinTintColor, guidanceColors: guidanceColors), sender: nil)
tableView.reloadSections(IndexSet([Section.pump.rawValue]), with: .none)
}
}

0 comments on commit 1042f10

Please sign in to comment.