Various improvements

This commit is contained in:
Ilya Laktyushin 2022-06-16 20:45:25 +04:00
parent 663baf1194
commit 2a9eb4346e
19 changed files with 157 additions and 57 deletions

View File

@ -6,10 +6,12 @@ import ViewControllerComponent
public final class SheetComponentEnvironment: Equatable { public final class SheetComponentEnvironment: Equatable {
public let isDisplaying: Bool public let isDisplaying: Bool
public let isCentered: Bool
public let dismiss: (Bool) -> Void public let dismiss: (Bool) -> Void
public init(isDisplaying: Bool, dismiss: @escaping (Bool) -> Void) { public init(isDisplaying: Bool, isCentered: Bool, dismiss: @escaping (Bool) -> Void) {
self.isDisplaying = isDisplaying self.isDisplaying = isDisplaying
self.isCentered = isCentered
self.dismiss = dismiss self.dismiss = dismiss
} }
@ -17,6 +19,9 @@ public final class SheetComponentEnvironment: Equatable {
if lhs.isDisplaying != rhs.isDisplaying { if lhs.isDisplaying != rhs.isDisplaying {
return false return false
} }
if lhs.isCentered != rhs.isCentered {
return false
}
return true return true
} }
} }
@ -180,6 +185,7 @@ public final class SheetComponent<ChildEnvironmentType: Equatable>: Component {
private var currentAvailableSize: CGSize? private var currentAvailableSize: CGSize?
func update(component: SheetComponent<ChildEnvironmentType>, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: Transition) -> CGSize { func update(component: SheetComponent<ChildEnvironmentType>, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: Transition) -> CGSize {
let sheetEnvironment = environment[SheetComponentEnvironment.self].value
component.animateOut.connect { [weak self] completion in component.animateOut.connect { [weak self] completion in
guard let strongSelf = self else { guard let strongSelf = self else {
return return
@ -195,19 +201,36 @@ public final class SheetComponent<ChildEnvironmentType: Equatable>: Component {
transition.setFrame(view: self.dimView, frame: CGRect(origin: CGPoint(), size: availableSize), completion: nil) transition.setFrame(view: self.dimView, frame: CGRect(origin: CGPoint(), size: availableSize), completion: nil)
let containerSize: CGSize
if sheetEnvironment.isCentered {
let verticalInset: CGFloat = 44.0
let maxSide = max(availableSize.width, availableSize.height)
let minSide = min(availableSize.width, availableSize.height)
containerSize = CGSize(width: min(availableSize.width - 20.0, floor(maxSide / 2.0)), height: min(availableSize.height, minSide) - verticalInset * 2.0)
} else {
containerSize = CGSize(width: availableSize.width, height: .greatestFiniteMagnitude)
}
let contentSize = self.contentView.update( let contentSize = self.contentView.update(
transition: transition, transition: transition,
component: component.content, component: component.content,
environment: { environment: {
environment[ChildEnvironmentType.self] environment[ChildEnvironmentType.self]
}, },
containerSize: CGSize(width: availableSize.width, height: .greatestFiniteMagnitude) containerSize: containerSize
) )
self.ignoreScrolling = true self.ignoreScrolling = true
transition.setFrame(view: self.contentView, frame: CGRect(origin: .zero, size: contentSize), completion: nil)
transition.setFrame(view: self.backgroundView, frame: CGRect(origin: .zero, size: CGSize(width: contentSize.width, height: contentSize.height + 1000.0)), completion: nil) if sheetEnvironment.isCentered {
transition.setFrame(view: self.contentView, frame: CGRect(origin: CGPoint(x: floorToScreenPixels((availableSize.width - contentSize.width) / 2.0), y: 0.0), size: contentSize), completion: nil)
transition.setFrame(view: self.backgroundView, frame: CGRect(origin: CGPoint(x: floorToScreenPixels((availableSize.width - contentSize.width) / 2.0), y: floorToScreenPixels((availableSize.height - contentSize.height) / 2.0)), size: contentSize), completion: nil)
} else {
transition.setFrame(view: self.contentView, frame: CGRect(origin: .zero, size: contentSize), completion: nil)
transition.setFrame(view: self.backgroundView, frame: CGRect(origin: .zero, size: CGSize(width: contentSize.width, height: contentSize.height + 1000.0)), completion: nil)
}
transition.setFrame(view: self.scrollView, frame: CGRect(origin: CGPoint(), size: availableSize), completion: nil) transition.setFrame(view: self.scrollView, frame: CGRect(origin: CGPoint(), size: availableSize), completion: nil)
self.scrollView.contentSize = contentSize self.scrollView.contentSize = contentSize
self.scrollView.contentInset = UIEdgeInsets(top: max(0.0, availableSize.height - contentSize.height) + contentSize.height, left: 0.0, bottom: 0.0, right: 0.0) self.scrollView.contentInset = UIEdgeInsets(top: max(0.0, availableSize.height - contentSize.height) + contentSize.height, left: 0.0, bottom: 0.0, right: 0.0)
self.ignoreScrolling = false self.ignoreScrolling = false
@ -222,9 +245,8 @@ public final class SheetComponent<ChildEnvironmentType: Equatable>: Component {
} else if !environment[SheetComponentEnvironment.self].value.isDisplaying, self.previousIsDisplaying, let _ = transition.userData(ViewControllerComponentContainer.AnimateOutTransition.self) { } else if !environment[SheetComponentEnvironment.self].value.isDisplaying, self.previousIsDisplaying, let _ = transition.userData(ViewControllerComponentContainer.AnimateOutTransition.self) {
self.animateOut(completion: {}) self.animateOut(completion: {})
} }
self.previousIsDisplaying = environment[SheetComponentEnvironment.self].value.isDisplaying self.previousIsDisplaying = sheetEnvironment.isDisplaying
self.dismiss = sheetEnvironment.dismiss
self.dismiss = environment[SheetComponentEnvironment.self].value.dismiss
return availableSize return availableSize
} }

View File

@ -69,6 +69,7 @@ open class ViewControllerComponentContainer: ViewController {
public let statusBarHeight: CGFloat public let statusBarHeight: CGFloat
public let navigationHeight: CGFloat public let navigationHeight: CGFloat
public let safeInsets: UIEdgeInsets public let safeInsets: UIEdgeInsets
public let metrics: LayoutMetrics
public let isVisible: Bool public let isVisible: Bool
public let theme: PresentationTheme public let theme: PresentationTheme
public let strings: PresentationStrings public let strings: PresentationStrings
@ -79,6 +80,7 @@ open class ViewControllerComponentContainer: ViewController {
statusBarHeight: CGFloat, statusBarHeight: CGFloat,
navigationHeight: CGFloat, navigationHeight: CGFloat,
safeInsets: UIEdgeInsets, safeInsets: UIEdgeInsets,
metrics: LayoutMetrics,
isVisible: Bool, isVisible: Bool,
theme: PresentationTheme, theme: PresentationTheme,
strings: PresentationStrings, strings: PresentationStrings,
@ -88,6 +90,7 @@ open class ViewControllerComponentContainer: ViewController {
self.statusBarHeight = statusBarHeight self.statusBarHeight = statusBarHeight
self.navigationHeight = navigationHeight self.navigationHeight = navigationHeight
self.safeInsets = safeInsets self.safeInsets = safeInsets
self.metrics = metrics
self.isVisible = isVisible self.isVisible = isVisible
self.theme = theme self.theme = theme
self.strings = strings self.strings = strings
@ -109,6 +112,9 @@ open class ViewControllerComponentContainer: ViewController {
if lhs.safeInsets != rhs.safeInsets { if lhs.safeInsets != rhs.safeInsets {
return false return false
} }
if lhs.metrics != rhs.metrics {
return false
}
if lhs.isVisible != rhs.isVisible { if lhs.isVisible != rhs.isVisible {
return false return false
} }
@ -164,6 +170,7 @@ open class ViewControllerComponentContainer: ViewController {
statusBarHeight: layout.statusBarHeight ?? 0.0, statusBarHeight: layout.statusBarHeight ?? 0.0,
navigationHeight: navigationHeight, navigationHeight: navigationHeight,
safeInsets: UIEdgeInsets(top: layout.intrinsicInsets.top + layout.safeInsets.top, left: layout.safeInsets.left, bottom: layout.intrinsicInsets.bottom + layout.safeInsets.bottom, right: layout.safeInsets.right), safeInsets: UIEdgeInsets(top: layout.intrinsicInsets.top + layout.safeInsets.top, left: layout.safeInsets.left, bottom: layout.intrinsicInsets.bottom + layout.safeInsets.bottom, right: layout.safeInsets.right),
metrics: layout.metrics,
isVisible: self.currentIsVisible, isVisible: self.currentIsVisible,
theme: self.theme ?? self.presentationData.theme, theme: self.theme ?? self.presentationData.theme,
strings: self.presentationData.strings, strings: self.presentationData.strings,

View File

@ -798,8 +798,8 @@ public func createPollController(context: AccountContext, updatedPresentationDat
) )
|> map { presentationData, state, limitsConfiguration -> (ItemListControllerState, (ItemListNodeState, Any)) in |> map { presentationData, state, limitsConfiguration -> (ItemListControllerState, (ItemListNodeState, Any)) in
var presentationData = presentationData var presentationData = presentationData
if presentationData.theme.list.blocksBackgroundColor.rgb == 0x000000 { if presentationData.theme.list.blocksBackgroundColor.rgb == presentationData.theme.list.plainBackgroundColor.rgb {
let updatedTheme = presentationData.theme.withInvertedBlocksBackground() let updatedTheme = presentationData.theme.withModalBlocksBackground()
presentationData = presentationData.withUpdated(theme: updatedTheme) presentationData = presentationData.withUpdated(theme: updatedTheme)
} }

View File

@ -207,6 +207,7 @@ private final class AddPaymentMethodSheetComponent: CombinedComponent {
environment environment
SheetComponentEnvironment( SheetComponentEnvironment(
isDisplaying: environment.value.isVisible, isDisplaying: environment.value.isVisible,
isCentered: false,
dismiss: { animated in dismiss: { animated in
if animated { if animated {
animateOut.invoke(Action { _ in animateOut.invoke(Action { _ in

View File

@ -1102,6 +1102,7 @@ private final class DemoSheetComponent: CombinedComponent {
environment environment
SheetComponentEnvironment( SheetComponentEnvironment(
isDisplaying: environment.value.isVisible, isDisplaying: environment.value.isVisible,
isCentered: environment.metrics.widthClass == .regular,
dismiss: { animated in dismiss: { animated in
if animated { if animated {
animateOut.invoke(Action { _ in animateOut.invoke(Action { _ in

View File

@ -654,7 +654,7 @@ private final class PerkComponent: CombinedComponent {
static var body: Body { static var body: Body {
let iconBackground = Child(RoundedRectangle.self) let iconBackground = Child(RoundedRectangle.self)
let icon = Child(BundleIconComponent.self) let icon = Child(BundleIconComponent.self)
let title = Child(Text.self) let title = Child(MultilineTextComponent.self)
let subtitle = Child(MultilineTextComponent.self) let subtitle = Child(MultilineTextComponent.self)
let arrow = Child(BundleIconComponent.self) let arrow = Child(BundleIconComponent.self)
@ -665,7 +665,7 @@ private final class PerkComponent: CombinedComponent {
let iconTopInset: CGFloat = 15.0 let iconTopInset: CGFloat = 15.0
let textTopInset: CGFloat = 9.0 let textTopInset: CGFloat = 9.0
let textBottomInset: CGFloat = 9.0 let textBottomInset: CGFloat = 9.0
let spacing: CGFloat = 3.0 let spacing: CGFloat = 2.0
let iconSize = CGSize(width: 30.0, height: 30.0) let iconSize = CGSize(width: 30.0, height: 30.0)
let iconBackground = iconBackground.update( let iconBackground = iconBackground.update(
@ -695,10 +695,16 @@ private final class PerkComponent: CombinedComponent {
) )
let title = title.update( let title = title.update(
component: Text( component: MultilineTextComponent(
text: component.title, text: .plain(
font: Font.regular(17.0), NSAttributedString(
color: component.titleColor string: component.title,
font: Font.regular(17),
textColor: component.titleColor
)
),
maximumNumberOfLines: 0,
lineSpacing: 0.1
), ),
availableSize: CGSize(width: context.availableSize.width - iconBackground.size.width - sideInset * 2.83, height: context.availableSize.height), availableSize: CGSize(width: context.availableSize.width - iconBackground.size.width - sideInset * 2.83, height: context.availableSize.height),
transition: context.transition transition: context.transition

View File

@ -1006,6 +1006,7 @@ private final class LimitSheetComponent: CombinedComponent {
environment environment
SheetComponentEnvironment( SheetComponentEnvironment(
isDisplaying: environment.value.isVisible, isDisplaying: environment.value.isVisible,
isCentered: environment.metrics.widthClass == .regular,
dismiss: { animated in dismiss: { animated in
if animated { if animated {
animateOut.invoke(Action { _ in animateOut.invoke(Action { _ in

View File

@ -617,16 +617,20 @@ public class PremimLimitsListScreen: ViewController {
transition.setFrame(view: self.containerView, frame: clipFrame) transition.setFrame(view: self.containerView, frame: clipFrame)
transition.setFrame(view: self.scrollView, frame: CGRect(origin: CGPoint(), size: clipFrame.size), completion: nil) transition.setFrame(view: self.scrollView, frame: CGRect(origin: CGPoint(), size: clipFrame.size), completion: nil)
let clipLayout = layout.withUpdatedSize(clipFrame.size) var clipLayout = layout.withUpdatedSize(clipFrame.size)
if case .regular = layout.metrics.widthClass {
clipLayout = clipLayout.withUpdatedIntrinsicInsets(.zero)
}
let footerHeight = self.footerNode.updateLayout(layout: clipLayout, transition: .immediate) let footerHeight = self.footerNode.updateLayout(layout: clipLayout, transition: .immediate)
let convertedFooterFrame = self.view.convert(CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - footerHeight), size: CGSize(width: clipFrame.width, height: footerHeight)), to: self.containerView) let convertedFooterFrame = self.view.convert(CGRect(origin: CGPoint(x: clipFrame.minX, y: clipFrame.maxY - footerHeight), size: CGSize(width: clipFrame.width, height: footerHeight)), to: self.containerView)
transition.setFrame(view: self.footerNode.view, frame: convertedFooterFrame) transition.setFrame(view: self.footerNode.view, frame: convertedFooterFrame)
let environment = ViewControllerComponentContainer.Environment( let environment = ViewControllerComponentContainer.Environment(
statusBarHeight: 0.0, statusBarHeight: 0.0,
navigationHeight: navigationHeight, navigationHeight: navigationHeight,
safeInsets: UIEdgeInsets(top: layout.intrinsicInsets.top + layout.safeInsets.top, left: layout.safeInsets.left, bottom: footerHeight, right: layout.safeInsets.right), safeInsets: UIEdgeInsets(top: layout.intrinsicInsets.top + layout.safeInsets.top, left: layout.safeInsets.left, bottom: footerHeight, right: layout.safeInsets.right),
metrics: layout.metrics,
isVisible: self.currentIsVisible, isVisible: self.currentIsVisible,
theme: self.theme ?? self.presentationData.theme, theme: self.theme ?? self.presentationData.theme,
strings: self.presentationData.strings, strings: self.presentationData.strings,

View File

@ -576,7 +576,7 @@ class TabBarNode: ASDisplayNode {
ContainedViewLayoutTransition.animated(duration: 0.2, curve: .easeInOut).updateTransformScale(node: node.ringImageNode, scale: 1.0, delay: 0.1) ContainedViewLayoutTransition.animated(duration: 0.2, curve: .easeInOut).updateTransformScale(node: node.ringImageNode, scale: 1.0, delay: 0.1)
node.imageNode.layer.animateScale(from: 1.0, to: 0.87, duration: 0.1, removeOnCompletion: false, completion: { [weak node] _ in node.imageNode.layer.animateScale(from: 1.0, to: 0.87, duration: 0.1, removeOnCompletion: false, completion: { [weak node] _ in
node?.imageNode.layer.animateScale(from: 0.87, to: 1.0, duration: 0.2, removeOnCompletion: false, completion: { [weak node] _ in node?.imageNode.layer.animateScale(from: 0.87, to: 1.0, duration: 0.14, removeOnCompletion: false, completion: { [weak node] _ in
node?.imageNode.layer.removeAllAnimations() node?.imageNode.layer.removeAllAnimations()
}) })
}) })

View File

@ -16,6 +16,7 @@ import TooltipUI
import AlertUI import AlertUI
import PresentationDataUtils import PresentationDataUtils
import DeviceAccess import DeviceAccess
import ContextUI
private func interpolateFrame(from fromValue: CGRect, to toValue: CGRect, t: CGFloat) -> CGRect { private func interpolateFrame(from fromValue: CGRect, to toValue: CGRect, t: CGFloat) -> CGRect {
return CGRect(x: floorToScreenPixels(toValue.origin.x * t + fromValue.origin.x * (1.0 - t)), y: floorToScreenPixels(toValue.origin.y * t + fromValue.origin.y * (1.0 - t)), width: floorToScreenPixels(toValue.size.width * t + fromValue.size.width * (1.0 - t)), height: floorToScreenPixels(toValue.size.height * t + fromValue.size.height * (1.0 - t))) return CGRect(x: floorToScreenPixels(toValue.origin.x * t + fromValue.origin.x * (1.0 - t)), y: floorToScreenPixels(toValue.origin.y * t + fromValue.origin.y * (1.0 - t)), width: floorToScreenPixels(toValue.size.width * t + fromValue.size.width * (1.0 - t)), height: floorToScreenPixels(toValue.size.height * t + fromValue.size.height * (1.0 - t)))
@ -200,17 +201,9 @@ private final class CallVideoNode: ASDisplayNode, PreviewVideoNode {
case .rotation90: case .rotation90:
rotationAngle = CGFloat.pi / 2.0 rotationAngle = CGFloat.pi / 2.0
case .rotation180: case .rotation180:
// if isCompactLayout { rotationAngle = CGFloat.pi
rotationAngle = CGFloat.pi
// } else {
// rotationAngle = 0.0
// }
case .rotation270: case .rotation270:
// if isCompactLayout { rotationAngle = -CGFloat.pi / 2.0
rotationAngle = -CGFloat.pi / 2.0
// } else {
// rotationAngle = CGFloat.pi / 2.0
// }
} }
var additionalAngle: CGFloat = 0.0 var additionalAngle: CGFloat = 0.0
@ -375,6 +368,7 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro
private let containerTransformationNode: ASDisplayNode private let containerTransformationNode: ASDisplayNode
private let containerNode: ASDisplayNode private let containerNode: ASDisplayNode
private let videoContainerNode: PinchSourceContainerNode
private let imageNode: TransformImageNode private let imageNode: TransformImageNode
private let dimNode: ASImageNode private let dimNode: ASImageNode
@ -397,7 +391,7 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro
private var displayedCameraConfirmation: Bool = false private var displayedCameraConfirmation: Bool = false
private var displayedCameraTooltip: Bool = false private var displayedCameraTooltip: Bool = false
private var expandedVideoNode: CallVideoNode? private var expandedVideoNode: CallVideoNode?
private var minimizedVideoNode: CallVideoNode? private var minimizedVideoNode: CallVideoNode?
private var disableAnimationForExpandedVideoOnce: Bool = false private var disableAnimationForExpandedVideoOnce: Bool = false
@ -455,6 +449,7 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro
private var isUIHidden: Bool = false private var isUIHidden: Bool = false
private var isVideoPaused: Bool = false private var isVideoPaused: Bool = false
private var isVideoPinched: Bool = false
private enum PictureInPictureGestureState { private enum PictureInPictureGestureState {
case none case none
@ -486,6 +481,8 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro
self.containerNode = ASDisplayNode() self.containerNode = ASDisplayNode()
self.videoContainerNode = PinchSourceContainerNode()
self.imageNode = TransformImageNode() self.imageNode = TransformImageNode()
self.imageNode.contentAnimations = [.subsequentUpdates] self.imageNode.contentAnimations = [.subsequentUpdates]
self.dimNode = ASImageNode() self.dimNode = ASImageNode()
@ -531,6 +528,7 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro
} }
self.containerNode.addSubnode(self.imageNode) self.containerNode.addSubnode(self.imageNode)
self.containerNode.addSubnode(self.videoContainerNode)
self.containerNode.addSubnode(self.dimNode) self.containerNode.addSubnode(self.dimNode)
self.containerNode.addSubnode(self.statusNode) self.containerNode.addSubnode(self.statusNode)
self.containerNode.addSubnode(self.buttonsNode) self.containerNode.addSubnode(self.buttonsNode)
@ -711,6 +709,40 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro
} }
} }
}) })
self.videoContainerNode.activate = { [weak self] sourceNode in
guard let strongSelf = self else {
return
}
let pinchController = PinchController(sourceNode: sourceNode, getContentAreaInScreenSpace: {
return UIScreen.main.bounds
})
strongSelf.sharedContext.mainWindow?.presentInGlobalOverlay(pinchController)
strongSelf.isVideoPinched = true
strongSelf.videoContainerNode.contentNode.clipsToBounds = true
strongSelf.videoContainerNode.backgroundColor = .black
if let (layout, navigationBarHeight) = strongSelf.validLayout {
strongSelf.videoContainerNode.contentNode.cornerRadius = layout.deviceMetrics.screenCornerRadius
strongSelf.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, transition: .immediate)
}
}
self.videoContainerNode.animatedOut = { [weak self] in
guard let strongSelf = self else {
return
}
strongSelf.isVideoPinched = false
strongSelf.videoContainerNode.backgroundColor = .clear
strongSelf.videoContainerNode.contentNode.cornerRadius = 0.0
if let (layout, navigationBarHeight) = strongSelf.validLayout {
strongSelf.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, transition: .animated(duration: 0.3, curve: .easeInOut))
}
}
} }
deinit { deinit {
@ -830,9 +862,9 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro
strongSelf.incomingVideoNodeValue = incomingVideoNode strongSelf.incomingVideoNodeValue = incomingVideoNode
if let expandedVideoNode = strongSelf.expandedVideoNode { if let expandedVideoNode = strongSelf.expandedVideoNode {
strongSelf.minimizedVideoNode = expandedVideoNode strongSelf.minimizedVideoNode = expandedVideoNode
strongSelf.containerNode.insertSubnode(incomingVideoNode, belowSubnode: expandedVideoNode) strongSelf.videoContainerNode.contentNode.insertSubnode(incomingVideoNode, belowSubnode: expandedVideoNode)
} else { } else {
strongSelf.containerNode.insertSubnode(incomingVideoNode, belowSubnode: strongSelf.dimNode) strongSelf.videoContainerNode.contentNode.addSubnode(incomingVideoNode)
} }
strongSelf.expandedVideoNode = incomingVideoNode strongSelf.expandedVideoNode = incomingVideoNode
strongSelf.updateButtonsMode(transition: .animated(duration: 0.4, curve: .spring)) strongSelf.updateButtonsMode(transition: .animated(duration: 0.4, curve: .spring))
@ -914,10 +946,10 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro
strongSelf.outgoingVideoNodeValue = outgoingVideoNode strongSelf.outgoingVideoNodeValue = outgoingVideoNode
if let expandedVideoNode = strongSelf.expandedVideoNode { if let expandedVideoNode = strongSelf.expandedVideoNode {
strongSelf.minimizedVideoNode = outgoingVideoNode strongSelf.minimizedVideoNode = outgoingVideoNode
strongSelf.containerNode.insertSubnode(outgoingVideoNode, aboveSubnode: expandedVideoNode) strongSelf.videoContainerNode.contentNode.insertSubnode(outgoingVideoNode, aboveSubnode: expandedVideoNode)
} else { } else {
strongSelf.expandedVideoNode = outgoingVideoNode strongSelf.expandedVideoNode = outgoingVideoNode
strongSelf.containerNode.insertSubnode(outgoingVideoNode, belowSubnode: strongSelf.dimNode) strongSelf.videoContainerNode.contentNode.addSubnode(outgoingVideoNode)
} }
strongSelf.updateButtonsMode(transition: .animated(duration: 0.4, curve: .spring)) strongSelf.updateButtonsMode(transition: .animated(duration: 0.4, curve: .spring))
@ -1140,6 +1172,9 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro
} }
self.callEnded?(presentRating) self.callEnded?(presentRating)
} }
let hasIncomingVideoNode = self.incomingVideoNodeValue != nil && self.expandedVideoNode === self.incomingVideoNodeValue
self.videoContainerNode.isPinchGestureEnabled = hasIncomingVideoNode
} }
private func updateToastContent() { private func updateToastContent() {
@ -1481,6 +1516,8 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro
let pipTransitionAlpha: CGFloat = 1.0 - self.pictureInPictureTransitionFraction let pipTransitionAlpha: CGFloat = 1.0 - self.pictureInPictureTransitionFraction
uiDisplayTransition *= pipTransitionAlpha uiDisplayTransition *= pipTransitionAlpha
let pinchTransitionAlpha: CGFloat = self.isVideoPinched ? 0.0 : 1.0
let previousVideoButtonFrame = self.buttonsNode.videoButtonFrame().flatMap { frame -> CGRect in let previousVideoButtonFrame = self.buttonsNode.videoButtonFrame().flatMap { frame -> CGRect in
return self.buttonsNode.view.convert(frame, to: self.view) return self.buttonsNode.view.convert(frame, to: self.view)
} }
@ -1501,8 +1538,8 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro
let toastCollapsedOriginY = self.pictureInPictureTransitionFraction > 0.0 ? layout.size.height : layout.size.height - max(layout.intrinsicInsets.bottom, 20.0) - toastHeight let toastCollapsedOriginY = self.pictureInPictureTransitionFraction > 0.0 ? layout.size.height : layout.size.height - max(layout.intrinsicInsets.bottom, 20.0) - toastHeight
let toastOriginY = interpolate(from: toastCollapsedOriginY, to: defaultButtonsOriginY - toastSpacing - toastHeight, value: uiDisplayTransition) let toastOriginY = interpolate(from: toastCollapsedOriginY, to: defaultButtonsOriginY - toastSpacing - toastHeight, value: uiDisplayTransition)
var overlayAlpha: CGFloat = uiDisplayTransition var overlayAlpha: CGFloat = min(pinchTransitionAlpha, uiDisplayTransition)
var toastAlpha: CGFloat = pipTransitionAlpha var toastAlpha: CGFloat = min(pinchTransitionAlpha, pipTransitionAlpha)
switch self.callState?.state { switch self.callState?.state {
case .terminated, .terminating: case .terminated, .terminating:
@ -1522,14 +1559,18 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro
transition.updateCornerRadius(layer: self.containerTransformationNode.layer, cornerRadius: self.pictureInPictureTransitionFraction * 10.0) transition.updateCornerRadius(layer: self.containerTransformationNode.layer, cornerRadius: self.pictureInPictureTransitionFraction * 10.0)
transition.updateFrame(node: self.containerNode, frame: CGRect(origin: CGPoint(x: (containerFrame.width - layout.size.width) / 2.0, y: floor(containerFrame.height - layout.size.height) / 2.0), size: layout.size)) transition.updateFrame(node: self.containerNode, frame: CGRect(origin: CGPoint(x: (containerFrame.width - layout.size.width) / 2.0, y: floor(containerFrame.height - layout.size.height) / 2.0), size: layout.size))
transition.updateFrame(node: self.dimNode, frame: CGRect(origin: CGPoint(), size: layout.size)) transition.updateFrame(node: self.videoContainerNode, frame: containerFullScreenFrame)
self.videoContainerNode.update(size: containerFullScreenFrame.size, transition: transition)
transition.updateAlpha(node: self.dimNode, alpha: pinchTransitionAlpha)
transition.updateFrame(node: self.dimNode, frame: containerFullScreenFrame)
if let keyPreviewNode = self.keyPreviewNode { if let keyPreviewNode = self.keyPreviewNode {
transition.updateFrame(node: keyPreviewNode, frame: CGRect(origin: CGPoint(), size: layout.size)) transition.updateFrame(node: keyPreviewNode, frame: containerFullScreenFrame)
keyPreviewNode.updateLayout(size: layout.size, transition: .immediate) keyPreviewNode.updateLayout(size: layout.size, transition: .immediate)
} }
transition.updateFrame(node: self.imageNode, frame: CGRect(origin: CGPoint(), size: layout.size)) transition.updateFrame(node: self.imageNode, frame: containerFullScreenFrame)
let arguments = TransformImageArguments(corners: ImageCorners(), imageSize: CGSize(width: 640.0, height: 640.0).aspectFilled(layout.size), boundingSize: layout.size, intrinsicInsets: UIEdgeInsets()) let arguments = TransformImageArguments(corners: ImageCorners(), imageSize: CGSize(width: 640.0, height: 640.0).aspectFilled(layout.size), boundingSize: layout.size, intrinsicInsets: UIEdgeInsets())
let apply = self.imageNode.asyncLayout()(arguments) let apply = self.imageNode.asyncLayout()(arguments)
apply() apply()
@ -1574,8 +1615,7 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro
transition.updateFrame(node: self.buttonsNode, frame: CGRect(origin: CGPoint(x: 0.0, y: buttonsOriginY), size: CGSize(width: layout.size.width, height: buttonsHeight))) transition.updateFrame(node: self.buttonsNode, frame: CGRect(origin: CGPoint(x: 0.0, y: buttonsOriginY), size: CGSize(width: layout.size.width, height: buttonsHeight)))
transition.updateAlpha(node: self.buttonsNode, alpha: overlayAlpha) transition.updateAlpha(node: self.buttonsNode, alpha: overlayAlpha)
let fullscreenVideoFrame = CGRect(origin: CGPoint(), size: layout.size) let fullscreenVideoFrame = containerFullScreenFrame
let previewVideoFrame = self.calculatePreviewVideoRect(layout: layout, navigationHeight: navigationBarHeight) let previewVideoFrame = self.calculatePreviewVideoRect(layout: layout, navigationHeight: navigationBarHeight)
if let removedMinimizedVideoNodeValue = self.removedMinimizedVideoNodeValue { if let removedMinimizedVideoNodeValue = self.removedMinimizedVideoNodeValue {
@ -1640,7 +1680,7 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro
if let minimizedVideoNode = self.minimizedVideoNode { if let minimizedVideoNode = self.minimizedVideoNode {
transition.updateAlpha(node: minimizedVideoNode, alpha: pipTransitionAlpha) transition.updateAlpha(node: minimizedVideoNode, alpha: min(pipTransitionAlpha, pinchTransitionAlpha))
var minimizedVideoTransition = transition var minimizedVideoTransition = transition
var didAppear = false var didAppear = false
if minimizedVideoNode.frame.isEmpty { if minimizedVideoNode.frame.isEmpty {

View File

@ -376,6 +376,7 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati
let list = PresentationThemeList( let list = PresentationThemeList(
blocksBackgroundColor: UIColor(rgb: 0x000000), blocksBackgroundColor: UIColor(rgb: 0x000000),
modalBlocksBackgroundColor: UIColor(rgb: 0x1c1c1d),
plainBackgroundColor: UIColor(rgb: 0x000000), plainBackgroundColor: UIColor(rgb: 0x000000),
itemPrimaryTextColor: UIColor(rgb: 0xffffff), itemPrimaryTextColor: UIColor(rgb: 0xffffff),
itemSecondaryTextColor: UIColor(rgb: 0x98989e), itemSecondaryTextColor: UIColor(rgb: 0x98989e),
@ -385,6 +386,7 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati
itemDestructiveColor: UIColor(rgb: 0xeb5545), itemDestructiveColor: UIColor(rgb: 0xeb5545),
itemPlaceholderTextColor: UIColor(rgb: 0x4d4d4d), itemPlaceholderTextColor: UIColor(rgb: 0x4d4d4d),
itemBlocksBackgroundColor: UIColor(rgb: 0x1c1c1d), itemBlocksBackgroundColor: UIColor(rgb: 0x1c1c1d),
itemModalBlocksBackgroundColor: UIColor(rgb: 0x2c2c2e),
itemHighlightedBackgroundColor: UIColor(rgb: 0x313135), itemHighlightedBackgroundColor: UIColor(rgb: 0x313135),
itemBlocksSeparatorColor: UIColor(rgb: 0x3d3d40), itemBlocksSeparatorColor: UIColor(rgb: 0x3d3d40),
itemPlainSeparatorColor: UIColor(rgb: 0x3d3d40), itemPlainSeparatorColor: UIColor(rgb: 0x3d3d40),

View File

@ -604,6 +604,7 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
let list = PresentationThemeList( let list = PresentationThemeList(
blocksBackgroundColor: additionalBackgroundColor, blocksBackgroundColor: additionalBackgroundColor,
modalBlocksBackgroundColor: additionalBackgroundColor,
plainBackgroundColor: additionalBackgroundColor, plainBackgroundColor: additionalBackgroundColor,
itemPrimaryTextColor: UIColor(rgb: 0xffffff), itemPrimaryTextColor: UIColor(rgb: 0xffffff),
itemSecondaryTextColor: mainSecondaryTextColor.withAlphaComponent(0.5), itemSecondaryTextColor: mainSecondaryTextColor.withAlphaComponent(0.5),
@ -613,6 +614,7 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
itemDestructiveColor: UIColor(rgb: 0xff6767), itemDestructiveColor: UIColor(rgb: 0xff6767),
itemPlaceholderTextColor: mainSecondaryTextColor.withAlphaComponent(0.5), itemPlaceholderTextColor: mainSecondaryTextColor.withAlphaComponent(0.5),
itemBlocksBackgroundColor: mainBackgroundColor, itemBlocksBackgroundColor: mainBackgroundColor,
itemModalBlocksBackgroundColor: mainBackgroundColor,
itemHighlightedBackgroundColor: mainSelectionColor, itemHighlightedBackgroundColor: mainSelectionColor,
itemBlocksSeparatorColor: mainSeparatorColor, itemBlocksSeparatorColor: mainSeparatorColor,
itemPlainSeparatorColor: mainSeparatorColor, itemPlainSeparatorColor: mainSeparatorColor,

View File

@ -447,6 +447,7 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
let list = PresentationThemeList( let list = PresentationThemeList(
blocksBackgroundColor: UIColor(rgb: 0xefeff4), blocksBackgroundColor: UIColor(rgb: 0xefeff4),
modalBlocksBackgroundColor: UIColor(rgb: 0xefeff4),
plainBackgroundColor: UIColor(rgb: 0xffffff), plainBackgroundColor: UIColor(rgb: 0xffffff),
itemPrimaryTextColor: UIColor(rgb: 0x000000), itemPrimaryTextColor: UIColor(rgb: 0x000000),
itemSecondaryTextColor: UIColor(rgb: 0x8e8e93), itemSecondaryTextColor: UIColor(rgb: 0x8e8e93),
@ -456,6 +457,7 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
itemDestructiveColor: UIColor(rgb: 0xff3b30), itemDestructiveColor: UIColor(rgb: 0xff3b30),
itemPlaceholderTextColor: UIColor(rgb: 0xc8c8ce), itemPlaceholderTextColor: UIColor(rgb: 0xc8c8ce),
itemBlocksBackgroundColor: UIColor(rgb: 0xffffff), itemBlocksBackgroundColor: UIColor(rgb: 0xffffff),
itemModalBlocksBackgroundColor: UIColor(rgb: 0xffffff),
itemHighlightedBackgroundColor: UIColor(rgb: 0xe5e5ea), itemHighlightedBackgroundColor: UIColor(rgb: 0xe5e5ea),
itemBlocksSeparatorColor: UIColor(rgb: 0xc8c7cc), itemBlocksSeparatorColor: UIColor(rgb: 0xc8c7cc),
itemPlainSeparatorColor: UIColor(rgb: 0xc8c7cc), itemPlainSeparatorColor: UIColor(rgb: 0xc8c7cc),

View File

@ -428,6 +428,7 @@ public final class PresentationThemeList {
public let blocksBackgroundColor: UIColor public let blocksBackgroundColor: UIColor
public let plainBackgroundColor: UIColor public let plainBackgroundColor: UIColor
public let modalBlocksBackgroundColor: UIColor
public let itemPrimaryTextColor: UIColor public let itemPrimaryTextColor: UIColor
public let itemSecondaryTextColor: UIColor public let itemSecondaryTextColor: UIColor
public let itemDisabledTextColor: UIColor public let itemDisabledTextColor: UIColor
@ -436,6 +437,7 @@ public final class PresentationThemeList {
public let itemDestructiveColor: UIColor public let itemDestructiveColor: UIColor
public let itemPlaceholderTextColor: UIColor public let itemPlaceholderTextColor: UIColor
public let itemBlocksBackgroundColor: UIColor public let itemBlocksBackgroundColor: UIColor
public let itemModalBlocksBackgroundColor: UIColor
public let itemHighlightedBackgroundColor: UIColor public let itemHighlightedBackgroundColor: UIColor
public let itemBlocksSeparatorColor: UIColor public let itemBlocksSeparatorColor: UIColor
public let itemPlainSeparatorColor: UIColor public let itemPlainSeparatorColor: UIColor
@ -461,6 +463,7 @@ public final class PresentationThemeList {
public init( public init(
blocksBackgroundColor: UIColor, blocksBackgroundColor: UIColor,
modalBlocksBackgroundColor: UIColor,
plainBackgroundColor: UIColor, plainBackgroundColor: UIColor,
itemPrimaryTextColor: UIColor, itemPrimaryTextColor: UIColor,
itemSecondaryTextColor: UIColor, itemSecondaryTextColor: UIColor,
@ -470,6 +473,7 @@ public final class PresentationThemeList {
itemDestructiveColor: UIColor, itemDestructiveColor: UIColor,
itemPlaceholderTextColor: UIColor, itemPlaceholderTextColor: UIColor,
itemBlocksBackgroundColor: UIColor, itemBlocksBackgroundColor: UIColor,
itemModalBlocksBackgroundColor: UIColor,
itemHighlightedBackgroundColor: UIColor, itemHighlightedBackgroundColor: UIColor,
itemBlocksSeparatorColor: UIColor, itemBlocksSeparatorColor: UIColor,
itemPlainSeparatorColor: UIColor, itemPlainSeparatorColor: UIColor,
@ -494,6 +498,7 @@ public final class PresentationThemeList {
paymentOption: PaymentOption paymentOption: PaymentOption
) { ) {
self.blocksBackgroundColor = blocksBackgroundColor self.blocksBackgroundColor = blocksBackgroundColor
self.modalBlocksBackgroundColor = modalBlocksBackgroundColor
self.plainBackgroundColor = plainBackgroundColor self.plainBackgroundColor = plainBackgroundColor
self.itemPrimaryTextColor = itemPrimaryTextColor self.itemPrimaryTextColor = itemPrimaryTextColor
self.itemSecondaryTextColor = itemSecondaryTextColor self.itemSecondaryTextColor = itemSecondaryTextColor
@ -505,6 +510,7 @@ public final class PresentationThemeList {
self.itemBlocksBackgroundColor = itemBlocksBackgroundColor self.itemBlocksBackgroundColor = itemBlocksBackgroundColor
self.itemHighlightedBackgroundColor = itemHighlightedBackgroundColor self.itemHighlightedBackgroundColor = itemHighlightedBackgroundColor
self.itemBlocksSeparatorColor = itemBlocksSeparatorColor self.itemBlocksSeparatorColor = itemBlocksSeparatorColor
self.itemModalBlocksBackgroundColor = itemModalBlocksBackgroundColor
self.itemPlainSeparatorColor = itemPlainSeparatorColor self.itemPlainSeparatorColor = itemPlainSeparatorColor
self.disclosureArrowColor = disclosureArrowColor self.disclosureArrowColor = disclosureArrowColor
self.sectionHeaderTextColor = sectionHeaderTextColor self.sectionHeaderTextColor = sectionHeaderTextColor
@ -527,8 +533,8 @@ public final class PresentationThemeList {
self.paymentOption = paymentOption self.paymentOption = paymentOption
} }
public func withUpdated(blocksBackgroundColor: UIColor? = nil, plainBackgroundColor: UIColor? = nil, itemPrimaryTextColor: UIColor? = nil, itemSecondaryTextColor: UIColor? = nil, itemDisabledTextColor: UIColor? = nil, itemAccentColor: UIColor? = nil, itemHighlightedColor: UIColor? = nil, itemDestructiveColor: UIColor? = nil, itemPlaceholderTextColor: UIColor? = nil, itemBlocksBackgroundColor: UIColor? = nil, itemHighlightedBackgroundColor: UIColor? = nil, itemBlocksSeparatorColor: UIColor? = nil, itemPlainSeparatorColor: UIColor? = nil, disclosureArrowColor: UIColor? = nil, sectionHeaderTextColor: UIColor? = nil, freeTextColor: UIColor? = nil, freeTextErrorColor: UIColor? = nil, freeTextSuccessColor: UIColor? = nil, freeMonoIconColor: UIColor? = nil, itemSwitchColors: PresentationThemeSwitch? = nil, itemDisclosureActions: PresentationThemeItemDisclosureActions? = nil, itemCheckColors: PresentationThemeFillStrokeForeground? = nil, controlSecondaryColor: UIColor? = nil, freeInputField: PresentationInputFieldTheme? = nil, freePlainInputField: PresentationInputFieldTheme? = nil, mediaPlaceholderColor: UIColor? = nil, scrollIndicatorColor: UIColor? = nil, pageIndicatorInactiveColor: UIColor? = nil, inputClearButtonColor: UIColor? = nil, itemBarChart: PresentationThemeItemBarChart? = nil, itemInputField: PresentationInputFieldTheme? = nil, paymentOption: PaymentOption? = nil) -> PresentationThemeList { public func withUpdated(blocksBackgroundColor: UIColor? = nil, modalBlocksBackgroundColor: UIColor? = nil, plainBackgroundColor: UIColor? = nil, itemPrimaryTextColor: UIColor? = nil, itemSecondaryTextColor: UIColor? = nil, itemDisabledTextColor: UIColor? = nil, itemAccentColor: UIColor? = nil, itemHighlightedColor: UIColor? = nil, itemDestructiveColor: UIColor? = nil, itemPlaceholderTextColor: UIColor? = nil, itemBlocksBackgroundColor: UIColor? = nil, itemModalBlocksBackgroundColor: UIColor? = nil, itemHighlightedBackgroundColor: UIColor? = nil, itemBlocksSeparatorColor: UIColor? = nil, itemPlainSeparatorColor: UIColor? = nil, disclosureArrowColor: UIColor? = nil, sectionHeaderTextColor: UIColor? = nil, freeTextColor: UIColor? = nil, freeTextErrorColor: UIColor? = nil, freeTextSuccessColor: UIColor? = nil, freeMonoIconColor: UIColor? = nil, itemSwitchColors: PresentationThemeSwitch? = nil, itemDisclosureActions: PresentationThemeItemDisclosureActions? = nil, itemCheckColors: PresentationThemeFillStrokeForeground? = nil, controlSecondaryColor: UIColor? = nil, freeInputField: PresentationInputFieldTheme? = nil, freePlainInputField: PresentationInputFieldTheme? = nil, mediaPlaceholderColor: UIColor? = nil, scrollIndicatorColor: UIColor? = nil, pageIndicatorInactiveColor: UIColor? = nil, inputClearButtonColor: UIColor? = nil, itemBarChart: PresentationThemeItemBarChart? = nil, itemInputField: PresentationInputFieldTheme? = nil, paymentOption: PaymentOption? = nil) -> PresentationThemeList {
return PresentationThemeList(blocksBackgroundColor: blocksBackgroundColor ?? self.blocksBackgroundColor, plainBackgroundColor: plainBackgroundColor ?? self.plainBackgroundColor, itemPrimaryTextColor: itemPrimaryTextColor ?? self.itemPrimaryTextColor, itemSecondaryTextColor: itemSecondaryTextColor ?? self.itemSecondaryTextColor, itemDisabledTextColor: itemDisabledTextColor ?? self.itemDisabledTextColor, itemAccentColor: itemAccentColor ?? self.itemAccentColor, itemHighlightedColor: itemHighlightedColor ?? self.itemHighlightedColor, itemDestructiveColor: itemDestructiveColor ?? self.itemDestructiveColor, itemPlaceholderTextColor: itemPlaceholderTextColor ?? self.itemPlaceholderTextColor, itemBlocksBackgroundColor: itemBlocksBackgroundColor ?? self.itemBlocksBackgroundColor, itemHighlightedBackgroundColor: itemHighlightedBackgroundColor ?? self.itemHighlightedBackgroundColor, itemBlocksSeparatorColor: itemBlocksSeparatorColor ?? self.itemBlocksSeparatorColor, itemPlainSeparatorColor: itemPlainSeparatorColor ?? self.itemPlainSeparatorColor, disclosureArrowColor: disclosureArrowColor ?? self.disclosureArrowColor, sectionHeaderTextColor: sectionHeaderTextColor ?? self.sectionHeaderTextColor, freeTextColor: freeTextColor ?? self.freeTextColor, freeTextErrorColor: freeTextErrorColor ?? self.freeTextErrorColor, freeTextSuccessColor: freeTextSuccessColor ?? self.freeTextSuccessColor, freeMonoIconColor: freeMonoIconColor ?? self.freeMonoIconColor, itemSwitchColors: itemSwitchColors ?? self.itemSwitchColors, itemDisclosureActions: itemDisclosureActions ?? self.itemDisclosureActions, itemCheckColors: itemCheckColors ?? self.itemCheckColors, controlSecondaryColor: controlSecondaryColor ?? self.controlSecondaryColor, freeInputField: freeInputField ?? self.freeInputField, freePlainInputField: freePlainInputField ?? self.freePlainInputField, mediaPlaceholderColor: mediaPlaceholderColor ?? self.mediaPlaceholderColor, scrollIndicatorColor: scrollIndicatorColor ?? self.scrollIndicatorColor, pageIndicatorInactiveColor: pageIndicatorInactiveColor ?? self.pageIndicatorInactiveColor, inputClearButtonColor: inputClearButtonColor ?? self.inputClearButtonColor, itemBarChart: itemBarChart ?? self.itemBarChart, itemInputField: itemInputField ?? self.itemInputField, paymentOption: paymentOption ?? self.paymentOption) return PresentationThemeList(blocksBackgroundColor: blocksBackgroundColor ?? self.blocksBackgroundColor, modalBlocksBackgroundColor: modalBlocksBackgroundColor ?? self.modalBlocksBackgroundColor, plainBackgroundColor: plainBackgroundColor ?? self.plainBackgroundColor, itemPrimaryTextColor: itemPrimaryTextColor ?? self.itemPrimaryTextColor, itemSecondaryTextColor: itemSecondaryTextColor ?? self.itemSecondaryTextColor, itemDisabledTextColor: itemDisabledTextColor ?? self.itemDisabledTextColor, itemAccentColor: itemAccentColor ?? self.itemAccentColor, itemHighlightedColor: itemHighlightedColor ?? self.itemHighlightedColor, itemDestructiveColor: itemDestructiveColor ?? self.itemDestructiveColor, itemPlaceholderTextColor: itemPlaceholderTextColor ?? self.itemPlaceholderTextColor, itemBlocksBackgroundColor: itemBlocksBackgroundColor ?? self.itemBlocksBackgroundColor, itemModalBlocksBackgroundColor: itemModalBlocksBackgroundColor ?? self.itemModalBlocksBackgroundColor, itemHighlightedBackgroundColor: itemHighlightedBackgroundColor ?? self.itemHighlightedBackgroundColor, itemBlocksSeparatorColor: itemBlocksSeparatorColor ?? self.itemBlocksSeparatorColor, itemPlainSeparatorColor: itemPlainSeparatorColor ?? self.itemPlainSeparatorColor, disclosureArrowColor: disclosureArrowColor ?? self.disclosureArrowColor, sectionHeaderTextColor: sectionHeaderTextColor ?? self.sectionHeaderTextColor, freeTextColor: freeTextColor ?? self.freeTextColor, freeTextErrorColor: freeTextErrorColor ?? self.freeTextErrorColor, freeTextSuccessColor: freeTextSuccessColor ?? self.freeTextSuccessColor, freeMonoIconColor: freeMonoIconColor ?? self.freeMonoIconColor, itemSwitchColors: itemSwitchColors ?? self.itemSwitchColors, itemDisclosureActions: itemDisclosureActions ?? self.itemDisclosureActions, itemCheckColors: itemCheckColors ?? self.itemCheckColors, controlSecondaryColor: controlSecondaryColor ?? self.controlSecondaryColor, freeInputField: freeInputField ?? self.freeInputField, freePlainInputField: freePlainInputField ?? self.freePlainInputField, mediaPlaceholderColor: mediaPlaceholderColor ?? self.mediaPlaceholderColor, scrollIndicatorColor: scrollIndicatorColor ?? self.scrollIndicatorColor, pageIndicatorInactiveColor: pageIndicatorInactiveColor ?? self.pageIndicatorInactiveColor, inputClearButtonColor: inputClearButtonColor ?? self.inputClearButtonColor, itemBarChart: itemBarChart ?? self.itemBarChart, itemInputField: itemInputField ?? self.itemInputField, paymentOption: paymentOption ?? self.paymentOption)
} }
} }
@ -1479,8 +1485,8 @@ public final class PresentationTheme: Equatable {
return PresentationTheme(name: self.name, index: self.index, referenceTheme: self.referenceTheme, overallDarkAppearance: self.overallDarkAppearance, intro: self.intro, passcode: self.passcode, rootController: self.rootController, list: self.list, chatList: self.chatList, chat: self.chat, actionSheet: self.actionSheet, contextMenu: self.contextMenu, inAppNotification: self.inAppNotification, chart: self.chart, preview: preview) return PresentationTheme(name: self.name, index: self.index, referenceTheme: self.referenceTheme, overallDarkAppearance: self.overallDarkAppearance, intro: self.intro, passcode: self.passcode, rootController: self.rootController, list: self.list, chatList: self.chatList, chat: self.chat, actionSheet: self.actionSheet, contextMenu: self.contextMenu, inAppNotification: self.inAppNotification, chart: self.chart, preview: preview)
} }
public func withInvertedBlocksBackground() -> PresentationTheme { public func withModalBlocksBackground() -> PresentationTheme {
let list = self.list.withUpdated(blocksBackgroundColor: self.list.itemBlocksBackgroundColor, itemBlocksBackgroundColor: self.list.blocksBackgroundColor) let list = self.list.withUpdated(blocksBackgroundColor: self.list.modalBlocksBackgroundColor, itemBlocksBackgroundColor: self.list.itemModalBlocksBackgroundColor)
return PresentationTheme(name: self.name, index: self.index, referenceTheme: self.referenceTheme, overallDarkAppearance: self.overallDarkAppearance, intro: self.intro, passcode: self.passcode, rootController: self.rootController, list: list, chatList: self.chatList, chat: self.chat, actionSheet: self.actionSheet, contextMenu: self.contextMenu, inAppNotification: self.inAppNotification, chart: self.chart, preview: self.preview) return PresentationTheme(name: self.name, index: self.index, referenceTheme: self.referenceTheme, overallDarkAppearance: self.overallDarkAppearance, intro: self.intro, passcode: self.passcode, rootController: self.rootController, list: list, chatList: self.chatList, chat: self.chat, actionSheet: self.actionSheet, contextMenu: self.contextMenu, inAppNotification: self.inAppNotification, chart: self.chart, preview: self.preview)
} }
} }

View File

@ -813,6 +813,7 @@ extension PresentationThemeList.PaymentOption: Codable {
extension PresentationThemeList: Codable { extension PresentationThemeList: Codable {
enum CodingKeys: String, CodingKey { enum CodingKeys: String, CodingKey {
case blocksBg case blocksBg
case modalBlocksBg
case plainBg case plainBg
case primaryText case primaryText
case secondaryText case secondaryText
@ -822,6 +823,7 @@ extension PresentationThemeList: Codable {
case destructive case destructive
case placeholderText case placeholderText
case itemBlocksBg case itemBlocksBg
case itemModalBlocksBg
case itemHighlightedBg case itemHighlightedBg
case blocksSeparator case blocksSeparator
case plainSeparator case plainSeparator
@ -848,6 +850,7 @@ extension PresentationThemeList: Codable {
public convenience init(from decoder: Decoder) throws { public convenience init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self) let values = try decoder.container(keyedBy: CodingKeys.self)
let codingPath = decoder.codingPath.map { $0.stringValue }.joined(separator: ".")
let freePlainInputField: PresentationInputFieldTheme let freePlainInputField: PresentationInputFieldTheme
if let value = try? values.decode(PresentationInputFieldTheme.self, forKey: .freePlainInputField) { if let value = try? values.decode(PresentationInputFieldTheme.self, forKey: .freePlainInputField) {
@ -860,6 +863,7 @@ extension PresentationThemeList: Codable {
self.init( self.init(
blocksBackgroundColor: try decodeColor(values, .blocksBg), blocksBackgroundColor: try decodeColor(values, .blocksBg),
modalBlocksBackgroundColor: try decodeColor(values, .modalBlocksBg, fallbackKey: "\(codingPath).blocksBg"),
plainBackgroundColor: try decodeColor(values, .plainBg), plainBackgroundColor: try decodeColor(values, .plainBg),
itemPrimaryTextColor: try decodeColor(values, .primaryText), itemPrimaryTextColor: try decodeColor(values, .primaryText),
itemSecondaryTextColor: try decodeColor(values, .secondaryText), itemSecondaryTextColor: try decodeColor(values, .secondaryText),
@ -869,6 +873,7 @@ extension PresentationThemeList: Codable {
itemDestructiveColor: try decodeColor(values, .destructive), itemDestructiveColor: try decodeColor(values, .destructive),
itemPlaceholderTextColor: try decodeColor(values, .placeholderText), itemPlaceholderTextColor: try decodeColor(values, .placeholderText),
itemBlocksBackgroundColor: try decodeColor(values, .itemBlocksBg), itemBlocksBackgroundColor: try decodeColor(values, .itemBlocksBg),
itemModalBlocksBackgroundColor: try decodeColor(values, .itemModalBlocksBg, fallbackKey: "\(codingPath).itemBlocksBg"),
itemHighlightedBackgroundColor: try decodeColor(values, .itemHighlightedBg), itemHighlightedBackgroundColor: try decodeColor(values, .itemHighlightedBg),
itemBlocksSeparatorColor: try decodeColor(values, .blocksSeparator), itemBlocksSeparatorColor: try decodeColor(values, .blocksSeparator),
itemPlainSeparatorColor: try decodeColor(values, .plainSeparator), itemPlainSeparatorColor: try decodeColor(values, .plainSeparator),

View File

@ -239,8 +239,8 @@ public func attachmentFileController(context: AccountContext, updatedPresentatio
) )
|> map { presentationData, recentDocuments, state -> (ItemListControllerState, (ItemListNodeState, Any)) in |> map { presentationData, recentDocuments, state -> (ItemListControllerState, (ItemListNodeState, Any)) in
var presentationData = presentationData var presentationData = presentationData
if presentationData.theme.list.blocksBackgroundColor.rgb == 0x000000 { if presentationData.theme.list.blocksBackgroundColor.rgb == presentationData.theme.list.plainBackgroundColor.rgb {
let updatedTheme = presentationData.theme.withInvertedBlocksBackground() let updatedTheme = presentationData.theme.withModalBlocksBackground()
presentationData = presentationData.withUpdated(theme: updatedTheme) presentationData = presentationData.withUpdated(theme: updatedTheme)
} }

View File

@ -1352,7 +1352,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
strongSelf.addSubnode(deliveryFailedNode) strongSelf.addSubnode(deliveryFailedNode)
} }
let deliveryFailedSize = deliveryFailedNode.updateLayout(theme: item.presentationData.theme.theme) let deliveryFailedSize = deliveryFailedNode.updateLayout(theme: item.presentationData.theme.theme)
let deliveryFailedFrame = CGRect(origin: CGPoint(x: imageFrame.maxX + deliveryFailedInset - deliveryFailedSize.width, y: imageFrame.maxY - deliveryFailedSize.height - imageInset), size: deliveryFailedSize) let deliveryFailedFrame = CGRect(origin: CGPoint(x: imageFrame.maxX + deliveryFailedInset - deliveryFailedSize.width, y: imageFrame.maxY - deliveryFailedSize.height - imageInset + imageVerticalInset), size: deliveryFailedSize)
if isAppearing { if isAppearing {
deliveryFailedNode.frame = deliveryFailedFrame deliveryFailedNode.frame = deliveryFailedFrame
transition.animatePositionAdditive(node: deliveryFailedNode, offset: CGPoint(x: deliveryFailedInset, y: 0.0)) transition.animatePositionAdditive(node: deliveryFailedNode, offset: CGPoint(x: deliveryFailedInset, y: 0.0))
@ -1370,7 +1370,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
if let actionButtonsSizeAndApply = actionButtonsSizeAndApply { if let actionButtonsSizeAndApply = actionButtonsSizeAndApply {
let actionButtonsNode = actionButtonsSizeAndApply.1(animation) let actionButtonsNode = actionButtonsSizeAndApply.1(animation)
let previousFrame = actionButtonsNode.frame let previousFrame = actionButtonsNode.frame
let actionButtonsFrame = CGRect(origin: CGPoint(x: imageFrame.minX, y: imageFrame.maxY), size: actionButtonsSizeAndApply.0) let actionButtonsFrame = CGRect(origin: CGPoint(x: imageFrame.minX, y: imageFrame.maxY + imageVerticalInset), size: actionButtonsSizeAndApply.0)
actionButtonsNode.frame = actionButtonsFrame actionButtonsNode.frame = actionButtonsFrame
if actionButtonsNode !== strongSelf.actionButtonsNode { if actionButtonsNode !== strongSelf.actionButtonsNode {
strongSelf.actionButtonsNode = actionButtonsNode strongSelf.actionButtonsNode = actionButtonsNode
@ -1397,7 +1397,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
if let reactionButtonsSizeAndApply = reactionButtonsSizeAndApply { if let reactionButtonsSizeAndApply = reactionButtonsSizeAndApply {
let reactionButtonsNode = reactionButtonsSizeAndApply.1(animation) let reactionButtonsNode = reactionButtonsSizeAndApply.1(animation)
var reactionButtonsFrame = CGRect(origin: CGPoint(x: imageFrame.minX, y: imageFrame.maxY), size: reactionButtonsSizeAndApply.0) var reactionButtonsFrame = CGRect(origin: CGPoint(x: imageFrame.minX, y: imageFrame.maxY + imageVerticalInset), size: reactionButtonsSizeAndApply.0)
if !incoming { if !incoming {
reactionButtonsFrame.origin.x = imageFrame.maxX - reactionButtonsSizeAndApply.0.width reactionButtonsFrame.origin.x = imageFrame.maxX - reactionButtonsSizeAndApply.0.width
} }
@ -1689,7 +1689,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
var animationFrame: CGRect var animationFrame: CGRect
if isStickerEffect { if isStickerEffect {
let scale: CGFloat = 0.245 let scale: CGFloat = 0.245
animationFrame = animationNode.frame.offsetBy(dx: incomingMessage ? animationNode.frame.width * scale : -animationNode.frame.width * scale + 21.0, dy: -1.0).insetBy(dx: -animationNode.frame.width * scale, dy: -animationNode.frame.height * scale) animationFrame = animationNode.frame.offsetBy(dx: incomingMessage ? animationNode.frame.width * scale - 21.0 : -animationNode.frame.width * scale + 21.0, dy: -1.0).insetBy(dx: -animationNode.frame.width * scale, dy: -animationNode.frame.height * scale)
} else { } else {
animationFrame = animationNode.frame.insetBy(dx: -animationNode.frame.width, dy: -animationNode.frame.height) animationFrame = animationNode.frame.insetBy(dx: -animationNode.frame.width, dy: -animationNode.frame.height)
.offsetBy(dx: incomingMessage ? animationNode.frame.width - 10.0 : -animationNode.frame.width + 10.0, dy: 0.0) .offsetBy(dx: incomingMessage ? animationNode.frame.width - 10.0 : -animationNode.frame.width + 10.0, dy: 0.0)

View File

@ -720,6 +720,7 @@ public class TranslateScreen: ViewController {
statusBarHeight: 0.0, statusBarHeight: 0.0,
navigationHeight: navigationHeight, navigationHeight: navigationHeight,
safeInsets: UIEdgeInsets(top: layout.intrinsicInsets.top + layout.safeInsets.top, left: layout.safeInsets.left, bottom: layout.intrinsicInsets.bottom + layout.safeInsets.bottom, right: layout.safeInsets.right), safeInsets: UIEdgeInsets(top: layout.intrinsicInsets.top + layout.safeInsets.top, left: layout.safeInsets.left, bottom: layout.intrinsicInsets.bottom + layout.safeInsets.bottom, right: layout.safeInsets.right),
metrics: layout.metrics,
isVisible: self.currentIsVisible, isVisible: self.currentIsVisible,
theme: self.theme ?? self.presentationData.theme, theme: self.theme ?? self.presentationData.theme,
strings: self.presentationData.strings, strings: self.presentationData.strings,

View File

@ -161,9 +161,9 @@ public struct WebAppParameters {
public func generateWebAppThemeParams(_ presentationTheme: PresentationTheme) -> [String: Any] { public func generateWebAppThemeParams(_ presentationTheme: PresentationTheme) -> [String: Any] {
var backgroundColor = presentationTheme.list.plainBackgroundColor.rgb var backgroundColor = presentationTheme.list.plainBackgroundColor.rgb
var secondaryBackgroundColor = presentationTheme.list.blocksBackgroundColor.rgb var secondaryBackgroundColor = presentationTheme.list.blocksBackgroundColor.rgb
if backgroundColor == 0x000000 { if presentationTheme.list.blocksBackgroundColor.rgb == presentationTheme.list.plainBackgroundColor.rgb {
backgroundColor = presentationTheme.list.itemBlocksBackgroundColor.rgb backgroundColor = presentationTheme.list.modalBlocksBackgroundColor.rgb
secondaryBackgroundColor = presentationTheme.list.itemBlocksBackgroundColor.rgb secondaryBackgroundColor = presentationTheme.list.plainBackgroundColor.rgb
} }
return [ return [
"bg_color": Int32(bitPattern: backgroundColor), "bg_color": Int32(bitPattern: backgroundColor),
@ -733,9 +733,9 @@ public final class WebAppController: ViewController, AttachmentContainable {
let color: UIColor? let color: UIColor?
var backgroundColor = self.presentationData.theme.list.plainBackgroundColor var backgroundColor = self.presentationData.theme.list.plainBackgroundColor
var secondaryBackgroundColor = self.presentationData.theme.list.blocksBackgroundColor var secondaryBackgroundColor = self.presentationData.theme.list.blocksBackgroundColor
if backgroundColor.rgb == 0x000000 { if self.presentationData.theme.list.blocksBackgroundColor.rgb == self.presentationData.theme.list.plainBackgroundColor.rgb {
backgroundColor = self.presentationData.theme.list.itemBlocksBackgroundColor backgroundColor = self.presentationData.theme.list.modalBlocksBackgroundColor
secondaryBackgroundColor = self.presentationData.theme.list.itemBlocksBackgroundColor secondaryBackgroundColor = self.presentationData.theme.list.plainBackgroundColor
} }
if let headerColorKey = self.headerColorKey { if let headerColorKey = self.headerColorKey {
switch headerColorKey { switch headerColorKey {