mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
8bcc38c24e
commit
41f943b5f1
@ -2185,7 +2185,10 @@ public func chatSecretMessageVideo(account: Account, userLocation: MediaResource
|
||||
}
|
||||
}
|
||||
|
||||
// addCorners(context, arguments: arguments)
|
||||
if arguments.corners.topLeft > 40.0 {
|
||||
} else {
|
||||
addCorners(context, arguments: arguments)
|
||||
}
|
||||
|
||||
return context
|
||||
}
|
||||
|
@ -443,7 +443,7 @@ public final class SemanticStatusNode: ASControlNode {
|
||||
self.setNeedsDisplay()
|
||||
}
|
||||
|
||||
public func transitionToState(_ state: SemanticStatusNodeState, animated: Bool = true, synchronous: Bool = false, completion: @escaping () -> Void = {}) {
|
||||
public func transitionToState(_ state: SemanticStatusNodeState, animated: Bool = true, synchronous: Bool = false, cutout: CGRect? = nil, updateCutout: Bool = false, completion: @escaping () -> Void = {}) {
|
||||
var animated = animated
|
||||
if !self.hasState {
|
||||
self.hasState = true
|
||||
@ -452,13 +452,18 @@ public final class SemanticStatusNode: ASControlNode {
|
||||
if self.state != state || self.appearanceContext.cutout != cutout {
|
||||
self.state = state
|
||||
let previousStateContext = self.stateContext
|
||||
let previousAppearanceContext = updateCutout ? self.appearanceContext : nil
|
||||
|
||||
self.stateContext = self.state.context(current: self.stateContext)
|
||||
self.stateContext.requestUpdate = { [weak self] in
|
||||
self?.setNeedsDisplay()
|
||||
}
|
||||
if updateCutout {
|
||||
self.appearanceContext = self.appearanceContext.withUpdatedCutout(cutout)
|
||||
}
|
||||
|
||||
if animated && previousStateContext !== self.stateContext {
|
||||
self.transitionContext = SemanticStatusNodeTransitionContext(startTime: CACurrentMediaTime(), duration: 0.18, previousStateContext: previousStateContext, previousAppearanceContext: nil, completion: completion)
|
||||
if animated && (previousStateContext !== self.stateContext || (updateCutout && previousAppearanceContext?.cutout != cutout)) {
|
||||
self.transitionContext = SemanticStatusNodeTransitionContext(startTime: CACurrentMediaTime(), duration: 0.18, previousStateContext: previousStateContext, previousAppearanceContext: previousAppearanceContext, completion: completion)
|
||||
} else {
|
||||
completion()
|
||||
}
|
||||
@ -513,7 +518,7 @@ public final class SemanticStatusNode: ASControlNode {
|
||||
return
|
||||
}
|
||||
|
||||
if let transitionAppearanceState = parameters.transitionState?.appearanceState {
|
||||
if let transitionAppearanceState = parameters.transitionState?.appearanceState, transitionAppearanceState.background.alpha == 1.0 {
|
||||
transitionAppearanceState.drawBackground(context: context, size: bounds.size)
|
||||
}
|
||||
parameters.appearanceState.drawBackground(context: context, size: bounds.size)
|
||||
|
@ -20,9 +20,11 @@ final class SemanticStatusNodeIconContext: SemanticStatusNodeStateContext {
|
||||
}
|
||||
|
||||
func draw(context: CGContext, size: CGSize, foregroundColor: UIColor) {
|
||||
let transitionScale = max(0.01, self.transitionFraction)
|
||||
|
||||
context.saveGState()
|
||||
context.translateBy(x: size.width / 2.0, y: size.height / 2.0)
|
||||
context.scaleBy(x: max(0.01, self.transitionFraction), y: max(0.01, self.transitionFraction))
|
||||
context.scaleBy(x: transitionScale, y: transitionScale)
|
||||
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
||||
|
||||
if foregroundColor.alpha.isZero {
|
||||
@ -38,45 +40,7 @@ final class SemanticStatusNodeIconContext: SemanticStatusNodeStateContext {
|
||||
switch self.icon {
|
||||
case .none, .secretTimeout:
|
||||
break
|
||||
case .play:
|
||||
let diameter = size.width
|
||||
let factor = diameter / 50.0
|
||||
|
||||
let size: CGSize
|
||||
var offset: CGFloat = 0.0
|
||||
if let iconImage = self.iconImage {
|
||||
size = iconImage.size
|
||||
offset = self.iconOffset
|
||||
} else {
|
||||
offset = 1.5
|
||||
size = CGSize(width: 15.0, height: 18.0)
|
||||
}
|
||||
context.translateBy(x: (diameter - size.width) / 2.0 + offset, y: (diameter - size.height) / 2.0)
|
||||
if (diameter < 40.0) {
|
||||
context.translateBy(x: size.width / 2.0, y: size.height / 2.0)
|
||||
context.scaleBy(x: factor, y: factor)
|
||||
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
||||
}
|
||||
if let iconImage = self.iconImage {
|
||||
context.saveGState()
|
||||
let iconRect = CGRect(origin: CGPoint(), size: iconImage.size)
|
||||
context.translateBy(x: size.width / 2.0, y: size.height / 2.0)
|
||||
context.scaleBy(x: 1.0, y: -1.0)
|
||||
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
||||
context.clip(to: iconRect, mask: iconImage.cgImage!)
|
||||
context.fill(iconRect)
|
||||
context.restoreGState()
|
||||
} else {
|
||||
let _ = try? drawSvgPath(context, path: "M1.71891969,0.209353049 C0.769586558,-0.350676705 0,0.0908839327 0,1.18800046 L0,16.8564753 C0,17.9569971 0.750549162,18.357187 1.67393713,17.7519379 L14.1073836,9.60224049 C15.0318735,8.99626906 15.0094718,8.04970371 14.062401,7.49100858 L1.71891969,0.209353049 ")
|
||||
context.fillPath()
|
||||
}
|
||||
if (diameter < 40.0) {
|
||||
context.translateBy(x: size.width / 2.0, y: size.height / 2.0)
|
||||
context.scaleBy(x: 1.0 / 0.8, y: 1.0 / 0.8)
|
||||
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
||||
}
|
||||
context.translateBy(x: -(diameter - size.width) / 2.0 - offset, y: -(diameter - size.height) / 2.0)
|
||||
case .pause:
|
||||
case .play, .pause:
|
||||
let diameter = size.width
|
||||
let factor = diameter / 50.0
|
||||
|
||||
@ -85,10 +49,15 @@ final class SemanticStatusNodeIconContext: SemanticStatusNodeStateContext {
|
||||
if let iconImage = self.iconImage {
|
||||
size = iconImage.size
|
||||
offset = self.iconOffset
|
||||
} else {
|
||||
if case .play = self.icon {
|
||||
offset = 1.5
|
||||
size = CGSize(width: 15.0, height: 18.0)
|
||||
} else {
|
||||
size = CGSize(width: 15.0, height: 16.0)
|
||||
offset = 0.0
|
||||
}
|
||||
}
|
||||
context.translateBy(x: (diameter - size.width) / 2.0 + offset, y: (diameter - size.height) / 2.0)
|
||||
if (diameter < 40.0) {
|
||||
context.translateBy(x: size.width / 2.0, y: size.height / 2.0)
|
||||
@ -97,34 +66,30 @@ final class SemanticStatusNodeIconContext: SemanticStatusNodeStateContext {
|
||||
}
|
||||
if let iconImage = self.iconImage {
|
||||
context.saveGState()
|
||||
let iconRect = CGRect(origin: CGPoint(), size: iconImage.size)
|
||||
let iconRect = CGRect(origin: CGPoint(), size: iconImage.size)//.applying(CGAffineTransformMakeScale(transitionScale, transitionScale))
|
||||
context.translateBy(x: size.width / 2.0, y: size.height / 2.0)
|
||||
context.scaleBy(x: 1.0, y: -1.0)
|
||||
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
||||
context.clip(to: iconRect, mask: iconImage.cgImage!)
|
||||
context.fill(iconRect)
|
||||
context.restoreGState()
|
||||
} else {
|
||||
if case .play = self.icon {
|
||||
let _ = try? drawSvgPath(context, path: "M1.71891969,0.209353049 C0.769586558,-0.350676705 0,0.0908839327 0,1.18800046 L0,16.8564753 C0,17.9569971 0.750549162,18.357187 1.67393713,17.7519379 L14.1073836,9.60224049 C15.0318735,8.99626906 15.0094718,8.04970371 14.062401,7.49100858 L1.71891969,0.209353049 ")
|
||||
} else {
|
||||
let _ = try? drawSvgPath(context, path: "M0,1.00087166 C0,0.448105505 0.443716645,0 0.999807492,0 L4.00019251,0 C4.55237094,0 5,0.444630861 5,1.00087166 L5,14.9991283 C5,15.5518945 4.55628335,16 4.00019251,16 L0.999807492,16 C0.447629061,16 0,15.5553691 0,14.9991283 L0,1.00087166 Z M10,1.00087166 C10,0.448105505 10.4437166,0 10.9998075,0 L14.0001925,0 C14.5523709,0 15,0.444630861 15,1.00087166 L15,14.9991283 C15,15.5518945 14.5562834,16 14.0001925,16 L10.9998075,16 C10.4476291,16 10,15.5553691 10,14.9991283 L10,1.00087166 ")
|
||||
}
|
||||
context.fillPath()
|
||||
}
|
||||
if (diameter < 40.0) {
|
||||
context.translateBy(x: size.width / 2.0, y: size.height / 2.0)
|
||||
context.scaleBy(x: 1.0 / 0.8, y: 1.0 / 0.8)
|
||||
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
||||
}
|
||||
context.translateBy(x: -(diameter - size.width) / 2.0, y: -(diameter - size.height) / 2.0)
|
||||
case let .custom(image):
|
||||
let diameter = size.width
|
||||
let imageRect = CGRect(origin: CGPoint(x: floor((diameter - image.size.width) / 2.0), y: floor((diameter - image.size.height) / 2.0)), size: image.size)
|
||||
|
||||
context.saveGState()
|
||||
context.translateBy(x: imageRect.midX, y: imageRect.midY)
|
||||
context.scaleBy(x: 1.0, y: -1.0)
|
||||
context.translateBy(x: -imageRect.midX, y: -imageRect.midY)
|
||||
context.clip(to: imageRect, mask: image.cgImage!)
|
||||
context.fill(imageRect)
|
||||
context.restoreGState()
|
||||
case .download:
|
||||
let diameter = size.width
|
||||
let factor = diameter / 50.0
|
||||
|
@ -634,7 +634,11 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
|
||||
var isChannel = false
|
||||
if let currentData = self.currentData {
|
||||
if currentData.isChannel || currentData.info.isStream {
|
||||
if let titleValue = currentData.info.title, !titleValue.isEmpty {
|
||||
title = titleValue
|
||||
} else {
|
||||
title = self.strings.VoiceChatChannel_Title
|
||||
}
|
||||
isChannel = true
|
||||
}
|
||||
}
|
||||
|
@ -1347,16 +1347,6 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
||||
if item.presentationData.isPreview {
|
||||
state = .play
|
||||
}
|
||||
if let statusNode = self.statusNode {
|
||||
if state == .none {
|
||||
self.statusNode = nil
|
||||
}
|
||||
statusNode.transitionToState(state, completion: { [weak statusNode] in
|
||||
if state == .none {
|
||||
statusNode?.removeFromSupernode()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
let streamingProgressDiameter: CGFloat = 20.0
|
||||
let streamingCacheStatusFrame = CGRect(origin: statusFrame.origin.offsetBy(dx: 37.0, dy: 37.0), size: CGSize(width: streamingProgressDiameter, height: streamingProgressDiameter))
|
||||
@ -1374,8 +1364,6 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
||||
streamingStatusNode.layer.animateScale(from: 0.1, to: 1.0, duration: 0.2, timingFunction: CAMediaTimingFunctionName.linear.rawValue)
|
||||
streamingStatusNode.layer.animateAlpha(from: 0.1, to: 1.0, duration: 0.2, timingFunction: CAMediaTimingFunctionName.linear.rawValue)
|
||||
}
|
||||
} else if let streamingStatusNode = self.streamingStatusNode {
|
||||
streamingStatusNode.backgroundNodeColor = item.presentationData.theme.theme.chat.message.mediaOverlayControlColors.fillColor
|
||||
}
|
||||
|
||||
if let streamingStatusNode = self.streamingStatusNode {
|
||||
@ -1399,9 +1387,21 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
|
||||
if let statusNode = self.statusNode, streamingState != .none {
|
||||
let cutoutFrame = streamingCacheStatusFrame.offsetBy(dx: -statusFrame.minX, dy: -statusFrame.minY).insetBy(dx: -2.0 + UIScreenPixel, dy: -2.0 + UIScreenPixel)
|
||||
statusNode.setCutout(cutoutFrame, animated: true)
|
||||
if let statusNode = self.statusNode {
|
||||
if state == .none {
|
||||
self.statusNode = nil
|
||||
}
|
||||
|
||||
var cutoutFrame: CGRect?
|
||||
if streamingState != .none {
|
||||
cutoutFrame = streamingCacheStatusFrame.offsetBy(dx: -statusFrame.minX, dy: -statusFrame.minY).insetBy(dx: -2.0 + UIScreenPixel, dy: -2.0 + UIScreenPixel)
|
||||
}
|
||||
|
||||
statusNode.transitionToState(state, animated: true, cutout: cutoutFrame, updateCutout: true, completion: { [weak statusNode] in
|
||||
if state == .none {
|
||||
statusNode?.removeFromSupernode()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if case .playbackStatus = status.mediaStatus, !isViewOnceMessage || item.associatedData.isStandalone {
|
||||
|
@ -15707,6 +15707,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
|
||||
switch recordedMediaPreview {
|
||||
case let .audio(audio):
|
||||
self.audioRecorder.set(.single(nil))
|
||||
|
||||
var isScheduledMessages = false
|
||||
if case .scheduledMessages = self.presentationInterfaceState.subject {
|
||||
isScheduledMessages = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user