-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac1d1f8
commit e069e26
Showing
165 changed files
with
5,205 additions
and
2,430 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
848 changes: 0 additions & 848 deletions
848
SiliconLabsApp/Base.lproj/RangeTest/RangeTestStoryboard.storyboard
This file was deleted.
Oops, something went wrong.
372 changes: 0 additions & 372 deletions
372
SiliconLabsApp/Base.lproj/RangeTest/SILRangeTestModeSelectionViewController.xib
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
SiliconLabsApp/BluetoothControllers/SILBluetoothDisabledAlert.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// SILBluetoothDisabledAlert.swift | ||
// BlueGecko | ||
// | ||
// Created by Kamil Czajka on 22.12.2020. | ||
// Copyright © 2020 SiliconLabs. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
@objc | ||
enum SILBluetoothDisabledAlert: Int { | ||
case browser | ||
case advertiser | ||
case healthThermometer | ||
case rangeTest | ||
case connectedLighting | ||
|
||
var title: String { | ||
"Bluetooth Disabled" | ||
} | ||
|
||
var message: String { | ||
let backMsg = "You will back to the home screen." | ||
let turnOnMsg = "Turn on Bluetooth to" | ||
switch self { | ||
case .browser: | ||
return "\(backMsg) \(turnOnMsg) using Browser." | ||
case .advertiser: | ||
return "\(turnOnMsg) start any Advertiser." | ||
case .healthThermometer: | ||
return "\(backMsg) \(turnOnMsg) using Health Thermometer." | ||
case .rangeTest: | ||
return "\(backMsg) \(turnOnMsg) using Range Test." | ||
case .connectedLighting: | ||
return "\(backMsg) \(turnOnMsg) using Connected Lighting." | ||
} | ||
} | ||
} | ||
|
||
@objc | ||
class SILBluetoothDisabledAlertObjc: NSObject { | ||
private let bluetoothDisabledAlert: SILBluetoothDisabledAlert | ||
|
||
@objc init(bluetoothDisabledAlert: SILBluetoothDisabledAlert) { | ||
self.bluetoothDisabledAlert = bluetoothDisabledAlert | ||
} | ||
|
||
@objc func getTitle() -> String { | ||
return bluetoothDisabledAlert.title | ||
} | ||
|
||
@objc func getMessage() -> String { | ||
return bluetoothDisabledAlert.message | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// NSObject+SILAssociatedObject.h | ||
// BlueGecko | ||
// | ||
// Created by Michal Lenart on 03/12/2020. | ||
// Copyright © 2020 SiliconLabs. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface NSObject(SILAssociatedObject) | ||
|
||
- (nullable id)sil_associatedObject:(NSString*)key; | ||
- (void)sil_setAssociatedObject:(nullable id)object forKey:(NSString*)key; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// NSObject+SILAssociatedObject.m | ||
// BlueGecko | ||
// | ||
// Created by Michal Lenart on 03/12/2020. | ||
// Copyright © 2020 SiliconLabs. All rights reserved. | ||
// | ||
|
||
#import "NSObject+SILAssociatedObject.h" | ||
|
||
static void* const kSILAssociatedObjectsKey = (void*)&kSILAssociatedObjectsKey; | ||
|
||
@implementation NSObject(SILAssociatedObject) | ||
|
||
- (nullable id)sil_associatedObject:(NSString*)key { | ||
NSDictionary* objects = objc_getAssociatedObject(self, kSILAssociatedObjectsKey); | ||
return [objects valueForKey:key]; | ||
} | ||
|
||
- (void)sil_setAssociatedObject:(nullable id)object forKey:(NSString*)key { | ||
NSMutableDictionary* objects = objc_getAssociatedObject(self, kSILAssociatedObjectsKey); | ||
|
||
if (objects == nil) { | ||
objects = [NSMutableDictionary dictionary]; | ||
objc_setAssociatedObject(self, kSILAssociatedObjectsKey, objects, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
} | ||
|
||
[objects setValue:object forKey:key]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// UIViewController+Alert.swift | ||
// BlueGecko | ||
// | ||
// Created by Kamil Czajka on 22.12.2020. | ||
// Copyright © 2020 SiliconLabs. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
@objc | ||
extension UIViewController { | ||
@objc func alertWithOKButton(title: String, message: String, completion: ((UIAlertAction) -> Void)? = nil) { | ||
let alert = UIAlertController(title: title, | ||
message: message, | ||
preferredStyle: .alert) | ||
|
||
let okButton = UIAlertAction(title: "OK", style: .default, handler: completion) | ||
alert.addAction(okButton) | ||
self.present(alert, animated: true, completion: nil) | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
SiliconLabsApp/Categories/UIViewController+SILContext.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// UIViewController+Context.swift | ||
// BlueGecko | ||
// | ||
// Created by Michal Lenart on 03/12/2020. | ||
// Copyright © 2020 SiliconLabs. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
extension UIViewController { | ||
/// Provide any context down to the UIViewController tree. Context can be retrieved with sil_useContext method in any UIViewController descendant. | ||
func sil_provideContext<T>(type: T.Type, value: T?) { | ||
let key = String(describing: T.self) | ||
self.sil_setAssociatedObject(value, forKey: key) | ||
} | ||
|
||
/// Get context with given type that was provider in any UIViewController ancestor. | ||
func sil_useContext<T>(type: T.Type) -> T? { | ||
let key = String(describing: T.self) | ||
|
||
if let value = self.sil_associatedObject(key) as? T { | ||
return value | ||
} else { | ||
return parent?.sil_useContext(type: type) | ||
} | ||
} | ||
} |
Oops, something went wrong.