mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various improvements
This commit is contained in:
parent
c445821e6e
commit
f0fa9461cd
@ -12297,7 +12297,7 @@ Sorry for the inconvenience.";
|
|||||||
|
|
||||||
"Stars.Transfer.Balance" = "Balance";
|
"Stars.Transfer.Balance" = "Balance";
|
||||||
|
|
||||||
"Stars.Transfer.Unavailable" = "Unavailable";
|
"Stars.Transfer.Unavailable" = "Sorry, no star purchases are available from your country.";
|
||||||
|
|
||||||
"Settings.Stars" = "Your Stars";
|
"Settings.Stars" = "Your Stars";
|
||||||
|
|
||||||
|
Binary file not shown.
@ -197,6 +197,7 @@ class CreateGiveawayHeaderItemNode: ItemListControllerHeaderItemNode {
|
|||||||
self.backgroundNode.update(size: CGSize(width: layout.size.width, height: navigationBarHeight), transition: transition)
|
self.backgroundNode.update(size: CGSize(width: layout.size.width, height: navigationBarHeight), transition: transition)
|
||||||
|
|
||||||
let component = AnyComponent(PremiumStarComponent(
|
let component = AnyComponent(PremiumStarComponent(
|
||||||
|
theme: self.item.theme,
|
||||||
isIntro: true,
|
isIntro: true,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
hasIdleAnimations: true,
|
hasIdleAnimations: true,
|
||||||
|
@ -267,6 +267,7 @@ private final class PremiumGiftCodeSheetContent: CombinedComponent {
|
|||||||
|
|
||||||
let star = star.update(
|
let star = star.update(
|
||||||
component: PremiumStarComponent(
|
component: PremiumStarComponent(
|
||||||
|
theme: theme,
|
||||||
isIntro: false,
|
isIntro: false,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
hasIdleAnimations: true,
|
hasIdleAnimations: true,
|
||||||
|
@ -3210,6 +3210,7 @@ private final class PremiumIntroScreenComponent: CombinedComponent {
|
|||||||
} else {
|
} else {
|
||||||
header = star.update(
|
header = star.update(
|
||||||
component: PremiumStarComponent(
|
component: PremiumStarComponent(
|
||||||
|
theme: environment.theme,
|
||||||
isIntro: isIntro,
|
isIntro: isIntro,
|
||||||
isVisible: starIsVisible,
|
isVisible: starIsVisible,
|
||||||
hasIdleAnimations: state.hasIdleAnimations,
|
hasIdleAnimations: state.hasIdleAnimations,
|
||||||
|
@ -183,7 +183,7 @@ private final class StarsContextImpl {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
var transactions = state.transactions
|
var transactions = state.transactions
|
||||||
transactions.insert(.init(id: "\(arc4random())", count: balance, date: Int32(Date().timeIntervalSince1970), peer: .appStore, title: nil, description: nil, photo: nil), at: 0)
|
transactions.insert(.init(id: "tmp_\(arc4random())", count: balance, date: Int32(Date().timeIntervalSince1970), peer: .appStore, title: nil, description: nil, photo: nil), at: 0)
|
||||||
|
|
||||||
self.updateState(StarsContext.State(flags: [.isPendingBalance], balance: state.balance + balance, transactions: transactions, canLoadMore: state.canLoadMore, isLoading: state.isLoading))
|
self.updateState(StarsContext.State(flags: [.isPendingBalance], balance: state.balance + balance, transactions: transactions, canLoadMore: state.canLoadMore, isLoading: state.isLoading))
|
||||||
}
|
}
|
||||||
@ -433,10 +433,13 @@ private final class StarsTransactionsContextImpl {
|
|||||||
if filteredTransactions != initialTransactions {
|
if filteredTransactions != initialTransactions {
|
||||||
var existingIds = Set<String>()
|
var existingIds = Set<String>()
|
||||||
for transaction in self._state.transactions {
|
for transaction in self._state.transactions {
|
||||||
existingIds.insert(transaction.id)
|
if !transaction.id.hasPrefix("tmp_") {
|
||||||
|
existingIds.insert(transaction.id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var updatedState = self._state
|
var updatedState = self._state
|
||||||
|
updatedState.transactions.removeAll(where: { $0.id.hasPrefix("tmp_") })
|
||||||
for transaction in filteredTransactions.reversed() {
|
for transaction in filteredTransactions.reversed() {
|
||||||
if !existingIds.contains(transaction.id) {
|
if !existingIds.contains(transaction.id) {
|
||||||
updatedState.transactions.insert(transaction, at: 0)
|
updatedState.transactions.insert(transaction, at: 0)
|
||||||
|
@ -7,6 +7,7 @@ import SceneKit
|
|||||||
import GZip
|
import GZip
|
||||||
import AppBundle
|
import AppBundle
|
||||||
import LegacyComponents
|
import LegacyComponents
|
||||||
|
import TelegramPresentationData
|
||||||
|
|
||||||
private let sceneVersion: Int = 7
|
private let sceneVersion: Int = 7
|
||||||
|
|
||||||
@ -69,25 +70,31 @@ public func loadCompressedScene(name: String, version: Int) -> SCNScene? {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class PremiumStarComponent: Component {
|
public final class PremiumStarComponent: Component {
|
||||||
|
let theme: PresentationTheme
|
||||||
let isIntro: Bool
|
let isIntro: Bool
|
||||||
let isVisible: Bool
|
let isVisible: Bool
|
||||||
let hasIdleAnimations: Bool
|
let hasIdleAnimations: Bool
|
||||||
let colors: [UIColor]?
|
let colors: [UIColor]?
|
||||||
|
let particleColor: UIColor?
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
|
theme: PresentationTheme,
|
||||||
isIntro: Bool,
|
isIntro: Bool,
|
||||||
isVisible: Bool,
|
isVisible: Bool,
|
||||||
hasIdleAnimations: Bool,
|
hasIdleAnimations: Bool,
|
||||||
colors: [UIColor]? = nil
|
colors: [UIColor]? = nil,
|
||||||
|
particleColor: UIColor? = nil
|
||||||
) {
|
) {
|
||||||
|
self.theme = theme
|
||||||
self.isIntro = isIntro
|
self.isIntro = isIntro
|
||||||
self.isVisible = isVisible
|
self.isVisible = isVisible
|
||||||
self.hasIdleAnimations = hasIdleAnimations
|
self.hasIdleAnimations = hasIdleAnimations
|
||||||
self.colors = colors
|
self.colors = colors
|
||||||
|
self.particleColor = particleColor
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func ==(lhs: PremiumStarComponent, rhs: PremiumStarComponent) -> Bool {
|
public static func ==(lhs: PremiumStarComponent, rhs: PremiumStarComponent) -> Bool {
|
||||||
return lhs.isIntro == rhs.isIntro && lhs.isVisible == rhs.isVisible && lhs.hasIdleAnimations == rhs.hasIdleAnimations && lhs.colors == rhs.colors
|
return lhs.theme === rhs.theme && lhs.isIntro == rhs.isIntro && lhs.isVisible == rhs.isVisible && lhs.hasIdleAnimations == rhs.hasIdleAnimations && lhs.colors == rhs.colors && lhs.particleColor == rhs.particleColor
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class View: UIView, SCNSceneRendererDelegate, ComponentTaggedView {
|
public final class View: UIView, SCNSceneRendererDelegate, ComponentTaggedView {
|
||||||
@ -293,9 +300,10 @@ public final class PremiumStarComponent: Component {
|
|||||||
self.sceneView.scene = scene
|
self.sceneView.scene = scene
|
||||||
self.sceneView.delegate = self
|
self.sceneView.delegate = self
|
||||||
|
|
||||||
if let node = scene.rootNode.childNode(withName: "star", recursively: false), let colors = self.component?.colors, let color = colors.first {
|
if let component = self.component, let node = scene.rootNode.childNode(withName: "star", recursively: false), let colors =
|
||||||
|
component.colors {
|
||||||
node.geometry?.materials.first?.diffuse.contents = generateDiffuseTexture(colors: colors)
|
node.geometry?.materials.first?.diffuse.contents = generateDiffuseTexture(colors: colors)
|
||||||
|
|
||||||
let names: [String] = [
|
let names: [String] = [
|
||||||
"particles_left",
|
"particles_left",
|
||||||
"particles_right",
|
"particles_right",
|
||||||
@ -304,10 +312,63 @@ public final class PremiumStarComponent: Component {
|
|||||||
"particles_center"
|
"particles_center"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
let starNames: [String] = [
|
||||||
|
"coins_left",
|
||||||
|
"coins_right"
|
||||||
|
]
|
||||||
|
|
||||||
|
if let particleColor = component.particleColor {
|
||||||
|
for name in starNames {
|
||||||
|
if let node = scene.rootNode.childNode(withName: name, recursively: false), let particleSystem = node.particleSystems?.first {
|
||||||
|
particleSystem.particleIntensity = 1.0
|
||||||
|
particleSystem.particleIntensityVariation = 0.05
|
||||||
|
particleSystem.particleColor = particleColor
|
||||||
|
particleSystem.particleColorVariation = SCNVector4Make(0.07, 0.0, 0.1, 0.0)
|
||||||
|
node.isHidden = false
|
||||||
|
|
||||||
|
if let propertyControllers = particleSystem.propertyControllers, let sizeController = propertyControllers[.size], let colorController = propertyControllers[.color] {
|
||||||
|
let animation = CAKeyframeAnimation()
|
||||||
|
if let existing = colorController.animation as? CAKeyframeAnimation {
|
||||||
|
animation.keyTimes = existing.keyTimes
|
||||||
|
animation.values = existing.values?.compactMap { ($0 as? UIColor)?.alpha } ?? []
|
||||||
|
} else {
|
||||||
|
animation.values = [ 0.0, 1.0, 1.0, 0.0 ]
|
||||||
|
}
|
||||||
|
let opacityController = SCNParticlePropertyController(animation: animation)
|
||||||
|
particleSystem.propertyControllers = [
|
||||||
|
.size: sizeController,
|
||||||
|
.opacity: opacityController
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for name in names {
|
for name in names {
|
||||||
if let node = scene.rootNode.childNode(withName: name, recursively: false), let particleSystem = node.particleSystems?.first, color.rgb != 0x6a94ff {
|
if let node = scene.rootNode.childNode(withName: name, recursively: false), let particleSystem = node.particleSystems?.first {
|
||||||
particleSystem.particleColor = color
|
if let particleColor = component.particleColor {
|
||||||
particleSystem.particleColorVariation = SCNVector4Make(0, 0, 0, 0)
|
particleSystem.particleIntensity = min(1.0, 2.0 * particleSystem.particleIntensity)
|
||||||
|
particleSystem.particleIntensityVariation = 0.05
|
||||||
|
particleSystem.particleColor = particleColor
|
||||||
|
particleSystem.particleColorVariation = SCNVector4Make(0.1, 0.0, 0.12, 0.0)
|
||||||
|
} else {
|
||||||
|
particleSystem.particleColorVariation = SCNVector4Make(0.12, 0.03, 0.035, 0.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
if let propertyControllers = particleSystem.propertyControllers, let sizeController = propertyControllers[.size], let colorController = propertyControllers[.color] {
|
||||||
|
let animation = CAKeyframeAnimation()
|
||||||
|
if let existing = colorController.animation as? CAKeyframeAnimation {
|
||||||
|
animation.keyTimes = existing.keyTimes
|
||||||
|
animation.values = existing.values?.compactMap { ($0 as? UIColor)?.alpha } ?? []
|
||||||
|
} else {
|
||||||
|
animation.values = [ 0.0, 1.0, 1.0, 0.0 ]
|
||||||
|
}
|
||||||
|
let opacityController = SCNParticlePropertyController(animation: animation)
|
||||||
|
particleSystem.propertyControllers = [
|
||||||
|
.size: sizeController,
|
||||||
|
.opacity: opacityController
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -600,6 +661,10 @@ public final class PremiumStarComponent: Component {
|
|||||||
|
|
||||||
self.setup()
|
self.setup()
|
||||||
|
|
||||||
|
if let _ = component.particleColor {
|
||||||
|
self.sceneView.backgroundColor = component.theme.list.blocksBackgroundColor
|
||||||
|
}
|
||||||
|
|
||||||
self.sceneView.bounds = CGRect(origin: .zero, size: CGSize(width: availableSize.width * 2.0, height: availableSize.height * 2.0))
|
self.sceneView.bounds = CGRect(origin: .zero, size: CGSize(width: availableSize.width * 2.0, height: availableSize.height * 2.0))
|
||||||
if self.sceneView.superview == self {
|
if self.sceneView.superview == self {
|
||||||
self.sceneView.center = CGPoint(x: availableSize.width / 2.0, y: availableSize.height / 2.0)
|
self.sceneView.center = CGPoint(x: availableSize.width / 2.0, y: availableSize.height / 2.0)
|
||||||
|
@ -167,7 +167,7 @@ private final class StarsPurchaseScreenContentComponent: CombinedComponent {
|
|||||||
|
|
||||||
static var body: Body {
|
static var body: Body {
|
||||||
let overscroll = Child(Rectangle.self)
|
let overscroll = Child(Rectangle.self)
|
||||||
let fade = Child(RoundedRectangle.self)
|
// let fade = Child(RoundedRectangle.self)
|
||||||
let text = Child(BalancedTextComponent.self)
|
let text = Child(BalancedTextComponent.self)
|
||||||
let list = Child(VStack<Empty>.self)
|
let list = Child(VStack<Empty>.self)
|
||||||
let termsText = Child(BalancedTextComponent.self)
|
let termsText = Child(BalancedTextComponent.self)
|
||||||
@ -203,21 +203,21 @@ private final class StarsPurchaseScreenContentComponent: CombinedComponent {
|
|||||||
.position(CGPoint(x: overscroll.size.width / 2.0, y: -overscroll.size.height / 2.0))
|
.position(CGPoint(x: overscroll.size.width / 2.0, y: -overscroll.size.height / 2.0))
|
||||||
)
|
)
|
||||||
|
|
||||||
let fade = fade.update(
|
// let fade = fade.update(
|
||||||
component: RoundedRectangle(
|
// component: RoundedRectangle(
|
||||||
colors: [
|
// colors: [
|
||||||
topBackgroundColor,
|
// topBackgroundColor,
|
||||||
bottomBackgroundColor
|
// bottomBackgroundColor
|
||||||
],
|
// ],
|
||||||
cornerRadius: 0.0,
|
// cornerRadius: 0.0,
|
||||||
gradientDirection: .vertical
|
// gradientDirection: .vertical
|
||||||
),
|
// ),
|
||||||
availableSize: CGSize(width: availableWidth, height: 300),
|
// availableSize: CGSize(width: availableWidth, height: 300),
|
||||||
transition: context.transition
|
// transition: context.transition
|
||||||
)
|
// )
|
||||||
context.add(fade
|
// context.add(fade
|
||||||
.position(CGPoint(x: fade.size.width / 2.0, y: fade.size.height / 2.0))
|
// .position(CGPoint(x: fade.size.width / 2.0, y: fade.size.height / 2.0))
|
||||||
)
|
// )
|
||||||
|
|
||||||
size.height += 183.0 + 10.0 + environment.navigationHeight - 56.0
|
size.height += 183.0 + 10.0 + environment.navigationHeight - 56.0
|
||||||
|
|
||||||
@ -724,6 +724,7 @@ private final class StarsPurchaseScreenComponent: CombinedComponent {
|
|||||||
|
|
||||||
let header = star.update(
|
let header = star.update(
|
||||||
component: PremiumStarComponent(
|
component: PremiumStarComponent(
|
||||||
|
theme: environment.theme,
|
||||||
isIntro: true,
|
isIntro: true,
|
||||||
isVisible: starIsVisible,
|
isVisible: starIsVisible,
|
||||||
hasIdleAnimations: state.hasIdleAnimations,
|
hasIdleAnimations: state.hasIdleAnimations,
|
||||||
@ -732,7 +733,8 @@ private final class StarsPurchaseScreenComponent: CombinedComponent {
|
|||||||
UIColor(rgb: 0xf09903),
|
UIColor(rgb: 0xf09903),
|
||||||
UIColor(rgb: 0xf9b004),
|
UIColor(rgb: 0xf9b004),
|
||||||
UIColor(rgb: 0xfdd219)
|
UIColor(rgb: 0xfdd219)
|
||||||
]
|
],
|
||||||
|
particleColor: UIColor(rgb: 0xf9b004)
|
||||||
),
|
),
|
||||||
availableSize: CGSize(width: min(414.0, context.availableSize.width), height: 220.0),
|
availableSize: CGSize(width: min(414.0, context.availableSize.width), height: 220.0),
|
||||||
transition: context.transition
|
transition: context.transition
|
||||||
|
@ -428,7 +428,7 @@ private final class StarsTransactionSheetContent: CombinedComponent {
|
|||||||
)
|
)
|
||||||
|
|
||||||
context.add(star
|
context.add(star
|
||||||
.position(CGPoint(x: context.availableSize.width / 2.0, y: star.size.height / 2.0 - 32.0))
|
.position(CGPoint(x: context.availableSize.width / 2.0, y: star.size.height / 2.0 - 19.0))
|
||||||
)
|
)
|
||||||
|
|
||||||
var originY: CGFloat = 0.0
|
var originY: CGFloat = 0.0
|
||||||
|
@ -383,6 +383,7 @@ final class StarsTransactionsScreenComponent: Component {
|
|||||||
let starSize = self.starView.update(
|
let starSize = self.starView.update(
|
||||||
transition: .immediate,
|
transition: .immediate,
|
||||||
component: AnyComponent(PremiumStarComponent(
|
component: AnyComponent(PremiumStarComponent(
|
||||||
|
theme: environment.theme,
|
||||||
isIntro: true,
|
isIntro: true,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
hasIdleAnimations: true,
|
hasIdleAnimations: true,
|
||||||
@ -391,7 +392,8 @@ final class StarsTransactionsScreenComponent: Component {
|
|||||||
UIColor(rgb: 0xf09903),
|
UIColor(rgb: 0xf09903),
|
||||||
UIColor(rgb: 0xf9b004),
|
UIColor(rgb: 0xf9b004),
|
||||||
UIColor(rgb: 0xfdd219)
|
UIColor(rgb: 0xfdd219)
|
||||||
]
|
],
|
||||||
|
particleColor: UIColor(rgb: 0xf9b004)
|
||||||
)),
|
)),
|
||||||
environment: {},
|
environment: {},
|
||||||
containerSize: CGSize(width: min(414.0, availableSize.width), height: 220.0)
|
containerSize: CGSize(width: min(414.0, availableSize.width), height: 220.0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user