-
-
Notifications
You must be signed in to change notification settings - Fork 308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tvOS] ErrorViews - Creation #1414
Open
JPKribs
wants to merge
5
commits into
jellyfin:main
Choose a base branch
from
JPKribs:errorView
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+250
−144
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3f20320
Button cleanup & errorViews
JPKribs 0a40e30
Change the Sign Out button to be `ListRowButton`. Sets a better heigh…
JPKribs 4d94362
deleteUsersButton needs to be manually set back to 75
JPKribs 0244259
Merge branch 'jellyfin:main' into errorView
JPKribs bd007db
Merge branch 'jellyfin:main' into errorView
JPKribs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,47 @@ | ||
// | ||
// 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 SwiftUI | ||
|
||
// TODO: should use environment refresh instead? | ||
struct ErrorView<ErrorType: Error>: View { | ||
|
||
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 { | ||
PrimaryButton(title: L10n.retry) | ||
.onSelect(onRetry) | ||
} | ||
} | ||
} | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// | ||
// 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 | ||
|
||
struct PrimaryButton: View { | ||
|
||
// MARK: - Defaults | ||
|
||
@Default(.accentColor) | ||
private var accentColor | ||
|
||
// MARK: - Environment | ||
|
||
@Environment(\.isEnabled) | ||
private var isEnabled | ||
|
||
// MARK: - Focus State | ||
|
||
@FocusState | ||
private var isFocused: Bool | ||
|
||
// MARK: - Button Variables | ||
|
||
private let title: String | ||
private var onSelect: () -> Void | ||
|
||
// MARK: - Body | ||
|
||
var body: some View { | ||
Button { | ||
onSelect() | ||
} label: { | ||
ZStack { | ||
RoundedRectangle(cornerRadius: 10) | ||
.fill(accentColor) | ||
|
||
if !isEnabled { | ||
Color.black.opacity(0.5) | ||
} else if isFocused { | ||
Color.white.opacity(0.25) | ||
} | ||
|
||
Text(title) | ||
.fontWeight(.bold) | ||
.foregroundStyle(isFocused ? Color.black : accentColor.overlayColor) | ||
} | ||
} | ||
.buttonStyle(.card) | ||
.frame(height: 75) | ||
.frame(maxWidth: 750) | ||
.focused($isFocused) | ||
} | ||
} | ||
|
||
extension PrimaryButton { | ||
|
||
// MARK: - Initializer | ||
|
||
init(title: String) { | ||
self.init( | ||
title: title, | ||
onSelect: {} | ||
) | ||
} | ||
|
||
func onSelect(_ action: @escaping () -> Void) -> Self { | ||
copy(modifying: \.onSelect, 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 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I brought this over from iOS. It doesn't seem to do anything and it's always disabled. It makes sense to pull this IMO but, if I'm pulling it from this PR I think it makes sense to pull this from iOS as well? Unless we have a usage for this we want to do in which case I think it should be on both platforms and we should TODO this so we know what we want to do later.