Skip to content

Commit a618cdb

Browse files
committed
Basic demo app functioning
1 parent 04713f6 commit a618cdb

File tree

145 files changed

+2725
-9095
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+2725
-9095
lines changed

Examples/UIKitBaseDemo/Shared/ContentView.swift

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,23 @@
88
import SwiftUI
99
import UIKitBase
1010

11+
1112
struct ContentView: View {
13+
@EnvironmentObject var appDelegate: AppDelegate
1214
var body: some View {
13-
Text(SwiftPackageClass().text)
14-
.padding()
15+
MainViewController()
1516
}
1617
}
1718

18-
struct ContentView_Previews: PreviewProvider {
19-
static var previews: some View {
20-
ContentView()
19+
20+
21+
22+
struct MainViewController: UIViewControllerRepresentable {
23+
func updateUIViewController(_ uiViewController: BaseNavigationController, context: Context) {
24+
25+
}
26+
27+
func makeUIViewController(context: Context) -> BaseNavigationController {
28+
return BaseNavigationController(rootViewController: ExampleTableViewController())
2129
}
2230
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
//
2+
// AppDelegate.swift
3+
// UIKitBase
4+
//
5+
// Created by Brian Strobach on 04/10/2016.
6+
// Copyright (c) 2016 Brian Strobach. All rights reserved.
7+
//
8+
9+
import UIKitBase
10+
import Swiftest
11+
import IQKeyboardManagerSwift
12+
import UserNotifications
13+
import UIKitTheme
14+
import UIKitBase
15+
import UIKitMixinable
16+
import UIFontLoader
17+
var sendDeepLink: Bool = false
18+
19+
20+
class AppDelegate: BaseUIApplicationDelegate, ObservableObject {
21+
22+
override open func createMixins() -> [LifeCycle] {
23+
return super.createMixins() + [AppIOManagerMixin(self)]
24+
}
25+
26+
static var activityMonitor: ActivityMonitoringWindow?{
27+
return shared?.window as? ActivityMonitoringWindow
28+
}
29+
static var shared: AppDelegate?{
30+
return UIApplication.shared.delegate as? AppDelegate
31+
}
32+
override var appConfiguration: AppConfiguration {
33+
let config = ExampleAppConfiguration()
34+
config.style.tabBarItem.defaults.selectedIconColor = config.style.colors.text.dark
35+
config.style.tabBarItem.defaults.selectedTextColor = config.style.colors.text.dark
36+
return config
37+
}
38+
override init() {
39+
FontLoader.loadAllFonts()
40+
super.init()
41+
UNUserNotificationCenter.current().delegate = self
42+
}
43+
open override func configureLoggingLevels(){
44+
UIApplication.enableAutolayoutWarningLog(false)
45+
}
46+
47+
// MARK: - UISceneSession Lifecycle
48+
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
49+
return true
50+
}
51+
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
52+
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
53+
}
54+
55+
// override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]?) -> Bool {
56+
// IQKeyboardManager.shared.enable = true
57+
// deepLinker.registerRoutes()
58+
//
59+
//// self.window = ActivityMonitoringWindow()
60+
//// self.window?.rootViewController = BaseNavigationController(rootViewController: ExampleTableViewController())
61+
//// self.window?.makeKeyAndVisible()
62+
//
63+
// return super.application(application, didFinishLaunchingWithOptions: launchOptions)
64+
// }
65+
66+
override func applicationWillResignActive(_ application: UIApplication) {
67+
super.applicationWillResignActive(application)
68+
if sendDeepLink{
69+
sendDeepLink = false
70+
let content = UNMutableNotificationContent()
71+
content.title = NSString.localizedUserNotificationString(forKey: "Yo!", arguments: nil)
72+
content.body = NSString.localizedUserNotificationString(forKey: "Did somebody order a deep link?",
73+
arguments: nil)
74+
content.userInfo = [
75+
"notificationId" : "exampleNotification",
76+
"id" : 99
77+
]
78+
var dateInfo = DateComponents()
79+
let date = Date()
80+
dateInfo.day = date.day
81+
dateInfo.hour = date.hour
82+
dateInfo.minute = date.minute
83+
dateInfo.second = date.second + 2
84+
85+
let trigger = UNCalendarNotificationTrigger(dateMatching: dateInfo, repeats: false)
86+
// Create the request object.
87+
let request = UNNotificationRequest(identifier: "Deep Link Trigger", content: content, trigger: trigger)
88+
// Schedule the request.
89+
90+
91+
let center = UNUserNotificationCenter.current()
92+
93+
center.add(request) { (error : Error?) in
94+
if let theError = error {
95+
debugLog(theError.localizedDescription)
96+
}
97+
}
98+
}
99+
}
100+
}
101+
102+
public enum ExampleNotificationId: String, AppNotificationID{
103+
case exampleNotification = "exampleNotification"
104+
}
105+
public enum ExampleDeepLinkEnum: String, DeepLinkRoute{
106+
public static var scheme: String = "uikitbasedemo"
107+
108+
case exampleDeepLinkWithId = "/id/:id"
109+
}
110+
111+
extension AppDelegate: AppIOManager {
112+
func registerDevice(withToken token: String, serviceToken: String?, success: VoidClosure?, failure: ErrorClosure?) {
113+
114+
}
115+
116+
117+
public typealias AppNotificationIDType = ExampleNotificationId
118+
public typealias DeepLinkRouteType = ExampleDeepLinkEnum
119+
120+
public func application(_ application: UIApplication = UIApplication.shared, didRecieveNotificationWhileActive notification: AppNotification<AppNotificationIDType>){
121+
122+
}
123+
open func convertNotificationToDeepLinkRequest(_ notification: AppNotification<AppNotificationIDType>) -> String? {
124+
let scheme = "UIKitBaseExample:"
125+
guard let notificationId = notification.notificationIdentifier else { return nil }
126+
do{
127+
switch notificationId{
128+
case .exampleNotification: return "\(scheme)//id/\(try notification.parse(key: "id"))"
129+
}
130+
}
131+
catch{
132+
UIApplication.topmostViewController?.showErrorAlert(title: "Error", message: "Unable to handle push notification. \(error.localizedDescription)")
133+
return nil
134+
}
135+
}
136+
func registerDevice(withToken token: String, success: VoidClosure?, failure: ErrorClosure?) {
137+
print("Do registration for token \(token)")
138+
}
139+
}
140+
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//
2+
// BaseButtonExamplesViewController.swift
3+
// UIKitBaseExample
4+
//
5+
// Created by Brian Strobach on 10/19/17.
6+
// Copyright © 2017 CocoaPods. All rights reserved.
7+
//
8+
9+
import UIKitTheme
10+
import UIKitBase
11+
import UIKitBase
12+
13+
open class BaseButtonExamplesViewController: BaseStackViewController{
14+
15+
16+
// open override lazy var initialArrangedSubviews: [UIView] = []// self.createButtons()
17+
18+
open override func initProperties() {
19+
super.initProperties()
20+
stackView.alignment = .center
21+
}
22+
23+
// open func createButtons() -> [UIButton]{
24+
// var buttons: [BaseUIButton] = []
25+
// 5.times {
26+
// let button = BaseUIButton()
27+
//// button.apply(buttonStyle: currentStyle.boldPrimaryContrastButtonStyle())
28+
//
29+
// button.backgroundColor = .blue
30+
// button.setTitleColor(.white, for: .normal)
31+
// button.setTitleColor(.orange, for: .highlighted)
32+
// button.setTitleColor(.yellow, for: .loading)
33+
// button.setTitleColor(.red, for: .error)
34+
// button.setTitleColor(.brown, for: .disabled)
35+
//
36+
// button.setTitle("Normal", for: .normal)
37+
// button.setTitle("Selected", for: .selected)
38+
// button.setTitle("Error", for: .error)
39+
// button.setTitle("Disabled", for: .disabled)
40+
// buttons.append(button)
41+
// button.imageView?.setFontIconImage(MaterialIcons.random())
42+
//
43+
// button.tapActionMap = [
44+
// UIControlState.normal.rawValue : {self.doNormalStuff(button)},
45+
// UIControlState.selected.rawValue : {self.doSelectedStuff(button)},
46+
// UIControlState.disabled.rawValue : {self.doDisabledStuff(button)},
47+
// UIControlState.error.rawValue : {self.doErrorStuff(button)}
48+
// ]
49+
// }
50+
// buttons.last?.isEnabled = false
51+
//
52+
// return buttons
53+
// }
54+
//
55+
// func doNormalStuff(_ button: BaseUIButton){
56+
// makeCall(for: button, chanceOfSuccess: 100)
57+
// print("Normal **************************+")
58+
// }
59+
//
60+
// func doDisabledStuff(_ button: BaseUIButton){
61+
// makeCall(for: button, chanceOfSuccess: 0)
62+
// print("Disabled **************************+")
63+
// }
64+
//
65+
// func doSelectedStuff(_ button: BaseUIButton){
66+
// makeCall(for: button, chanceOfSuccess: 50)
67+
// print("Selected **************************+")
68+
// }
69+
//
70+
// func doErrorStuff(_ button: BaseUIButton){
71+
// makeCall(for: button, chanceOfSuccess: 50)
72+
// print("error **************************+")
73+
// }
74+
//
75+
// func makeCall(for button: BaseUIButton, chanceOfSuccess: Int){
76+
// button.isLoading = true
77+
// Placeholder.makeFakeNetworkCall(delay: 2, chanceOfSuccess: chanceOfSuccess, success: {
78+
// button.isSelected.toggle()
79+
// }, failure: {
80+
// button.isError = true
81+
// })
82+
// }
83+
}
84+
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
//
2+
// ExampleAppStyle.swift
3+
// UIKitBase
4+
//
5+
// Created by Brian Strobach on 10/3/17.
6+
// Copyright © 2017 CocoaPods. All rights reserved.
7+
//
8+
9+
import UIKitTheme
10+
import UIKitBase
11+
import UIKitBase
12+
13+
public class ExampleAppConfiguration: AppConfiguration{
14+
public override func didInit() {
15+
super.didInit()
16+
style = ExampleStyleGuide()
17+
}
18+
}
19+
20+
21+
22+
//MARK: Example
23+
24+
open class ExampleColorScheme: ColorScheme{
25+
26+
internal var s: ExampleColorScheme.Type{
27+
return ExampleColorScheme.self
28+
}
29+
open override func overrideStoredDefaults(){
30+
super.overrideStoredDefaults()
31+
primary = s.mintMojitoGreen
32+
secondary = s.strawberryDaiquiriRed
33+
primaryContrast = s.whiteRussian
34+
neutrals = ExampleNeutralsColorScheme()
35+
text = ExampleTextColorScheme()
36+
functional = ExampleFunctionalColorScheme()
37+
}
38+
39+
open class ExampleNeutralsColorScheme: NeutralColorScheme{
40+
41+
open override func overrideStoredDefaults() {
42+
super.overrideStoredDefaults()
43+
light = whiteRussian
44+
mediumLight = fuzzyGray
45+
medium = buzzedGray
46+
mediumDark = hammeredGray
47+
dark = blackout
48+
49+
}
50+
51+
}
52+
53+
open class ExampleTextColorScheme: NeutralTextColorScheme{
54+
55+
open override func overrideStoredDefaults() {
56+
super.overrideStoredDefaults()
57+
light = whiteRussian
58+
mediumLight = fuzzyGray
59+
medium = buzzedGray
60+
mediumDark = hammeredGray
61+
dark = blackout
62+
63+
}
64+
}
65+
66+
open class ExampleFunctionalColorScheme: FunctionalColorScheme{
67+
68+
open override func overrideStoredDefaults() {
69+
super.overrideStoredDefaults()
70+
success = mintMojitoGreen
71+
disabled = fuzzyGray
72+
deselected = fuzzyGray
73+
error = strawberryDaiquiriRed
74+
selected = mintMojitoGreen
75+
}
76+
}
77+
78+
//MARK: Brand color palette.
79+
//Only to be used internally and referenced abstractly through schemes api. Normally these would be internal, but since this is a pod,
80+
//and there is no protected access scope, they need to be referencable by subclass schemes in apps via public access.
81+
82+
83+
public static let mintMojitoGreen: UIColor = UIColor(r: 93.0, g: 215.0, b: 173.0) //seafoamBlue
84+
85+
public static let darkMintMojitoGreen: UIColor = UIColor(r: 87.0, g: 201.0, b: 162.0) //greenyBlue
86+
87+
public static let strawberryDaiquiriRed: UIColor = UIColor(r: 255.0, g: 150.0, b: 157.0)
88+
89+
90+
public static let whiteRussian: UIColor = .white
91+
92+
//Grays/Blacks from light to dark
93+
94+
public static let hangoverGray: UIColor = UIColor(r: 246, g: 246, b: 246)
95+
96+
public static let fuzzyGray: UIColor = UIColor(r: 189, g: 189, b: 189)
97+
98+
public static let buzzedGray: UIColor = UIColor(r: 161, g: 161, b: 161)
99+
100+
public static let tipsyGray: UIColor = UIColor(r: 51, g: 51, b: 51)
101+
102+
public static let hammeredGray: UIColor = UIColor(r: 38.0, g: 38.0, b: 40.0) //darkGrey
103+
104+
public static let blackout: UIColor = .black
105+
106+
107+
108+
}
109+
110+
open class ExampleVendorColorScheme: ExampleColorScheme{
111+
open override func overrideStoredDefaults() {
112+
super.overrideStoredDefaults()
113+
primary = s.whiteRussian
114+
}
115+
}
116+
117+
open class ExampleStyleGuide: AppStyleGuide{
118+
119+
open override func overrideStoredDefaults() {
120+
super.overrideStoredDefaults()
121+
colors = ExampleColorScheme()
122+
typography = ExampleTypographyGuide()
123+
}
124+
}
125+
126+
open class ExampleTypographyGuide: TypographyGuide{
127+
open override func overrideStoredDefaults() {
128+
super.overrideStoredDefaults()
129+
font = ExampleFontGuide()
130+
}
131+
}
132+
133+
open class ExampleFontGuide: FontGuide{
134+
// open override lazy var thinName: String? = "Wavehaus-28Thin"
135+
// open override lazy var lightName: String? = "Wavehaus-42Light"
136+
// open override lazy var regularName: String? = "Wavehaus-66Book"
137+
// open override lazy var semiboldName: String? = "Wavehaus-95SemiBold"
138+
// open override lazy var boldName: String? = "Wavehaus-128Bold"
139+
// open override lazy var heavyName: String? = "Wavehaus-158ExtraBold"
140+
}

0 commit comments

Comments
 (0)