mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-08 01:40:09 +00:00
Supporting varying aspect ratio
This commit is contained in:
parent
abe0be6d63
commit
073920c5ec
@ -1013,7 +1013,7 @@ public final class _MediaStreamComponent: CombinedComponent {
|
|||||||
if forceFullScreenInLandscape && /*videoSize.width > videoSize.height &&*/ isLandscape && !state.isFullscreen {
|
if forceFullScreenInLandscape && /*videoSize.width > videoSize.height &&*/ isLandscape && !state.isFullscreen {
|
||||||
state.isFullscreen = true
|
state.isFullscreen = true
|
||||||
isFullscreen = true
|
isFullscreen = true
|
||||||
} else if let videoSize = context.state.videoSize, videoSize.width > videoSize.height && !isLandscape && state.isFullscreen && canEnforceOrientation {
|
} else if /*let videoSize = context.state.videoSize, videoSize.width > videoSize.height &&*/ !isLandscape && state.isFullscreen && canEnforceOrientation {
|
||||||
state.isFullscreen = false
|
state.isFullscreen = false
|
||||||
isFullscreen = false
|
isFullscreen = false
|
||||||
} else {
|
} else {
|
||||||
@ -1991,15 +1991,14 @@ public final class Throttler<T: Hashable> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func publish(_ value: T, includingLatest: Bool = false, using completion: ((T) -> Void)?) {
|
public func publish(_ value: T, includingLatest: Bool = false, using completion: ((T) -> Void)?) {
|
||||||
|
queue.async { [self] in
|
||||||
accumulator.insert(value)
|
accumulator.insert(value)
|
||||||
|
|
||||||
if !isThrottling {
|
if !isThrottling {
|
||||||
isThrottling = true
|
isThrottling = true
|
||||||
lastValue = nil
|
lastValue = nil
|
||||||
queue.async {
|
|
||||||
completion?(value)
|
completion?(value)
|
||||||
self.lastCompletedValue = value
|
self.lastCompletedValue = value
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
lastValue = value
|
lastValue = value
|
||||||
}
|
}
|
||||||
@ -2024,6 +2023,7 @@ public final class Throttler<T: Hashable> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func cancelCurrent() {
|
public func cancelCurrent() {
|
||||||
lastValue = nil
|
lastValue = nil
|
||||||
|
|||||||
@ -595,8 +595,10 @@ final class _MediaStreamVideoComponent: Component {
|
|||||||
// aspect == 1 the first run
|
// aspect == 1 the first run
|
||||||
if component.isFullscreen && self.hadVideo {
|
if component.isFullscreen && self.hadVideo {
|
||||||
if aspect <= 0.01 {
|
if aspect <= 0.01 {
|
||||||
aspect = 16.0 / 9 // 3.0 / 4.0
|
aspect = 16.0 / 9
|
||||||
}
|
}
|
||||||
|
} else if self.hadVideo {
|
||||||
|
// aspect = aspect
|
||||||
} else {
|
} else {
|
||||||
aspect = 16.0 / 9
|
aspect = 16.0 / 9
|
||||||
}
|
}
|
||||||
@ -604,7 +606,10 @@ final class _MediaStreamVideoComponent: Component {
|
|||||||
if component.isFullscreen {
|
if component.isFullscreen {
|
||||||
videoSize = CGSize(width: aspect * 100.0, height: 100.0).aspectFitted(.init(width: availableSize.width - videoInset * 2, height: availableSize.height))
|
videoSize = CGSize(width: aspect * 100.0, height: 100.0).aspectFitted(.init(width: availableSize.width - videoInset * 2, height: availableSize.height))
|
||||||
} else {
|
} else {
|
||||||
videoSize = CGSize(width: aspect * 100.0, height: 100.0).aspectFitted(.init(width: min(availableSize.width, availableSize.height) - videoInset * 2, height: max(availableSize.height, availableSize.width)))
|
let availableVideoWidth = availableSize.width - videoInset * 2
|
||||||
|
let availableVideoHeight = availableVideoWidth * 9.0 / 16
|
||||||
|
|
||||||
|
videoSize = CGSize(width: aspect * 100.0, height: 100.0).aspectFitted(.init(width: availableVideoWidth, height: availableVideoHeight))
|
||||||
}
|
}
|
||||||
let blurredVideoSize = videoSize.aspectFilled(availableSize)
|
let blurredVideoSize = videoSize.aspectFilled(availableSize)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user