Skip to content

Commit c756ebb

Browse files
committed
Add settings for open chat mode
1 parent 2a2b5df commit c756ebb

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

Core/Sources/HostApp/FeatureSettings/Chat/ChatSettingsGeneralSectionView.swift

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ struct ChatSettingsGeneralSectionView: View {
2828
@AppStorage(
2929
\.disableFloatOnTopWhenTheChatPanelIsDetached
3030
) var disableFloatOnTopWhenTheChatPanelIsDetached
31+
@AppStorage(\.openChatMode) var openChatMode
32+
@AppStorage(\.openChatInBrowserURL) var openChatInBrowserURL
33+
@AppStorage(\.openChatInBrowserInInAppBrowser) var openChatInBrowserInInAppBrowser
3134

3235
init() {}
3336
}
@@ -39,6 +42,8 @@ struct ChatSettingsGeneralSectionView: View {
3942

4043
var body: some View {
4144
VStack {
45+
openChatSettingsForm
46+
SettingsDivider("Conversation")
4247
chatSettingsForm
4348
SettingsDivider("UI")
4449
uiForm
@@ -47,6 +52,45 @@ struct ChatSettingsGeneralSectionView: View {
4752
}
4853
}
4954

55+
@ViewBuilder
56+
var openChatSettingsForm: some View {
57+
Form {
58+
Picker(
59+
"Open Chat Mode",
60+
selection: $settings.openChatMode
61+
) {
62+
ForEach(OpenChatMode.allCases, id: \.rawValue) { mode in
63+
switch mode {
64+
case .chatPanel:
65+
Text("Open chat panel").tag(mode)
66+
case .browser:
67+
Text("Open web page in browser").tag(mode)
68+
}
69+
}
70+
}
71+
72+
if settings.openChatMode == .browser {
73+
TextField(
74+
"Chat web page URL",
75+
text: $settings.openChatInBrowserURL,
76+
prompt: Text("https://")
77+
)
78+
.textFieldStyle(.roundedBorder)
79+
.disableAutocorrection(true)
80+
.autocorrectionDisabled(true)
81+
82+
#if canImport(ProHostApp)
83+
WithFeatureEnabled(\.browserTab) {
84+
Toggle(
85+
"Open web page in chat panel",
86+
isOn: $settings.openChatInBrowserInInAppBrowser
87+
)
88+
}
89+
#endif
90+
}
91+
}
92+
}
93+
5094
@ViewBuilder
5195
var chatSettingsForm: some View {
5296
Form {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
public enum OpenChatMode: String {
3+
public enum OpenChatMode: String, CaseIterable {
44
case chatPanel
55
case browser
66
}

0 commit comments

Comments
 (0)