Various improvements

This commit is contained in:
Ilya Laktyushin 2022-06-06 02:50:22 +04:00
parent 61d128d750
commit debbe67e5a
6 changed files with 53 additions and 29 deletions

View File

@ -7653,8 +7653,6 @@ Sorry for the inconvenience.";
"Premium.Terms" = "By purchasing a Premium subscription, you agree to our [Terms of Service](terms) and [Privacy Policy](privacy)."; "Premium.Terms" = "By purchasing a Premium subscription, you agree to our [Terms of Service](terms) and [Privacy Policy](privacy).";
"Premium.ChargeInfo" = "Next charge: %1$@ on %2$@. [Cancel](cancel).";
"Conversation.CopyProtectionSavingDisabledSecret" = "Saving is restricted"; "Conversation.CopyProtectionSavingDisabledSecret" = "Saving is restricted";
"Conversation.CopyProtectionForwardingDisabledSecret" = "Forwards are restricted"; "Conversation.CopyProtectionForwardingDisabledSecret" = "Forwards are restricted";
@ -7668,8 +7666,6 @@ Sorry for the inconvenience.";
"SponsoredMessageMenu.Hide" = "Hide"; "SponsoredMessageMenu.Hide" = "Hide";
"ChatListFolder.MaxChatsInFolder" = "Sorry, you can't add more than %d chats to a folder.";
"Conversation.SaveGif" = "Save GIF"; "Conversation.SaveGif" = "Save GIF";
"Premium.Limits.Title" = "Doubled Limits"; "Premium.Limits.Title" = "Doubled Limits";
@ -7705,3 +7701,7 @@ Sorry for the inconvenience.";
"Message.AudioTranscription.ErrorTooLong" = "The audio is too long"; "Message.AudioTranscription.ErrorTooLong" = "The audio is too long";
"WebApp.SelectChat" = "Select Chat"; "WebApp.SelectChat" = "Select Chat";
"Premium.Purchase.ErrorUnknown" = "An error occurred. Please try again.";
"Premium.Purchase.ErrorNetwork" = "Please check your internet connection and try again.";
"Premium.Purchase.ErrorNotAllowed" = "The device is not not allowed to make the payment.";

View File

@ -28,6 +28,8 @@ public final class InAppPurchaseManager: NSObject {
public enum PurchaseError { public enum PurchaseError {
case generic case generic
case cancelled case cancelled
case network
case notAllowed
} }
private final class PaymentTransactionContext { private final class PaymentTransactionContext {
@ -43,7 +45,7 @@ public final class InAppPurchaseManager: NSObject {
case purchased(transactionId: String?) case purchased(transactionId: String?)
case restored(transactionId: String?) case restored(transactionId: String?)
case purchasing case purchasing
case failed case failed(error: SKError?)
case deferred case deferred
} }
@ -109,8 +111,23 @@ public final class InAppPurchaseManager: NSObject {
} else { } else {
subscriber.putError(.generic) subscriber.putError(.generic)
} }
case .failed: case let .failed(error):
subscriber.putError(.generic) if let error = error {
let mappedError: PurchaseError
switch error.code {
case .paymentCancelled:
mappedError = .cancelled
case .cloudServiceNetworkConnectionFailed, .cloudServicePermissionDenied:
mappedError = .network
case .paymentNotAllowed, .clientInvalid:
mappedError = .notAllowed
default:
mappedError = .generic
}
subscriber.putError(mappedError)
} else {
subscriber.putError(.generic)
}
case .deferred, .purchasing: case .deferred, .purchasing:
break break
} }
@ -174,7 +191,7 @@ extension InAppPurchaseManager: SKPaymentTransactionObserver {
) )
} }
case .failed: case .failed:
transactionState = .failed transactionState = .failed(error: transaction.error as? SKError)
queue.finishTransaction(transaction) queue.finishTransaction(transaction)
case .purchasing: case .purchasing:
transactionState = .purchasing transactionState = .purchasing

View File

@ -894,7 +894,7 @@ private final class DemoSheetContent: CombinedComponent {
font: .bold, font: .bold,
fontSize: 17.0, fontSize: 17.0,
height: 50.0, height: 50.0,
cornerRadius: 10.0, cornerRadius: 11.0,
gloss: state.isPremium != true, gloss: state.isPremium != true,
animationName: isStandalone && component.subject == .uniqueReactions ? "premium_unlock" : nil, animationName: isStandalone && component.subject == .uniqueReactions ? "premium_unlock" : nil,
iconPosition: .right, iconPosition: .right,

View File

@ -1404,12 +1404,25 @@ private final class PremiumIntroScreenComponent: CombinedComponent {
strongSelf.updateInProgress(false) strongSelf.updateInProgress(false)
strongSelf.updated(transition: .immediate) strongSelf.updated(transition: .immediate)
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
var errorText: String?
switch error { switch error {
case .generic: case .generic:
addAppLogEvent(postbox: strongSelf.context.account.postbox, type: "premium.promo_screen_fail") errorText = presentationData.strings.Premium_Purchase_ErrorUnknown
case .network:
errorText = presentationData.strings.Premium_Purchase_ErrorNetwork
case .notAllowed:
errorText = presentationData.strings.Premium_Purchase_ErrorNotAllowed
case .cancelled: case .cancelled:
break break
} }
if let errorText = errorText {
addAppLogEvent(postbox: strongSelf.context.account.postbox, type: "premium.promo_screen_fail")
let alertController = textAlertController(context: strongSelf.context, title: nil, text: errorText, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})])
strongSelf.present(alertController)
}
} }
})) }))
} else { } else {
@ -1635,7 +1648,7 @@ private final class PremiumIntroScreenComponent: CombinedComponent {
foregroundColor: .white foregroundColor: .white
), ),
height: 50.0, height: 50.0,
cornerRadius: 10.0, cornerRadius: 11.0,
gloss: true, gloss: true,
isLoading: state.inProgress, isLoading: state.inProgress,
action: { action: {

View File

@ -388,7 +388,7 @@ private final class PremimLimitsListScreenComponent: CombinedComponent {
.position(CGPoint(x: context.availableSize.width / 2.0, y: environment.navigationHeight + list.size.height / 2.0)) .position(CGPoint(x: context.availableSize.width / 2.0, y: environment.navigationHeight + list.size.height / 2.0))
) )
return CGSize(width: context.availableSize.width, height: environment.navigationHeight + list.size.height + environment.safeInsets.bottom - 16.0) return CGSize(width: context.availableSize.width, height: environment.navigationHeight + list.size.height + environment.safeInsets.bottom)
} }
} }
} }
@ -492,7 +492,7 @@ public class PremimLimitsListScreen: ViewController {
let contentOffset = self.scrollView.contentOffset.y let contentOffset = self.scrollView.contentOffset.y
self.controller?.navigationBar?.updateBackgroundAlpha(min(30.0, contentOffset) / 30.0, transition: .immediate) self.controller?.navigationBar?.updateBackgroundAlpha(min(30.0, contentOffset) / 30.0, transition: .immediate)
let bottomOffsetY = max(0.0, self.scrollView.contentSize.height + 20.0 - contentOffset - self.scrollView.frame.height) let bottomOffsetY = max(0.0, self.scrollView.contentSize.height - contentOffset - self.scrollView.frame.height)
let backgroundAlpha: CGFloat = min(30.0, bottomOffsetY) / 30.0 let backgroundAlpha: CGFloat = min(30.0, bottomOffsetY) / 30.0
self.footerNode.updateBackgroundAlpha(backgroundAlpha, transition: .immediate) self.footerNode.updateBackgroundAlpha(backgroundAlpha, transition: .immediate)
@ -1077,28 +1077,19 @@ private class FooterNode: ASDisplayNode {
let buttonInset: CGFloat = 16.0 let buttonInset: CGFloat = 16.0
let buttonWidth = layout.size.width - layout.safeInsets.left - layout.safeInsets.right - buttonInset * 2.0 let buttonWidth = layout.size.width - layout.safeInsets.left - layout.safeInsets.right - buttonInset * 2.0
let buttonHeight = self.buttonNode.updateLayout(width: buttonWidth, transition: transition) let buttonHeight = self.buttonNode.updateLayout(width: buttonWidth, transition: transition)
let inset: CGFloat = 9.0 let bottomPanelPadding: CGFloat = 12.0
let bottomInset: CGFloat = layout.intrinsicInsets.bottom > 0.0 ? layout.intrinsicInsets.bottom + 5.0 : bottomPanelPadding
let insets = layout.insets(options: [.input])
let panelHeight: CGFloat = bottomPanelPadding + 50.0 + bottomInset
var panelHeight: CGFloat = buttonHeight + inset * 2.0
let totalPanelHeight: CGFloat
if let inputHeight = layout.inputHeight, inputHeight > 0.0 {
totalPanelHeight = panelHeight + insets.bottom
} else {
panelHeight += insets.bottom
totalPanelHeight = panelHeight
}
let panelFrame = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: layout.size.width, height: panelHeight)) let panelFrame = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: layout.size.width, height: panelHeight))
transition.updateFrame(node: self.buttonNode, frame: CGRect(origin: CGPoint(x: layout.safeInsets.left + buttonInset, y: panelFrame.minY + inset), size: CGSize(width: buttonWidth, height: buttonHeight))) transition.updateFrame(node: self.buttonNode, frame: CGRect(origin: CGPoint(x: layout.safeInsets.left + buttonInset, y: bottomPanelPadding), size: CGSize(width: buttonWidth, height: buttonHeight)))
transition.updateFrame(node: self.backgroundNode, frame: panelFrame) transition.updateFrame(node: self.backgroundNode, frame: panelFrame)
self.backgroundNode.update(size: panelFrame.size, transition: transition) self.backgroundNode.update(size: panelFrame.size, transition: transition)
transition.updateFrame(node: self.separatorNode, frame: CGRect(origin: panelFrame.origin, size: CGSize(width: panelFrame.width, height: UIScreenPixel))) transition.updateFrame(node: self.separatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: -UIScreenPixel), size: CGSize(width: panelFrame.width, height: UIScreenPixel)))
return totalPanelHeight return panelHeight
} }
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {

View File

@ -649,6 +649,9 @@ public final class SolidRoundedButtonView: UIView {
self.buttonBackgroundNode = UIImageView() self.buttonBackgroundNode = UIImageView()
self.buttonBackgroundNode.clipsToBounds = true self.buttonBackgroundNode.clipsToBounds = true
self.buttonBackgroundNode.layer.cornerRadius = cornerRadius self.buttonBackgroundNode.layer.cornerRadius = cornerRadius
if #available(iOS 13.0, *) {
self.buttonBackgroundNode.layer.cornerCurve = .continuous
}
self.buttonBackgroundNode.backgroundColor = theme.backgroundColor self.buttonBackgroundNode.backgroundColor = theme.backgroundColor
if theme.backgroundColors.count > 1 { if theme.backgroundColors.count > 1 {