mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 09:20:08 +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,36 +1991,36 @@ 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)?) {
|
||||||
accumulator.insert(value)
|
queue.async { [self] in
|
||||||
|
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 {
|
||||||
|
lastValue = value
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
lastValue = value
|
|
||||||
}
|
|
||||||
|
|
||||||
if lastValue == nil {
|
if lastValue == nil {
|
||||||
queue.asyncAfter(deadline: .now() + duration) { [self] in
|
|
||||||
accumulator.removeAll()
|
|
||||||
// TODO: quick fix, replace with timer
|
|
||||||
queue.asyncAfter(deadline: .now() + duration) { [self] in
|
queue.asyncAfter(deadline: .now() + duration) { [self] in
|
||||||
isThrottling = false
|
accumulator.removeAll()
|
||||||
|
// TODO: quick fix, replace with timer
|
||||||
|
queue.asyncAfter(deadline: .now() + duration) { [self] in
|
||||||
|
isThrottling = false
|
||||||
|
}
|
||||||
|
|
||||||
|
guard
|
||||||
|
let lastValue = lastValue,
|
||||||
|
lastCompletedValue != lastValue || includingLatest
|
||||||
|
else { return }
|
||||||
|
|
||||||
|
accumulator.insert(lastValue)
|
||||||
|
self.lastValue = nil
|
||||||
|
completion?(lastValue)
|
||||||
|
lastCompletedValue = lastValue
|
||||||
}
|
}
|
||||||
|
|
||||||
guard
|
|
||||||
let lastValue = lastValue,
|
|
||||||
lastCompletedValue != lastValue || includingLatest
|
|
||||||
else { return }
|
|
||||||
|
|
||||||
accumulator.insert(lastValue)
|
|
||||||
self.lastValue = nil
|
|
||||||
completion?(lastValue)
|
|
||||||
lastCompletedValue = lastValue
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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