Skip to content

Commit

Permalink
Add HKErrors in AppError
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanov91 committed Mar 31, 2024
1 parent 8118076 commit 664ad43
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 14 deletions.
15 changes: 1 addition & 14 deletions Sources/OversizeModels/Config/AppConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,7 @@ public struct PlistConfiguration: Codable {
public var facebookUrl: URL? {
URL(string: "https://www.facebook.com/\(String(describing: facebook))")
}

//
// public var telegramUrl: URL? {
// URL(string: "https://www.facebook.com/\(String(describing: fecebook))")
// }
//
// public var dribbbleUrl: URL? {
// URL(string: "https://www.facebook.com/\(String(describing: fecebook))")
// }
//
// public var instagramUrl: URL? {
// URL(string: "https://www.instagram.com/\(String(describing: fecebook))")
// }


public var url: URL? {
URL(string: urlString ?? "")
}
Expand Down
5 changes: 5 additions & 0 deletions Sources/OversizeModels/Error/AppError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public enum AppError: Error {
case notifications(type: Enums.Notification)
case cloudDocuments(type: Enums.CloudDocuments)
case fileManager(type: Enums.FileManager)
case healthKit(type: Enums.HealthKit)
case custom(title: String, subtitle: String? = nil, image: Image? = nil)
public class Enums {}
}
Expand All @@ -38,6 +39,7 @@ extension AppError: AppErrorProtocol {
case let .notifications(type): return type.title
case let .cloudDocuments(type): return type.title
case let .fileManager(type): return type.title
case let .healthKit(type): return type.title
case let .custom(title, _, _): return title
}
}
Expand All @@ -53,6 +55,7 @@ extension AppError: AppErrorProtocol {
case let .notifications(type): return type.subtitle
case let .cloudDocuments(type): return type.subtitle
case let .fileManager(type): return type.subtitle
case let .healthKit(type): return type.subtitle
case let .custom(_, subtitle, _): return subtitle
}
}
Expand All @@ -68,6 +71,7 @@ extension AppError: AppErrorProtocol {
case let .notifications(type): return type.image
case let .cloudDocuments(type): return type.image
case let .fileManager(type): return type.image
case let .healthKit(type): return type.image
case let .custom(_, _, image): return image
}
}
Expand All @@ -83,6 +87,7 @@ extension AppError: AppErrorProtocol {
case let .notifications(type): return type.icon
case let .cloudDocuments(type): return type.icon
case let .fileManager(type): return type.icon
case let .healthKit(type): return type.icon
case let .custom(_, _, image): return image
}
}
Expand Down
46 changes: 46 additions & 0 deletions Sources/OversizeModels/Error/HealthKitErrors.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// Copyright © 2024 Alexander Romanov
// HealthKitErrors.swift, created on 26.03.2024
//

import OversizeLocalizable
import SwiftUI

public extension AppError.Enums {
enum HealthKit {
case deleteItem
case updateItem
case savingItem
case fetchItems
case notAccess
case unknown
}
}

extension AppError.Enums.HealthKit: AppErrorProtocol {
public var title: String {
switch self {
case .deleteItem: return "Delete error"
case .updateItem: return "Update error"
case .savingItem: return "Saving error"
case .fetchItems: return "Fetch error"
case .notAccess: return "No access to the HealthKit"
case .unknown: return "Unknown"
}
}

public var subtitle: String? {
switch self {
case .notAccess: return "Please allow access to HealthKit in settings"
default: return L10n.Error.tryAgainLater
}
}

public var image: Image? {
Image(.error)
}

public var icon: Image? {
nil
}
}

0 comments on commit 664ad43

Please sign in to comment.