UI improvements

This commit is contained in:
Arkadiusz Fal 2021-11-07 17:52:42 +01:00
parent 63406a2933
commit 7d247bddb3
11 changed files with 71 additions and 45 deletions

View File

@ -58,6 +58,15 @@ final class PlayerModel: ObservableObject {
var playingInPictureInPicture = false
@Published var presentingErrorDetails = false
var playerError: Error? { didSet {
#if !os(tvOS)
if !playerError.isNil {
presentingErrorDetails = true
}
#endif
}}
init(accounts: AccountsModel? = nil, instances: InstancesModel? = nil) {
self.accounts = accounts ?? AccountsModel()
self.instances = instances ?? InstancesModel()
@ -123,6 +132,7 @@ final class PlayerModel: ObservableObject {
of video: Video,
preservingTime: Bool = false
) {
playerError = nil
resetSegments()
sponsorBlock.loadSegments(videoID: video.videoID, categories: Defaults[.sponsorBlockCategories])
@ -298,8 +308,7 @@ final class PlayerModel: ObservableObject {
self.play()
}
case .failed:
print("item error: \(String(describing: item.error))")
print((item.asset as! AVURLAsset).url)
self.playerError = item.error
default:
return

View File

@ -1,15 +0,0 @@
:root {
color-scheme: light dark;
}
body {
width: 100px;
padding: 10px;
font-family: system-ui;
text-align: center;
}
@media (prefers-color-scheme: dark) {
/* Dark Mode styles go here. */
}

View File

@ -1,11 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="popup.css">
<script type="module" src="popup.js"></script>
</head>
<body>
<strong>Hello World!</strong>
</body>
</html>

View File

@ -1 +0,0 @@
console.log("Hello World!", browser);

View File

@ -17,7 +17,7 @@ function redirect() {
}
function replaceContentWithLink() {
document.querySelector('body').innerHTML = yatteeLink();
document.querySelector('body').innerHTML = '<h1>' + yatteeLink() + '</h1>';
}
function redirectAndReplaceContentWithLink(){

View File

@ -11,6 +11,24 @@
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "0.263",
"green" : "0.290",
"red" : "0.859"
}
},
"idiom" : "universal"
}
],
"info" : {

View File

@ -10,24 +10,37 @@ struct FavoritesView: View {
@State private var dragging: FavoriteItem?
@State private var presentingEditFavorites = false
@State private var favoritesChanged = false
var favoritesObserver: Any?
#if !os(tvOS)
@Default(.favorites) private var favorites
#endif
var body: some View {
PlayerControlsView {
ScrollView(.vertical, showsIndicators: false) {
if !accounts.current.isNil {
ForEach(Defaults[.favorites]) { item in
FavoriteItemView(item: item, dragging: $dragging)
}
#if os(tvOS)
Button {
presentingEditFavorites = true
} label: {
Text("Edit Favorites...")
ForEach(Defaults[.favorites]) { item in
FavoriteItemView(item: item, dragging: $dragging)
}
#else
ForEach(favorites) { item in
FavoriteItemView(item: item, dragging: $dragging)
}
#endif
}
}
.redrawOn(change: presentingEditFavorites)
.onAppear {
Defaults.observe(.favorites) { _ in
favoritesChanged.toggle()
}
.tieToLifetime(of: accounts)
}
.redrawOn(change: favoritesChanged)
#if os(tvOS)
.sheet(isPresented: $presentingEditFavorites) {
EditFavorites()

View File

@ -26,7 +26,7 @@ struct Sidebar: View {
}
.navigationTitle("Yattee")
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
.navigationBarTitleDisplayMode(.inline)
#endif
}

View File

@ -34,6 +34,14 @@ struct PlaybackBar: View {
Image(systemName: "dot.radiowaves.left.and.right")
} else if player.isLoadingAvailableStreams || player.isLoadingStream {
Image(systemName: "bolt.horizontal.fill")
} else if !player.playerError.isNil {
Button {
player.presentingErrorDetails = true
} label: {
Image(systemName: "exclamationmark.circle.fill")
.foregroundColor(.red)
}
.buttonStyle(.plain)
}
streamControl
@ -57,6 +65,9 @@ struct PlaybackBar: View {
Spacer()
}
}
.alert(player.playerError?.localizedDescription ?? "", isPresented: $player.presentingErrorDetails) {
Button("OK") {}
}
.environment(\.colorScheme, .dark)
.frame(minWidth: 0, maxWidth: .infinity)
.padding(4)

View File

@ -55,6 +55,12 @@ struct SettingsView: View {
List {
#if os(tvOS)
AccountSelectionView()
Section(header: SettingsHeader(text: "Favorites")) {
NavigationLink("Edit favorites...") {
EditFavorites()
}
}
#endif
InstancesSettings()
BrowsingSettings()

View File

@ -11,11 +11,6 @@ struct EditFavorites: View {
var body: some View {
VStack {
ScrollView {
Text("Edit Favorites")
.font(.system(size: 40))
.fontWeight(.bold)
.foregroundColor(.secondary)
ForEach(favorites) { item in
HStack {
Text(label(item))
@ -75,6 +70,7 @@ struct EditFavorites: View {
}
.frame(width: 1000, alignment: .leading)
}
.navigationTitle("Edit Favorites")
}
func label(_ item: FavoriteItem) -> String {