forked from Artificial-Pancreas/iAPS
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
117 changed files
with
3,371 additions
and
56 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
FreeAPS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
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,52 @@ | ||
{ | ||
"object": { | ||
"pins": [ | ||
{ | ||
"package": "Alamofire", | ||
"repositoryURL": "https://github.com/Alamofire/Alamofire.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "eaf6e622dd41b07b251d8f01752eab31bc811493", | ||
"version": "5.4.1" | ||
} | ||
}, | ||
{ | ||
"package": "Moya", | ||
"repositoryURL": "https://github.com/Moya/Moya", | ||
"state": { | ||
"branch": null, | ||
"revision": "b3e5a233e0d85fd4d69f561c80988590859c7dee", | ||
"version": "14.0.0" | ||
} | ||
}, | ||
{ | ||
"package": "ReactiveSwift", | ||
"repositoryURL": "https://github.com/Moya/ReactiveSwift.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "f195d82bb30e412e70446e2b4a77e1b514099e88", | ||
"version": "6.1.0" | ||
} | ||
}, | ||
{ | ||
"package": "RxSwift", | ||
"repositoryURL": "https://github.com/ReactiveX/RxSwift.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "002d325b0bdee94e7882e1114af5ff4fe1e96afa", | ||
"version": "5.1.1" | ||
} | ||
}, | ||
{ | ||
"package": "Swinject", | ||
"repositoryURL": "https://github.com/Swinject/Swinject", | ||
"state": { | ||
"branch": null, | ||
"revision": "8a76d2c74bafbb455763487cc6a08e91bad1f78b", | ||
"version": "2.7.1" | ||
} | ||
} | ||
] | ||
}, | ||
"version": 1 | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,10 @@ | ||
<?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>com.apple.developer.applesignin</key> | ||
<array> | ||
<string>Default</string> | ||
</array> | ||
</dict> | ||
</plist> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,26 @@ | ||
// | ||
// FreeAPSApp.swift | ||
// FreeAPS | ||
// | ||
// Created by Ivan Valkou on 12.01.2021. | ||
// | ||
|
||
import SwiftUI | ||
import Swinject | ||
|
||
@main | ||
struct FreeAPSApp: App { | ||
private let resolver = Container(defaultObjectScope: .container) { container in | ||
UIContainer.register(container: container) | ||
StorageContainer.register(container: container) | ||
NetworkContainer.register(container: container) | ||
SecurityContainer.register(container: container) | ||
}.synchronize() | ||
|
||
var body: some Scene { | ||
resolver.resolve(AppearanceManager.self)!.setupGlobalAppearance() | ||
return WindowGroup { | ||
Main.Builder(resolver: resolver).buildView() | ||
} | ||
} | ||
} |
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,9 @@ | ||
import Swinject | ||
import UIKit | ||
|
||
enum NetworkContainer { | ||
static func register(container: Container) { | ||
container.register(NetworkManager.self) { _ in BaseNetworkManager() } | ||
container.register(AuthorizationManager.self) { r in BaseAuthorizationManager(resolver: r) } | ||
} | ||
} |
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,7 @@ | ||
import Swinject | ||
|
||
enum SecurityContainer { | ||
static func register(container: Container) { | ||
container.register(UnlockManager.self) { _ in BaseUnlockManager() } | ||
} | ||
} |
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,23 @@ | ||
import Foundation | ||
import Swinject | ||
|
||
enum StorageContainer { | ||
static func register(container: Container) { | ||
container.register(FileManager.self) { _ in | ||
Foundation.FileManager.default | ||
} | ||
|
||
container.register(Keychain.self) { _ in BaseKeychain() } | ||
|
||
container.register(IsDrinkImageFileStorage.self) { r in BaseImageFileStorage(resolver: r, name: "IsDrink") | ||
} | ||
container | ||
.register(DrinkTypeImageFileStorage.self) { r in BaseImageFileStorage(resolver: r, name: "DrinkType") | ||
} | ||
} | ||
} | ||
|
||
protocol IsDrinkImageFileStorage: ImageFileStorage {} | ||
protocol DrinkTypeImageFileStorage: ImageFileStorage {} | ||
extension BaseImageFileStorage: IsDrinkImageFileStorage {} | ||
extension BaseImageFileStorage: DrinkTypeImageFileStorage {} |
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,8 @@ | ||
import Swinject | ||
|
||
enum UIContainer { | ||
static func register(container: Container) { | ||
container.register(AppearanceManager.self) { _ in BaseAppearanceManager() } | ||
container.register(Router.self) { r in BaseRouter(resolver: r) } | ||
} | ||
} |
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,9 @@ | ||
import SwiftUI | ||
|
||
struct CheckBox: View { | ||
@Binding var isChecked: Bool | ||
|
||
var body: some View { | ||
Image(systemName: isChecked ? "checkmark.circle.fill" : "circle") | ||
} | ||
} |
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,82 @@ | ||
import SwiftUI | ||
|
||
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *) | ||
struct FlowStack<Content>: View where Content: View { | ||
// The number of columns we want to display | ||
var columns: Int | ||
// The total number of items in the stack | ||
var numItems: Int | ||
// The alignment of our columns in the last row | ||
// when they don't fill all the column slots | ||
var alignment: HorizontalAlignment | ||
|
||
let content: (Int, CGFloat) -> Content | ||
|
||
private func width(for size: CGSize) -> CGFloat { | ||
size.width / CGFloat(columns) | ||
} | ||
|
||
private func index(forRow row: Int, column: Int) -> Int { | ||
(row * columns) + column | ||
} | ||
|
||
private var lastRowColumns: Int { numItems % columns } | ||
|
||
private var rows: Int { numItems / columns } | ||
|
||
init( | ||
columns: Int, | ||
numItems: Int, | ||
alignment: HorizontalAlignment?, | ||
@ViewBuilder content: @escaping (Int, CGFloat) -> Content | ||
) { | ||
self.content = content | ||
self.columns = columns | ||
self.numItems = numItems | ||
self.alignment = alignment ?? HorizontalAlignment.leading | ||
} | ||
|
||
var body: some View { | ||
// A GeometryReader is required to size items in the scroll view | ||
GeometryReader { geometry in | ||
|
||
// Assume a vertical scrolling orientation for the grid | ||
ScrollView(Axis.Set.vertical) { | ||
// VStacks are our rows | ||
VStack(alignment: self.alignment, spacing: 0) { | ||
ForEach(0 ..< self.rows) { row in | ||
|
||
// HStacks are our columns | ||
HStack(spacing: 0) { | ||
ForEach(0 ..< self.columns) { column in | ||
self.content( | ||
// Pass the index to the content | ||
self.index(forRow: row, column: column), | ||
// Pass the column width to the content | ||
self.width(for: geometry.size) | ||
) | ||
// Size the content to frame to fill the column | ||
.frame(width: self.width(for: geometry.size)) | ||
} | ||
} | ||
} | ||
|
||
// Last row | ||
// HStacks are our columns | ||
HStack(spacing: 0) { | ||
ForEach(0 ..< self.lastRowColumns) { column in | ||
self.content( | ||
// Pass the index to the content | ||
self.index(forRow: self.rows, column: column), | ||
// Pass the column width to the content | ||
self.width(for: geometry.size) | ||
) | ||
// Size the content to frame to fill the column | ||
.frame(width: self.width(for: geometry.size)) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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,17 @@ | ||
import Foundation | ||
import HealthKit | ||
|
||
enum Formatters { | ||
static func percent(for number: Double) -> String { | ||
let formater = NumberFormatter() | ||
formater.numberStyle = .percent | ||
return formater.string(for: number)! | ||
} | ||
|
||
static func timeFor(minutes: Int) -> String { | ||
let formater = DateComponentsFormatter() | ||
formater.unitsStyle = .abbreviated | ||
formater.allowedUnits = [.hour, .minute] | ||
return formater.string(from: TimeInterval(minutes * 60))! | ||
} | ||
} |
Oops, something went wrong.