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
|
return context
|
||||||
}
|
}
|
||||||
|
@ -443,7 +443,7 @@ public final class SemanticStatusNode: ASControlNode {
|
|||||||
self.setNeedsDisplay()
|
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
|
var animated = animated
|
||||||
if !self.hasState {
|
if !self.hasState {
|
||||||
self.hasState = true
|
self.hasState = true
|
||||||
@ -452,13 +452,18 @@ public final class SemanticStatusNode: ASControlNode {
|
|||||||
if self.state != state || self.appearanceContext.cutout != cutout {
|
if self.state != state || self.appearanceContext.cutout != cutout {
|
||||||
self.state = state
|
self.state = state
|
||||||
let previousStateContext = self.stateContext
|
let previousStateContext = self.stateContext
|
||||||
|
let previousAppearanceContext = updateCutout ? self.appearanceContext : nil
|
||||||
|
|
||||||
self.stateContext = self.state.context(current: self.stateContext)
|
self.stateContext = self.state.context(current: self.stateContext)
|
||||||
self.stateContext.requestUpdate = { [weak self] in
|
self.stateContext.requestUpdate = { [weak self] in
|
||||||
self?.setNeedsDisplay()
|
self?.setNeedsDisplay()
|
||||||
}
|
}
|
||||||
|
if updateCutout {
|
||||||
|
self.appearanceContext = self.appearanceContext.withUpdatedCutout(cutout)
|
||||||
|
}
|
||||||
|
|
||||||
if animated && previousStateContext !== self.stateContext {
|
if animated && (previousStateContext !== self.stateContext || (updateCutout && previousAppearanceContext?.cutout != cutout)) {
|
||||||
self.transitionContext = SemanticStatusNodeTransitionContext(startTime: CACurrentMediaTime(), duration: 0.18, previousStateContext: previousStateContext, previousAppearanceContext: nil, completion: completion)
|
self.transitionContext = SemanticStatusNodeTransitionContext(startTime: CACurrentMediaTime(), duration: 0.18, previousStateContext: previousStateContext, previousAppearanceContext: previousAppearanceContext, completion: completion)
|
||||||
} else {
|
} else {
|
||||||
completion()
|
completion()
|
||||||
}
|
}
|
||||||
@ -513,7 +518,7 @@ public final class SemanticStatusNode: ASControlNode {
|
|||||||
return
|
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)
|
transitionAppearanceState.drawBackground(context: context, size: bounds.size)
|
||||||
}
|
}
|
||||||
parameters.appearanceState.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) {
|
func draw(context: CGContext, size: CGSize, foregroundColor: UIColor) {
|
||||||
|
let transitionScale = max(0.01, self.transitionFraction)
|
||||||
|
|
||||||
context.saveGState()
|
context.saveGState()
|
||||||
context.translateBy(x: size.width / 2.0, y: size.height / 2.0)
|
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)
|
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
||||||
|
|
||||||
if foregroundColor.alpha.isZero {
|
if foregroundColor.alpha.isZero {
|
||||||
@ -38,56 +40,23 @@ final class SemanticStatusNodeIconContext: SemanticStatusNodeStateContext {
|
|||||||
switch self.icon {
|
switch self.icon {
|
||||||
case .none, .secretTimeout:
|
case .none, .secretTimeout:
|
||||||
break
|
break
|
||||||
case .play:
|
case .play, .pause:
|
||||||
let diameter = size.width
|
let diameter = size.width
|
||||||
let factor = diameter / 50.0
|
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:
|
|
||||||
let diameter = size.width
|
|
||||||
let factor = diameter / 50.0
|
|
||||||
|
|
||||||
let size: CGSize
|
let size: CGSize
|
||||||
let offset: CGFloat
|
let offset: CGFloat
|
||||||
if let iconImage = self.iconImage {
|
if let iconImage = self.iconImage {
|
||||||
size = iconImage.size
|
size = iconImage.size
|
||||||
offset = self.iconOffset
|
offset = self.iconOffset
|
||||||
} else {
|
} else {
|
||||||
size = CGSize(width: 15.0, height: 16.0)
|
if case .play = self.icon {
|
||||||
offset = 0.0
|
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)
|
context.translateBy(x: (diameter - size.width) / 2.0 + offset, y: (diameter - size.height) / 2.0)
|
||||||
if (diameter < 40.0) {
|
if (diameter < 40.0) {
|
||||||
@ -97,7 +66,7 @@ final class SemanticStatusNodeIconContext: SemanticStatusNodeStateContext {
|
|||||||
}
|
}
|
||||||
if let iconImage = self.iconImage {
|
if let iconImage = self.iconImage {
|
||||||
context.saveGState()
|
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.translateBy(x: size.width / 2.0, y: size.height / 2.0)
|
||||||
context.scaleBy(x: 1.0, y: -1.0)
|
context.scaleBy(x: 1.0, y: -1.0)
|
||||||
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
||||||
@ -105,26 +74,22 @@ final class SemanticStatusNodeIconContext: SemanticStatusNodeStateContext {
|
|||||||
context.fill(iconRect)
|
context.fill(iconRect)
|
||||||
context.restoreGState()
|
context.restoreGState()
|
||||||
} else {
|
} 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 ")
|
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()
|
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):
|
case let .custom(image):
|
||||||
let diameter = size.width
|
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)
|
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.translateBy(x: imageRect.midX, y: imageRect.midY)
|
||||||
context.scaleBy(x: 1.0, y: -1.0)
|
context.scaleBy(x: 1.0, y: -1.0)
|
||||||
context.translateBy(x: -imageRect.midX, y: -imageRect.midY)
|
context.translateBy(x: -imageRect.midX, y: -imageRect.midY)
|
||||||
context.clip(to: imageRect, mask: image.cgImage!)
|
context.clip(to: imageRect, mask: image.cgImage!)
|
||||||
context.fill(imageRect)
|
context.fill(imageRect)
|
||||||
context.restoreGState()
|
|
||||||
case .download:
|
case .download:
|
||||||
let diameter = size.width
|
let diameter = size.width
|
||||||
let factor = diameter / 50.0
|
let factor = diameter / 50.0
|
||||||
|
@ -634,7 +634,11 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
|
|||||||
var isChannel = false
|
var isChannel = false
|
||||||
if let currentData = self.currentData {
|
if let currentData = self.currentData {
|
||||||
if currentData.isChannel || currentData.info.isStream {
|
if currentData.isChannel || currentData.info.isStream {
|
||||||
title = self.strings.VoiceChatChannel_Title
|
if let titleValue = currentData.info.title, !titleValue.isEmpty {
|
||||||
|
title = titleValue
|
||||||
|
} else {
|
||||||
|
title = self.strings.VoiceChatChannel_Title
|
||||||
|
}
|
||||||
isChannel = true
|
isChannel = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1347,16 +1347,6 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
|||||||
if item.presentationData.isPreview {
|
if item.presentationData.isPreview {
|
||||||
state = .play
|
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 streamingProgressDiameter: CGFloat = 20.0
|
||||||
let streamingCacheStatusFrame = CGRect(origin: statusFrame.origin.offsetBy(dx: 37.0, dy: 37.0), size: CGSize(width: streamingProgressDiameter, height: streamingProgressDiameter))
|
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.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)
|
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 {
|
if let streamingStatusNode = self.streamingStatusNode {
|
||||||
@ -1399,9 +1387,21 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let statusNode = self.statusNode, streamingState != .none {
|
if let statusNode = self.statusNode {
|
||||||
let cutoutFrame = streamingCacheStatusFrame.offsetBy(dx: -statusFrame.minX, dy: -statusFrame.minY).insetBy(dx: -2.0 + UIScreenPixel, dy: -2.0 + UIScreenPixel)
|
if state == .none {
|
||||||
statusNode.setCutout(cutoutFrame, animated: true)
|
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 {
|
if case .playbackStatus = status.mediaStatus, !isViewOnceMessage || item.associatedData.isStandalone {
|
||||||
|
@ -15707,6 +15707,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
|
|
||||||
switch recordedMediaPreview {
|
switch recordedMediaPreview {
|
||||||
case let .audio(audio):
|
case let .audio(audio):
|
||||||
|
self.audioRecorder.set(.single(nil))
|
||||||
|
|
||||||
var isScheduledMessages = false
|
var isScheduledMessages = false
|
||||||
if case .scheduledMessages = self.presentationInterfaceState.subject {
|
if case .scheduledMessages = self.presentationInterfaceState.subject {
|
||||||
isScheduledMessages = true
|
isScheduledMessages = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user