Skip to content

Commit 7afa30f

Browse files
committed
Various fixes
1 parent 9fcc324 commit 7afa30f

File tree

4 files changed

+138
-13
lines changed

4 files changed

+138
-13
lines changed

submodules/TelegramUI/Components/Gifts/GiftItemComponent/Sources/GiftItemComponent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ public final class GiftItemComponent: Component {
872872
if range.location != NSNotFound {
873873
labelText.addAttribute(NSAttributedString.Key.font, value: Font.semibold(10.0), range: range)
874874
labelText.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: 0, file: nil, custom: .stars(tinted: true)), range: range)
875-
labelText.addAttribute(.kern, value: -2.0, range: NSRange(location: range.lowerBound, length: 1))
875+
labelText.addAttribute(.kern, value: -1.5, range: NSRange(location: range.upperBound, length: 1))
876876
}
877877

878878
let resellSize = self.reselLabel.update(

submodules/TelegramUI/Components/MediaEditor/Sources/MediaEditorValues.swift

Lines changed: 109 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public enum MediaCropOrientation: Int32 {
230230
}
231231
}
232232

233-
public final class MediaEditorValues: Codable, Equatable {
233+
public final class MediaEditorValues: Codable, Equatable, CustomStringConvertible {
234234
public static func == (lhs: MediaEditorValues, rhs: MediaEditorValues) -> Bool {
235235
if lhs.peerId != rhs.peerId {
236236
return false
@@ -1010,6 +1010,114 @@ public final class MediaEditorValues: Codable, Equatable {
10101010
}
10111011
return false
10121012
}
1013+
1014+
public var description: String {
1015+
var components: [String] = []
1016+
1017+
components.append("originalDimensions: \(self.originalDimensions.width)x\(self.originalDimensions.height)")
1018+
1019+
if self.cropOffset != .zero {
1020+
components.append("cropOffset: \(cropOffset)")
1021+
}
1022+
1023+
if let cropRect = self.cropRect {
1024+
components.append("cropRect: \(cropRect)")
1025+
}
1026+
1027+
if self.cropScale != 1.0 {
1028+
components.append("cropScale: \(self.cropScale)")
1029+
}
1030+
1031+
if self.cropRotation != 0.0 {
1032+
components.append("cropRotation: \(self.cropRotation)")
1033+
}
1034+
1035+
if self.cropMirroring {
1036+
components.append("cropMirroring: true")
1037+
}
1038+
1039+
if let cropOrientation = self.cropOrientation {
1040+
components.append("cropOrientation: \(cropOrientation)")
1041+
}
1042+
1043+
if let gradientColors = self.gradientColors, !gradientColors.isEmpty {
1044+
components.append("gradientColors: \(gradientColors.count) colors")
1045+
}
1046+
1047+
if let videoTrimRange = self.videoTrimRange {
1048+
components.append("videoTrimRange: \(videoTrimRange.lowerBound) - \(videoTrimRange.upperBound)")
1049+
}
1050+
1051+
if self.videoIsMuted {
1052+
components.append("videoIsMuted: true")
1053+
}
1054+
1055+
if self.videoIsFullHd {
1056+
components.append("videoIsFullHd: true")
1057+
}
1058+
1059+
if self.videoIsMirrored {
1060+
components.append("videoIsMirrored: true")
1061+
}
1062+
1063+
if let videoVolume = self.videoVolume, videoVolume != 1.0 {
1064+
components.append("videoVolume: \(videoVolume)")
1065+
}
1066+
1067+
if let additionalVideoPath = self.additionalVideoPath {
1068+
components.append("additionalVideo: \(additionalVideoPath)")
1069+
}
1070+
1071+
if let position = self.additionalVideoPosition {
1072+
components.append("additionalVideoPosition: \(position)")
1073+
}
1074+
1075+
if let scale = self.additionalVideoScale {
1076+
components.append("additionalVideoScale: \(scale)")
1077+
}
1078+
1079+
if let rotation = self.additionalVideoRotation {
1080+
components.append("additionalVideoRotation: \(rotation)")
1081+
}
1082+
1083+
if !self.additionalVideoPositionChanges.isEmpty {
1084+
components.append("additionalVideoPositionChanges: \(additionalVideoPositionChanges.count) changes")
1085+
}
1086+
1087+
if !self.collage.isEmpty {
1088+
components.append("collage: \(collage.count) items")
1089+
}
1090+
1091+
if self.nightTheme {
1092+
components.append("nightTheme: true")
1093+
}
1094+
1095+
if self.drawing != nil {
1096+
components.append("drawing: true")
1097+
}
1098+
1099+
if self.maskDrawing != nil {
1100+
components.append("maskDrawing: true")
1101+
}
1102+
1103+
if !self.entities.isEmpty {
1104+
components.append("entities: \(self.entities.count) items")
1105+
}
1106+
1107+
if !self.toolValues.isEmpty {
1108+
components.append("toolValues: \(self.toolValues.count) tools")
1109+
}
1110+
1111+
if let audioTrack = self.audioTrack {
1112+
components.append("audioTrack: \(audioTrack.path)")
1113+
}
1114+
1115+
if let qualityPreset = self.qualityPreset {
1116+
components.append("qualityPreset: \(qualityPreset)")
1117+
}
1118+
1119+
return "MediaEditorValues(\(components.joined(separator: ", ")))"
1120+
}
10131121
}
10141122

10151123
public struct TintValue: Equatable, Codable {

submodules/TelegramUI/Components/MediaEditor/Sources/MediaEditorVideoExport.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@ public final class MediaEditorVideoExport {
264264
self.outputPath = outputPath
265265
self.textScale = textScale
266266

267+
Logger.shared.log("VideoExport", "Init")
268+
Logger.shared.log("VideoExport", "Subject: \(subject)")
269+
Logger.shared.log("VideoExport", "Output Path: \(outputPath)")
270+
Logger.shared.log("VideoExport", "Configuration: \(configuration)")
271+
267272
if FileManager.default.fileExists(atPath: outputPath) {
268273
try? FileManager.default.removeItem(atPath: outputPath)
269274
}
@@ -297,6 +302,9 @@ public final class MediaEditorVideoExport {
297302
}
298303

299304
private func setup() {
305+
Logger.shared.log("VideoExport", "Setting up")
306+
307+
300308
var mainAsset: AVAsset?
301309

302310
var signals: [Signal<Input, NoError>] = []
@@ -948,11 +956,6 @@ public final class MediaEditorVideoExport {
948956
return false
949957
}
950958
}
951-
} else {
952-
// if !writer.appendVideoBuffer(sampleBuffer) {
953-
// writer.markVideoAsFinished()
954-
// return false
955-
// }
956959
}
957960
}
958961
return true
@@ -983,17 +986,21 @@ public final class MediaEditorVideoExport {
983986
}
984987

985988
private func start() {
989+
Logger.shared.log("VideoExport", "Start")
986990
guard self.internalStatus == .idle, let writer = self.writer else {
991+
Logger.shared.log("VideoExport", "Failed with invalid state")
987992
self.statusValue = .failed(.invalid)
988993
return
989994
}
990995

991996
guard writer.startWriting() else {
997+
Logger.shared.log("VideoExport", "Failed on startWriting")
992998
self.statusValue = .failed(.writing(nil))
993999
return
9941000
}
9951001

9961002
if let reader = self.reader, !reader.startReading() {
1003+
Logger.shared.log("VideoExport", "Failed on startReading")
9971004
self.statusValue = .failed(.reading(nil))
9981005
return
9991006
}
@@ -1067,6 +1074,7 @@ public final class MediaEditorVideoExport {
10671074
}
10681075

10691076
if cancelled {
1077+
Logger.shared.log("VideoExport", "Cancelled")
10701078
try? FileManager.default.removeItem(at: outputUrl)
10711079
self.internalStatus = .finished
10721080
self.statusValue = .failed(.cancelled)
@@ -1108,6 +1116,7 @@ public final class MediaEditorVideoExport {
11081116
let exportDuration = end - self.startTimestamp
11091117
print("video processing took \(exportDuration)s")
11101118
if duration.seconds > 0 {
1119+
Logger.shared.log("VideoExport", "Completed with path \(self.outputPath)")
11111120
Logger.shared.log("VideoExport", "Video processing took \(exportDuration / duration.seconds)")
11121121
}
11131122
})

submodules/WebUI/Sources/WebAppController.swift

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,11 @@ public final class WebAppController: ViewController, AttachmentContainable {
828828
}
829829

830830
if let webView = self.webView {
831-
var scrollInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: layout.intrinsicInsets.bottom, right: 0.0)
831+
let inputHeight = self.validLayout?.0.inputHeight ?? 0.0
832+
833+
let intrinsicBottomInset = layout.intrinsicInsets.bottom > 40.0 ? layout.intrinsicInsets.bottom : 0.0
834+
835+
var scrollInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: max(inputHeight, intrinsicBottomInset), right: 0.0)
832836
var frameBottomInset: CGFloat = 0.0
833837
if scrollInset.bottom > 40.0 {
834838
frameBottomInset = scrollInset.bottom
@@ -841,12 +845,12 @@ public final class WebAppController: ViewController, AttachmentContainable {
841845
if !webView.frame.width.isZero && webView.frame != webViewFrame {
842846
self.updateWebViewWhenStable = true
843847
}
844-
845-
var bottomInset = layout.intrinsicInsets.bottom + layout.additionalInsets.bottom
846-
if let inputHeight = self.validLayout?.0.inputHeight, inputHeight > 44.0 {
847-
bottomInset = max(bottomInset, inputHeight)
848+
849+
var viewportBottomInset = max(frameBottomInset, scrollInset.bottom)
850+
if (self.validLayout?.0.inputHeight ?? 0.0) < 44.0 {
851+
viewportBottomInset += layout.additionalInsets.bottom
848852
}
849-
let viewportFrame = CGRect(origin: CGPoint(x: layout.safeInsets.left, y: topInset), size: CGSize(width: layout.size.width - layout.safeInsets.left - layout.safeInsets.right, height: max(1.0, layout.size.height - topInset - bottomInset)))
853+
let viewportFrame = CGRect(origin: CGPoint(x: layout.safeInsets.left, y: topInset), size: CGSize(width: layout.size.width - layout.safeInsets.left - layout.safeInsets.right, height: max(1.0, layout.size.height - topInset - viewportBottomInset)))
850854

851855
if webView.scrollView.contentInset != scrollInset {
852856
webView.scrollView.contentInset = scrollInset
@@ -1061,6 +1065,10 @@ public final class WebAppController: ViewController, AttachmentContainable {
10611065
} else {
10621066
self.lastExpansionTimestamp = currentTimestamp
10631067
controller.requestAttachmentMenuExpansion()
1068+
1069+
Queue.mainQueue().after(0.4) {
1070+
self.webView?.setNeedsLayout()
1071+
}
10641072
}
10651073
case "web_app_close":
10661074
controller.dismiss()

0 commit comments

Comments
 (0)