mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-29 11:25:38 +00:00
Stars fixes
This commit is contained in:
parent
4d6810c5c0
commit
b1be15e4a1
@ -1031,6 +1031,8 @@ public protocol ChatController: ViewController {
|
|||||||
func performScrollToTop() -> Bool
|
func performScrollToTop() -> Bool
|
||||||
func transferScrollingVelocity(_ velocity: CGFloat)
|
func transferScrollingVelocity(_ velocity: CGFloat)
|
||||||
func updateIsScrollingLockedAtTop(isScrollingLockedAtTop: Bool)
|
func updateIsScrollingLockedAtTop(isScrollingLockedAtTop: Bool)
|
||||||
|
|
||||||
|
func playShakeAnimation()
|
||||||
}
|
}
|
||||||
|
|
||||||
public protocol ChatMessagePreviewItemNode: AnyObject {
|
public protocol ChatMessagePreviewItemNode: AnyObject {
|
||||||
|
|||||||
@ -147,7 +147,7 @@ private final class SheetContent: CombinedComponent {
|
|||||||
showPeer = true
|
showPeer = true
|
||||||
case let .withdrawal(status, amount, date, provider, _, transactionUrl):
|
case let .withdrawal(status, amount, date, provider, _, transactionUrl):
|
||||||
labelColor = theme.list.itemDestructiveColor
|
labelColor = theme.list.itemDestructiveColor
|
||||||
amountString = amountAttributedString(formatBalanceText(amount, decimalSeparator: dateTimeFormat.decimalSeparator), integralFont: integralFont, fractionalFont: fractionalFont, color: labelColor).mutableCopy() as! NSMutableAttributedString
|
amountString = amountAttributedString(formatBalanceText(amount, decimalSeparator: dateTimeFormat.groupingSeparator), integralFont: integralFont, fractionalFont: fractionalFont, color: labelColor).mutableCopy() as! NSMutableAttributedString
|
||||||
dateString = stringForFullDate(timestamp: date, strings: strings, dateTimeFormat: dateTimeFormat)
|
dateString = stringForFullDate(timestamp: date, strings: strings, dateTimeFormat: dateTimeFormat)
|
||||||
|
|
||||||
switch status {
|
switch status {
|
||||||
|
|||||||
@ -982,7 +982,7 @@ private func settingsItems(data: PeerInfoScreenData?, context: AccountContext, p
|
|||||||
if let starsState = data.starsState {
|
if let starsState = data.starsState {
|
||||||
let balanceText: String
|
let balanceText: String
|
||||||
if starsState.balance > 0 {
|
if starsState.balance > 0 {
|
||||||
balanceText = "\(starsState.balance)"
|
balanceText = presentationStringsFormattedNumber(Int32(starsState.balance), presentationData.dateTimeFormat.groupingSeparator)
|
||||||
} else {
|
} else {
|
||||||
balanceText = ""
|
balanceText = ""
|
||||||
}
|
}
|
||||||
|
|||||||
@ -787,7 +787,7 @@ private final class StarsPurchaseScreenComponent: CombinedComponent {
|
|||||||
let balanceValue = balanceValue.update(
|
let balanceValue = balanceValue.update(
|
||||||
component: MultilineTextComponent(
|
component: MultilineTextComponent(
|
||||||
text: .plain(NSAttributedString(
|
text: .plain(NSAttributedString(
|
||||||
string: presentationStringsFormattedNumber(Int32(state.starsState?.balance ?? 0), environment.dateTimeFormat.decimalSeparator),
|
string: presentationStringsFormattedNumber(Int32(state.starsState?.balance ?? 0), environment.dateTimeFormat.groupingSeparator),
|
||||||
font: Font.semibold(14.0),
|
font: Font.semibold(14.0),
|
||||||
textColor: environment.theme.actionSheet.primaryTextColor
|
textColor: environment.theme.actionSheet.primaryTextColor
|
||||||
)),
|
)),
|
||||||
|
|||||||
@ -127,11 +127,12 @@ private final class StarsTransactionSheetContent: CombinedComponent {
|
|||||||
|
|
||||||
return { context in
|
return { context in
|
||||||
let environment = context.environment[ViewControllerComponentContainer.Environment.self].value
|
let environment = context.environment[ViewControllerComponentContainer.Environment.self].value
|
||||||
|
let controller = environment.controller
|
||||||
|
|
||||||
let component = context.component
|
let component = context.component
|
||||||
let theme = environment.theme
|
let theme = environment.theme
|
||||||
let strings = environment.strings
|
let strings = environment.strings
|
||||||
let dateTimeFormat = environment.dateTimeFormat
|
let dateTimeFormat = environment.dateTimeFormat
|
||||||
let accountContext = context.component.context
|
|
||||||
|
|
||||||
let state = context.state
|
let state = context.state
|
||||||
let subject = component.subject
|
let subject = component.subject
|
||||||
@ -171,7 +172,7 @@ private final class StarsTransactionSheetContent: CombinedComponent {
|
|||||||
let toPeer: EnginePeer?
|
let toPeer: EnginePeer?
|
||||||
let photo: TelegramMediaWebFile?
|
let photo: TelegramMediaWebFile?
|
||||||
|
|
||||||
let gloss = false
|
var delayedCloseOnOpenPeer = true
|
||||||
switch subject {
|
switch subject {
|
||||||
case let .transaction(transaction):
|
case let .transaction(transaction):
|
||||||
switch transaction.peer {
|
switch transaction.peer {
|
||||||
@ -218,9 +219,10 @@ private final class StarsTransactionSheetContent: CombinedComponent {
|
|||||||
toPeer = nil
|
toPeer = nil
|
||||||
}
|
}
|
||||||
photo = receipt.invoiceMedia.photo
|
photo = receipt.invoiceMedia.photo
|
||||||
|
delayedCloseOnOpenPeer = false
|
||||||
}
|
}
|
||||||
|
|
||||||
let formattedAmount = presentationStringsFormattedNumber(abs(Int32(count)), dateTimeFormat.decimalSeparator)
|
let formattedAmount = presentationStringsFormattedNumber(abs(Int32(count)), dateTimeFormat.groupingSeparator)
|
||||||
if count < 0 {
|
if count < 0 {
|
||||||
amountText = "- \(formattedAmount)"
|
amountText = "- \(formattedAmount)"
|
||||||
} else {
|
} else {
|
||||||
@ -300,11 +302,16 @@ private final class StarsTransactionSheetContent: CombinedComponent {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
action: {
|
action: {
|
||||||
if toPeer.id != accountContext.account.peerId {
|
if delayedCloseOnOpenPeer {
|
||||||
component.openPeer(toPeer)
|
component.openPeer(toPeer)
|
||||||
Queue.mainQueue().after(1.0, {
|
Queue.mainQueue().after(1.0, {
|
||||||
component.cancel(false)
|
component.cancel(false)
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
if let controller = controller() as? StarsTransactionScreen, let navigationController = controller.navigationController, let chatController = navigationController.viewControllers.first(where: { $0 is ChatController }) as? ChatController {
|
||||||
|
chatController.playShakeAnimation()
|
||||||
|
}
|
||||||
|
component.cancel(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -325,11 +332,15 @@ private final class StarsTransactionSheetContent: CombinedComponent {
|
|||||||
id: "transaction",
|
id: "transaction",
|
||||||
title: strings.Stars_Transaction_Id,
|
title: strings.Stars_Transaction_Id,
|
||||||
component: AnyComponent(
|
component: AnyComponent(
|
||||||
TransactionCellComponent(
|
Button(
|
||||||
textColor: tableTextColor,
|
content: AnyComponent(
|
||||||
accentColor: tableLinkColor,
|
TransactionCellComponent(
|
||||||
transactionId: transactionId,
|
textColor: tableTextColor,
|
||||||
copy: {
|
accentColor: tableLinkColor,
|
||||||
|
transactionId: transactionId
|
||||||
|
)
|
||||||
|
),
|
||||||
|
action: {
|
||||||
component.copyTransactionId()
|
component.copyTransactionId()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -393,7 +404,7 @@ private final class StarsTransactionSheetContent: CombinedComponent {
|
|||||||
fontSize: 17.0,
|
fontSize: 17.0,
|
||||||
height: 50.0,
|
height: 50.0,
|
||||||
cornerRadius: 10.0,
|
cornerRadius: 10.0,
|
||||||
gloss: gloss,
|
gloss: false,
|
||||||
iconName: nil,
|
iconName: nil,
|
||||||
animationName: nil,
|
animationName: nil,
|
||||||
iconPosition: .left,
|
iconPosition: .left,
|
||||||
@ -656,7 +667,7 @@ public class StarsTransactionScreen: ViewControllerComponentContainer {
|
|||||||
guard let peer else {
|
guard let peer else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, chatController: nil, context: context, chatLocation: .peer(peer), subject: nil, botStart: nil, updateTextInputState: nil, keepStack: .always, useExisting: false, purposefulAction: nil, scrollToEndIfExists: false, activateMessageSearch: nil, animated: true))
|
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, chatController: nil, context: context, chatLocation: .peer(peer), subject: nil, botStart: nil, updateTextInputState: nil, keepStack: .always, useExisting: true, purposefulAction: nil, scrollToEndIfExists: false, activateMessageSearch: nil, animated: true))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1029,13 +1040,11 @@ private final class TransactionCellComponent: Component {
|
|||||||
let textColor: UIColor
|
let textColor: UIColor
|
||||||
let accentColor: UIColor
|
let accentColor: UIColor
|
||||||
let transactionId: String
|
let transactionId: String
|
||||||
let copy: () -> Void
|
|
||||||
|
init(textColor: UIColor, accentColor: UIColor, transactionId: String) {
|
||||||
init(textColor: UIColor, accentColor: UIColor, transactionId: String, copy: @escaping () -> Void) {
|
|
||||||
self.textColor = textColor
|
self.textColor = textColor
|
||||||
self.accentColor = accentColor
|
self.accentColor = accentColor
|
||||||
self.transactionId = transactionId
|
self.transactionId = transactionId
|
||||||
self.copy = copy
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static func ==(lhs: TransactionCellComponent, rhs: TransactionCellComponent) -> Bool {
|
static func ==(lhs: TransactionCellComponent, rhs: TransactionCellComponent) -> Bool {
|
||||||
@ -1075,14 +1084,7 @@ private final class TransactionCellComponent: Component {
|
|||||||
let buttonSize = self.button.update(
|
let buttonSize = self.button.update(
|
||||||
transition: .immediate,
|
transition: .immediate,
|
||||||
component: AnyComponent(
|
component: AnyComponent(
|
||||||
Button(
|
BundleIconComponent(name: "Chat/Context Menu/Copy", tintColor: component.accentColor)
|
||||||
content: AnyComponent(
|
|
||||||
BundleIconComponent(name: "Chat/Context Menu/Copy", tintColor: component.accentColor)
|
|
||||||
),
|
|
||||||
action: {
|
|
||||||
component.copy()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
environment: {},
|
environment: {},
|
||||||
containerSize: CGSize(width: availableSize.width, height: availableSize.height)
|
containerSize: CGSize(width: availableSize.width, height: availableSize.height)
|
||||||
|
|||||||
@ -237,7 +237,7 @@ final class StarsTransactionsListPanelComponent: Component {
|
|||||||
let itemLabel: NSAttributedString
|
let itemLabel: NSAttributedString
|
||||||
let labelString: String
|
let labelString: String
|
||||||
|
|
||||||
let formattedLabel = presentationStringsFormattedNumber(abs(Int32(item.transaction.count)), environment.dateTimeFormat.decimalSeparator)
|
let formattedLabel = presentationStringsFormattedNumber(abs(Int32(item.transaction.count)), environment.dateTimeFormat.groupingSeparator)
|
||||||
if item.transaction.count < 0 {
|
if item.transaction.count < 0 {
|
||||||
labelString = "- \(formattedLabel)"
|
labelString = "- \(formattedLabel)"
|
||||||
} else {
|
} else {
|
||||||
@ -475,8 +475,7 @@ private final class AvatarComponent: Component {
|
|||||||
|
|
||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
|
|
||||||
self.iconView.contentMode = .center
|
self.iconView.contentMode = .scaleAspectFit
|
||||||
self.iconView.image = UIImage(bundleImageName: "Premium/Stars/Apple")
|
|
||||||
|
|
||||||
self.addSubnode(self.avatarNode)
|
self.addSubnode(self.avatarNode)
|
||||||
self.addSubview(self.backgroundView)
|
self.addSubview(self.backgroundView)
|
||||||
@ -492,8 +491,8 @@ private final class AvatarComponent: Component {
|
|||||||
self.state = state
|
self.state = state
|
||||||
|
|
||||||
let size = CGSize(width: 40.0, height: 40.0)
|
let size = CGSize(width: 40.0, height: 40.0)
|
||||||
|
var iconInset: CGFloat = 3.0
|
||||||
let gradientImage = generateGradientFilledCircleImage(diameter: size.width, colors: [UIColor(rgb: 0x2a9ef1).cgColor, UIColor(rgb: 0x72d5fd).cgColor], direction: .mirroredDiagonal)
|
var iconOffset: CGFloat = 0.0
|
||||||
|
|
||||||
switch component.peer {
|
switch component.peer {
|
||||||
case let .peer(peer):
|
case let .peer(peer):
|
||||||
@ -507,34 +506,73 @@ private final class AvatarComponent: Component {
|
|||||||
self.iconView.isHidden = true
|
self.iconView.isHidden = true
|
||||||
self.avatarNode.isHidden = false
|
self.avatarNode.isHidden = false
|
||||||
case .appStore:
|
case .appStore:
|
||||||
self.backgroundView.image = gradientImage
|
self.backgroundView.image = generateGradientFilledCircleImage(
|
||||||
|
diameter: size.width,
|
||||||
|
colors: [
|
||||||
|
UIColor(rgb: 0x2a9ef1).cgColor,
|
||||||
|
UIColor(rgb: 0x72d5fd).cgColor
|
||||||
|
],
|
||||||
|
direction: .mirroredDiagonal
|
||||||
|
)
|
||||||
self.backgroundView.isHidden = false
|
self.backgroundView.isHidden = false
|
||||||
self.iconView.isHidden = false
|
self.iconView.isHidden = false
|
||||||
self.avatarNode.isHidden = true
|
self.avatarNode.isHidden = true
|
||||||
|
self.iconView.image = UIImage(bundleImageName: "Premium/Stars/Apple")
|
||||||
case .playMarket:
|
case .playMarket:
|
||||||
self.backgroundView.image = gradientImage
|
self.backgroundView.image = generateGradientFilledCircleImage(
|
||||||
|
diameter: size.width,
|
||||||
|
colors: [
|
||||||
|
UIColor(rgb: 0x54cb68).cgColor,
|
||||||
|
UIColor(rgb: 0xa0de7e).cgColor
|
||||||
|
],
|
||||||
|
direction: .mirroredDiagonal
|
||||||
|
)
|
||||||
self.backgroundView.isHidden = false
|
self.backgroundView.isHidden = false
|
||||||
self.iconView.isHidden = false
|
self.iconView.isHidden = false
|
||||||
self.avatarNode.isHidden = true
|
self.avatarNode.isHidden = true
|
||||||
|
self.iconView.image = UIImage(bundleImageName: "Premium/Stars/Google")
|
||||||
case .fragment:
|
case .fragment:
|
||||||
self.backgroundView.image = gradientImage
|
self.backgroundView.image = generateFilledCircleImage(diameter: size.width, color: UIColor(rgb: 0x1b1f24))
|
||||||
self.backgroundView.isHidden = false
|
self.backgroundView.isHidden = false
|
||||||
self.iconView.isHidden = false
|
self.iconView.isHidden = false
|
||||||
self.avatarNode.isHidden = true
|
self.avatarNode.isHidden = true
|
||||||
|
self.iconView.image = UIImage(bundleImageName: "Premium/Stars/Fragment")
|
||||||
|
iconOffset = 2.0
|
||||||
case .premiumBot:
|
case .premiumBot:
|
||||||
self.backgroundView.image = gradientImage
|
iconInset = 7.0
|
||||||
|
self.backgroundView.image = generateGradientFilledCircleImage(
|
||||||
|
diameter: size.width,
|
||||||
|
colors: [
|
||||||
|
UIColor(rgb: 0x6b93ff).cgColor,
|
||||||
|
UIColor(rgb: 0x6b93ff).cgColor,
|
||||||
|
UIColor(rgb: 0x8d77ff).cgColor,
|
||||||
|
UIColor(rgb: 0xb56eec).cgColor,
|
||||||
|
UIColor(rgb: 0xb56eec).cgColor
|
||||||
|
],
|
||||||
|
direction: .mirroredDiagonal
|
||||||
|
)
|
||||||
self.backgroundView.isHidden = false
|
self.backgroundView.isHidden = false
|
||||||
self.iconView.isHidden = false
|
self.iconView.isHidden = false
|
||||||
self.avatarNode.isHidden = true
|
self.avatarNode.isHidden = true
|
||||||
|
self.iconView.image = generateTintedImage(image: UIImage(bundleImageName: "Chat/Input/Media/EntityInputPremiumIcon"), color: .white)
|
||||||
case .unsupported:
|
case .unsupported:
|
||||||
self.backgroundView.image = gradientImage
|
iconInset = 7.0
|
||||||
|
self.backgroundView.image = generateGradientFilledCircleImage(
|
||||||
|
diameter: size.width,
|
||||||
|
colors: [
|
||||||
|
UIColor(rgb: 0xb1b1b1).cgColor,
|
||||||
|
UIColor(rgb: 0xcdcdcd).cgColor
|
||||||
|
],
|
||||||
|
direction: .mirroredDiagonal
|
||||||
|
)
|
||||||
self.backgroundView.isHidden = false
|
self.backgroundView.isHidden = false
|
||||||
self.iconView.isHidden = false
|
self.iconView.isHidden = false
|
||||||
self.avatarNode.isHidden = true
|
self.avatarNode.isHidden = true
|
||||||
|
self.iconView.image = generateTintedImage(image: UIImage(bundleImageName: "Chat/Input/Media/EntityInputPremiumIcon"), color: .white)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.avatarNode.frame = CGRect(origin: .zero, size: size)
|
self.avatarNode.frame = CGRect(origin: .zero, size: size)
|
||||||
self.iconView.frame = CGRect(origin: .zero, size: size)
|
self.iconView.frame = CGRect(origin: .zero, size: size).insetBy(dx: iconInset, dy: iconInset).offsetBy(dx: 0.0, dy: iconOffset)
|
||||||
self.backgroundView.frame = CGRect(origin: .zero, size: size)
|
self.backgroundView.frame = CGRect(origin: .zero, size: size)
|
||||||
|
|
||||||
return size
|
return size
|
||||||
|
|||||||
@ -437,7 +437,7 @@ final class StarsTransactionsScreenComponent: Component {
|
|||||||
transition: .immediate,
|
transition: .immediate,
|
||||||
component: AnyComponent(MultilineTextComponent(
|
component: AnyComponent(MultilineTextComponent(
|
||||||
text: .plain(NSAttributedString(
|
text: .plain(NSAttributedString(
|
||||||
string: presentationStringsFormattedNumber(Int32(self.starsState?.balance ?? 0), environment.dateTimeFormat.decimalSeparator),
|
string: presentationStringsFormattedNumber(Int32(self.starsState?.balance ?? 0), environment.dateTimeFormat.groupingSeparator),
|
||||||
font: Font.semibold(14.0),
|
font: Font.semibold(14.0),
|
||||||
textColor: environment.theme.actionSheet.primaryTextColor
|
textColor: environment.theme.actionSheet.primaryTextColor
|
||||||
)),
|
)),
|
||||||
|
|||||||
@ -331,7 +331,7 @@ private final class SheetContent: CombinedComponent {
|
|||||||
let balanceValue = balanceValue.update(
|
let balanceValue = balanceValue.update(
|
||||||
component: MultilineTextComponent(
|
component: MultilineTextComponent(
|
||||||
text: .plain(NSAttributedString(
|
text: .plain(NSAttributedString(
|
||||||
string: presentationStringsFormattedNumber(Int32(state.balance ?? 0), environment.dateTimeFormat.decimalSeparator),
|
string: presentationStringsFormattedNumber(Int32(state.balance ?? 0), environment.dateTimeFormat.groupingSeparator),
|
||||||
font: Font.semibold(16.0),
|
font: Font.semibold(16.0),
|
||||||
textColor: textColor
|
textColor: textColor
|
||||||
)),
|
)),
|
||||||
|
|||||||
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"images" : [
|
|
||||||
{
|
|
||||||
"filename" : "topbalance.pdf",
|
|
||||||
"idiom" : "universal"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"info" : {
|
|
||||||
"author" : "xcode",
|
|
||||||
"version" : 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user