From 8a46bdffce88e172d748b7c5d283a8129595591d Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Mon, 17 Nov 2025 21:49:36 +0400 Subject: [PATCH 1/2] Various improvements --- .../AccountContext/Sources/Premium.swift | 4 +++ .../LoginEmailSetupController.swift | 1 + .../Sources/GiftSetupScreen.swift | 3 +- .../Sources/GiftAuctionBidScreen.swift | 30 +++++++++++++++++-- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/submodules/AccountContext/Sources/Premium.swift b/submodules/AccountContext/Sources/Premium.swift index 47e50d3b10..a97e750a4f 100644 --- a/submodules/AccountContext/Sources/Premium.swift +++ b/submodules/AccountContext/Sources/Premium.swift @@ -347,3 +347,7 @@ public struct AccountFreezeConfiguration { public protocol GiftOptionsScreenProtocol { } + +public protocol GiftSetupScreenProtocol { + +} diff --git a/submodules/SettingsUI/Sources/Privacy and Security/LoginEmailSetupController.swift b/submodules/SettingsUI/Sources/Privacy and Security/LoginEmailSetupController.swift index 4665aade46..45cb19e099 100644 --- a/submodules/SettingsUI/Sources/Privacy and Security/LoginEmailSetupController.swift +++ b/submodules/SettingsUI/Sources/Privacy and Security/LoginEmailSetupController.swift @@ -212,6 +212,7 @@ public func loginEmailSetupController(context: AccountContext, blocking: Bool, e } dismissEmailControllerImpl = { [weak emailController] in + dismiss() emailController?.dismiss() } return emailController diff --git a/submodules/TelegramUI/Components/Gifts/GiftSetupScreen/Sources/GiftSetupScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftSetupScreen/Sources/GiftSetupScreen.swift index 1a22c8d6c0..5adbd507c2 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftSetupScreen/Sources/GiftSetupScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftSetupScreen/Sources/GiftSetupScreen.swift @@ -584,7 +584,6 @@ private final class GiftSetupScreenComponent: Component { } navigationController.setViewControllers(controllers, animated: true) - if case let .starGift(starGift, _) = component.subject, let perUserLimit = starGift.perUserLimit { Queue.mainQueue().after(0.5) { let remains = max(0, perUserLimit.remains - 1) @@ -2019,7 +2018,7 @@ private final class GiftSetupScreenComponent: Component { } } -public class GiftSetupScreen: ViewControllerComponentContainer { +public class GiftSetupScreen: ViewControllerComponentContainer, GiftSetupScreenProtocol { public enum Subject: Equatable { case premium(PremiumGiftProduct) case starGift(StarGift.Gift, Bool?) diff --git a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionBidScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionBidScreen.swift index 6beee060f3..c3eeab41f6 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionBidScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionBidScreen.swift @@ -1635,7 +1635,9 @@ private final class GiftAuctionBidScreenComponent: Component { customUndoText: nil ), position: .bottom, - action: { _ in return true } + action: { _ in + return true + } ), in: .current ) @@ -2018,8 +2020,30 @@ private final class GiftAuctionBidScreenComponent: Component { self.loadAcquiredGifts() } if !isFirstTime { - self.resetSliderValue() - self.addSubview(ConfettiView(frame: self.bounds)) + if let bidPeerId = previousState?.myState.bidPeerId, let controller = self.environment?.controller() { + if let navigationController = controller.navigationController as? NavigationController { + var controllers = navigationController.viewControllers + controllers = controllers.filter { !($0 is GiftAuctionBidScreen) && !($0 is GiftSetupScreenProtocol) && !($0 is GiftOptionsScreenProtocol) && !($0 is PeerInfoScreen) && !($0 is ContactSelectionController) } + + var foundController = false + for controller in controllers.reversed() { + if let chatController = controller as? ChatController, case .peer(id: bidPeerId) = chatController.chatLocation { + chatController.hintPlayNextOutgoingGift() + foundController = true + break + } + } + if !foundController { + let chatController = component.context.sharedContext.makeChatController(context: component.context, chatLocation: .peer(id: bidPeerId), subject: nil, botStart: nil, mode: .standard(.default), params: nil) + chatController.hintPlayNextOutgoingGift() + controllers.append(chatController) + } + navigationController.setViewControllers(controllers, animated: true) + } + } else { + self.resetSliderValue() + self.addSubview(ConfettiView(frame: self.bounds)) + } } } From 183bc34f79dd0a782f5807fd8f0b6f70b870ed9f Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 18 Nov 2025 17:13:27 +0400 Subject: [PATCH 2/2] Various fixes --- .../Sources/PremiumIntroScreen.swift | 1 + .../Sources/CreateLinkScreen.swift | 62 ++++++++++-------- .../Sources/StarsWithdrawalScreen.swift | 64 +++++++------------ 3 files changed, 61 insertions(+), 66 deletions(-) diff --git a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift index 4cdd3c3c78..1327b3be18 100644 --- a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift @@ -2047,6 +2047,7 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent { subtitle = environment.strings.Premium_PricePerYear(subtitle).string accessibilitySubtitle = environment.strings.Premium_PricePerYear(accessibilitySubtitle).string } + subtitle = "\(environment.strings.Gift_Options_Premium_Months(product.months)) • \(product.price)" } else { subtitle = product.price } diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/CreateLinkScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/CreateLinkScreen.swift index 8b64da17ae..d3d015aca5 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/CreateLinkScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/CreateLinkScreen.swift @@ -21,6 +21,7 @@ import ListSectionComponent import TelegramStringFormatting import MediaEditor import UrlEscaping +import GlassBarButtonComponent private let linkTag = GenericComponentViewTag() private let nameTag = GenericComponentViewTag() @@ -69,8 +70,8 @@ private final class SheetContent: CombinedComponent { static var body: Body { let background = Child(RoundedRectangle.self) - let cancelButton = Child(Button.self) - let doneButton = Child(Button.self) + let cancelButton = Child(GlassBarButtonComponent.self) + let doneButton = Child(GlassBarButtonComponent.self) let title = Child(Text.self) let urlSection = Child(ListSectionComponent.self) let nameSection = Child(ListSectionComponent.self) @@ -85,7 +86,7 @@ private final class SheetContent: CombinedComponent { let presentationData = component.context.sharedContext.currentPresentationData.with { $0 } let sideInset: CGFloat = 16.0 - var contentSize = CGSize(width: context.availableSize.width, height: 18.0) + var contentSize = CGSize(width: context.availableSize.width, height: 36.0) let background = background.update( component: RoundedRectangle(color: theme.list.blocksBackgroundColor, cornerRadius: 8.0), @@ -98,16 +99,20 @@ private final class SheetContent: CombinedComponent { let constrainedTitleWidth = context.availableSize.width - 16.0 * 2.0 + let barButtonSize = CGSize(width: 40.0, height: 40.0) let cancelButton = cancelButton.update( - component: Button( - content: AnyComponent( - Text( - text: strings.Common_Cancel, - font: Font.regular(17.0), - color: theme.actionSheet.controlAccentColor + component: GlassBarButtonComponent( + size: barButtonSize, + backgroundColor: theme.rootController.navigationBar.glassBarButtonBackgroundColor, + isDark: theme.overallDarkAppearance, + state: .generic, + component: AnyComponentWithIdentity(id: "close", component: AnyComponent( + BundleIconComponent( + name: "Navigation/Close", + tintColor: theme.rootController.navigationBar.glassBarButtonForegroundColor ) - ), - action: { + )), + action: { _ in component.dismiss() } ), @@ -115,7 +120,7 @@ private final class SheetContent: CombinedComponent { transition: .immediate ) context.add(cancelButton - .position(CGPoint(x: sideInset + cancelButton.size.width / 2.0, y: contentSize.height + cancelButton.size.height / 2.0)) + .position(CGPoint(x: sideInset + cancelButton.size.width / 2.0, y: 16.0 + cancelButton.size.height / 2.0)) ) let explicitLink = explicitUrl(context.component.link) @@ -126,16 +131,19 @@ private final class SheetContent: CombinedComponent { let controller = environment.controller let doneButton = doneButton.update( - component: Button( - content: AnyComponent( - Text( - text: strings.Common_Done, - font: Font.bold(17.0), - color: isValidLink ? theme.actionSheet.controlAccentColor : theme.actionSheet.secondaryTextColor - ) - ), + component: GlassBarButtonComponent( + size: barButtonSize, + backgroundColor: isValidLink ? environment.theme.list.itemCheckColors.fillColor : environment.theme.list.itemCheckColors.fillColor.desaturated().withMultipliedAlpha(0.5), + isDark: environment.theme.overallDarkAppearance, + state: .tintedGlass, isEnabled: isValidLink, - action: { [weak state] in + component: AnyComponentWithIdentity(id: "done", component: AnyComponent( + BundleIconComponent( + name: "Navigation/Done", + tintColor: environment.theme.list.itemCheckColors.foregroundColor + ) + )), + action: { [weak state] _ in if let controller = controller() as? CreateLinkScreen, let state { if state.complete(controller: controller) { component.dismiss() @@ -147,17 +155,16 @@ private final class SheetContent: CombinedComponent { transition: .immediate ) context.add(doneButton - .position(CGPoint(x: context.availableSize.width - sideInset - doneButton.size.width / 2.0, y: contentSize.height + doneButton.size.height / 2.0)) + .position(CGPoint(x: context.availableSize.width - sideInset - doneButton.size.width / 2.0, y: 16.0 + doneButton.size.height / 2.0)) ) - let title = title.update( component: Text(text: component.isEdit ? strings.MediaEditor_Link_EditTitle : strings.MediaEditor_Link_CreateTitle, font: Font.bold(17.0), color: theme.list.itemPrimaryTextColor), availableSize: CGSize(width: constrainedTitleWidth, height: context.availableSize.height), transition: .immediate ) context.add(title - .position(CGPoint(x: context.availableSize.width / 2.0, y: contentSize.height + title.size.height / 2.0)) + .position(CGPoint(x: context.availableSize.width / 2.0, y: contentSize.height)) ) contentSize.height += title.size.height contentSize.height += 40.0 @@ -222,6 +229,7 @@ private final class SheetContent: CombinedComponent { let urlSection = urlSection.update( component: ListSectionComponent( theme: theme, + style: .glass, header: AnyComponent(MultilineTextComponent( text: .plain(NSAttributedString( string: strings.MediaEditor_Link_LinkTo_Title.uppercased(), @@ -249,6 +257,7 @@ private final class SheetContent: CombinedComponent { let nameSection = nameSection.update( component: ListSectionComponent( theme: theme, + style: .glass, header: AnyComponent(MultilineTextComponent( text: .plain(NSAttributedString( string: strings.MediaEditor_Link_LinkName_Title.uppercased(), @@ -542,6 +551,7 @@ private final class CreateLinkSheetComponent: CombinedComponent { }) } )), + style: .glass, backgroundColor: .blur(.dark), followContentSizeChanges: true, clipsContent: true, @@ -816,7 +826,7 @@ private final class LinkFieldComponent: Component { containerSize: availableSize ) - let size = CGSize(width: availableSize.width, height: 44.0) + let size = CGSize(width: availableSize.width, height: 52.0) if let placeholderComponentView = self.placeholderView.view { if placeholderComponentView.superview == nil { self.insertSubview(placeholderComponentView, at: 0) @@ -827,7 +837,7 @@ private final class LinkFieldComponent: Component { placeholderComponentView.isHidden = !component.text.isEmpty } - self.textField.frame = CGRect(x: 15.0, y: 0.0, width: size.width - 30.0, height: 44.0) + self.textField.frame = CGRect(x: 15.0, y: 4.0, width: size.width - 30.0, height: 44.0) return size } diff --git a/submodules/TelegramUI/Components/Stars/StarsWithdrawalScreen/Sources/StarsWithdrawalScreen.swift b/submodules/TelegramUI/Components/Stars/StarsWithdrawalScreen/Sources/StarsWithdrawalScreen.swift index b319abb883..3a3a2ee0b3 100644 --- a/submodules/TelegramUI/Components/Stars/StarsWithdrawalScreen/Sources/StarsWithdrawalScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsWithdrawalScreen/Sources/StarsWithdrawalScreen.swift @@ -56,7 +56,6 @@ private final class SheetContent: CombinedComponent { static var body: (CombinedComponentContext) -> CGSize { let closeButton = Child(GlassBarButtonComponent.self) - let cancelButton = Child(Button.self) let balance = Child(BalanceComponent.self) let title = Child(Text.self) let currencyToggle = Child(TabSelectorComponent.self) @@ -115,46 +114,31 @@ private final class SheetContent: CombinedComponent { .position(CGPoint(x: balanceFrame.maxX, y: balanceFrame.minY)) ) } - - let cancelButton = cancelButton.update( - component: Button( - content: AnyComponent(Text(text: environment.strings.Common_Cancel, font: Font.regular(17.0), color: environment.theme.list.itemAccentColor)), - action: { - component.dismiss() - } - ).minSize(CGSize(width: 8.0, height: 44.0)), - availableSize: CGSize(width: 200.0, height: 100.0), - transition: .immediate - ) - let closeFrame = CGRect(origin: CGPoint(x: 16.0, y: floor((56.0 - cancelButton.size.height) * 0.5)), size: cancelButton.size) - context.add(cancelButton - .position(closeFrame.center) - ) - } else { - let closeButton = closeButton.update( - component: GlassBarButtonComponent( - size: CGSize(width: 40.0, height: 40.0), - backgroundColor: theme.rootController.navigationBar.glassBarButtonBackgroundColor, - isDark: theme.overallDarkAppearance, - state: .generic, - component: AnyComponentWithIdentity(id: "close", component: AnyComponent( - BundleIconComponent( - name: "Navigation/Close", - tintColor: theme.rootController.navigationBar.glassBarButtonForegroundColor - ) - )), - action: { _ in - component.dismiss() - } - ), - availableSize: CGSize(width: 40.0, height: 40.0), - transition: .immediate - ) - context.add(closeButton - .position(CGPoint(x: 16.0 + closeButton.size.width / 2.0, y: 16.0 + closeButton.size.height / 2.0)) - ) } + let closeButton = closeButton.update( + component: GlassBarButtonComponent( + size: CGSize(width: 40.0, height: 40.0), + backgroundColor: theme.rootController.navigationBar.glassBarButtonBackgroundColor, + isDark: theme.overallDarkAppearance, + state: .generic, + component: AnyComponentWithIdentity(id: "close", component: AnyComponent( + BundleIconComponent( + name: "Navigation/Close", + tintColor: theme.rootController.navigationBar.glassBarButtonForegroundColor + ) + )), + action: { _ in + component.dismiss() + } + ), + availableSize: CGSize(width: 40.0, height: 40.0), + transition: .immediate + ) + context.add(closeButton + .position(CGPoint(x: 16.0 + closeButton.size.width / 2.0, y: 16.0 + closeButton.size.height / 2.0)) + ) + let titleString: String let amountTitle: String let amountPlaceholder: String @@ -264,7 +248,7 @@ private final class SheetContent: CombinedComponent { .position(CGPoint(x: context.availableSize.width / 2.0, y: 36.0)) ) contentSize.height += title.size.height - contentSize.height += 40.0 + contentSize.height += 56.0 let balance: StarsAmount? if case .accountWithdraw = component.mode {