@@ -22,24 +22,14 @@ final class SuggestionPanelViewModel: ObservableObject {
2222
2323 enum ActiveTab {
2424 case suggestion
25- case chat
2625 }
27-
28- @AppStorage ( \. chatPanelInASeparateWindow) var chatPanelInASeparateWindow
2926
3027 @Published var content : Content ? {
3128 didSet {
32- adjustActiveTabAndShowHideIfNeeded ( tab: . suggestion)
3329 requestApplicationPolicyUpdate ? ( self )
3430 }
3531 }
3632
37- @Published var chat : ChatProvider ? {
38- didSet {
39- adjustActiveTabAndShowHideIfNeeded ( tab: . chat)
40- }
41- }
42-
4333 @Published var activeTab : ActiveTab {
4434 didSet {
4535 requestApplicationPolicyUpdate ? ( self )
@@ -54,51 +44,17 @@ final class SuggestionPanelViewModel: ObservableObject {
5444
5545 public init (
5646 content: Content ? = nil ,
57- chat: ChatProvider ? = nil ,
5847 isPanelDisplayed: Bool = false ,
5948 activeTab: ActiveTab = . suggestion,
6049 colorScheme: ColorScheme = . dark,
6150 requestApplicationPolicyUpdate: ( ( SuggestionPanelViewModel ) -> Void ) ? = nil
6251 ) {
6352 self . content = content
64- self . chat = chat
6553 self . isPanelDisplayed = isPanelDisplayed
6654 self . activeTab = activeTab
6755 self . colorScheme = colorScheme
6856 self . requestApplicationPolicyUpdate = requestApplicationPolicyUpdate
6957 }
70-
71- func adjustActiveTabAndShowHideIfNeeded( tab: ActiveTab ) {
72- if chatPanelInASeparateWindow {
73- activeTab = . suggestion
74- return
75- }
76-
77- switch tab {
78- case . suggestion:
79- if content != nil {
80- activeTab = . suggestion
81- return
82- }
83- case . chat:
84- if chat != nil {
85- activeTab = . chat
86- return
87- }
88- }
89-
90- if content != nil {
91- activeTab = . suggestion
92- return
93- }
94-
95- if chat != nil {
96- activeTab = . chat
97- return
98- }
99-
100- activeTab = . suggestion
101- }
10258}
10359
10460struct SuggestionPanelView : View {
@@ -130,15 +86,6 @@ struct SuggestionPanelView: View {
13086 . allowsHitTesting ( viewModel. isPanelDisplayed)
13187 }
13288 }
133-
134- // if let chat = viewModel.chat {
135- // if case .chat = viewModel.activeTab {
136- // ChatPanel(chat: chat)
137- // .frame(maxWidth: .infinity, maxHeight: Style.panelHeight)
138- // .fixedSize(horizontal: false, vertical: true)
139- // .allowsHitTesting(viewModel.isPanelDisplayed)
140- // }
141- // }
14289 }
14390 . frame ( maxWidth: . infinity)
14491
@@ -151,7 +98,7 @@ struct SuggestionPanelView: View {
15198 . preferredColorScheme ( viewModel. colorScheme)
15299 . opacity ( {
153100 guard viewModel. isPanelDisplayed else { return 0 }
154- guard viewModel. content != nil || viewModel . chat != nil else { return 0 }
101+ guard viewModel. content != nil else { return 0 }
155102 return 1
156103 } ( ) )
157104 . animation ( . easeInOut( duration: 0.2 ) , value: viewModel. content? . contentHash)
@@ -193,59 +140,6 @@ struct SuggestionPanelView_Error_Preview: PreviewProvider {
193140 }
194141}
195142
196- struct SuggestionPanelView_Chat_Preview : PreviewProvider {
197- static var previews : some View {
198- SuggestionPanelView ( viewModel: . init(
199- chat: . init(
200- history: [
201- . init( id: " 1 " , isUser: true , text: " Hello " ) ,
202- . init( id: " 2 " , isUser: false , text: " Hi " ) ,
203- . init( id: " 3 " , isUser: true , text: " What's up? " ) ,
204- ]
205- ) ,
206- isPanelDisplayed: true ,
207- activeTab: . chat
208- ) )
209- . frame ( width: 450 , height: 300 )
210- }
211- }
212-
213- struct SuggestionPanelView_Both_DisplayingChat_Preview : PreviewProvider {
214- static var previews : some View {
215- SuggestionPanelView ( viewModel: . init(
216- content: . suggestion( SuggestionProvider (
217- code: """
218- - (void)addSubview:(UIView *)view {
219- [self addSubview:view];
220- }
221- """ ,
222- language: " objective-c " ,
223- startLineIndex: 8 ,
224- suggestionCount: 2 ,
225- currentSuggestionIndex: 0
226- ) ) ,
227- chat: . init(
228- history: [
229- . init( id: " 1 " , isUser: true , text: " Hello " ) ,
230- . init( id: " 2 " , isUser: false , text: " Hi " ) ,
231- . init( id: " 3 " , isUser: true , text: " What's up? " ) ,
232- ]
233- ) ,
234- isPanelDisplayed: true ,
235- activeTab: . chat,
236- colorScheme: . light
237- ) )
238- . frame ( width: 450 , height: 500 )
239- . background {
240- HStack {
241- Color . red
242- Color . green
243- Color . blue
244- }
245- }
246- }
247- }
248-
249143struct SuggestionPanelView_Both_DisplayingSuggestion_Preview : PreviewProvider {
250144 static var previews : some View {
251145 SuggestionPanelView ( viewModel: . init(
@@ -260,13 +154,6 @@ struct SuggestionPanelView_Both_DisplayingSuggestion_Preview: PreviewProvider {
260154 suggestionCount: 2 ,
261155 currentSuggestionIndex: 0
262156 ) ) ,
263- chat: . init(
264- history: [
265- . init( id: " 1 " , isUser: true , text: " Hello " ) ,
266- . init( id: " 2 " , isUser: false , text: " Hi " ) ,
267- . init( id: " 3 " , isUser: true , text: " What's up? " ) ,
268- ]
269- ) ,
270157 isPanelDisplayed: true ,
271158 activeTab: . suggestion,
272159 colorScheme: . dark
@@ -281,3 +168,4 @@ struct SuggestionPanelView_Both_DisplayingSuggestion_Preview: PreviewProvider {
281168 }
282169 }
283170}
171+
0 commit comments