Skip to content

Commit 17ea06a

Browse files
committed
Attempting to fix compile error
1 parent 9324d3d commit 17ea06a

1 file changed

Lines changed: 25 additions & 17 deletions

File tree

StikJIT/Views/ProfileView.swift

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,12 @@ struct ProfileView: View {
131131
@State private var confirmRemove = false
132132
@State private var removeTargetName: String = ""
133133
@State private var removeTargetUUID: String = ""
134-
135-
134+
135+
// Computed strings to reduce body complexity
136+
private var removeProfileText: String {
137+
String(format: "Remove profile for %@ (UUID: %@)?\nApps associated with this profile may become unavailable.".localized, removeTargetName, removeTargetUUID)
138+
}
139+
136140
var body: some View {
137141
NavigationStack {
138142
List {
@@ -189,25 +193,15 @@ struct ProfileView: View {
189193
if entry.profileMatches.count > 1 {
190194
let showMore = expandedApps.contains(entry.id)
191195
let extraProfiles = entry.profileMatches.dropFirst(recentAndBestCount(for: entry))
192-
196+
193197
if !extraProfiles.isEmpty {
194198
if showMore {
195199
ForEach(extraProfiles, id: \.profile.uuid) { match in
196200
profileRow(match: match, isMostRecent: false)
197201
}
198202
}
199-
200-
Button {
201-
withAnimation {
202-
if showMore { expandedApps.remove(entry.id) }
203-
else { expandedApps.insert(entry.id) }
204-
}
205-
} label: {
206-
Label(showMore ? String(format: "Hide older profiles".localized) : String(format: "Show %d older profiles".localized, extraProfiles.count),
207-
systemImage: showMore ? "chevron.up" : "chevron.down")
208-
.font(.caption)
209-
.foregroundStyle(.blue)
210-
}
203+
204+
showMoreButton(showMore: showMore, extraCount: extraProfiles.count, entryId: entry.id)
211205
}
212206
}
213207
} header: {
@@ -282,10 +276,24 @@ struct ProfileView: View {
282276
}
283277
Button("Cancel", role: .cancel) { }
284278
} message: {
285-
Text(String(format: "Remove profile for %@ (UUID: %@)?\nApps associated with this profile may become unavailable.".localized, removeTargetName, removeTargetUUID))
279+
Text(removeProfileText)
286280
}
287281
}
288-
282+
283+
private func showMoreButton(showMore: Bool, extraCount: Int, entryId: String) -> some View {
284+
Button {
285+
withAnimation {
286+
if showMore { expandedApps.remove(entryId) }
287+
else { expandedApps.insert(entryId) }
288+
}
289+
} label: {
290+
Label(showMore ? "Hide older profiles".localized : String(format: "Show %d older profiles".localized, extraCount),
291+
systemImage: showMore ? "chevron.up" : "chevron.down")
292+
.font(.caption)
293+
.foregroundStyle(.blue)
294+
}
295+
}
296+
289297
private func profileActionButton(icon: String, color: Color, action: @escaping () -> Void) -> some View {
290298
Button(action: action) {
291299
Image(systemName: icon)

0 commit comments

Comments
 (0)