Use Swift 5.7 if-let style

This commit is contained in:
Arkadiusz Fal
2022-09-28 16:27:01 +02:00
parent 8f96a7c5e0
commit a086a0f440
50 changed files with 114 additions and 114 deletions

View File

@@ -32,7 +32,7 @@ struct Buffering: View {
Text(reason)
.font(.system(size: playerControlsLayout.timeFontSize))
if let state = state {
if let state {
Text(state)
.font(.system(size: playerControlsLayout.bufferingStateFontSize).monospacedDigit())
}

View File

@@ -206,12 +206,12 @@ struct PlayerControls: View {
}
var detailsWidth: Double {
guard let player = player, player.playerSize.width.isFinite else { return 200 }
guard let player, player.playerSize.width.isFinite else { return 200 }
return [player.playerSize.width, 600].min()!
}
var detailsHeight: Double {
guard let player = player, player.playerSize.height.isFinite else { return 200 }
guard let player, player.playerSize.height.isFinite else { return 200 }
return [player.playerSize.height, 500].min()!
}

View File

@@ -36,7 +36,7 @@ final class MPVOGLView: GLKView {
}
override func draw(_: CGRect) {
guard needsDrawing, let mpvGL = mpvGL else {
guard needsDrawing, let mpvGL else {
return
}

View File

@@ -53,7 +53,7 @@ struct StreamControl: View {
}
.transaction { t in t.animation = .none }
.onChange(of: player.streamSelection) { selection in
guard let selection = selection else { return }
guard let selection else { return }
player.upgradeToStream(selection)
player.controls.hideOverlays()
}

View File

@@ -143,7 +143,7 @@ struct VideoDetails: View {
var publishedDateSection: some View {
Group {
if let video = video {
if let video {
HStack(spacing: 4) {
if let published = video.publishedDate {
Text(published)
@@ -227,7 +227,7 @@ struct VideoDetails: View {
var detailsPage: some View {
VStack(alignment: .leading, spacing: 0) {
if let video = video {
if let video {
VStack(spacing: 6) {
videoProperties

View File

@@ -33,7 +33,7 @@ struct VideoPlayerSizeModifier: ViewModifier {
}
var usedAspectRatio: Double {
guard let aspectRatio = aspectRatio, aspectRatio > 0, aspectRatio < VideoPlayerView.defaultAspectRatio else {
guard let aspectRatio, aspectRatio > 0, aspectRatio < VideoPlayerView.defaultAspectRatio else {
return VideoPlayerView.defaultAspectRatio
}