mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 09:20:08 +00:00
Various fixes
This commit is contained in:
parent
ed8f1b35e9
commit
9d3cc5996b
@ -392,7 +392,10 @@ public class AttachmentController: ViewController {
|
|||||||
self.container.interactivelyDismissed = { [weak self] velocity in
|
self.container.interactivelyDismissed = { [weak self] velocity in
|
||||||
if let strongSelf = self, let layout = strongSelf.validLayout {
|
if let strongSelf = self, let layout = strongSelf.validLayout {
|
||||||
if let controller = strongSelf.controller, controller.shouldMinimizeOnSwipe?(strongSelf.currentType) == true {
|
if let controller = strongSelf.controller, controller.shouldMinimizeOnSwipe?(strongSelf.currentType) == true {
|
||||||
let delta = layout.size.height - controller.minimizedTopEdgeOffset
|
var delta = layout.size.height
|
||||||
|
if let minimizedTopEdgeOffset = controller.minimizedTopEdgeOffset {
|
||||||
|
delta -= minimizedTopEdgeOffset
|
||||||
|
}
|
||||||
let damping: CGFloat = 180.0
|
let damping: CGFloat = 180.0
|
||||||
let initialVelocity: CGFloat = delta > 0.0 ? velocity / delta : 0.0
|
let initialVelocity: CGFloat = delta > 0.0 ? velocity / delta : 0.0
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,7 @@ swift_library(
|
|||||||
"//submodules/Components/MultilineTextComponent:MultilineTextComponent",
|
"//submodules/Components/MultilineTextComponent:MultilineTextComponent",
|
||||||
"//submodules/Components/BundleIconComponent:BundleIconComponent",
|
"//submodules/Components/BundleIconComponent:BundleIconComponent",
|
||||||
"//submodules/Components/BlurredBackgroundComponent:BlurredBackgroundComponent",
|
"//submodules/Components/BlurredBackgroundComponent:BlurredBackgroundComponent",
|
||||||
|
"//submodules/TelegramUI/Components/MinimizedContainer",
|
||||||
],
|
],
|
||||||
visibility = [
|
visibility = [
|
||||||
"//visibility:public",
|
"//visibility:public",
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import BundleIconComponent
|
|||||||
import TelegramUIPreferences
|
import TelegramUIPreferences
|
||||||
import OpenInExternalAppUI
|
import OpenInExternalAppUI
|
||||||
import MultilineTextComponent
|
import MultilineTextComponent
|
||||||
|
import MinimizedContainer
|
||||||
|
|
||||||
private let settingsTag = GenericComponentViewTag()
|
private let settingsTag = GenericComponentViewTag()
|
||||||
|
|
||||||
@ -291,6 +292,7 @@ public class BrowserScreen: ViewController {
|
|||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
strongSelf.controller?.title = state.title
|
||||||
strongSelf.contentState = state
|
strongSelf.contentState = state
|
||||||
strongSelf.requestLayout(transition: .immediate)
|
strongSelf.requestLayout(transition: .immediate)
|
||||||
}).strict()
|
}).strict()
|
||||||
@ -318,7 +320,7 @@ public class BrowserScreen: ViewController {
|
|||||||
}
|
}
|
||||||
self.controller?.present(shareController, in: .window(.root))
|
self.controller?.present(shareController, in: .window(.root))
|
||||||
case .minimize:
|
case .minimize:
|
||||||
break
|
self.minimize()
|
||||||
case .openIn:
|
case .openIn:
|
||||||
self.context.sharedContext.applicationBindings.openUrl(url)
|
self.context.sharedContext.applicationBindings.openUrl(url)
|
||||||
case .openSettings:
|
case .openSettings:
|
||||||
@ -441,6 +443,23 @@ public class BrowserScreen: ViewController {
|
|||||||
self.requestLayout(transition: animated ? .easeInOut(duration: 0.2) : .immediate)
|
self.requestLayout(transition: animated ? .easeInOut(duration: 0.2) : .immediate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func minimize() {
|
||||||
|
guard let controller = self.controller, let navigationController = controller.navigationController as? NavigationController else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
navigationController.minimizeViewController(controller, damping: nil, setupContainer: { [weak self] current in
|
||||||
|
let minimizedContainer: MinimizedContainerImpl?
|
||||||
|
if let current = current as? MinimizedContainerImpl {
|
||||||
|
minimizedContainer = current
|
||||||
|
} else if let context = self?.controller?.context {
|
||||||
|
minimizedContainer = MinimizedContainerImpl(sharedContext: context.sharedContext)
|
||||||
|
} else {
|
||||||
|
minimizedContainer = nil
|
||||||
|
}
|
||||||
|
return minimizedContainer
|
||||||
|
}, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
func openSettings() {
|
func openSettings() {
|
||||||
guard let referenceView = self.componentHost.findTaggedView(tag: settingsTag) as? ReferenceButtonComponent.View else {
|
guard let referenceView = self.componentHost.findTaggedView(tag: settingsTag) as? ReferenceButtonComponent.View else {
|
||||||
return
|
return
|
||||||
@ -535,7 +554,8 @@ public class BrowserScreen: ViewController {
|
|||||||
self.context.sharedContext.applicationBindings.openUrl(openInUrl)
|
self.context.sharedContext.applicationBindings.openUrl(openInUrl)
|
||||||
}
|
}
|
||||||
action(.default)
|
action(.default)
|
||||||
}))]
|
}))
|
||||||
|
]
|
||||||
|
|
||||||
let contextController = ContextController(presentationData: self.presentationData, source: source, items: .single(ContextController.Items(content: .list(items))))
|
let contextController = ContextController(presentationData: self.presentationData, source: source, items: .single(ContextController.Items(content: .list(items))))
|
||||||
self.controller?.present(contextController, in: .window(.root))
|
self.controller?.present(contextController, in: .window(.root))
|
||||||
|
|||||||
@ -104,7 +104,9 @@ final class BrowserToolbarComponent: CombinedComponent {
|
|||||||
transition.animatePosition(view: view, from: CGPoint(x: 0.0, y: size.height), to: .zero, additive: true)
|
transition.animatePosition(view: view, from: CGPoint(x: 0.0, y: size.height), to: .zero, additive: true)
|
||||||
}))
|
}))
|
||||||
.disappear(ComponentTransition.Disappear({ view, transition, completion in
|
.disappear(ComponentTransition.Disappear({ view, transition, completion in
|
||||||
transition.animatePosition(view: view, from: .zero, to: CGPoint(x: 0.0, y: size.height), additive: true, completion: { _ in
|
let from = view.center
|
||||||
|
view.center = from.offsetBy(dx: 0.0, dy: size.height)
|
||||||
|
transition.animatePosition(view: view, from: from, to: view.center, completion: { _ in
|
||||||
completion()
|
completion()
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
@ -224,12 +226,12 @@ final class NavigationToolbarContentComponent: CombinedComponent {
|
|||||||
component: Button(
|
component: Button(
|
||||||
content: AnyComponent(
|
content: AnyComponent(
|
||||||
BundleIconComponent(
|
BundleIconComponent(
|
||||||
name: "Chat/Context Menu/Browser",
|
name: "Instant View/Minimize",
|
||||||
tintColor: context.component.textColor
|
tintColor: context.component.textColor
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
action: {
|
action: {
|
||||||
performAction.invoke(.openIn)
|
performAction.invoke(.minimize)
|
||||||
}
|
}
|
||||||
).minSize(buttonSize),
|
).minSize(buttonSize),
|
||||||
availableSize: buttonSize,
|
availableSize: buttonSize,
|
||||||
|
|||||||
@ -1453,9 +1453,13 @@ private func debugControllerEntries(sharedContext: SharedAccountContext, present
|
|||||||
entries.append(.experimentalCompatibility(experimentalSettings.experimentalCompatibility))
|
entries.append(.experimentalCompatibility(experimentalSettings.experimentalCompatibility))
|
||||||
entries.append(.enableDebugDataDisplay(experimentalSettings.enableDebugDataDisplay))
|
entries.append(.enableDebugDataDisplay(experimentalSettings.enableDebugDataDisplay))
|
||||||
entries.append(.acceleratedStickers(experimentalSettings.acceleratedStickers))
|
entries.append(.acceleratedStickers(experimentalSettings.acceleratedStickers))
|
||||||
|
#if DEBUG
|
||||||
|
entries.append(.browserExperiment(experimentalSettings.browserExperiment))
|
||||||
|
#else
|
||||||
if sharedContext.applicationBindings.appBuildType == .internal {
|
if sharedContext.applicationBindings.appBuildType == .internal {
|
||||||
entries.append(.browserExperiment(experimentalSettings.browserExperiment))
|
entries.append(.browserExperiment(experimentalSettings.browserExperiment))
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
entries.append(.localTranscription(experimentalSettings.localTranscription))
|
entries.append(.localTranscription(experimentalSettings.localTranscription))
|
||||||
if case .internal = sharedContext.applicationBindings.appBuildType {
|
if case .internal = sharedContext.applicationBindings.appBuildType {
|
||||||
entries.append(.enableReactionOverrides(experimentalSettings.enableReactionOverrides))
|
entries.append(.enableReactionOverrides(experimentalSettings.enableReactionOverrides))
|
||||||
|
|||||||
@ -4,11 +4,13 @@ import AsyncDisplayKit
|
|||||||
public protocol MinimizedContainer: ASDisplayNode {
|
public protocol MinimizedContainer: ASDisplayNode {
|
||||||
var navigationController: NavigationController? { get set }
|
var navigationController: NavigationController? { get set }
|
||||||
var controllers: [ViewController] { get }
|
var controllers: [ViewController] { get }
|
||||||
|
var isExpanded: Bool { get }
|
||||||
|
|
||||||
var willMaximize: (() -> Void)? { get set }
|
var willMaximize: (() -> Void)? { get set }
|
||||||
|
|
||||||
func addController(_ viewController: ViewController, transition: ContainedViewLayoutTransition)
|
func addController(_ viewController: ViewController, transition: ContainedViewLayoutTransition)
|
||||||
func maximizeController(_ viewController: ViewController, animated: Bool, completion: @escaping (Bool) -> Void)
|
func maximizeController(_ viewController: ViewController, animated: Bool, completion: @escaping (Bool) -> Void)
|
||||||
|
func collapse()
|
||||||
func dismissAll(completion: @escaping () -> Void)
|
func dismissAll(completion: @escaping () -> Void)
|
||||||
|
|
||||||
func updateLayout(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition)
|
func updateLayout(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition)
|
||||||
|
|||||||
@ -1335,7 +1335,9 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||||||
if let _ = self.inCallStatusBar {
|
if let _ = self.inCallStatusBar {
|
||||||
self.inCallNavigate?()
|
self.inCallNavigate?()
|
||||||
} else if let rootContainer = self.rootContainer {
|
} else if let rootContainer = self.rootContainer {
|
||||||
if let modalContainer = self.modalContainers.last {
|
if let minimizedContainer = self.minimizedContainer, minimizedContainer.isExpanded {
|
||||||
|
minimizedContainer.collapse()
|
||||||
|
} else if let modalContainer = self.modalContainers.last {
|
||||||
modalContainer.container.controllers.last?.scrollToTop?()
|
modalContainer.container.controllers.last?.scrollToTop?()
|
||||||
} else {
|
} else {
|
||||||
switch rootContainer {
|
switch rootContainer {
|
||||||
|
|||||||
@ -230,7 +230,7 @@ public protocol CustomViewControllerNavigationDataSummary: AnyObject {
|
|||||||
|
|
||||||
private var navigationBarOrigin: CGFloat = 0.0
|
private var navigationBarOrigin: CGFloat = 0.0
|
||||||
|
|
||||||
public var minimizedTopEdgeOffset: CGFloat = 0.0
|
public var minimizedTopEdgeOffset: CGFloat?
|
||||||
public var minimizedBounds: CGRect?
|
public var minimizedBounds: CGRect?
|
||||||
open var isMinimized: Bool = false
|
open var isMinimized: Bool = false
|
||||||
|
|
||||||
|
|||||||
@ -196,7 +196,7 @@ class IncreaseLimitHeaderItemNode: ListViewItemNode {
|
|||||||
badgeIconName: badgeIconName,
|
badgeIconName: badgeIconName,
|
||||||
badgeText: "\(item.count)",
|
badgeText: "\(item.count)",
|
||||||
badgePosition: CGFloat(item.count) / CGFloat(item.premiumCount),
|
badgePosition: CGFloat(item.count) / CGFloat(item.premiumCount),
|
||||||
badgeGraphPosition: CGFloat(item.count) / CGFloat(item.premiumCount),
|
badgeGraphPosition: CGFloat(item.limit) / CGFloat(item.premiumCount),
|
||||||
isPremiumDisabled: item.isPremiumDisabled
|
isPremiumDisabled: item.isPremiumDisabled
|
||||||
))
|
))
|
||||||
let containerSize = CGSize(width: layout.size.width - params.leftInset - params.rightInset, height: 200.0)
|
let containerSize = CGSize(width: layout.size.width - params.leftInset - params.rightInset, height: 200.0)
|
||||||
|
|||||||
@ -41,7 +41,7 @@ func _internal_inactiveChannelList(network: Network) -> Signal<[InactiveChannel]
|
|||||||
}
|
}
|
||||||
var inactive: [InactiveChannel] = []
|
var inactive: [InactiveChannel] = []
|
||||||
for (i, channel) in channels.enumerated() {
|
for (i, channel) in channels.enumerated() {
|
||||||
inactive.append(InactiveChannel(peer: channel, lastActivityDate: dates[i], participantsCount: participantsCounts[channel.id]))
|
inactive.append(InactiveChannel(peer: channel, lastActivityDate: i < dates.count ? dates[i] : 0, participantsCount: participantsCounts[channel.id]))
|
||||||
}
|
}
|
||||||
return inactive
|
return inactive
|
||||||
}
|
}
|
||||||
|
|||||||
@ -212,7 +212,9 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
|||||||
topInset += 10.0
|
topInset += 10.0
|
||||||
}
|
}
|
||||||
self.containerNode.frame = CGRect(origin: .zero, size: size)
|
self.containerNode.frame = CGRect(origin: .zero, size: size)
|
||||||
|
if let _ = self.item.controller.minimizedTopEdgeOffset {
|
||||||
self.containerNode.subnodeTransform = CATransform3DMakeTranslation(0.0, -topInset, 0.0)
|
self.containerNode.subnodeTransform = CATransform3DMakeTranslation(0.0, -topInset, 0.0)
|
||||||
|
}
|
||||||
|
|
||||||
self.snapshotContainerView.frame = CGRect(origin: .zero, size: size)
|
self.snapshotContainerView.frame = CGRect(origin: .zero, size: size)
|
||||||
|
|
||||||
@ -234,11 +236,15 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
|||||||
var requiresBlur = false
|
var requiresBlur = false
|
||||||
var blurFrame = snapshotFrame
|
var blurFrame = snapshotFrame
|
||||||
if snapshotView.frame.width * 1.1 < size.width {
|
if snapshotView.frame.width * 1.1 < size.width {
|
||||||
|
if let _ = self.item.controller.minimizedTopEdgeOffset {
|
||||||
snapshotFrame = snapshotFrame.offsetBy(dx: 0.0, dy: -66.0)
|
snapshotFrame = snapshotFrame.offsetBy(dx: 0.0, dy: -66.0)
|
||||||
|
}
|
||||||
blurFrame = CGRect(origin: CGPoint(x: 0.0, y: snapshotFrame.minY), size: CGSize(width: size.width, height: snapshotFrame.height))
|
blurFrame = CGRect(origin: CGPoint(x: 0.0, y: snapshotFrame.minY), size: CGSize(width: size.width, height: snapshotFrame.height))
|
||||||
requiresBlur = true
|
requiresBlur = true
|
||||||
} else if snapshotView.frame.width > size.width * 1.5 {
|
} else if snapshotView.frame.width > size.width * 1.5 {
|
||||||
|
if let _ = self.item.controller.minimizedTopEdgeOffset {
|
||||||
snapshotFrame = snapshotFrame.offsetBy(dx: 0.0, dy: 66.0)
|
snapshotFrame = snapshotFrame.offsetBy(dx: 0.0, dy: 66.0)
|
||||||
|
}
|
||||||
blurFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((size.width - snapshotView.frame.width) / 2.0), y: snapshotFrame.minY), size: CGSize(width: snapshotFrame.width, height: size.height))
|
blurFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((size.width - snapshotView.frame.width) / 2.0), y: snapshotFrame.minY), size: CGSize(width: snapshotFrame.width, height: size.height))
|
||||||
requiresBlur = true
|
requiresBlur = true
|
||||||
}
|
}
|
||||||
@ -282,7 +288,7 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
|||||||
private var presentationData: PresentationData
|
private var presentationData: PresentationData
|
||||||
private var presentationDataDisposable: Disposable?
|
private var presentationDataDisposable: Disposable?
|
||||||
|
|
||||||
var isExpanded: Bool = false
|
public private(set) var isExpanded: Bool = false
|
||||||
public var willMaximize: (() -> Void)?
|
public var willMaximize: (() -> Void)?
|
||||||
|
|
||||||
private let bottomEdgeView: UIImageView
|
private let bottomEdgeView: UIImageView
|
||||||
@ -553,6 +559,12 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func collapse() {
|
||||||
|
self.isExpanded = false
|
||||||
|
self.currentTransition = .collapse
|
||||||
|
self.requestUpdate(transition: .animated(duration: 0.4, curve: .spring))
|
||||||
|
}
|
||||||
|
|
||||||
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||||
guard self.isExpanded, let layout = self.validLayout else {
|
guard self.isExpanded, let layout = self.validLayout else {
|
||||||
return
|
return
|
||||||
@ -824,7 +836,10 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
|||||||
|
|
||||||
itemNode.animateIn()
|
itemNode.animateIn()
|
||||||
|
|
||||||
var initialOffset = insets.top + itemNode.item.controller.minimizedTopEdgeOffset
|
var initialOffset = insets.top
|
||||||
|
if let minimizedTopEdgeOffset = itemNode.item.controller.minimizedTopEdgeOffset {
|
||||||
|
initialOffset += minimizedTopEdgeOffset
|
||||||
|
}
|
||||||
if layout.size.width < layout.size.height {
|
if layout.size.width < layout.size.height {
|
||||||
initialOffset += 10.0
|
initialOffset += 10.0
|
||||||
}
|
}
|
||||||
|
|||||||
@ -187,7 +187,7 @@ private struct OldChannelsState: Equatable {
|
|||||||
private func oldChannelsEntries(presentationData: PresentationData, state: OldChannelsState, isPremium: Bool, isPremiumDisabled: Bool, limit: Int32, premiumLimit: Int32, peers: [InactiveChannel]?, intent: OldChannelsControllerIntent) -> [OldChannelsEntry] {
|
private func oldChannelsEntries(presentationData: PresentationData, state: OldChannelsState, isPremium: Bool, isPremiumDisabled: Bool, limit: Int32, premiumLimit: Int32, peers: [InactiveChannel]?, intent: OldChannelsControllerIntent) -> [OldChannelsEntry] {
|
||||||
var entries: [OldChannelsEntry] = []
|
var entries: [OldChannelsEntry] = []
|
||||||
|
|
||||||
let count = max(limit, Int32(peers?.count ?? 0))
|
let count = max(isPremium ? premiumLimit : limit, Int32(peers?.count ?? 0))
|
||||||
var text: String?
|
var text: String?
|
||||||
if count >= premiumLimit {
|
if count >= premiumLimit {
|
||||||
switch intent {
|
switch intent {
|
||||||
@ -359,7 +359,7 @@ public func oldChannelsController(context: AccountContext, updatedPresentationDa
|
|||||||
}
|
}
|
||||||
|
|
||||||
let footerItem: IncreaseLimitFooterItem?
|
let footerItem: IncreaseLimitFooterItem?
|
||||||
if (state.isSearching || premiumConfiguration.isPremiumDisabled) && state.selectedPeers.count == 0 {
|
if (state.isSearching || premiumConfiguration.isPremiumDisabled || isPremium) && state.selectedPeers.count == 0 {
|
||||||
footerItem = nil
|
footerItem = nil
|
||||||
} else {
|
} else {
|
||||||
footerItem = IncreaseLimitFooterItem(theme: presentationData.theme, title: buttonText, colorful: colorful, action: {
|
footerItem = IncreaseLimitFooterItem(theme: presentationData.theme, title: buttonText, colorful: colorful, action: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user