-
-
Notifications
You must be signed in to change notification settings - Fork 297
Expand file tree
/
Copy pathComposeContentToolbarView+ViewModel.swift
More file actions
84 lines (69 loc) · 2.64 KB
/
ComposeContentToolbarView+ViewModel.swift
File metadata and controls
84 lines (69 loc) · 2.64 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// ComposeContentToolbarView.swift
//
//
// Created by MainasuK on 22/10/18.
//
import SwiftUI
import MastodonCore
import MastodonAsset
import MastodonLocalization
import MastodonSDK
extension ComposeContentToolbarView {
class ViewModel: ObservableObject {
weak var delegate: ComposeContentToolbarViewDelegate?
// input
@Published var backgroundColor = ThemeService.shared.currentTheme.value.composeToolbarBackgroundColor
@Published var suggestedLanguages: [String] = []
@Published var highConfidenceSuggestedLanguage: String?
@Published var visibility: Mastodon.Entity.Status.Visibility = .public
var allVisibilities: [Mastodon.Entity.Status.Visibility] {
return [.public, .private, .direct]
}
@Published var isVisibilityButtonEnabled = false
@Published var isPollActive = false
@Published var isEmojiActive = false
@Published var isContentWarningActive = false
@Published var isAttachmentButtonEnabled = false
@Published var isPollButtonEnabled = false
@Published var language = Locale.current.languageCode ?? "en"
@Published var recentLanguages: [String] = []
@Published public var maxTextInputLimit = 500
@Published public var contentWeightedLength = 0
@Published public var contentWarningWeightedLength = 0
// output
init(delegate: ComposeContentToolbarViewDelegate) {
self.delegate = delegate
// end init
ThemeService.shared.currentTheme
.map { $0.composeToolbarBackgroundColor }
.assign(to: &$backgroundColor)
}
}
}
extension ComposeContentToolbarView.ViewModel {
enum Action: CaseIterable {
case poll
case emoji
case contentWarning
}
enum AttachmentAction: CaseIterable {
case photoLibrary
case camera
case browse
var title: String {
switch self {
case .photoLibrary: return L10n.Scene.Compose.MediaSelection.photoLibrary
case .camera: return L10n.Scene.Compose.MediaSelection.camera
case .browse: return L10n.Scene.Compose.MediaSelection.browse
}
}
var image: UIImage {
switch self {
case .photoLibrary: return UIImage(systemName: "photo.on.rectangle")!
case .camera: return UIImage(systemName: "camera")!
case .browse: return UIImage(systemName: "ellipsis")!
}
}
}
}