diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 121e9361b2..42e90545a5 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -11381,3 +11381,7 @@ to respond to messages faster."; "Conversation.BoostToUnrestrictText" = "Boost this group to send messages"; "Settings.Business" = "Telegram Business"; + +"Story.Editor.DiscardText" = "If you go back now, you will lose any changes you made."; + +"Premium.Business.Description" = "Turn your account to a business page with these additional features."; diff --git a/submodules/PremiumUI/Sources/BusinessPageComponent.swift b/submodules/PremiumUI/Sources/BusinessPageComponent.swift index f11fcc9ac5..8740f125db 100644 --- a/submodules/PremiumUI/Sources/BusinessPageComponent.swift +++ b/submodules/PremiumUI/Sources/BusinessPageComponent.swift @@ -14,10 +14,12 @@ import BundleIconComponent private final class HeaderComponent: Component { let context: AccountContext let theme: PresentationTheme + let strings: PresentationStrings - init(context: AccountContext, theme: PresentationTheme) { + init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings) { self.context = context self.theme = theme + self.strings = strings } static func ==(lhs: HeaderComponent, rhs: HeaderComponent) -> Bool { @@ -61,14 +63,14 @@ private final class HeaderComponent: Component { if view.superview == nil { self.addSubview(view) } - view.frame = CGRect(origin: CGPoint(x: floor((availableSize.width - coinSize.width) / 2.0), y: -90.0), size: coinSize) + view.frame = CGRect(origin: CGPoint(x: floor((availableSize.width - coinSize.width) / 2.0), y: -84.0), size: coinSize) } let textSize = self.text.update( transition: .immediate, component: AnyComponent( MultilineTextComponent( - text: .plain(NSAttributedString(string: "Turn your account to a business page with these additional features.", font: Font.regular(15.0), textColor: .black)), + text: .plain(NSAttributedString(string: component.strings.Premium_Business_Description, font: Font.regular(15.0), textColor: .black)), horizontalAlignment: .center, maximumNumberOfLines: 0, lineSpacing: 0.2 @@ -77,14 +79,14 @@ private final class HeaderComponent: Component { environment: {}, containerSize: CGSize(width: availableSize.width - 32.0, height: 1000.0) ) - if let view = text.view { + if let view = self.text.view { if view.superview == nil { self.addSubview(view) } - view.frame = CGRect(origin: CGPoint(x: floor((availableSize.width - textSize.width) / 2.0), y: 118.0), size: textSize) + view.frame = CGRect(origin: CGPoint(x: floor((availableSize.width - textSize.width) / 2.0), y: 139.0), size: textSize) } - return CGSize(width: availableSize.width, height: 189.0) + return CGSize(width: availableSize.width, height: 210.0) } } @@ -319,7 +321,8 @@ private final class BusinessListComponent: CombinedComponent { id: "header", component: AnyComponent(HeaderComponent( context: context.component.context, - theme: theme + theme: theme, + strings: strings )) ) ) @@ -414,7 +417,7 @@ private final class BusinessListComponent: CombinedComponent { transition: context.transition ) - let contentHeight = context.component.topInset + list.size.height + context.component.bottomInset + let contentHeight = context.component.topInset - 56.0 + list.size.height + context.component.bottomInset context.add(list .position(CGPoint(x: list.size.width / 2.0, y: context.component.topInset + list.size.height / 2.0)) ) @@ -631,7 +634,7 @@ final class BusinessPageComponent: CombinedComponent { ) let titleTopOriginY = topPanel.size.height / 2.0 - let titleBottomOriginY: CGFloat = 155.0 + let titleBottomOriginY: CGFloat = 176.0 let titleOriginDelta = titleTopOriginY - titleBottomOriginY let fraction = min(1.0, state.topContentOffset / abs(titleOriginDelta)) diff --git a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift index 0dfd30f7ed..d5d9c5fbd6 100644 --- a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift @@ -2568,6 +2568,9 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent { } size.height += scrollEnvironment.insets.bottom + if case .business = context.component.mode, state.isPremium == false { + size.height += 123.0 + } if context.component.source != .settings { size.height += 44.0 diff --git a/submodules/PremiumUI/Sources/PremiumLimitsListScreen.swift b/submodules/PremiumUI/Sources/PremiumLimitsListScreen.swift index 3f375d3fd9..3ae7dc6294 100644 --- a/submodules/PremiumUI/Sources/PremiumLimitsListScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumLimitsListScreen.swift @@ -29,6 +29,7 @@ public class PremiumLimitsListScreen: ViewController { let backgroundView: ComponentHostView let pagerView: ComponentHostView let closeView: ComponentHostView + let closeDarkIconView = UIImageView() fileprivate let footerNode: FooterNode @@ -380,11 +381,12 @@ public class PremiumLimitsListScreen: ViewController { isStandalone = true } + let theme = self.presentationData.theme + let strings = self.presentationData.strings + if let stickers = self.stickers, let appIcons = self.appIcons, let configuration = self.promoConfiguration { let context = controller.context - let theme = self.presentationData.theme - let strings = self.presentationData.strings - + let textColor = theme.actionSheet.primaryTextColor var availableItems: [PremiumPerk: DemoPagerComponent.Item] = [:] @@ -398,8 +400,8 @@ public class PremiumLimitsListScreen: ViewController { if let order = controller.order { storiesIndex = order.firstIndex(where: { $0 == .stories }) limitsIndex = order.firstIndex(where: { $0 == .doubleLimits }) - businessIndex = order.firstIndex(where: { $0 == .doubleLimits }) - if let limitsIndex, let storiesIndex, let _ = businessIndex { + businessIndex = order.firstIndex(where: { $0 == .business }) + if let limitsIndex, let storiesIndex { if limitsIndex == storiesIndex + 1 { storiesNeighbors.rightIsList = true limitsNeighbors.leftIsList = true @@ -823,7 +825,7 @@ public class PremiumLimitsListScreen: ViewController { }, updatedIsDisplaying: { [weak self] isDisplaying in if let self, self.isExpanded && !isDisplaying { - if let limitsIndex, let indexPosition = self.indexPosition, abs(CGFloat(limitsIndex) - indexPosition) < 0.1 { + if let businessIndex, let indexPosition = self.indexPosition, abs(CGFloat(businessIndex) - indexPosition) < 0.1 { } else { self.update(isExpanded: false, transition: .animated(duration: 0.2, curve: .easeInOut)) } @@ -884,7 +886,7 @@ public class PremiumLimitsListScreen: ViewController { context: context, position: .top, model: .island, - videoFile: configuration.videos["greeting_message"], + videoFile: configuration.videos["quick_replies"], decoration: .business )), title: strings.Business_QuickReplies, @@ -955,8 +957,6 @@ public class PremiumLimitsListScreen: ViewController { ) ) - - if let order = controller.order { var items: [DemoPagerComponent.Item] = order.compactMap { availableItems[$0] } let initialIndex: Int @@ -979,8 +979,42 @@ public class PremiumLimitsListScreen: ViewController { nextAction: nextAction, updated: { [weak self] position, count in if let self { - self.indexPosition = position * CGFloat(count) + let indexPosition = position * CGFloat(count - 1) + self.indexPosition = indexPosition self.footerNode.updatePosition(position, count: count) + + var distance: CGFloat? + if let storiesIndex { + let value = indexPosition - CGFloat(storiesIndex) + if abs(value) < 1.0 { + distance = value + } + } + if let limitsIndex { + let value = indexPosition - CGFloat(limitsIndex) + if abs(value) < 1.0 { + distance = value + } + } + if let businessIndex { + let value = indexPosition - CGFloat(businessIndex) + if abs(value) < 1.0 { + distance = value + } + } + var distanceToPage: CGFloat = 1.0 + if let distance { + if distance >= 0.0 && distance < 0.1 { + distanceToPage = distance / 0.1 + } else if distance < 0.0 { + if distance >= -1.0 && distance < -0.9 { + distanceToPage = ((distance * -1.0) - 0.9) / 0.1 + } else { + distanceToPage = 0.0 + } + } + } + self.closeDarkIconView.alpha = 1.0 - max(0.0, min(1.0, distanceToPage)) } } ) @@ -1031,6 +1065,12 @@ public class PremiumLimitsListScreen: ViewController { self.closeView.clipsToBounds = true self.closeView.layer.cornerRadius = 15.0 self.closeView.frame = CGRect(origin: CGPoint(x: contentSize.width - closeSize.width * 1.5, y: 28.0 - closeSize.height / 2.0), size: closeSize) + + if self.closeDarkIconView.image == nil { + self.closeDarkIconView.image = generateCloseButtonImage(backgroundColor: .clear, foregroundColor: theme.list.itemSecondaryTextColor)! + self.closeDarkIconView.frame = CGRect(origin: .zero, size: closeSize) + self.closeView.addSubview(self.closeDarkIconView) + } } private var cachedCloseImage: UIImage? diff --git a/submodules/TelegramUI/Components/ListActionItemComponent/Sources/ListActionItemComponent.swift b/submodules/TelegramUI/Components/ListActionItemComponent/Sources/ListActionItemComponent.swift index 7768a92c55..36fd9dc3a1 100644 --- a/submodules/TelegramUI/Components/ListActionItemComponent/Sources/ListActionItemComponent.swift +++ b/submodules/TelegramUI/Components/ListActionItemComponent/Sources/ListActionItemComponent.swift @@ -321,15 +321,16 @@ public final class ListActionItemComponent: Component { var arrowTransition = transition if let current = self.arrowView { arrowView = current + if themeUpdated { + arrowView.image = PresentationResourcesItemList.disclosureArrowImage(component.theme) + } } else { arrowTransition = arrowTransition.withAnimation(.none) - arrowView = UIImageView(image: PresentationResourcesItemList.disclosureArrowImage(component.theme)?.withRenderingMode(.alwaysTemplate)) + arrowView = UIImageView(image: PresentationResourcesItemList.disclosureArrowImage(component.theme)) self.arrowView = arrowView self.addSubview(arrowView) } - - arrowView.tintColor = component.theme.list.disclosureArrowColor - + if let image = arrowView.image { let arrowFrame = CGRect(origin: CGPoint(x: availableSize.width - 7.0 - image.size.width, y: floor((contentHeight - image.size.height) * 0.5)), size: image.size) arrowTransition.setFrame(view: arrowView, frame: arrowFrame)