Various fixes

This commit is contained in:
Ilya Laktyushin 2023-10-29 17:52:44 +04:00
parent bbb543f836
commit 32de3c0e53
4 changed files with 27 additions and 9 deletions

View File

@ -387,12 +387,12 @@ public final class MediaEditorVideoExport {
} }
switch self.subject { switch self.subject {
case let .video(asset, _): case let .video(asset, isStory):
var additionalAsset: AVAsset? var additionalAsset: AVAsset?
if let additionalPath = self.configuration.values.additionalVideoPath { if let additionalPath = self.configuration.values.additionalVideoPath {
additionalAsset = AVURLAsset(url: URL(fileURLWithPath: additionalPath)) additionalAsset = AVURLAsset(url: URL(fileURLWithPath: additionalPath))
} }
self.setupWithAsset(asset, additionalAsset: additionalAsset) self.setupWithAsset(asset, additionalAsset: additionalAsset, isStory: isStory)
case let .image(image): case let .image(image):
self.setupWithImage(image) self.setupWithImage(image)
} }
@ -405,7 +405,7 @@ public final class MediaEditorVideoExport {
self.composer = MediaEditorComposer(postbox: self.postbox, values: self.configuration.values, dimensions: self.configuration.composerDimensions, outputDimensions: self.configuration.dimensions, textScale: self.textScale) self.composer = MediaEditorComposer(postbox: self.postbox, values: self.configuration.values, dimensions: self.configuration.composerDimensions, outputDimensions: self.configuration.dimensions, textScale: self.textScale)
} }
private func setupWithAsset(_ asset: AVAsset, additionalAsset: AVAsset?) { private func setupWithAsset(_ asset: AVAsset, additionalAsset: AVAsset?, isStory: Bool) {
var inputAsset = asset var inputAsset = asset
var inputAudioMix: AVMutableAudioMix? var inputAudioMix: AVMutableAudioMix?
@ -476,7 +476,7 @@ public final class MediaEditorVideoExport {
if let timeRange = self.configuration.timeRange { if let timeRange = self.configuration.timeRange {
reader.timeRange = timeRange reader.timeRange = timeRange
self.additionalReader?.timeRange = timeRange self.additionalReader?.timeRange = timeRange
} else if asset.duration.seconds > 60.0 { } else if asset.duration.seconds > 60.0 && isStory {
let trimmedRange = CMTimeRange(start: CMTime(seconds: 0.0, preferredTimescale: CMTimeScale(NSEC_PER_SEC)), end: CMTime(seconds: 60.0, preferredTimescale: CMTimeScale(NSEC_PER_SEC))) let trimmedRange = CMTimeRange(start: CMTime(seconds: 0.0, preferredTimescale: CMTimeScale(NSEC_PER_SEC)), end: CMTime(seconds: 60.0, preferredTimescale: CMTimeScale(NSEC_PER_SEC)))
reader.timeRange = trimmedRange reader.timeRange = trimmedRange
self.additionalReader?.timeRange = trimmedRange self.additionalReader?.timeRange = trimmedRange

View File

@ -534,7 +534,11 @@ public func PeerNameColorScreen(
guard let controller else { guard let controller else {
return return
} }
if c is UndoOverlayController {
controller.present(c, in: .current) controller.present(c, in: .current)
} else {
controller.present(c, in: .window(.root))
}
} }
pushImpl = { [weak controller] c in pushImpl = { [weak controller] c in
guard let controller else { guard let controller else {

View File

@ -235,7 +235,6 @@ public struct WebAppParameters {
public func generateWebAppThemeParams(_ presentationTheme: PresentationTheme) -> [String: Any] { public func generateWebAppThemeParams(_ presentationTheme: PresentationTheme) -> [String: Any] {
let backgroundColor = presentationTheme.list.plainBackgroundColor.rgb let backgroundColor = presentationTheme.list.plainBackgroundColor.rgb
let secondaryBackgroundColor = presentationTheme.list.blocksBackgroundColor.rgb let secondaryBackgroundColor = presentationTheme.list.blocksBackgroundColor.rgb
return [ return [
"bg_color": Int32(bitPattern: backgroundColor), "bg_color": Int32(bitPattern: backgroundColor),
"secondary_bg_color": Int32(bitPattern: secondaryBackgroundColor), "secondary_bg_color": Int32(bitPattern: secondaryBackgroundColor),
@ -329,6 +328,13 @@ public final class WebAppController: ViewController, AttachmentContainable {
strongSelf.handleScriptMessage(delayedScriptMessage) strongSelf.handleScriptMessage(delayedScriptMessage)
} }
} }
if #available(iOS 13.0, *) {
if self.presentationData.theme.overallDarkAppearance {
webView.overrideUserInterfaceStyle = .dark
} else {
webView.overrideUserInterfaceStyle = .unspecified
}
}
self.webView = webView self.webView = webView
self.addSubnode(self.backgroundNode) self.addSubnode(self.backgroundNode)
@ -1120,6 +1126,14 @@ public final class WebAppController: ViewController, AttachmentContainable {
} }
self.updateHeaderBackgroundColor(transition: .immediate) self.updateHeaderBackgroundColor(transition: .immediate)
self.sendThemeChangedEvent() self.sendThemeChangedEvent()
if #available(iOS 13.0, *) {
if self.presentationData.theme.overallDarkAppearance {
self.webView?.overrideUserInterfaceStyle = .dark
} else {
self.webView?.overrideUserInterfaceStyle = .unspecified
}
}
} }
private func sendThemeChangedEvent() { private func sendThemeChangedEvent() {

View File

@ -66,7 +66,7 @@ final class WebAppWebView: WKWebView {
configuration.allowsInlineMediaPlayback = true configuration.allowsInlineMediaPlayback = true
configuration.allowsPictureInPictureMediaPlayback = false configuration.allowsPictureInPictureMediaPlayback = false
if #available(iOSApplicationExtension 10.0, iOS 10.0, *) { if #available(iOS 10.0, *) {
configuration.mediaTypesRequiringUserActionForPlayback = .all configuration.mediaTypesRequiringUserActionForPlayback = .all
} else { } else {
configuration.mediaPlaybackRequiresUserAction = true configuration.mediaPlaybackRequiresUserAction = true
@ -78,10 +78,10 @@ final class WebAppWebView: WKWebView {
self.isOpaque = false self.isOpaque = false
self.backgroundColor = .clear self.backgroundColor = .clear
if #available(iOSApplicationExtension 9.0, iOS 9.0, *) { if #available(iOS 9.0, *) {
self.allowsLinkPreview = false self.allowsLinkPreview = false
} }
if #available(iOSApplicationExtension 11.0, iOS 11.0, *) { if #available(iOS 11.0, *) {
self.scrollView.contentInsetAdjustmentBehavior = .never self.scrollView.contentInsetAdjustmentBehavior = .never
} }
self.interactiveTransitionGestureRecognizerTest = { point -> Bool in self.interactiveTransitionGestureRecognizerTest = { point -> Bool in