mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
ed8f1b35e9
commit
9d3cc5996b
@ -392,7 +392,10 @@ public class AttachmentController: ViewController {
|
||||
self.container.interactivelyDismissed = { [weak self] velocity in
|
||||
if let strongSelf = self, let layout = strongSelf.validLayout {
|
||||
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 initialVelocity: CGFloat = delta > 0.0 ? velocity / delta : 0.0
|
||||
|
||||
|
@ -26,6 +26,7 @@ swift_library(
|
||||
"//submodules/Components/MultilineTextComponent:MultilineTextComponent",
|
||||
"//submodules/Components/BundleIconComponent:BundleIconComponent",
|
||||
"//submodules/Components/BlurredBackgroundComponent:BlurredBackgroundComponent",
|
||||
"//submodules/TelegramUI/Components/MinimizedContainer",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -13,6 +13,7 @@ import BundleIconComponent
|
||||
import TelegramUIPreferences
|
||||
import OpenInExternalAppUI
|
||||
import MultilineTextComponent
|
||||
import MinimizedContainer
|
||||
|
||||
private let settingsTag = GenericComponentViewTag()
|
||||
|
||||
@ -291,6 +292,7 @@ public class BrowserScreen: ViewController {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.controller?.title = state.title
|
||||
strongSelf.contentState = state
|
||||
strongSelf.requestLayout(transition: .immediate)
|
||||
}).strict()
|
||||
@ -318,7 +320,7 @@ public class BrowserScreen: ViewController {
|
||||
}
|
||||
self.controller?.present(shareController, in: .window(.root))
|
||||
case .minimize:
|
||||
break
|
||||
self.minimize()
|
||||
case .openIn:
|
||||
self.context.sharedContext.applicationBindings.openUrl(url)
|
||||
case .openSettings:
|
||||
@ -441,6 +443,23 @@ public class BrowserScreen: ViewController {
|
||||
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() {
|
||||
guard let referenceView = self.componentHost.findTaggedView(tag: settingsTag) as? ReferenceButtonComponent.View else {
|
||||
return
|
||||
@ -535,7 +554,8 @@ public class BrowserScreen: ViewController {
|
||||
self.context.sharedContext.applicationBindings.openUrl(openInUrl)
|
||||
}
|
||||
action(.default)
|
||||
}))]
|
||||
}))
|
||||
]
|
||||
|
||||
let contextController = ContextController(presentationData: self.presentationData, source: source, items: .single(ContextController.Items(content: .list(items))))
|
||||
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)
|
||||
}))
|
||||
.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()
|
||||
})
|
||||
}))
|
||||
@ -224,12 +226,12 @@ final class NavigationToolbarContentComponent: CombinedComponent {
|
||||
component: Button(
|
||||
content: AnyComponent(
|
||||
BundleIconComponent(
|
||||
name: "Chat/Context Menu/Browser",
|
||||
name: "Instant View/Minimize",
|
||||
tintColor: context.component.textColor
|
||||
)
|
||||
),
|
||||
action: {
|
||||
performAction.invoke(.openIn)
|
||||
performAction.invoke(.minimize)
|
||||
}
|
||||
).minSize(buttonSize),
|
||||
availableSize: buttonSize,
|
||||
|
@ -1453,9 +1453,13 @@ private func debugControllerEntries(sharedContext: SharedAccountContext, present
|
||||
entries.append(.experimentalCompatibility(experimentalSettings.experimentalCompatibility))
|
||||
entries.append(.enableDebugDataDisplay(experimentalSettings.enableDebugDataDisplay))
|
||||
entries.append(.acceleratedStickers(experimentalSettings.acceleratedStickers))
|
||||
#if DEBUG
|
||||
entries.append(.browserExperiment(experimentalSettings.browserExperiment))
|
||||
#else
|
||||
if sharedContext.applicationBindings.appBuildType == .internal {
|
||||
entries.append(.browserExperiment(experimentalSettings.browserExperiment))
|
||||
}
|
||||
#endif
|
||||
entries.append(.localTranscription(experimentalSettings.localTranscription))
|
||||
if case .internal = sharedContext.applicationBindings.appBuildType {
|
||||
entries.append(.enableReactionOverrides(experimentalSettings.enableReactionOverrides))
|
||||
|
@ -4,11 +4,13 @@ import AsyncDisplayKit
|
||||
public protocol MinimizedContainer: ASDisplayNode {
|
||||
var navigationController: NavigationController? { get set }
|
||||
var controllers: [ViewController] { get }
|
||||
var isExpanded: Bool { get }
|
||||
|
||||
var willMaximize: (() -> Void)? { get set }
|
||||
|
||||
func addController(_ viewController: ViewController, transition: ContainedViewLayoutTransition)
|
||||
func maximizeController(_ viewController: ViewController, animated: Bool, completion: @escaping (Bool) -> Void)
|
||||
func collapse()
|
||||
func dismissAll(completion: @escaping () -> Void)
|
||||
|
||||
func updateLayout(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition)
|
||||
|
@ -1335,7 +1335,9 @@ open class NavigationController: UINavigationController, ContainableController,
|
||||
if let _ = self.inCallStatusBar {
|
||||
self.inCallNavigate?()
|
||||
} 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?()
|
||||
} else {
|
||||
switch rootContainer {
|
||||
|
@ -230,7 +230,7 @@ public protocol CustomViewControllerNavigationDataSummary: AnyObject {
|
||||
|
||||
private var navigationBarOrigin: CGFloat = 0.0
|
||||
|
||||
public var minimizedTopEdgeOffset: CGFloat = 0.0
|
||||
public var minimizedTopEdgeOffset: CGFloat?
|
||||
public var minimizedBounds: CGRect?
|
||||
open var isMinimized: Bool = false
|
||||
|
||||
|
@ -196,7 +196,7 @@ class IncreaseLimitHeaderItemNode: ListViewItemNode {
|
||||
badgeIconName: badgeIconName,
|
||||
badgeText: "\(item.count)",
|
||||
badgePosition: CGFloat(item.count) / CGFloat(item.premiumCount),
|
||||
badgeGraphPosition: CGFloat(item.count) / CGFloat(item.premiumCount),
|
||||
badgeGraphPosition: CGFloat(item.limit) / CGFloat(item.premiumCount),
|
||||
isPremiumDisabled: item.isPremiumDisabled
|
||||
))
|
||||
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] = []
|
||||
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
|
||||
}
|
||||
|
@ -212,7 +212,9 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
||||
topInset += 10.0
|
||||
}
|
||||
self.containerNode.frame = CGRect(origin: .zero, size: size)
|
||||
self.containerNode.subnodeTransform = CATransform3DMakeTranslation(0.0, -topInset, 0.0)
|
||||
if let _ = self.item.controller.minimizedTopEdgeOffset {
|
||||
self.containerNode.subnodeTransform = CATransform3DMakeTranslation(0.0, -topInset, 0.0)
|
||||
}
|
||||
|
||||
self.snapshotContainerView.frame = CGRect(origin: .zero, size: size)
|
||||
|
||||
@ -234,11 +236,15 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
||||
var requiresBlur = false
|
||||
var blurFrame = snapshotFrame
|
||||
if snapshotView.frame.width * 1.1 < size.width {
|
||||
snapshotFrame = snapshotFrame.offsetBy(dx: 0.0, dy: -66.0)
|
||||
if let _ = self.item.controller.minimizedTopEdgeOffset {
|
||||
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))
|
||||
requiresBlur = true
|
||||
} else if snapshotView.frame.width > size.width * 1.5 {
|
||||
snapshotFrame = snapshotFrame.offsetBy(dx: 0.0, dy: 66.0)
|
||||
if let _ = self.item.controller.minimizedTopEdgeOffset {
|
||||
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))
|
||||
requiresBlur = true
|
||||
}
|
||||
@ -282,7 +288,7 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
||||
private var presentationData: PresentationData
|
||||
private var presentationDataDisposable: Disposable?
|
||||
|
||||
var isExpanded: Bool = false
|
||||
public private(set) var isExpanded: Bool = false
|
||||
public var willMaximize: (() -> Void)?
|
||||
|
||||
private let bottomEdgeView: UIImageView
|
||||
@ -552,6 +558,12 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
||||
self.requestUpdate(transition: .animated(duration: 0.4, curve: .spring))
|
||||
}
|
||||
}
|
||||
|
||||
public func collapse() {
|
||||
self.isExpanded = false
|
||||
self.currentTransition = .collapse
|
||||
self.requestUpdate(transition: .animated(duration: 0.4, curve: .spring))
|
||||
}
|
||||
|
||||
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
guard self.isExpanded, let layout = self.validLayout else {
|
||||
@ -824,7 +836,10 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
||||
|
||||
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 {
|
||||
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] {
|
||||
var entries: [OldChannelsEntry] = []
|
||||
|
||||
let count = max(limit, Int32(peers?.count ?? 0))
|
||||
let count = max(isPremium ? premiumLimit : limit, Int32(peers?.count ?? 0))
|
||||
var text: String?
|
||||
if count >= premiumLimit {
|
||||
switch intent {
|
||||
@ -359,7 +359,7 @@ public func oldChannelsController(context: AccountContext, updatedPresentationDa
|
||||
}
|
||||
|
||||
let footerItem: IncreaseLimitFooterItem?
|
||||
if (state.isSearching || premiumConfiguration.isPremiumDisabled) && state.selectedPeers.count == 0 {
|
||||
if (state.isSearching || premiumConfiguration.isPremiumDisabled || isPremium) && state.selectedPeers.count == 0 {
|
||||
footerItem = nil
|
||||
} else {
|
||||
footerItem = IncreaseLimitFooterItem(theme: presentationData.theme, title: buttonText, colorful: colorful, action: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user