mirror of
https://github.com/yattee/yattee.git
synced 2026-11-01 01:17:20 +00:00
Remove dead code found by Periphery on all platforms
Delete declarations that Periphery reports unused on every platform that compiles them (iOS, macOS, tvOS), including nine views used only by their own previews. Platform-gated code still used on another platform, device- only MPV render paths, migration models, CloudKit record names, App Intents metadata and unused parameters are kept.
This commit is contained in:
@@ -83,52 +83,6 @@ struct ErrorStateView: View {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Load State View (Generic Container)
|
||||
|
||||
/// A generic container that handles loading, error, and content states.
|
||||
///
|
||||
/// Example usage:
|
||||
/// ```swift
|
||||
/// LoadStateView(
|
||||
/// isLoading: viewModel.isLoading,
|
||||
/// errorMessage: viewModel.error,
|
||||
/// data: viewModel.data,
|
||||
/// loadingMessage: "Loading...",
|
||||
/// errorTitle: "Error",
|
||||
/// onRetry: { await viewModel.load() }
|
||||
/// ) { data in
|
||||
/// ContentView(data: data)
|
||||
/// }
|
||||
/// ```
|
||||
struct LoadStateView<Content: View, Data>: View {
|
||||
let isLoading: Bool
|
||||
let errorMessage: String?
|
||||
let data: Data?
|
||||
var loadingMessage: String? = nil
|
||||
var loadingSubtext: String? = nil
|
||||
var errorTitle: String = "Error"
|
||||
var onRetry: (() async -> Void)? = nil
|
||||
var onDismiss: (() -> Void)? = nil
|
||||
@ViewBuilder let content: (Data) -> Content
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
if isLoading && data == nil {
|
||||
LoadingView(message: loadingMessage, subtext: loadingSubtext)
|
||||
} else if let error = errorMessage, data == nil {
|
||||
ErrorStateView(
|
||||
title: errorTitle,
|
||||
message: error,
|
||||
onRetry: onRetry,
|
||||
onDismiss: onDismiss
|
||||
)
|
||||
} else if let data {
|
||||
content(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
|
||||
#Preview("Loading") {
|
||||
@@ -143,38 +97,3 @@ struct LoadStateView<Content: View, Data>: View {
|
||||
onDismiss: {}
|
||||
)
|
||||
}
|
||||
|
||||
#Preview("LoadStateView - Loading") {
|
||||
LoadStateView(
|
||||
isLoading: true,
|
||||
errorMessage: nil,
|
||||
data: nil as String?,
|
||||
loadingMessage: "Fetching data..."
|
||||
) { data in
|
||||
Text(data)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview("LoadStateView - Error") {
|
||||
LoadStateView(
|
||||
isLoading: false,
|
||||
errorMessage: "Network error occurred",
|
||||
data: nil as String?,
|
||||
errorTitle: "Failed to Load",
|
||||
onRetry: {}
|
||||
) { data in
|
||||
Text(data)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview("LoadStateView - Content") {
|
||||
LoadStateView(
|
||||
isLoading: false,
|
||||
errorMessage: nil,
|
||||
data: "Hello, World!",
|
||||
loadingMessage: "Loading..."
|
||||
) { data in
|
||||
Text(data)
|
||||
.font(.largeTitle)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user