mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Theme preview fixes
This commit is contained in:
parent
73dee20244
commit
8c525b16a4
@ -4676,6 +4676,11 @@ Any member of this group will be able to see messages in the channel.";
|
||||
"Appearance.ThemePreview.Chat.2.Text" = "Right side. And, uh, with intensity.";
|
||||
"Appearance.ThemePreview.Chat.3.Text" = "Is that everything? It seemed like he said quite a bit more than that. 😯";
|
||||
|
||||
"Appearance.ThemePreview.Chat.4.Text" = "For relaxing times, make it Suntory time. 😎";
|
||||
"Appearance.ThemePreview.Chat.5.Text" = "He wants you to turn, look in camera. O.K.?";
|
||||
"Appearance.ThemePreview.Chat.6.Text" = "That’s all he said?";
|
||||
"Appearance.ThemePreview.Chat.7.Text" = "Yes, turn to camera.";
|
||||
|
||||
"GroupInfo.Permissions.SlowmodeValue.Off" = "Off";
|
||||
|
||||
"Undo.ScheduledMessagesCleared" = "Scheduled messages cleared";
|
||||
|
@ -1687,7 +1687,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
|
||||
updateIndices.subtract(explicitelyUpdateIndices)
|
||||
|
||||
self.updateNodes(synchronous: options.contains(.Synchronous), synchronousLoads: options.contains(.PreferSynchronousResourceLoading), animated: animated, updateIndicesAndItems: updateIndicesAndItems, inputState: updatedState, previousNodes: previousNodes, inputOperations: operations, completion: { updatedState, operations in
|
||||
self.updateNodes(synchronous: options.contains(.Synchronous), synchronousLoads: options.contains(.PreferSynchronousResourceLoading), crossfade: options.contains(.AnimateCrossfade), animated: animated, updateIndicesAndItems: updateIndicesAndItems, inputState: updatedState, previousNodes: previousNodes, inputOperations: operations, completion: { updatedState, operations in
|
||||
self.updateAdjacent(synchronous: options.contains(.Synchronous), animated: animated, state: updatedState, updateAdjacentItemsIndices: updateIndices, operations: operations, completion: { state, operations in
|
||||
var updatedState = state
|
||||
var updatedOperations = operations
|
||||
@ -1893,7 +1893,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
}
|
||||
}
|
||||
|
||||
private func updateNodes(synchronous: Bool, synchronousLoads: Bool, animated: Bool, updateIndicesAndItems: [ListViewUpdateItem], inputState: ListViewState, previousNodes: [Int: QueueLocalObject<ListViewItemNode>], inputOperations: [ListViewStateOperation], completion: @escaping (ListViewState, [ListViewStateOperation]) -> Void) {
|
||||
private func updateNodes(synchronous: Bool, synchronousLoads: Bool, crossfade: Bool, animated: Bool, updateIndicesAndItems: [ListViewUpdateItem], inputState: ListViewState, previousNodes: [Int: QueueLocalObject<ListViewItemNode>], inputOperations: [ListViewStateOperation], completion: @escaping (ListViewState, [ListViewStateOperation]) -> Void) {
|
||||
var state = inputState
|
||||
var operations = inputOperations
|
||||
var updateIndicesAndItems = updateIndicesAndItems
|
||||
@ -1905,11 +1905,19 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
} else {
|
||||
let updateItem = updateIndicesAndItems[0]
|
||||
if let previousNode = previousNodes[updateItem.index] {
|
||||
self.nodeForItem(synchronous: synchronous, synchronousLoads: synchronousLoads, item: updateItem.item, previousNode: previousNode, index: updateItem.index, previousItem: updateItem.index == 0 ? nil : self.items[updateItem.index - 1], nextItem: updateItem.index == (self.items.count - 1) ? nil : self.items[updateItem.index + 1], params: ListViewItemLayoutParams(width: state.visibleSize.width, leftInset: state.insets.left, rightInset: state.insets.right, availableHeight: state.visibleSize.height - state.insets.top - state.insets.bottom), updateAnimation: animated ? .System(duration: insertionAnimationDuration) : .None, completion: { _, layout, apply in
|
||||
let updateAnimation: ListViewItemUpdateAnimation
|
||||
if crossfade {
|
||||
updateAnimation = .Crossfade
|
||||
} else if animated {
|
||||
updateAnimation = .System(duration: insertionAnimationDuration)
|
||||
} else {
|
||||
updateAnimation = .None
|
||||
}
|
||||
self.nodeForItem(synchronous: synchronous, synchronousLoads: synchronousLoads, item: updateItem.item, previousNode: previousNode, index: updateItem.index, previousItem: updateItem.index == 0 ? nil : self.items[updateItem.index - 1], nextItem: updateItem.index == (self.items.count - 1) ? nil : self.items[updateItem.index + 1], params: ListViewItemLayoutParams(width: state.visibleSize.width, leftInset: state.insets.left, rightInset: state.insets.right, availableHeight: state.visibleSize.height - state.insets.top - state.insets.bottom), updateAnimation: updateAnimation, completion: { _, layout, apply in
|
||||
state.updateNodeAtItemIndex(updateItem.index, layout: layout, direction: updateItem.directionHint, animation: animated ? .System(duration: insertionAnimationDuration) : .None, apply: apply, operations: &operations)
|
||||
|
||||
updateIndicesAndItems.remove(at: 0)
|
||||
self.updateNodes(synchronous: synchronous, synchronousLoads: synchronousLoads, animated: animated, updateIndicesAndItems: updateIndicesAndItems, inputState: state, previousNodes: previousNodes, inputOperations: operations, completion: completion)
|
||||
self.updateNodes(synchronous: synchronous, synchronousLoads: synchronousLoads, crossfade: crossfade, animated: animated, updateIndicesAndItems: updateIndicesAndItems, inputState: state, previousNodes: previousNodes, inputOperations: operations, completion: completion)
|
||||
})
|
||||
break
|
||||
} else {
|
||||
|
@ -810,7 +810,7 @@ struct ListViewState {
|
||||
i += 1
|
||||
if node.index == itemIndex {
|
||||
switch animation {
|
||||
case .None:
|
||||
case .None, .Crossfade:
|
||||
let offsetDirection: ListViewInsertionOffsetDirection
|
||||
if let direction = direction {
|
||||
offsetDirection = ListViewInsertionOffsetDirection(direction)
|
||||
|
@ -5,6 +5,7 @@ import SwiftSignalKit
|
||||
public enum ListViewItemUpdateAnimation {
|
||||
case None
|
||||
case System(duration: Double)
|
||||
case Crossfade
|
||||
|
||||
public var isAnimated: Bool {
|
||||
if case .None = self {
|
||||
|
@ -34,6 +34,11 @@ public final class ThemePreviewController: ViewController {
|
||||
return self.displayNode as! ThemePreviewControllerNode
|
||||
}
|
||||
|
||||
private let _ready = Promise<Bool>()
|
||||
override public var ready: Promise<Bool> {
|
||||
return self._ready
|
||||
}
|
||||
|
||||
private var didPlayPresentationAnimation = false
|
||||
|
||||
private var presentationData: PresentationData
|
||||
@ -185,7 +190,7 @@ public final class ThemePreviewController: ViewController {
|
||||
if let strongSelf = self {
|
||||
strongSelf.apply()
|
||||
}
|
||||
}, isPreview: isPreview)
|
||||
}, isPreview: isPreview, ready: self._ready)
|
||||
self.displayNodeDidLoad()
|
||||
|
||||
let previewTheme = self.previewTheme
|
||||
@ -193,7 +198,7 @@ public final class ThemePreviewController: ViewController {
|
||||
self.controllerNode.wallpaperPromise.set(.single(initialWallpaper))
|
||||
} else if case let .file(file) = previewTheme.chat.defaultWallpaper, file.id == 0 {
|
||||
self.controllerNode.wallpaperPromise.set(cachedWallpaper(account: self.context.account, slug: file.slug, settings: file.settings)
|
||||
|> mapToSignal { wallpaper in
|
||||
|> mapToSignal { wallpaper in
|
||||
return .single(wallpaper?.wallpaper ?? .color(Int32(bitPattern: previewTheme.chatList.backgroundColor.rgb)))
|
||||
})
|
||||
} else {
|
||||
|
@ -33,6 +33,8 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
private var previewTheme: PresentationTheme
|
||||
private var presentationData: PresentationData
|
||||
private let isPreview: Bool
|
||||
|
||||
private let ready: Promise<Bool>
|
||||
|
||||
public let wallpaperPromise = Promise<TelegramWallpaper>()
|
||||
|
||||
@ -65,11 +67,13 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
private var statusDisposable: Disposable?
|
||||
private var fetchDisposable = MetaDisposable()
|
||||
|
||||
init(context: AccountContext, previewTheme: PresentationTheme, initialWallpaper: TelegramWallpaper?, dismiss: @escaping () -> Void, apply: @escaping () -> Void, isPreview: Bool) {
|
||||
init(context: AccountContext, previewTheme: PresentationTheme, initialWallpaper: TelegramWallpaper?, dismiss: @escaping () -> Void, apply: @escaping () -> Void, isPreview: Bool, ready: Promise<Bool>) {
|
||||
self.context = context
|
||||
self.previewTheme = previewTheme
|
||||
self.isPreview = isPreview
|
||||
|
||||
self.ready = ready
|
||||
|
||||
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
|
||||
let calendar = Calendar(identifier: .gregorian)
|
||||
@ -101,6 +105,9 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
|
||||
let wallpaper = initialWallpaper ?? previewTheme.chat.defaultWallpaper
|
||||
self.instantChatBackgroundNode.image = chatControllerBackgroundImage(theme: previewTheme, wallpaper: wallpaper, mediaBox: context.sharedContext.accountManager.mediaBox, knockoutMode: context.sharedContext.immediateExperimentalUISettings.knockoutWallpaper)
|
||||
if self.instantChatBackgroundNode.image != nil {
|
||||
self.ready.set(.single(true))
|
||||
}
|
||||
if case .gradient = wallpaper {
|
||||
self.instantChatBackgroundNode.imageContentMode = .scaleToFill
|
||||
}
|
||||
@ -108,7 +115,6 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
self.instantChatBackgroundNode.view.contentMode = .scaleAspectFill
|
||||
|
||||
self.remoteChatBackgroundNode = TransformImageNode()
|
||||
self.remoteChatBackgroundNode.backgroundColor = previewTheme.chatList.backgroundColor
|
||||
self.remoteChatBackgroundNode.view.contentMode = .scaleAspectFill
|
||||
|
||||
self.blurredNode = BlurredImageNode()
|
||||
@ -230,7 +236,7 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
let fileReference = FileMediaReference.standalone(media: file.file)
|
||||
if file.isPattern {
|
||||
signal = patternWallpaperImage(account: context.account, accountManager: context.sharedContext.accountManager, representations: convertedRepresentations, mode: .screen, autoFetchFullSize: false)
|
||||
} else {
|
||||
} else if strongSelf.instantChatBackgroundNode.image == nil {
|
||||
signal = wallpaperImage(account: context.account, accountManager: context.sharedContext.accountManager, fileReference: fileReference, representations: convertedRepresentations, alwaysShowThumbnailFirst: false, autoFetchFullSize: false)
|
||||
|> afterNext { next in
|
||||
if let _ = context.sharedContext.accountManager.mediaBox.completedResourcePath(file.file.resource) {
|
||||
@ -238,8 +244,13 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
context.sharedContext.accountManager.mediaBox.storeResourceData(file.file.resource.id, data: data)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
signal = .complete()
|
||||
}
|
||||
strongSelf.remoteChatBackgroundNode.setSignal(signal)
|
||||
strongSelf.remoteChatBackgroundNode.imageUpdated = { [weak self] _ in
|
||||
self?.ready.set(.single(true))
|
||||
}
|
||||
|
||||
strongSelf.fetchDisposable.set(freeMediaFileInteractiveFetched(account: context.account, fileReference: .standalone(media: file.file)).start())
|
||||
|
||||
|
@ -112,7 +112,13 @@ private class ThemeSettingsAccentColorIconItem: ListViewItem {
|
||||
let (nodeLayout, apply) = layout(self, params)
|
||||
Queue.mainQueue().async {
|
||||
completion(nodeLayout, { _ in
|
||||
apply(animation.isAnimated)
|
||||
let animated: Bool
|
||||
if case .Crossfade = animation {
|
||||
animated = true
|
||||
} else {
|
||||
animated = false
|
||||
}
|
||||
apply(animated)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -240,7 +246,7 @@ private final class ThemeSettingsAccentColorIconItemNode : ListViewItemNode {
|
||||
transition.updateTransformScale(node: self.fillNode, scale: 1.2)
|
||||
transition.updateTransformScale(node: self.centerNode, scale: 1.0)
|
||||
transition.updateAlpha(node: self.centerNode, alpha: 1.0)
|
||||
transition.updateTransformScale(node: self.dotsNode, scale: 0.7)
|
||||
transition.updateTransformScale(node: self.dotsNode, scale: 0.8)
|
||||
transition.updateAlpha(node: self.dotsNode, alpha: 0.0)
|
||||
}
|
||||
}
|
||||
@ -270,7 +276,7 @@ private final class ThemeSettingsAccentColorIconItemNode : ListViewItemNode {
|
||||
if strokeColor == .clear {
|
||||
strokeColor = fillColor
|
||||
}
|
||||
|
||||
|
||||
// if strokeColor.distance(to: theme.list.itemBlocksBackgroundColor) < 200 {
|
||||
// if strokeColor.distance(to: UIColor.white) < 200 {
|
||||
// strokeColor = UIColor(rgb: 0x999999)
|
||||
@ -319,7 +325,7 @@ private final class ThemeSettingsAccentColorIconItemNode : ListViewItemNode {
|
||||
strongSelf.dotsNode.bounds = bounds
|
||||
|
||||
if updatedSelected {
|
||||
strongSelf.setSelected(item.selected, animated: currentItem != nil)
|
||||
strongSelf.setSelected(item.selected, animated: currentItem != nil && !animated)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -611,7 +611,8 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
|
||||
settings.themeSpecificChatWallpapers[reference.index]
|
||||
}
|
||||
return (accentColor, wallpaper)
|
||||
} |> mapToSignal { accentColor, wallpaper -> Signal<(PresentationTheme?, TelegramWallpaper?), NoError> in
|
||||
}
|
||||
|> map { accentColor, wallpaper -> (PresentationThemeAccentColor?, TelegramWallpaper) in
|
||||
let effectiveWallpaper: TelegramWallpaper
|
||||
if let wallpaper = wallpaper {
|
||||
effectiveWallpaper = wallpaper
|
||||
@ -619,7 +620,24 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
|
||||
let theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: reference, accentColor: accentColor?.color, bubbleColors: accentColor?.customBubbleColors)
|
||||
effectiveWallpaper = theme?.chat.defaultWallpaper ?? .builtin(WallpaperSettings())
|
||||
}
|
||||
return chatServiceBackgroundColor(wallpaper: effectiveWallpaper, mediaBox: context.sharedContext.accountManager.mediaBox)
|
||||
return (accentColor, effectiveWallpaper)
|
||||
}
|
||||
|> mapToSignal { accentColor, wallpaper -> Signal<(PresentationThemeAccentColor?, TelegramWallpaper), NoError> in
|
||||
if case let .file(file) = wallpaper, file.id == 0 {
|
||||
return cachedWallpaper(account: context.account, slug: file.slug, settings: file.settings)
|
||||
|> map { cachedWallpaper in
|
||||
if let wallpaper = cachedWallpaper?.wallpaper, case let .file(file) = wallpaper {
|
||||
return (accentColor, wallpaper)
|
||||
} else {
|
||||
return (accentColor, .builtin(WallpaperSettings()))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return .single((accentColor, wallpaper))
|
||||
}
|
||||
}
|
||||
|> mapToSignal { accentColor, wallpaper -> Signal<(PresentationTheme?, TelegramWallpaper?), NoError> in
|
||||
return chatServiceBackgroundColor(wallpaper: wallpaper, mediaBox: context.sharedContext.accountManager.mediaBox)
|
||||
|> map { serviceBackgroundColor in
|
||||
return (makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: reference, accentColor: accentColor?.color, bubbleColors: accentColor?.customBubbleColors, serviceBackgroundColor: serviceBackgroundColor), wallpaper)
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -767,7 +767,7 @@ final class ChatMessageAttachedContentNode: ASDisplayNode {
|
||||
var hasAnimation = true
|
||||
var transition: ContainedViewLayoutTransition = .immediate
|
||||
switch animation {
|
||||
case .None:
|
||||
case .None, .Crossfade:
|
||||
hasAnimation = false
|
||||
case let .System(duration):
|
||||
hasAnimation = true
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user