mirror of
https://github.com/jellyfin/Swiftfin.git
synced 2025-02-19 23:02:49 +00:00

* Button cleanup & errorViews * Change the Sign Out button to be `ListRowButton`. Sets a better height value using `maxHeight` to ensure that it doesn't exceed the `ListRow` sizing. * deleteUsersButton needs to be manually set back to 75 * wip --------- Co-authored-by: Ethan Pippin <ethanpippin2343@gmail.com>
53 lines
1.3 KiB
Swift
53 lines
1.3 KiB
Swift
//
|
|
// Swiftfin is subject to the terms of the Mozilla Public
|
|
// License, v2.0. If a copy of the MPL was not distributed with this
|
|
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
|
//
|
|
// Copyright (c) 2025 Jellyfin & Jellyfin Contributors
|
|
//
|
|
|
|
import Defaults
|
|
import SwiftUI
|
|
|
|
// TODO: should use environment refresh instead?
|
|
struct ErrorView<ErrorType: Error>: View {
|
|
|
|
@Default(.accentColor)
|
|
private var accentColor
|
|
|
|
private let error: ErrorType
|
|
private var onRetry: (() -> Void)?
|
|
|
|
var body: some View {
|
|
VStack(spacing: 20) {
|
|
Image(systemName: "xmark.circle.fill")
|
|
.font(.system(size: 150))
|
|
.foregroundColor(Color.red)
|
|
|
|
Text(error.localizedDescription)
|
|
.frame(minWidth: 250, maxWidth: 750)
|
|
.multilineTextAlignment(.center)
|
|
|
|
if let onRetry {
|
|
ListRowButton(L10n.retry, action: onRetry)
|
|
.foregroundStyle(accentColor.overlayColor, accentColor)
|
|
.frame(maxWidth: 750)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
extension ErrorView {
|
|
|
|
init(error: ErrorType) {
|
|
self.init(
|
|
error: error,
|
|
onRetry: nil
|
|
)
|
|
}
|
|
|
|
func onRetry(_ action: @escaping () -> Void) -> Self {
|
|
copy(modifying: \.onRetry, with: action)
|
|
}
|
|
}
|