Skip to content

Commit ebe085d

Browse files
fix: self-review — remove duplicate types, dead code, deprecated APIs
- Remove duplicate ShareSheet definition (already in ShareSheet.swift), which caused an "Invalid redeclaration" compile error - Remove duplicate RetroToggleStyle struct; use RetroTheme.RetroToggleStyle() - Drop unused currentUser variable and unused scanlineOffset @State var - Fix deprecated onChange(of:) single-param closures to two-param form (iOS 17) - Remove redundant @available(iOS 15.0,...) annotation (min target is iOS 17) - Add missing .foregroundColor(.white) on Refresh button in BatchArtworkMatchingView Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2374fbf commit ebe085d

File tree

3 files changed

+7
-80
lines changed

3 files changed

+7
-80
lines changed

PVUI/Sources/PVSwiftUI/Settings/RetroAchievementsView.swift

Lines changed: 4 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import PVCheevos
44
import Combine
55

66
/// RetroAchievements login and profile view with RetroWave styling
7-
@available(iOS 15.0, tvOS 15.0, macOS 12.0, *)
87
public struct RetroAchievementsView: View {
98
// MARK: - Configuration
109

@@ -584,7 +583,6 @@ public struct RetroAchievementsView: View {
584583
if let currentClient = client {
585584
Task {
586585
let authenticated = await currentClient.isAuthenticated
587-
let currentUser = await currentClient.currentUsername
588586

589587
await MainActor.run {
590588
isAuthenticated = authenticated
@@ -744,8 +742,8 @@ public struct RetroAchievementsView: View {
744742
Spacer()
745743

746744
Toggle("", isOn: $retroAchievementsEnabled)
747-
.toggleStyle(RetroToggleStyle())
748-
.onChange(of: retroAchievementsEnabled) { newValue in
745+
.toggleStyle(RetroTheme.RetroToggleStyle())
746+
.onChange(of: retroAchievementsEnabled) { _, newValue in
749747
PVCheevos.retroArch.isRetroAchievementsEnabled = newValue
750748
}
751749
}
@@ -766,8 +764,8 @@ public struct RetroAchievementsView: View {
766764
Spacer()
767765

768766
Toggle("", isOn: $hardcoreModeEnabled)
769-
.toggleStyle(RetroToggleStyle())
770-
.onChange(of: hardcoreModeEnabled) { newValue in
767+
.toggleStyle(RetroTheme.RetroToggleStyle())
768+
.onChange(of: hardcoreModeEnabled) { _, newValue in
771769
PVCheevos.retroArch.isHardcoreModeEnabled = newValue
772770
}
773771
}
@@ -785,65 +783,6 @@ public struct RetroAchievementsView: View {
785783
}
786784
}
787785

788-
// MARK: - Custom Toggle Style
789-
790-
struct RetroToggleStyle: ToggleStyle {
791-
func makeBody(configuration: Configuration) -> some View {
792-
HStack {
793-
configuration.label
794-
Spacer()
795-
toggleSwitch(isOn: configuration.isOn) {
796-
configuration.isOn.toggle()
797-
}
798-
}
799-
}
800-
801-
@ViewBuilder
802-
private func toggleSwitch(isOn: Bool, action: @escaping () -> Void) -> some View {
803-
Button(action: action) {
804-
toggleBackground(isOn: isOn)
805-
.overlay(toggleThumb(isOn: isOn))
806-
.frame(width: 50, height: 30)
807-
}
808-
.buttonStyle(.plain)
809-
}
810-
811-
@ViewBuilder
812-
private func toggleBackground(isOn: Bool) -> some View {
813-
RoundedRectangle(cornerRadius: 16)
814-
.fill(backgroundFill(isOn: isOn))
815-
.overlay(backgroundBorder(isOn: isOn))
816-
.animation(.spring(response: 0.3, dampingFraction: 0.7), value: isOn)
817-
}
818-
819-
@ViewBuilder
820-
private func toggleThumb(isOn: Bool) -> some View {
821-
Circle()
822-
.fill(Color.white)
823-
.frame(width: 26, height: 26)
824-
.offset(x: isOn ? 10 : -10)
825-
.shadow(color: .black.opacity(0.2), radius: 2, x: 0, y: 1)
826-
.animation(.spring(response: 0.3, dampingFraction: 0.7), value: isOn)
827-
}
828-
829-
private func backgroundFill(isOn: Bool) -> AnyShapeStyle {
830-
if isOn {
831-
return AnyShapeStyle(RetroTheme.retroHorizontalGradient)
832-
} else {
833-
return AnyShapeStyle(Color.black.opacity(0.6))
834-
}
835-
}
836-
837-
@ViewBuilder
838-
private func backgroundBorder(isOn: Bool) -> some View {
839-
RoundedRectangle(cornerRadius: 16)
840-
.strokeBorder(
841-
isOn ? Color.clear : Color.white.opacity(0.3),
842-
lineWidth: 1
843-
)
844-
}
845-
}
846-
847786
// MARK: - Supporting Types
848787

849788
enum LoginError: LocalizedError {
@@ -863,15 +802,3 @@ enum LoginError: LocalizedError {
863802
}
864803
}
865804

866-
#if !os(tvOS)
867-
/// Share sheet for tvOS compatibility
868-
struct ShareSheet: UIViewControllerRepresentable {
869-
let activityItems: [Any]
870-
871-
func makeUIViewController(context: Context) -> UIActivityViewController {
872-
UIActivityViewController(activityItems: activityItems, applicationActivities: nil)
873-
}
874-
875-
func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {}
876-
}
877-
#endif

PVUI/Sources/PVSwiftUI/Settings/Views/BackupRestoreView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ struct BackupRestoreView: View {
113113
#endif
114114
}
115115
#if !os(tvOS)
116-
.onChange(of: coordinator.backupState) { state in
116+
.onChange(of: coordinator.backupState) { _, state in
117117
if state == .done, coordinator.backupURL != nil {
118118
showShareSheet = true
119119
}
120120
}
121121
#endif
122-
.onChange(of: coordinator.restoreState) { state in
122+
.onChange(of: coordinator.restoreState) { _, state in
123123
switch state {
124124
case .done(let restored):
125125
// Release security-scoped access now that restore has finished

PVUI/Sources/PVSwiftUI/Settings/Views/BatchArtworkMatchingView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public struct BatchArtworkMatchingView: View {
5858

5959
// Animation states for retrowave effects
6060
@State private var glowOpacity: Double = 0.7
61-
@State private var scanlineOffset: CGFloat = 0
6261

6362
// MARK: - Body
6463

@@ -314,6 +313,7 @@ public struct BatchArtworkMatchingView: View {
314313
Text("REFRESH")
315314
.font(.system(size: 14, weight: .bold))
316315
}
316+
.foregroundColor(.white)
317317
.frame(maxWidth: .infinity)
318318
.padding(.vertical, 12)
319319
.background(

0 commit comments

Comments
 (0)