-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathAppearanceInteractor.swift
66 lines (56 loc) · 2.01 KB
/
AppearanceInteractor.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#if arch(x86_64) || arch(arm64)
import Combine
import SwiftUI
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public enum GradientType: Equatable {
case linear
case angular
case radial
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct SkeletonColor {
public static var primary: Color {
#if os(iOS)
return Color(.systemGray4)
#elseif os(tvOS)
return Color(.tertiaryLabel)
#elseif os(watchOS)
return Color.secondary
#elseif os(macOS)
return Color(.alternateSelectedControlColor)
#endif
}
public static var background: Color {
#if os(iOS)
return Color(.systemGray6)
#elseif os(tvOS)
return Color(.secondaryLabel)
#elseif os(watchOS)
return Color.primary
#elseif os(macOS)
return Color(.unemphasizedSelectedContentBackgroundColor)
#endif
}
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public enum AppearanceType: Equatable {
case solid(color: Color = SkeletonColor.primary, background: Color = SkeletonColor.background)
case gradient(GradientType = .linear, color: Color = SkeletonColor.primary, background: Color = SkeletonColor.background, radius: CGFloat = 1, angle: CGFloat = .zero)
}
// sourcery: AutoMockable
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
protocol AppearanceInteractable: AnyObject {
var presenter: AppearancePresenter { get }
var type: CurrentValueSubject<AppearanceType, Never> { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
final class AppearanceInteractor: AppearanceInteractable {
let presenter = AppearancePresenter()
let type: CurrentValueSubject<AppearanceType, Never>
private var cancellables = Set<AnyCancellable>()
init() {
type = CurrentValueSubject<AppearanceType, Never>(presenter.type)
type.assign(to: \.type, on: presenter).store(in: &cancellables)
}
}
#endif