Various improvements

This commit is contained in:
Ilya Laktyushin 2022-06-07 16:08:46 +04:00
parent 57e7e6906b
commit 1084abaac0
3 changed files with 25 additions and 9 deletions

View File

@ -1392,6 +1392,8 @@ public func channelVisibilityController(context: AccountContext, updatedPresenta
}
}
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 })
let presentationData = updatedPresentationData?.signal ?? context.sharedContext.presentationData
let signal = combineLatest(
presentationData,
@ -1417,10 +1419,12 @@ public func channelVisibilityController(context: AccountContext, updatedPresenta
var rightNavigationButton: ItemListNavigationButton?
if case .revokeNames = mode {
if !premiumConfiguration.isPremiumDisabled {
footerItem = IncreaseLimitFooterItem(theme: presentationData.theme, title: presentationData.strings.Premium_IncreaseLimit, colorful: true, action: {
let controller = PremiumIntroScreen(context: context, source: .publicLinks)
pushControllerImpl?(controller)
})
}
} else {
if let peer = peer as? TelegramChannel {
var doneEnabled = true
@ -1692,7 +1696,6 @@ public func channelVisibilityController(context: AccountContext, updatedPresenta
title = presentationData.strings.Premium_LimitReached
}
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 })
let entries = channelVisibilityControllerEntries(presentationData: presentationData, mode: mode, view: view, publicChannelsToRevoke: publicChannelsToRevoke, importers: importers, state: state, limits: limits, premiumLimits: premiumLimits, isPremium: isPremium, isPremiumDisabled: premiumConfiguration.isPremiumDisabled)
var focusItemTag: ItemListItemTag?

View File

@ -114,7 +114,7 @@ class IncreaseLimitHeaderItemNode: ListViewItemNode {
self.view.addSubview(hostView)
if let (component, containerSize, layout, textSize) = self.params {
let size = hostView.update(
var size = hostView.update(
transition: .immediate,
component: component,
environment: {},
@ -122,6 +122,10 @@ class IncreaseLimitHeaderItemNode: ListViewItemNode {
)
hostView.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((layout.size.width - size.width) / 2.0), y: -30.0), size: size)
if let item = self.item, item.isPremiumDisabled {
size.height -= 54.0
}
let textSpacing: CGFloat = -6.0
self.textNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((layout.size.width - textSize.width) / 2.0), y: size.height + textSpacing), size: textSize)
}
@ -144,7 +148,11 @@ class IncreaseLimitHeaderItemNode: ListViewItemNode {
let (textLayout, textApply) = makeTextLayout(TextNodeLayoutArguments(attributedString: attributedText, backgroundColor: nil, maximumNumberOfLines: 0, truncationType: .end, constrainedSize: CGSize(width: params.width - params.leftInset - params.rightInset - 20.0, height: CGFloat.greatestFiniteMagnitude), alignment: .center, lineSpacing: 0.1, cutout: nil, insets: UIEdgeInsets()))
let contentSize = CGSize(width: params.width, height: topInset + badgeHeight + textSpacing + textLayout.size.height + bottomInset)
var contentSize = CGSize(width: params.width, height: topInset + badgeHeight + textSpacing + textLayout.size.height + bottomInset)
if item.isPremiumDisabled {
contentSize.height -= 54.0
}
let insets = itemListNeighborsGroupedInsets(neighbors, params)
let layout = ListViewItemNodeLayout(contentSize: contentSize, insets: insets)
@ -196,12 +204,15 @@ class IncreaseLimitHeaderItemNode: ListViewItemNode {
let _ = textApply()
if let hostView = strongSelf.hostView {
let size = hostView.update(
var size = hostView.update(
transition: .immediate,
component: component,
environment: {},
containerSize: containerSize
)
if item.isPremiumDisabled {
size.height -= 54.0
}
hostView.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((layout.size.width - size.width) / 2.0), y: -30.0), size: size)
strongSelf.textNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((layout.size.width - textLayout.size.width) / 2.0), y: size.height + textSpacing), size: textLayout.size)
}

View File

@ -279,6 +279,8 @@ public func oldChannelsController(context: AccountContext, updatedPresentationDa
var previousPeersWereEmpty = true
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 })
let presentationData = updatedPresentationData?.signal ?? context.sharedContext.presentationData
let signal = combineLatest(
queue: Queue.mainQueue(),
@ -337,7 +339,7 @@ public func oldChannelsController(context: AccountContext, updatedPresentationDa
}
let footerItem: IncreaseLimitFooterItem?
if state.isSearching && state.selectedPeers.count == 0 {
if (state.isSearching || premiumConfiguration.isPremiumDisabled) && state.selectedPeers.count == 0 {
footerItem = nil
} else {
footerItem = IncreaseLimitFooterItem(theme: presentationData.theme, title: buttonText, colorful: colorful, action: {