diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 66be514ea9..d06761c33d 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -451,6 +451,8 @@ "Login.PhoneGenericEmailSubject" = "Telegram iOS error: %@"; "Login.PhoneGenericEmailBody" = "I'm trying to use my mobile phone number: %1$@\nBut Telegram shows an error. Please help.\n\nError: %2$@\nApp version: %3$@\nOS version: %4$@\nLocale: %5$@\nMNC: %6$@"; +"Login.PhonePaidEmailSubject" = "Payment Issue"; +"Login.PhonePaidEmailBody" = "Hello Telegram Support,\n\nI’m experiencing an issue with an in-app purchase on iOS.\nMy phone number: %1$@\nApple ID (email used in the App Store): \nApp version: %2$@\nDevice model / iOS version: %3$@\nApp Store country/region: %4$@\nDate & time of attempt (with timezone): %5$@\nExact error message: \n\n#payment_failed"; "Login.PhoneTitle" = "Your Phone"; "Login.PhonePlaceholder" = "Your phone number"; diff --git a/submodules/AuthorizationUI/BUILD b/submodules/AuthorizationUI/BUILD index ee1b9354de..fc3eb3f659 100644 --- a/submodules/AuthorizationUI/BUILD +++ b/submodules/AuthorizationUI/BUILD @@ -45,6 +45,7 @@ swift_library( "//submodules/ContextUI:ContextUI", "//submodules/InAppPurchaseManager", "//submodules/TelegramUI/Components/Premium/PremiumCoinComponent", + "//submodules/TelegramUI/Components/PlainButtonComponent", ], visibility = [ "//visibility:public", diff --git a/submodules/AuthorizationUI/Sources/AuthorizationSequencePaymentScreen.swift b/submodules/AuthorizationUI/Sources/AuthorizationSequencePaymentScreen.swift index 1f35a72415..61d8674044 100644 --- a/submodules/AuthorizationUI/Sources/AuthorizationSequencePaymentScreen.swift +++ b/submodules/AuthorizationUI/Sources/AuthorizationSequencePaymentScreen.swift @@ -26,6 +26,8 @@ import AlertUI import MessageUI import CoreTelephony import PhoneNumberFormat +import PlainButtonComponent +import StoreKit final class AuthorizationSequencePaymentScreenComponent: Component { typealias EnvironmentType = ViewControllerComponentContainer.Environment @@ -75,6 +77,7 @@ final class AuthorizationSequencePaymentScreenComponent: Component { private let list = ComponentView() private let check = ComponentView() private let button = ComponentView() + private let helpButton = ComponentView() private var isUpdating: Bool = false @@ -223,6 +226,51 @@ final class AuthorizationSequencePaymentScreenComponent: Component { } let sideInset: CGFloat = 16.0 + environment.safeInsets.left + + let presentationData = component.presentationData + let helpButtonSize = self.helpButton.update( + transition: transition, + component: AnyComponent(PlainButtonComponent( + content: AnyComponent(MultilineTextComponent( + text: .plain(NSAttributedString(string: environment.strings.Login_PhoneNumberHelp, font: Font.regular(17.0), textColor: environment.theme.list.itemAccentColor)) + )), + minSize: CGSize(width: 0.0, height: 44.0), + contentInsets: UIEdgeInsets(top: 0.0, left: 8.0, bottom: 0.0, right: 8.0), + action: { [weak self] in + guard let self, let environment = self.environment, let controller = environment.controller() else { + return + } + let formattedNumber = formatPhoneNumber(component.phoneNumber) + let appVersion = (Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String) ?? "unknown" + let systemVersion = UIDevice.current.systemVersion + let region = SKPaymentQueue.default().storefront?.countryCode ?? "" + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss zzz" + let dateString = dateFormatter.string(from: Date()) + + let body = environment.strings.Login_PhonePaidEmailBody( + formattedNumber, + appVersion, + systemVersion, + region, + dateString + ).string + + AuthorizationSequenceController.presentEmailComposeController(address: component.supportEmailAddress, subject: environment.strings.Login_PhonePaidEmailSubject, body: body, from: controller, presentationData: presentationData) + }, + animateScale: false, + animateContents: false + )), + environment: {}, + containerSize: CGSize(width: 200.0, height: 100.0) + ) + let helpButtonFrame = CGRect(origin: CGPoint(x: availableSize.width - 8.0 - helpButtonSize.width, y: environment.statusBarHeight), size: helpButtonSize) + if let helpButtonView = self.helpButton.view { + if helpButtonView.superview == nil { + self.addSubview(helpButtonView) + } + transition.setFrame(view: helpButtonView, frame: helpButtonFrame) + } let animationSize = self.animation.update( transition: transition,