Chat wallpaper fixes

This commit is contained in:
Ilya Laktyushin 2023-04-13 13:57:29 +04:00
parent c5d3666a8d
commit 0ca302e947
6 changed files with 182 additions and 16 deletions

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina6_7" orientation="portrait" appearance="light"/> <device id="ipad12_9" orientation="landscape" layout="fullscreen" appearance="dark"/>
<dependencies> <dependencies>
<deployment version="4096" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/> <capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@ -10,7 +11,7 @@
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="O8c-13-3vw"> <view contentMode="scaleToFill" id="O8c-13-3vw">
<rect key="frame" x="0.0" y="0.0" width="428" height="926"/> <rect key="frame" x="0.0" y="0.0" width="1366" height="1024"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/> <color key="backgroundColor" systemColor="systemBackgroundColor"/>
<point key="canvasLocation" x="139" y="117"/> <point key="canvasLocation" x="139" y="117"/>

View File

@ -116,11 +116,11 @@ final class ThemeAccentColorController: ViewController {
if case .background = mode { if case .background = mode {
self.title = self.presentationData.strings.Wallpaper_Title self.title = self.presentationData.strings.Wallpaper_Title
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Cancel, style: .plain, target: self, action: #selector(self.cancelPressed))
} else { } else {
self.navigationItem.titleView = self.segmentedTitleView self.navigationItem.titleView = self.segmentedTitleView
self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: UIView())
} }
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Cancel, style: .plain, target: self, action: #selector(self.cancelPressed))
} }
required init(coder aDecoder: NSCoder) { required init(coder aDecoder: NSCoder) {

View File

@ -188,7 +188,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
private var messageNodes: [ListViewItemNode]? private var messageNodes: [ListViewItemNode]?
private let colorPanelNode: WallpaperColorPanelNode private let colorPanelNode: WallpaperColorPanelNode
private let patternPanelNode: WallpaperPatternPanelNode private let patternPanelNode: WallpaperPatternPanelNode
private let toolbarNode: WallpaperGalleryToolbarNode private let toolbarNode: WallpaperGalleryToolbar
private var serviceColorDisposable: Disposable? private var serviceColorDisposable: Disposable?
private var stateDisposable: Disposable? private var stateDisposable: Disposable?
@ -312,9 +312,14 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
} else { } else {
doneButtonType = .set doneButtonType = .set
} }
self.toolbarNode = WallpaperGalleryToolbarNode(theme: self.theme, strings: self.presentationData.strings, doneButtonType: doneButtonType) if case .background = mode {
self.toolbarNode.dark = true let toolbarNode = WallpaperGalleryToolbarNode(theme: self.theme, strings: self.presentationData.strings, doneButtonType: doneButtonType)
self.toolbarNode.setDoneIsSolid(true, transition: .immediate) toolbarNode.dark = true
toolbarNode.setDoneIsSolid(true, transition: .immediate)
self.toolbarNode = toolbarNode
} else {
self.toolbarNode = WallpaperGalleryOldToolbarNode(theme: self.theme, strings: self.presentationData.strings, doneButtonType: doneButtonType)
}
self.maskNode = ASImageNode() self.maskNode = ASImageNode()
self.maskNode.displaysAsynchronously = false self.maskNode.displaysAsynchronously = false
@ -1168,8 +1173,12 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
self.pageControlNode.setPage(0.0) self.pageControlNode.setPage(0.0)
} }
let toolbarHeight = 49.0 + layout.intrinsicInsets.bottom var toolbarBottomInset = layout.intrinsicInsets.bottom
transition.updateFrame(node: self.toolbarNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - toolbarHeight), size: CGSize(width: layout.size.width, height: 49.0 + layout.intrinsicInsets.bottom))) if case .background = mode, toolbarBottomInset.isZero {
toolbarBottomInset = 16.0
}
let toolbarHeight = 49.0 + toolbarBottomInset
transition.updateFrame(node: self.toolbarNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - toolbarHeight), size: CGSize(width: layout.size.width, height: toolbarHeight)))
self.toolbarNode.updateLayout(size: CGSize(width: layout.size.width, height: 49.0), layout: layout, transition: transition) self.toolbarNode.updateLayout(size: CGSize(width: layout.size.width, height: 49.0), layout: layout, transition: transition)
var bottomInset = toolbarHeight var bottomInset = toolbarHeight
@ -1179,26 +1188,29 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
var colorPanelOffset: CGFloat = 0.0 var colorPanelOffset: CGFloat = 0.0
var colorPanelY = layout.size.height - bottomInset - colorPanelHeight var colorPanelY = layout.size.height - bottomInset - colorPanelHeight
let originalBottomInset = bottomInset
if self.state.colorPanelCollapsed { if self.state.colorPanelCollapsed {
colorPanelOffset = colorPanelHeight colorPanelOffset = colorPanelHeight
colorPanelY = layout.size.height colorPanelY = layout.size.height
} }
let colorPanelFrame = CGRect(origin: CGPoint(x: 0.0, y: colorPanelY), size: CGSize(width: layout.size.width, height: colorPanelHeight))
bottomInset += (colorPanelHeight - colorPanelOffset) bottomInset += (colorPanelHeight - colorPanelOffset)
self.toolbarNode.setDoneIsSolid(!self.state.colorPanelCollapsed, transition: transition) if let toolbarNode = self.toolbarNode as? WallpaperGalleryToolbarNode {
toolbarNode.setDoneIsSolid(!self.state.colorPanelCollapsed, transition: transition)
}
if bottomInset + navigationBarHeight > bounds.height { if bottomInset + navigationBarHeight > bounds.height {
return return
} }
transition.updateFrame(node: self.colorPanelNode, frame: colorPanelFrame) let colorPanelFrame = CGRect(origin: CGPoint(x: 0.0, y: colorPanelY), size: CGSize(width: layout.size.width, height: colorPanelHeight))
self.colorPanelNode.updateLayout(size: colorPanelFrame.size, bottomInset: 0.0, transition: transition) transition.updateFrame(node: self.colorPanelNode, frame: CGRect(origin: colorPanelFrame.origin, size: CGSize(width: colorPanelFrame.width, height: colorPanelFrame.height + originalBottomInset)))
self.colorPanelNode.updateLayout(size: colorPanelFrame.size, bottomInset: originalBottomInset, transition: transition)
let patternPanelAlpha: CGFloat = self.state.displayPatternPanel ? 1.0 : 0.0 let patternPanelAlpha: CGFloat = self.state.displayPatternPanel ? 1.0 : 0.0
let patternPanelFrame = colorPanelFrame let patternPanelFrame = colorPanelFrame
transition.updateFrame(node: self.patternPanelNode, frame: patternPanelFrame) transition.updateFrame(node: self.patternPanelNode, frame: patternPanelFrame)
self.patternPanelNode.updateLayout(size: patternPanelFrame.size, bottomInset: 0.0, transition: transition) self.patternPanelNode.updateLayout(size: patternPanelFrame.size, bottomInset: originalBottomInset, transition: transition)
self.patternPanelNode.isUserInteractionEnabled = self.state.displayPatternPanel self.patternPanelNode.isUserInteractionEnabled = self.state.displayPatternPanel
transition.updateAlpha(node: self.patternPanelNode, alpha: patternPanelAlpha) transition.updateAlpha(node: self.patternPanelNode, alpha: patternPanelAlpha)

View File

@ -259,6 +259,12 @@ final class ThemeColorsGridControllerNode: ASDisplayNode {
self.backgroundColor = presentationData.theme.list.plainBackgroundColor self.backgroundColor = presentationData.theme.list.plainBackgroundColor
} }
self.leftOverlayNode.backgroundColor = presentationData.theme.list.blocksBackgroundColor
self.rightOverlayNode.backgroundColor = presentationData.theme.list.blocksBackgroundColor
self.topBackgroundNode.backgroundColor = presentationData.theme.list.blocksBackgroundColor
self.separatorNode.backgroundColor = presentationData.theme.list.itemBlocksSeparatorColor
self.customColorItem = ItemListActionItem(presentationData: ItemListPresentationData(presentationData), title: presentationData.strings.WallpaperColors_SetCustomColor, kind: .generic, alignment: .natural, sectionId: 0, style: .blocks, action: { [weak self] in self.customColorItem = ItemListActionItem(presentationData: ItemListPresentationData(presentationData), title: presentationData.strings.WallpaperColors_SetCustomColor, kind: .generic, alignment: .natural, sectionId: 0, style: .blocks, action: { [weak self] in
self?.presentColorPicker() self?.presentColorPicker()
}) })

View File

@ -17,7 +17,19 @@ enum WallpaperGalleryToolbarDoneButtonType {
case none case none
} }
final class WallpaperGalleryToolbarNode: ASDisplayNode { protocol WallpaperGalleryToolbar: ASDisplayNode {
var cancelButtonType: WallpaperGalleryToolbarCancelButtonType { get set }
var doneButtonType: WallpaperGalleryToolbarDoneButtonType { get set }
var cancel: (() -> Void)? { get set }
var done: (() -> Void)? { get set }
func updateThemeAndStrings(theme: PresentationTheme, strings: PresentationStrings)
func updateLayout(size: CGSize, layout: ContainerViewLayout, transition: ContainedViewLayoutTransition)
}
final class WallpaperGalleryToolbarNode: ASDisplayNode, WallpaperGalleryToolbar {
private var theme: PresentationTheme private var theme: PresentationTheme
private let strings: PresentationStrings private let strings: PresentationStrings
@ -203,3 +215,134 @@ final class WallpaperGalleryToolbarNode: ASDisplayNode {
self.done?() self.done?()
} }
} }
final class WallpaperGalleryOldToolbarNode: ASDisplayNode, WallpaperGalleryToolbar {
private var theme: PresentationTheme
private let strings: PresentationStrings
var cancelButtonType: WallpaperGalleryToolbarCancelButtonType {
didSet {
self.updateThemeAndStrings(theme: self.theme, strings: self.strings)
}
}
var doneButtonType: WallpaperGalleryToolbarDoneButtonType {
didSet {
self.updateThemeAndStrings(theme: self.theme, strings: self.strings)
}
}
private let cancelButton = HighlightTrackingButtonNode()
private let cancelHighlightBackgroundNode = ASDisplayNode()
private let doneButton = HighlightTrackingButtonNode()
private let doneHighlightBackgroundNode = ASDisplayNode()
private let backgroundNode = NavigationBackgroundNode(color: .clear)
private let separatorNode = ASDisplayNode()
private let topSeparatorNode = ASDisplayNode()
var cancel: (() -> Void)?
var done: (() -> Void)?
init(theme: PresentationTheme, strings: PresentationStrings, cancelButtonType: WallpaperGalleryToolbarCancelButtonType = .cancel, doneButtonType: WallpaperGalleryToolbarDoneButtonType = .set) {
self.theme = theme
self.strings = strings
self.cancelButtonType = cancelButtonType
self.doneButtonType = doneButtonType
self.cancelHighlightBackgroundNode.alpha = 0.0
self.doneHighlightBackgroundNode.alpha = 0.0
super.init()
self.addSubnode(self.backgroundNode)
self.addSubnode(self.cancelHighlightBackgroundNode)
self.addSubnode(self.cancelButton)
self.addSubnode(self.doneHighlightBackgroundNode)
self.addSubnode(self.doneButton)
self.addSubnode(self.separatorNode)
self.addSubnode(self.topSeparatorNode)
self.updateThemeAndStrings(theme: theme, strings: strings)
self.cancelButton.highligthedChanged = { [weak self] highlighted in
if let strongSelf = self {
if highlighted {
strongSelf.cancelHighlightBackgroundNode.layer.removeAnimation(forKey: "opacity")
strongSelf.cancelHighlightBackgroundNode.alpha = 1.0
} else {
strongSelf.cancelHighlightBackgroundNode.alpha = 0.0
strongSelf.cancelHighlightBackgroundNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3)
}
}
}
self.doneButton.highligthedChanged = { [weak self] highlighted in
if let strongSelf = self {
if highlighted {
strongSelf.doneHighlightBackgroundNode.layer.removeAnimation(forKey: "opacity")
strongSelf.doneHighlightBackgroundNode.alpha = 1.0
} else {
strongSelf.doneHighlightBackgroundNode.alpha = 0.0
strongSelf.doneHighlightBackgroundNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3)
}
}
}
self.cancelButton.addTarget(self, action: #selector(self.cancelPressed), forControlEvents: .touchUpInside)
self.doneButton.addTarget(self, action: #selector(self.donePressed), forControlEvents: .touchUpInside)
}
func setDoneEnabled(_ enabled: Bool) {
self.doneButton.alpha = enabled ? 1.0 : 0.4
self.doneButton.isUserInteractionEnabled = enabled
}
func updateThemeAndStrings(theme: PresentationTheme, strings: PresentationStrings) {
self.theme = theme
self.backgroundNode.updateColor(color: theme.rootController.tabBar.backgroundColor, transition: .immediate)
self.separatorNode.backgroundColor = theme.rootController.tabBar.separatorColor
self.topSeparatorNode.backgroundColor = theme.rootController.tabBar.separatorColor
self.cancelHighlightBackgroundNode.backgroundColor = theme.list.itemHighlightedBackgroundColor
self.doneHighlightBackgroundNode.backgroundColor = theme.list.itemHighlightedBackgroundColor
let cancelTitle: String
switch self.cancelButtonType {
case .cancel:
cancelTitle = strings.Common_Cancel
case .discard:
cancelTitle = strings.WallpaperPreview_PatternPaternDiscard
}
let doneTitle: String
switch self.doneButtonType {
case .set, .setPeer:
doneTitle = strings.Wallpaper_Set
case .proceed:
doneTitle = strings.Theme_Colors_Proceed
case .apply:
doneTitle = strings.WallpaperPreview_PatternPaternApply
case .none:
doneTitle = ""
self.doneButton.isUserInteractionEnabled = false
}
self.cancelButton.setTitle(cancelTitle, with: Font.regular(17.0), with: theme.list.itemPrimaryTextColor, for: [])
self.doneButton.setTitle(doneTitle, with: Font.regular(17.0), with: theme.list.itemPrimaryTextColor, for: [])
}
func updateLayout(size: CGSize, layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
self.cancelButton.frame = CGRect(origin: CGPoint(), size: CGSize(width: floor(size.width / 2.0), height: size.height))
self.cancelHighlightBackgroundNode.frame = CGRect(origin: CGPoint(), size: CGSize(width: floor(size.width / 2.0), height: size.height))
self.doneButton.frame = CGRect(origin: CGPoint(x: floor(size.width / 2.0), y: 0.0), size: CGSize(width: size.width - floor(size.width / 2.0), height: size.height))
self.doneHighlightBackgroundNode.frame = CGRect(origin: CGPoint(x: floor(size.width / 2.0), y: 0.0), size: CGSize(width: size.width - floor(size.width / 2.0), height: size.height))
self.separatorNode.frame = CGRect(origin: CGPoint(x: floor(size.width / 2.0), y: 0.0), size: CGSize(width: UIScreenPixel, height: size.height + layout.intrinsicInsets.bottom))
self.topSeparatorNode.frame = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: UIScreenPixel))
self.backgroundNode.frame = CGRect(origin: CGPoint(), size: size)
self.backgroundNode.update(size: CGSize(width: size.width, height: size.height + layout.intrinsicInsets.bottom), transition: .immediate)
}
@objc func cancelPressed() {
self.cancel?()
}
@objc func donePressed() {
self.done?()
}
}

View File

@ -1331,6 +1331,10 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, UIScrollViewDelega
if self.controller?.canResetWallpaper == true { if self.controller?.canResetWallpaper == true {
contentHeight += 50.0 contentHeight += 50.0
} }
if cleanInsets.bottom.isZero {
insets.bottom += 14.0
contentHeight += 14.0
}
let width = horizontalContainerFillingSizeForLayout(layout: layout, sideInset: 0.0) let width = horizontalContainerFillingSizeForLayout(layout: layout, sideInset: 0.0)