Various improvements

This commit is contained in:
Ilya Laktyushin 2025-08-27 23:47:26 +04:00
parent eb8464f687
commit effaa875a6
5 changed files with 30 additions and 14 deletions

View File

@ -65,6 +65,7 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
public let clipsContent: Bool public let clipsContent: Bool
public let isScrollEnabled: Bool public let isScrollEnabled: Bool
public let hasDimView: Bool public let hasDimView: Bool
public let autoAnimateOut: Bool
public let externalState: ExternalState? public let externalState: ExternalState?
public let animateOut: ActionSlot<Action<()>> public let animateOut: ActionSlot<Action<()>>
public let onPan: () -> Void public let onPan: () -> Void
@ -77,6 +78,7 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
clipsContent: Bool = false, clipsContent: Bool = false,
isScrollEnabled: Bool = true, isScrollEnabled: Bool = true,
hasDimView: Bool = true, hasDimView: Bool = true,
autoAnimateOut: Bool = true,
externalState: ExternalState? = nil, externalState: ExternalState? = nil,
animateOut: ActionSlot<Action<()>>, animateOut: ActionSlot<Action<()>>,
onPan: @escaping () -> Void = {}, onPan: @escaping () -> Void = {},
@ -88,6 +90,7 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
self.clipsContent = clipsContent self.clipsContent = clipsContent
self.isScrollEnabled = isScrollEnabled self.isScrollEnabled = isScrollEnabled
self.hasDimView = hasDimView self.hasDimView = hasDimView
self.autoAnimateOut = autoAnimateOut
self.externalState = externalState self.externalState = externalState
self.animateOut = animateOut self.animateOut = animateOut
self.onPan = onPan self.onPan = onPan
@ -110,6 +113,9 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
if lhs.hasDimView != rhs.hasDimView { if lhs.hasDimView != rhs.hasDimView {
return false return false
} }
if lhs.autoAnimateOut != rhs.autoAnimateOut {
return false
}
if lhs.animateOut != rhs.animateOut { if lhs.animateOut != rhs.animateOut {
return false return false
} }
@ -430,9 +436,15 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
if environment[SheetComponentEnvironment.self].value.isDisplaying, !self.previousIsDisplaying, let _ = transition.userData(ViewControllerComponentContainer.AnimateInTransition.self) { if environment[SheetComponentEnvironment.self].value.isDisplaying, !self.previousIsDisplaying, let _ = transition.userData(ViewControllerComponentContainer.AnimateInTransition.self) {
self.animateIn() self.animateIn()
} else if !environment[SheetComponentEnvironment.self].value.isDisplaying, self.previousIsDisplaying, let _ = transition.userData(ViewControllerComponentContainer.AnimateOutTransition.self) { } else if !environment[SheetComponentEnvironment.self].value.isDisplaying, self.previousIsDisplaying, let _ = transition.userData(ViewControllerComponentContainer.AnimateOutTransition.self) {
self.animateOut(completion: {}) if component.autoAnimateOut {
self.animateOut(completion: {})
}
}
if !sheetEnvironment.isDisplaying && !component.autoAnimateOut {
} else {
self.previousIsDisplaying = sheetEnvironment.isDisplaying
} }
self.previousIsDisplaying = sheetEnvironment.isDisplaying
self.dismiss = sheetEnvironment.dismiss self.dismiss = sheetEnvironment.dismiss
return availableSize return availableSize

View File

@ -1379,6 +1379,7 @@ private final class ProfileGiftsContextImpl {
private var sorting: ProfileGiftsContext.Sorting private var sorting: ProfileGiftsContext.Sorting
private var filter: ProfileGiftsContext.Filters private var filter: ProfileGiftsContext.Filters
private var limit: Int32
private var gifts: [ProfileGiftsContext.State.StarGift] = [] private var gifts: [ProfileGiftsContext.State.StarGift] = []
private var count: Int32? private var count: Int32?
@ -1402,7 +1403,8 @@ private final class ProfileGiftsContextImpl {
peerId: EnginePeer.Id, peerId: EnginePeer.Id,
collectionId: Int32?, collectionId: Int32?,
sorting: ProfileGiftsContext.Sorting, sorting: ProfileGiftsContext.Sorting,
filter: ProfileGiftsContext.Filters filter: ProfileGiftsContext.Filters,
limit: Int32
) { ) {
self.queue = queue self.queue = queue
self.account = account self.account = account
@ -1410,6 +1412,7 @@ private final class ProfileGiftsContextImpl {
self.collectionId = collectionId self.collectionId = collectionId
self.sorting = sorting self.sorting = sorting
self.filter = filter self.filter = filter
self.limit = limit
self.loadMore() self.loadMore()
} }
@ -2420,14 +2423,15 @@ public final class ProfileGiftsContext {
peerId: EnginePeer.Id, peerId: EnginePeer.Id,
collectionId: Int32? = nil, collectionId: Int32? = nil,
sorting: ProfileGiftsContext.Sorting = .date, sorting: ProfileGiftsContext.Sorting = .date,
filter: ProfileGiftsContext.Filters = .All filter: ProfileGiftsContext.Filters = .All,
limit: Int32 = 36
) { ) {
self.peerId = peerId self.peerId = peerId
self.collectionId = collectionId self.collectionId = collectionId
let queue = self.queue let queue = self.queue
self.impl = QueueLocalObject(queue: queue, generate: { self.impl = QueueLocalObject(queue: queue, generate: {
return ProfileGiftsContextImpl(queue: queue, account: account, peerId: peerId, collectionId: collectionId, sorting: sorting, filter: filter) return ProfileGiftsContextImpl(queue: queue, account: account, peerId: peerId, collectionId: collectionId, sorting: sorting, filter: filter, limit: limit)
}) })
} }
@ -3009,6 +3013,7 @@ private final class ResaleGiftsContextImpl {
let network = self.account.network let network = self.account.network
let postbox = self.account.postbox let postbox = self.account.postbox
let sorting = self.sorting let sorting = self.sorting
let limit = self.limit
let filterAttributes = self.filterAttributes let filterAttributes = self.filterAttributes
let currentAttributesHash = self.attributesHash let currentAttributesHash = self.attributesHash
@ -3048,7 +3053,7 @@ private final class ResaleGiftsContextImpl {
let attributesHash = currentAttributesHash ?? 0 let attributesHash = currentAttributesHash ?? 0
flags |= (1 << 0) flags |= (1 << 0)
let signal = network.request(Api.functions.payments.getResaleStarGifts(flags: flags, attributesHash: attributesHash, giftId: giftId, attributes: apiAttributes, offset: initialNextOffset ?? "", limit: 36)) let signal = network.request(Api.functions.payments.getResaleStarGifts(flags: flags, attributesHash: attributesHash, giftId: giftId, attributes: apiAttributes, offset: initialNextOffset ?? "", limit: limit))
|> map(Optional.init) |> map(Optional.init)
|> `catch` { _ -> Signal<Api.payments.ResaleStarGifts?, NoError> in |> `catch` { _ -> Signal<Api.payments.ResaleStarGifts?, NoError> in
return .single(nil) return .single(nil)

View File

@ -149,10 +149,6 @@ private final class GiftValueSheetContent: CombinedComponent {
gift: gift gift: gift
) )
controller.push(storeController) controller.push(storeController)
Queue.mainQueue().after(2.0, {
controller.dismiss(animated: false)
})
} }
func openGiftFragmentResale(url: String) { func openGiftFragmentResale(url: String) {
@ -721,6 +717,7 @@ final class GiftValueSheetComponent: CombinedComponent {
backgroundColor: .color(environment.theme.actionSheet.opaqueItemBackgroundColor), backgroundColor: .color(environment.theme.actionSheet.opaqueItemBackgroundColor),
followContentSizeChanges: true, followContentSizeChanges: true,
clipsContent: true, clipsContent: true,
autoAnimateOut: false,
externalState: sheetExternalState, externalState: sheetExternalState,
animateOut: animateOut, animateOut: animateOut,
onPan: { onPan: {

View File

@ -676,7 +676,9 @@ private final class GiftViewSheetContent: CombinedComponent {
guard let self else { guard let self else {
return return
} }
self.isOpeningValue = false Queue.mainQueue().after(0.2) {
self.isOpeningValue = false
}
if let valueInfo { if let valueInfo {
let valueController = GiftValueScreen(context: self.context, gift: gift, valueInfo: valueInfo) let valueController = GiftValueScreen(context: self.context, gift: gift, valueInfo: valueInfo)
controller.push(valueController) controller.push(valueController)
@ -4545,8 +4547,8 @@ public class GiftViewScreen: ViewControllerComponentContainer {
self.navigationPresentation = .flatModal self.navigationPresentation = .flatModal
self.automaticallyControlPresentationContextLayout = false self.automaticallyControlPresentationContextLayout = false
if "".isEmpty { if let gift = subject.arguments?.gift, case .generic = gift {
let upgradableGiftsContext = ProfileGiftsContext(account: context.account, peerId: context.account.peerId, collectionId: nil, sorting: .date, filter: [.displayed, .hidden, .limitedUpgradable]) let upgradableGiftsContext = ProfileGiftsContext(account: context.account, peerId: context.account.peerId, collectionId: nil, sorting: .date, filter: [.displayed, .hidden, .limitedUpgradable], limit: 50)
self.upgradableDisposable = (upgradableGiftsContext.state self.upgradableDisposable = (upgradableGiftsContext.state
|> deliverOnMainQueue).start(next: { [weak self] state in |> deliverOnMainQueue).start(next: { [weak self] state in
guard let self else { guard let self else {

View File

@ -2053,7 +2053,7 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
} }
var isSuspiciousPeer = false var isSuspiciousPeer = false
if let cachedUserData = data.cachedData as? CachedUserData, let peerStatusSettings = cachedUserData.peerStatusSettings, peerStatusSettings.flags.contains(.canBlock) { if let cachedUserData = data.cachedData as? CachedUserData, let peerStatusSettings = cachedUserData.peerStatusSettings, peerStatusSettings.flags.contains(.canBlock) || peerStatusSettings.flags.contains(.canReport) {
isSuspiciousPeer = true isSuspiciousPeer = true
} }