Model improvements

This commit is contained in:
Arkadiusz Fal
2022-08-31 21:24:46 +02:00
parent b220f212df
commit 0d3ccc00ce
23 changed files with 190 additions and 133 deletions

View File

@@ -37,15 +37,23 @@ struct ChannelCell: View {
.opacity(0.6)
}
.foregroundColor(.secondary)
WebImage(url: channel.thumbnailURL)
.resizable()
.placeholder {
Rectangle().fill(Color("PlaceholderColor"))
if #available(iOS 15, macOS 12, *) {
AsyncImage(url: channel.thumbnailURL) { image in
image
.resizable()
} placeholder: {
Rectangle().foregroundColor(Color("PlaceholderColor"))
}
.indicator(.activity)
.frame(width: 88, height: 88)
.clipShape(Circle())
} else {
WebImage(url: channel.thumbnailURL)
.resizable()
.placeholder {
Rectangle().fill(Color("PlaceholderColor"))
}
.indicator(.activity)
.frame(width: 88, height: 88)
.clipShape(Circle())
}
DetailBadge(text: channel.name, style: .prominent)

View File

@@ -37,15 +37,23 @@ struct ChannelPlaylistCell: View {
}
.foregroundColor(.secondary)
WebImage(url: playlist.thumbnailURL)
.resizable()
.placeholder {
Rectangle().fill(Color("PlaceholderColor"))
if #available(iOS 15, macOS 12, *) {
AsyncImage(url: playlist.thumbnailURL) { image in
image
.resizable()
} placeholder: {
Rectangle().foregroundColor(Color("PlaceholderColor"))
}
.indicator(.activity)
.frame(width: 165, height: 88)
.clipShape(RoundedRectangle(cornerRadius: 10))
} else {
WebImage(url: playlist.thumbnailURL)
.resizable()
.placeholder {
Rectangle().fill(Color("PlaceholderColor"))
}
.indicator(.activity)
.frame(width: 165, height: 88)
.clipShape(RoundedRectangle(cornerRadius: 10))
}
Group {
DetailBadge(text: playlist.title, style: .prominent)
.lineLimit(2)

View File

@@ -12,7 +12,6 @@ struct ControlsBar: View {
@EnvironmentObject<AccountsModel> private var accounts
@EnvironmentObject<NavigationModel> private var navigation
@EnvironmentObject<PlayerControlsModel> private var playerControls
@EnvironmentObject<PlayerModel> private var model
@EnvironmentObject<PlaylistsModel> private var playlists
@EnvironmentObject<RecentsModel> private var recents
@@ -63,8 +62,8 @@ struct ControlsBar: View {
}
} else if detailsToggleFullScreen {
Button {
playerControls.presentingControlsOverlay = false
playerControls.presentingControls = false
model.controls.presentingControlsOverlay = false
model.controls.presentingControls = false
withAnimation {
fullScreen.toggle()
}
@@ -83,7 +82,7 @@ struct ControlsBar: View {
var controls: some View {
HStack(spacing: 4) {
Group {
if playerControls.isPlaying {
if model.controls.isPlaying {
Button(action: {
model.pause()
}) {
@@ -103,7 +102,7 @@ struct ControlsBar: View {
}
}
}
.disabled(playerControls.isLoadingVideo || model.currentItem.isNil)
.disabled(model.controls.isLoadingVideo || model.currentItem.isNil)
Button(action: { model.advanceToNextItem() }) {
Label("Next", systemImage: "forward.fill")
@@ -268,13 +267,22 @@ struct ControlsBar: View {
private var authorAvatar: some View {
Group {
if let video = model.currentItem?.video, let url = video.channel.thumbnailURL {
WebImage(url: url)
.resizable()
.placeholder {
Rectangle().fill(Color("PlaceholderColor"))
if #available(iOS 15, macOS 12, *) {
AsyncImage(url: url) { image in
image
.resizable()
} placeholder: {
Rectangle().foregroundColor(Color("PlaceholderColor"))
}
.retryOnAppear(true)
.indicator(.activity)
} else {
WebImage(url: url)
.resizable()
.placeholder {
Rectangle().fill(Color("PlaceholderColor"))
}
.retryOnAppear(true)
.indicator(.activity)
}
} else {
ZStack {
Color(white: 0.6)