Skip to content

Commit 3670c3f

Browse files
Fixed a few issues
1 parent d053fe8 commit 3670c3f

6 files changed

Lines changed: 50 additions & 52 deletions

File tree

Recap/UIComponents/Buttons/PillButton.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//
2-
// PillButton.swift
3-
// Recap
4-
//
5-
// Created by Rawand Ahmad on 25/07/2025.
6-
//
7-
81
import SwiftUI
92

103
struct PillButton: View {

Recap/UseCases/Settings/Components/Reusable/CustomTextEditor.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import SwiftUI
22

33
struct CustomTextEditor: View {
44
let title: String
5-
@Binding var text: String
5+
let textBinding: Binding<String>
66
let placeholder: String
77
let height: CGFloat
88

@@ -16,13 +16,13 @@ struct CustomTextEditor: View {
1616
height: CGFloat = 100
1717
) {
1818
self.title = title
19-
self._text = text
19+
self.textBinding = text
2020
self.placeholder = placeholder
2121
self.height = height
2222
}
2323

2424
var body: some View {
25-
VStack(alignment: .leading, spacing: 6) {
25+
VStack(alignment: .leading, spacing: 8) {
2626
Text(title)
2727
.font(.system(size: 11, weight: .medium))
2828
.foregroundColor(UIConstants.Colors.textSecondary)
@@ -46,7 +46,7 @@ struct CustomTextEditor: View {
4646
)
4747
.frame(height: height)
4848

49-
if text.isEmpty && !isFocused {
49+
if textBinding.wrappedValue.isEmpty && !isFocused {
5050
Text(placeholder)
5151
.font(.system(size: 12, weight: .medium))
5252
.foregroundColor(UIConstants.Colors.textSecondary.opacity(0.6))
@@ -55,14 +55,16 @@ struct CustomTextEditor: View {
5555
.allowsHitTesting(false)
5656
}
5757

58-
TextEditor(text: $text)
58+
TextEditor(text: textBinding)
5959
.font(.system(size: 12, weight: .medium))
6060
.foregroundColor(UIConstants.Colors.textPrimary)
6161
.background(Color.clear)
6262
.scrollContentBackground(.hidden)
6363
.padding(.horizontal, 8)
6464
.padding(.vertical, 4)
6565
.focused($isFocused)
66+
.lineLimit(nil)
67+
.textSelection(.enabled)
6668
.onChange(of: isFocused) { _, focused in
6769
withAnimation(.easeInOut(duration: 0.2)) {
6870
isEditing = focused
@@ -92,4 +94,4 @@ struct CustomTextEditor: View {
9294
.frame(width: 400, height: 300)
9395
.padding(20)
9496
.background(Color.black)
95-
}
97+
}

Recap/UseCases/Settings/Components/TabViews/GeneralSettingsView.swift

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ struct GeneralSettingsView<ViewModel: GeneralSettingsViewModelType>: View {
9090
VStack(alignment: .leading, spacing: 12) {
9191
CustomTextEditor(
9292
title: "Prompt Template",
93-
text: $viewModel.customPromptTemplate,
93+
text: viewModel.customPromptTemplate,
9494
placeholder: "Enter your custom prompt template here...",
9595
height: 120
9696
)
@@ -102,13 +102,11 @@ struct GeneralSettingsView<ViewModel: GeneralSettingsViewModelType>: View {
102102

103103
Spacer()
104104

105-
Button("Reset to Default") {
105+
PillButton(text: "Reset to Default") {
106106
Task {
107107
await viewModel.resetToDefaultPrompt()
108108
}
109109
}
110-
.font(.system(size: 11, weight: .medium))
111-
.foregroundColor(Color.blue)
112110
}
113111
}
114112
}
@@ -148,13 +146,15 @@ struct GeneralSettingsView<ViewModel: GeneralSettingsViewModelType>: View {
148146
}
149147

150148
#Preview {
151-
GeneralSettingsView<PreviewGeneralSettingsViewModel>(viewModel: PreviewGeneralSettingsViewModel())
149+
GeneralSettingsView(viewModel: PreviewGeneralSettingsViewModel())
152150
.frame(width: 550, height: 500)
153151
.background(Color.black)
154152
}
155153

156-
private final class PreviewGeneralSettingsViewModel: ObservableObject, GeneralSettingsViewModelType {
157-
@Published var customPromptTemplate: String = UserPreferencesInfo.defaultPromptTemplate
154+
private final class PreviewGeneralSettingsViewModel: GeneralSettingsViewModelType {
155+
var customPromptTemplate: Binding<String> {
156+
.constant(UserPreferencesInfo.defaultPromptTemplate)
157+
}
158158
@Published var availableModels: [LLMModelInfo] = [
159159
LLMModelInfo(name: "llama3.2", provider: "ollama"),
160160
LLMModelInfo(name: "codellama", provider: "ollama")
@@ -199,11 +199,7 @@ private final class PreviewGeneralSettingsViewModel: ObservableObject, GeneralSe
199199
isAutoStopRecording = enabled
200200
}
201201

202-
func updateCustomPromptTemplate(_ template: String) async {
203-
customPromptTemplate = template
204-
}
202+
func updateCustomPromptTemplate(_ template: String) async {}
205203

206-
func resetToDefaultPrompt() async {
207-
customPromptTemplate = UserPreferencesInfo.defaultPromptTemplate
208-
}
204+
func resetToDefaultPrompt() async {}
209205
}

Recap/UseCases/Settings/SettingsView.swift

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,11 @@ struct SettingsView<GeneralViewModel: GeneralSettingsViewModelType>: View {
150150
.frame(width: 550, height: 500)
151151
}
152152

153-
private final class PreviewGeneralSettingsViewModel: ObservableObject, GeneralSettingsViewModelType {
154-
var activeWarnings: [WarningItem] = []
155-
@Published var customPromptTemplate: String = UserPreferencesInfo.defaultPromptTemplate
156-
153+
154+
private final class PreviewGeneralSettingsViewModel: GeneralSettingsViewModelType {
155+
var customPromptTemplate: Binding<String> {
156+
.constant(UserPreferencesInfo.defaultPromptTemplate)
157+
}
157158
@Published var availableModels: [LLMModelInfo] = [
158159
LLMModelInfo(name: "llama3.2", provider: "ollama"),
159160
LLMModelInfo(name: "codellama", provider: "ollama")
@@ -166,6 +167,15 @@ private final class PreviewGeneralSettingsViewModel: ObservableObject, GeneralSe
166167
@Published var errorMessage: String?
167168
@Published var showToast = false
168169
@Published var toastMessage = ""
170+
@Published var activeWarnings: [WarningItem] = [
171+
WarningItem(
172+
id: "ollama",
173+
title: "Ollama Not Running",
174+
message: "Please start Ollama to use local AI models for summarization.",
175+
icon: "server.rack",
176+
severity: .warning
177+
)
178+
]
169179

170180
var hasModels: Bool {
171181
!availableModels.isEmpty
@@ -189,11 +199,7 @@ private final class PreviewGeneralSettingsViewModel: ObservableObject, GeneralSe
189199
isAutoStopRecording = enabled
190200
}
191201

192-
func updateCustomPromptTemplate(_ template: String) async {
193-
customPromptTemplate = template
194-
}
202+
func updateCustomPromptTemplate(_ template: String) async {}
195203

196-
func resetToDefaultPrompt() async {
197-
customPromptTemplate = UserPreferencesInfo.defaultPromptTemplate
198-
}
204+
func resetToDefaultPrompt() async {}
199205
}

Recap/UseCases/Settings/ViewModels/General/GeneralSettingsViewModel.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
import Foundation
22
import Combine
3+
import SwiftUI
34

45
@MainActor
5-
final class GeneralSettingsViewModel: ObservableObject, GeneralSettingsViewModelType {
6+
final class GeneralSettingsViewModel: GeneralSettingsViewModelType {
67
@Published private(set) var availableModels: [LLMModelInfo] = []
78
@Published private(set) var selectedModel: LLMModelInfo?
89
@Published private(set) var selectedProvider: LLMProvider = .default
910
@Published private(set) var autoDetectMeetings: Bool = false
1011
@Published private(set) var isAutoStopRecording: Bool = false
1112
@Published private var _customPromptTemplate: String = ""
1213

13-
var customPromptTemplate: String {
14-
get { _customPromptTemplate }
15-
set {
16-
_customPromptTemplate = newValue
17-
Task {
18-
await updateCustomPromptTemplate(newValue)
14+
var customPromptTemplate: Binding<String> {
15+
Binding(
16+
get: { self._customPromptTemplate },
17+
set: { newValue in
18+
Task {
19+
await self.updateCustomPromptTemplate(newValue)
20+
}
1921
}
20-
}
22+
)
2123
}
24+
2225
@Published private(set) var isLoading = false
2326
@Published private(set) var errorMessage: String?
2427
@Published private(set) var showToast = false
@@ -42,7 +45,7 @@ final class GeneralSettingsViewModel: ObservableObject, GeneralSettingsViewModel
4245
init(
4346
llmService: LLMServiceType,
4447
userPreferencesRepository: UserPreferencesRepositoryType,
45-
environmentValidator: EnvironmentValidatorType = EnvironmentValidator(),
48+
environmentValidator: EnvironmentValidatorType,
4649
warningManager: WarningManagerType
4750
) {
4851
self.llmService = llmService
@@ -182,20 +185,17 @@ final class GeneralSettingsViewModel: ObservableObject, GeneralSettingsViewModel
182185
}
183186

184187
func updateCustomPromptTemplate(_ template: String) async {
185-
errorMessage = nil
186-
let trimmedTemplate = template.trimmingCharacters(in: .whitespacesAndNewlines)
187-
_customPromptTemplate = trimmedTemplate
188+
_customPromptTemplate = template
188189

189190
do {
190-
let templateToSave = trimmedTemplate.isEmpty ? nil : trimmedTemplate
191+
let templateToSave = template.isEmpty ? nil : template
191192
try await userPreferencesRepository.updateSummaryPromptTemplate(templateToSave)
192193
} catch {
193194
errorMessage = error.localizedDescription
194195
}
195196
}
196197

197198
func resetToDefaultPrompt() async {
198-
_customPromptTemplate = UserPreferencesInfo.defaultPromptTemplate
199199
await updateCustomPromptTemplate(UserPreferencesInfo.defaultPromptTemplate)
200200
}
201-
}
201+
}

Recap/UseCases/Settings/ViewModels/General/GeneralSettingsViewModelType.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Foundation
22
import Combine
3+
import SwiftUI
34

45
@MainActor
56
protocol GeneralSettingsViewModelType: ObservableObject {
@@ -15,7 +16,7 @@ protocol GeneralSettingsViewModelType: ObservableObject {
1516
var showToast: Bool { get }
1617
var toastMessage: String { get }
1718
var activeWarnings: [WarningItem] { get }
18-
var customPromptTemplate: String { get set }
19+
var customPromptTemplate: Binding<String> { get }
1920

2021
func loadModels() async
2122
func selectModel(_ model: LLMModelInfo) async

0 commit comments

Comments
 (0)