-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathSuggestionPanelFeature.swift
More file actions
44 lines (41 loc) · 1.18 KB
/
SuggestionPanelFeature.swift
File metadata and controls
44 lines (41 loc) · 1.18 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
import ComposableArchitecture
import Foundation
import SwiftUI
@Reducer
public struct SuggestionPanelFeature {
@ObservableState
public struct State: Equatable {
var content: CodeSuggestionProvider?
var isExpanded: Bool = false
var colorScheme: ColorScheme = .light
var alignTopToAnchor = false
var firstLineIndent: Double = 0
var lineHeight: Double = 17
var isPanelDisplayed: Bool = false
var isPanelOutOfFrame: Bool = false
var warningMessage: String?
var warningURL: String?
var opacity: Double {
guard isPanelDisplayed else { return 0 }
if isPanelOutOfFrame { return 0 }
guard content != nil else { return 0 }
return 1
}
}
public enum Action: Equatable {
case noAction
case dismissWarning
}
public var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .dismissWarning:
state.warningMessage = nil
state.warningURL = nil
return .none
default:
return .none
}
}
}
}