-
-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tvOS] ErrorViews - Creation (#1414)
* 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>
- Loading branch information
Showing
16 changed files
with
178 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// 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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.