diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 42e365f7d1..8a502a8149 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -12702,6 +12702,7 @@ Sorry for the inconvenience."; "Stars.Transaction.Subscription.JoinChannel" = "Join Channel"; "Stars.Transaction.Subscription.JoinAgainChannel" = "Join Channel"; "Stars.Transaction.Subscription.LeftChannel" = "You left channel but you can still get back until %@"; +"Stars.Transaction.Subscription.Expired" = "Your subscription expired on %@."; "Stars.Transaction.Subscription.PerMonth" = "%@ / month"; "Stars.Transaction.Subscription.PerMonthUsd" = "appx. %@ per month"; "Stars.Transaction.Subscription.Subscription" = "Subscription"; @@ -12724,6 +12725,7 @@ Sorry for the inconvenience."; "Stars.Intro.Subscriptions.Expires" = "expires on %@"; "Stars.Intro.Subscriptions.Expired" = "expired on %@"; "Stars.Intro.Subscriptions.Cancelled" = "cancelled"; +"Stars.Intro.Subscriptions.ExpiredStatus" = "expired"; "Stars.Intro.Subscriptions.ShowMore" = "Show More"; "Stars.Intro.Transaction.SubscriptionFee.Title" = "Monthly Subscription Fee"; diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionScreen/Sources/StarsTransactionScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionScreen/Sources/StarsTransactionScreen.swift index dc6825564e..0849afdcad 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionScreen/Sources/StarsTransactionScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionScreen/Sources/StarsTransactionScreen.swift @@ -260,6 +260,7 @@ private final class StarsTransactionSheetContent: CombinedComponent { } } else { if date < Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970) { + statusText = strings.Stars_Transaction_Subscription_Expired(stringForMediumDate(timestamp: subscription.untilDate, strings: strings, dateTimeFormat: dateTimeFormat, withTime: false)).string buttonText = strings.Stars_Transaction_Subscription_Renew } else { statusText = strings.Stars_Transaction_Subscription_LeftChannel(stringForMediumDate(timestamp: subscription.untilDate, strings: strings, dateTimeFormat: dateTimeFormat, withTime: false)).string @@ -1135,7 +1136,7 @@ public class StarsTransactionScreen: ViewControllerComponentContainer { theme: forceDark ? .dark : .default ) - self.navigationPresentation = .standaloneModal + self.navigationPresentation = .flatModal self.automaticallyControlPresentationContextLayout = false openPeerImpl = { [weak self] peer in diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift index 5fe5a816ae..7b654761cd 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift @@ -323,10 +323,15 @@ final class StarsTransactionsScreenComponent: Component { guard let self else { return } - self.subscriptionsState = state + let isFirstTime = self.subscriptionsState == nil + if !state.subscriptions.isEmpty { + self.subscriptionsState = state + } else { + self.subscriptionsState = nil + } if !self.isUpdating { - self.state?.updated() + self.state?.updated(transition: isFirstTime ? .immediate : .spring(duration: 0.4)) } }) } @@ -628,14 +633,18 @@ final class StarsTransactionsScreenComponent: Component { ) let dateText: String let dateValue = stringForDateWithoutYear(date: Date(timeIntervalSince1970: Double(subscription.untilDate)), strings: environment.strings) - if subscription.flags.contains(.isCancelled) { - if subscription.untilDate > Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970) { + var isExpired = false + if subscription.untilDate > Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970) { + if subscription.flags.contains(.isCancelled) { dateText = environment.strings.Stars_Intro_Subscriptions_Expires(dateValue).string } else { - dateText = environment.strings.Stars_Intro_Subscriptions_Expired(dateValue).string + dateText = environment.strings.Stars_Intro_Subscriptions_Renews(dateValue).string } } else { - dateText = environment.strings.Stars_Intro_Subscriptions_Renews(dateValue).string + dateText = environment.strings.Stars_Intro_Subscriptions_Expired(dateValue).string + if !subscription.flags.contains(.isCancelled) { + isExpired = true + } } titleComponents.append( AnyComponentWithIdentity(id: AnyHashable(1), component: AnyComponent(MultilineTextComponent( @@ -648,9 +657,9 @@ final class StarsTransactionsScreenComponent: Component { ))) ) let labelComponent: AnyComponentWithIdentity - if subscription.flags.contains(.isCancelled) { + if subscription.flags.contains(.isCancelled) || isExpired { labelComponent = AnyComponentWithIdentity(id: "cancelledLabel", component: AnyComponent( - MultilineTextComponent(text: .plain(NSAttributedString(string: environment.strings.Stars_Intro_Subscriptions_Cancelled, font: Font.regular(floor(fontBaseDisplaySize * 13.0 / 17.0)), textColor: environment.theme.list.itemDestructiveColor))) + MultilineTextComponent(text: .plain(NSAttributedString(string: isExpired ? environment.strings.Stars_Intro_Subscriptions_ExpiredStatus : environment.strings.Stars_Intro_Subscriptions_Cancelled, font: Font.regular(floor(fontBaseDisplaySize * 13.0 / 17.0)), textColor: environment.theme.list.itemDestructiveColor))) )) } else { let itemLabel = NSAttributedString(string: "\(subscription.pricing.amount)", font: Font.medium(fontBaseDisplaySize), textColor: environment.theme.list.itemPrimaryTextColor) @@ -710,6 +719,7 @@ final class StarsTransactionsScreenComponent: Component { } else { self.subscriptionsExpanded = true } + self.state?.updated(transition: .spring(duration: 0.4)) component.subscriptionsContext.loadMore() }, highlighting: .default, @@ -723,7 +733,7 @@ final class StarsTransactionsScreenComponent: Component { if !subscriptionsItems.isEmpty { let subscriptionsSize = self.subscriptionsView.update( - transition: .immediate, + transition: transition, component: AnyComponent(ListSectionComponent( theme: environment.theme, header: AnyComponent(MultilineTextComponent( @@ -956,7 +966,22 @@ public final class StarsTransactionsScreen: ViewControllerComponentContainer { guard let self else { return } - self.subscriptionsContext.updateSubscription(id: subscription.id, cancel: cancel) + if subscription.untilDate > Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970) { + if let channel = subscription.peer._asPeer() as? TelegramChannel, channel.participationStatus == .left { + let _ = self.context.engine.payments.fulfillStarsSubscription(peerId: context.account.peerId, subscriptionId: subscription.id).startStandalone() + if subscription.flags.contains(.isCancelled) { + self.subscriptionsContext.updateSubscription(id: subscription.id, cancel: false) + } + } else { + if !subscription.flags.contains(.isCancelled) { + self.subscriptionsContext.updateSubscription(id: subscription.id, cancel: true) + } + } + } else { + if let inviteHash = subscription.inviteHash { + self.context.sharedContext.openResolvedUrl(.join(inviteHash), context: self.context, urlContext: .generic, navigationController: self.navigationController as? NavigationController, forceExternal: false, openPeer: { _, _ in }, sendFile: nil, sendSticker: nil, sendEmoji: nil, requestMessageActionUrlAuth: nil, joinVoiceChat: nil, present: { _, _ in }, dismissInput: {}, contentContext: nil, progress: Promise(), completion: nil) + } + } }) self.push(controller) } diff --git a/submodules/TelegramUI/Components/Stars/StarsTransferScreen/Sources/StarsTransferScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransferScreen/Sources/StarsTransferScreen.swift index 6c04340737..44b575595d 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransferScreen/Sources/StarsTransferScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransferScreen/Sources/StarsTransferScreen.swift @@ -800,7 +800,7 @@ public final class StarsTransferScreen: ViewControllerComponentContainer { theme: .default ) - self.navigationPresentation = .standaloneModal + self.navigationPresentation = .flatModal starsContext.load(force: false) } diff --git a/submodules/TelegramUI/Components/Stars/StarsWithdrawalScreen/Sources/StarsWithdrawalScreen.swift b/submodules/TelegramUI/Components/Stars/StarsWithdrawalScreen/Sources/StarsWithdrawalScreen.swift index ac660de671..7a03e2b91c 100644 --- a/submodules/TelegramUI/Components/Stars/StarsWithdrawalScreen/Sources/StarsWithdrawalScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsWithdrawalScreen/Sources/StarsWithdrawalScreen.swift @@ -524,7 +524,7 @@ public final class StarsWithdrawScreen: ViewControllerComponentContainer { theme: .default ) - self.navigationPresentation = .standaloneModal + self.navigationPresentation = .flatModal } required public init(coder aDecoder: NSCoder) {