Skip to content

Commit d40e803

Browse files
author
Isaac
committed
Merge commit 'b3aef934353318083f1a6aa105aeef56baaaf3c7'
2 parents 8c54db6 + b3aef93 commit d40e803

16 files changed

Lines changed: 177 additions & 58 deletions

File tree

3.31 KB
Binary file not shown.

Telegram/Telegram-iOS/en.lproj/Localizable.strings

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15703,7 +15703,8 @@ Error: %8$@";
1570315703

1570415704
"Gift.Craft.Select.Title" = "Select Gifts";
1570515705
"Gift.Craft.Select.YourGifts" = "Your Gifts";
15706-
"Gift.Craft.Select.SaleGifts" = "Suitable Gifts On Sale";
15706+
"Gift.Craft.Select.SaleGiftsCount_1" = "%@ Suitable Gift On Sale";
15707+
"Gift.Craft.Select.SaleGiftsCount_any" = "%@ Suitable Gifts On Sale";
1570715708
"Gift.Craft.Select.NoGiftsFromCollection" = "You don't have other gifts\nfrom this collection";
1570815709

1570915710
"Gift.Attribute.Rare" = "rare";

submodules/SettingsUI/Sources/Data and Storage/IntentsSettingsController.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private enum IntentsSettingsSection: Int32 {
4747

4848
private enum IntentsSettingsControllerEntry: ItemListNodeEntry {
4949
case accountHeader(PresentationTheme, String)
50-
case account(PresentationTheme, EnginePeer, Bool, Int32)
50+
case account(PresentationTheme, Account, EnginePeer, Bool, Int32)
5151
case accountInfo(PresentationTheme, String)
5252

5353
case chatsHeader(PresentationTheme, String)
@@ -80,7 +80,7 @@ private enum IntentsSettingsControllerEntry: ItemListNodeEntry {
8080
switch self {
8181
case .accountHeader:
8282
return 0
83-
case let .account(_, _, _, index):
83+
case let .account(_, _, _, _, index):
8484
return 1 + index
8585
case .accountInfo:
8686
return 1000
@@ -115,8 +115,8 @@ private enum IntentsSettingsControllerEntry: ItemListNodeEntry {
115115
} else {
116116
return false
117117
}
118-
case let .account(lhsTheme, lhsPeer, lhsSelected, lhsIndex):
119-
if case let .account(rhsTheme, rhsPeer, rhsSelected, rhsIndex) = rhs, lhsTheme === rhsTheme, lhsPeer == rhsPeer, lhsSelected == rhsSelected, lhsIndex == rhsIndex {
118+
case let .account(lhsTheme, lhsAccount, lhsPeer, lhsSelected, lhsIndex):
119+
if case let .account(rhsTheme, rhsAccount, rhsPeer, rhsSelected, rhsIndex) = rhs, lhsTheme === rhsTheme, lhsAccount === rhsAccount, lhsPeer == rhsPeer, lhsSelected == rhsSelected, lhsIndex == rhsIndex {
120120
return true
121121
} else {
122122
return false
@@ -200,8 +200,8 @@ private enum IntentsSettingsControllerEntry: ItemListNodeEntry {
200200
switch self {
201201
case let .accountHeader(_, text):
202202
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
203-
case let .account(_, peer, selected, _):
204-
return ItemListPeerItem(presentationData: presentationData, systemStyle: .glass, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: .firstLast, context: arguments.context.sharedContext.makeTempAccountContext(account: arguments.context.account), peer: peer, height: .generic, aliasHandling: .standard, nameStyle: .plain, presence: nil, text: .none, label: .none, editing: ItemListPeerItemEditing(editable: true, editing: false, revealed: false), revealOptions: nil, switchValue: ItemListPeerItemSwitch(value: selected, style: .check), enabled: true, selectable: true, sectionId: self.section, action: {
203+
case let .account(_, account, peer, selected, _):
204+
return ItemListPeerItem(presentationData: presentationData, systemStyle: .glass, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: .firstLast, context: arguments.context.sharedContext.makeTempAccountContext(account: account), peer: peer, height: .generic, aliasHandling: .standard, nameStyle: .plain, presence: nil, text: .none, label: .none, editing: ItemListPeerItemEditing(editable: true, editing: false, revealed: false), revealOptions: nil, switchValue: ItemListPeerItemSwitch(value: selected, style: .check), enabled: true, selectable: true, sectionId: self.section, action: {
205205
arguments.updateSettings { $0.withUpdatedAccount(peer.id) }
206206
}, setPeerIdWithRevealedOptions: { _, _ in}, removePeer: { _ in })
207207
case let .accountInfo(_, text):
@@ -251,8 +251,8 @@ private func intentsSettingsControllerEntries(context: AccountContext, presentat
251251
if accounts.count > 1 {
252252
entries.append(.accountHeader(presentationData.theme, presentationData.strings.IntentsSettings_MainAccount.uppercased()))
253253
var index: Int32 = 0
254-
for (_, peer) in accounts {
255-
entries.append(.account(presentationData.theme, peer, peer.id == settings.account, index))
254+
for (account, peer) in accounts {
255+
entries.append(.account(presentationData.theme, account, peer, peer.id == settings.account, index))
256256
index += 1
257257
}
258258
entries.append(.accountInfo(presentationData.theme, presentationData.strings.IntentsSettings_MainAccountInfo))

submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4241,11 +4241,15 @@ public final class ResaleGiftsContext {
42414241
}
42424242
}
42434243

4244+
public let forCrafting: Bool
4245+
42444246
public init(
42454247
account: Account,
42464248
giftId: Int64,
42474249
forCrafting: Bool
42484250
) {
4251+
self.forCrafting = forCrafting
4252+
42494253
let queue = self.queue
42504254
self.impl = QueueLocalObject(queue: queue, generate: {
42514255
return ResaleGiftsContextImpl(queue: queue, account: account, giftId: giftId, forCrafting: forCrafting)

submodules/TelegramUI/Components/Gifts/GiftCraftScreen/Sources/CraftTableComponent.swift

Lines changed: 76 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ final class CraftTableComponent: Component {
9898
super.init(frame: frame)
9999

100100
self.addSubview(self.animationView)
101+
102+
self.animationView.onStickerLaunch = {
103+
HapticFeedback().impact(.soft)
104+
}
101105
}
102106

103107
required init?(coder: NSCoder) {
@@ -110,26 +114,29 @@ final class CraftTableComponent: Component {
110114
}
111115
self.didSetupFinishAnimation = true
112116

113-
self.animationView.onFinishApproach = { [weak self] isUpsideDown in
114-
guard let self else {
117+
self.animationView.onFinishApproach = { [weak self] isUpsideDown, isClockwise in
118+
guard let self, let component = self.component else {
115119
return
116120
}
117121
self.isFailed = true
118122
self.animationView.setSticker(nil, face: 0, mirror: false)
119123

120124
var availableStickers: [ComponentView<Empty>] = []
121-
for gift in self.selectedGifts.values {
122-
availableStickers.append(gift)
125+
for (id, gift) in self.selectedGifts {
126+
if let id = id.base as? Int, component.gifts[Int32(id)] != nil {
127+
availableStickers.append(gift)
128+
}
123129
}
124-
for i in 0 ..< min(2, availableStickers.count) {
130+
let wrappingCount = min(2, availableStickers.count)
131+
for i in 0 ..< wrappingCount {
125132
if let sticker = availableStickers[i].view {
126133
let face: Int
127-
if isUpsideDown {
134+
if isClockwise {
128135
face = i + 1
129136
} else {
130137
face = 3 - i
131138
}
132-
self.animationView.setSticker(sticker, face: face, mirror: isUpsideDown)
139+
self.animationView.setSticker(sticker, face: face, mirror: isUpsideDown, animated: true)
133140
}
134141
}
135142

@@ -159,25 +166,28 @@ final class CraftTableComponent: Component {
159166

160167
self.animationView.isSuccess = true
161168

162-
self.animationView.onFinishApproach = { [weak self] isUpsideDown in
169+
self.animationView.onFinishApproach = { [weak self] isUpsideDown, isClockwise in
163170
guard let self else {
164171
return
165172
}
166173
self.isSuccess = true
167174

168175
var availableStickers: [ComponentView<Empty>] = []
169-
for gift in self.selectedGifts.values {
170-
availableStickers.append(gift)
176+
for (id, gift) in self.selectedGifts {
177+
if let id = id.base as? Int, component.gifts[Int32(id)] != nil {
178+
availableStickers.append(gift)
179+
}
171180
}
172-
for i in 0 ..< min(2, availableStickers.count) {
181+
let wrappingCount = min(2, availableStickers.count)
182+
for i in 0 ..< wrappingCount {
173183
if let sticker = availableStickers[i].view {
174184
let face: Int
175-
if isUpsideDown {
185+
if isClockwise {
176186
face = i + 1
177187
} else {
178188
face = 3 - i
179189
}
180-
self.animationView.setSticker(sticker, face: face, mirror: isUpsideDown)
190+
self.animationView.setSticker(sticker, face: face, mirror: isUpsideDown, animated: true)
181191
}
182192
}
183193

@@ -258,7 +268,7 @@ final class CraftTableComponent: Component {
258268
if index == 0 {
259269
faceItems.append(
260270
AnyComponentWithIdentity(id: "background", component: AnyComponent(
261-
FilledRoundedRectangleComponent(color: component.buttonColor, cornerRadius: .value(28.0), smoothCorners: true)
271+
CubeFaceComponent(color: component.buttonColor, cornerRadius: 28.0)
262272
))
263273
)
264274
if !component.isCrafting || self.isFailed {
@@ -324,12 +334,12 @@ final class CraftTableComponent: Component {
324334
} else {
325335
faceItems.append(
326336
AnyComponentWithIdentity(id: "background", component: AnyComponent(
327-
FilledRoundedRectangleComponent(color: component.buttonColor, cornerRadius: .value(28.0), smoothCorners: true)
337+
CubeFaceComponent(color: component.buttonColor, cornerRadius: 28.0)
328338
))
329339
)
330340
faceItems.append(
331341
AnyComponentWithIdentity(id: "icon", component: AnyComponent(
332-
BundleIconComponent(name: "Components/CubeSide", tintColor: nil, flipVertically: self.flipFaces)
342+
BundleIconComponent(name: "Components/CubeSide", tintColor: nil, flipVertically: index < 4 ? self.flipFaces : false)
333343
))
334344
)
335345
}
@@ -408,8 +418,13 @@ final class CraftTableComponent: Component {
408418
for index in component.gifts.keys.sorted() {
409419
indices.append(Int(index))
410420
}
421+
422+
Queue.mainQueue().after(0.55) {
423+
HapticFeedback().impact(.light)
424+
}
425+
411426
self.anvilPlayOnce.invoke(Void())
412-
Queue.mainQueue().after(0.6, {
427+
Queue.mainQueue().after(0.75, {
413428
self.animationView.startStickerSequence(indices: indices)
414429

415430
switch component.result {
@@ -772,3 +787,47 @@ private func generateAddIcon(backgroundColor: UIColor) -> UIImage? {
772787
context.strokePath()
773788
})
774789
}
790+
791+
private final class CubeFaceComponent: Component {
792+
private let color: UIColor
793+
private let cornerRadius: CGFloat
794+
795+
public init(color: UIColor, cornerRadius: CGFloat) {
796+
self.color = color
797+
self.cornerRadius = cornerRadius
798+
}
799+
800+
public static func ==(lhs: CubeFaceComponent, rhs: CubeFaceComponent) -> Bool {
801+
if !lhs.color.isEqual(rhs.color) {
802+
return false
803+
}
804+
if lhs.cornerRadius != rhs.cornerRadius {
805+
return false
806+
}
807+
return true
808+
}
809+
810+
public final class View: UIView {
811+
override public init(frame: CGRect) {
812+
super.init(frame: frame)
813+
814+
self.clipsToBounds = true
815+
self.layer.cornerCurve = .continuous
816+
}
817+
818+
required public init?(coder: NSCoder) {
819+
fatalError("init(coder:) has not been implemented")
820+
}
821+
}
822+
823+
public func makeView() -> View {
824+
return View(frame: CGRect())
825+
}
826+
827+
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
828+
transition.setBackgroundColor(view: view, color: self.color)
829+
transition.setCornerRadius(layer: view.layer, cornerRadius: self.cornerRadius)
830+
831+
return availableSize
832+
}
833+
}

submodules/TelegramUI/Components/Gifts/GiftCraftScreen/Sources/CubeAnimationView.swift

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ final class CubeAnimationView: UIView {
8282

8383
var isSuccess = false
8484

85-
var onFinishApproach: ((Bool) -> Void)?
85+
var onStickerLaunch: (() -> Void)?
86+
var onFinishApproach: ((Bool, Bool) -> Void)?
8687

8788
private let defaultStickOrder: [Int] = [0, 5, 4, 3]
8889
private let sequenceStickOrders: [String: [Int]] = [
@@ -160,7 +161,7 @@ final class CubeAnimationView: UIView {
160161
self.layoutStickers()
161162
}
162163

163-
func setSticker(_ sticker: UIView?, face index: Int, mirror: Bool) {
164+
func setSticker(_ sticker: UIView?, face index: Int, mirror: Bool, animated: Bool = false) {
164165
guard self.faces.indices.contains(index) else {
165166
return
166167
}
@@ -177,6 +178,13 @@ final class CubeAnimationView: UIView {
177178
if let priorIndex = self.faceOccupants.first(where: { $0.value === sticker })?.key {
178179
self.faceOccupants[priorIndex] = nil
179180
}
181+
182+
if animated, let stickerSuperview = sticker.superview, let snapshotView = sticker.snapshotView(afterScreenUpdates: false) {
183+
stickerSuperview.addSubview(snapshotView)
184+
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { _ in
185+
snapshotView.removeFromSuperview()
186+
})
187+
}
180188
sticker.removeFromSuperview()
181189

182190
let targetFace = self.faces[index]
@@ -200,6 +208,10 @@ final class CubeAnimationView: UIView {
200208
snappedAngle += .pi
201209
}
202210
sticker.transform = CGAffineTransform(rotationAngle: snappedAngle)
211+
212+
if animated {
213+
sticker.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
214+
}
203215
}
204216

205217
func startStickerSequence(indices: [Int]? = nil) {
@@ -520,6 +532,8 @@ final class CubeAnimationView: UIView {
520532
return
521533
}
522534

535+
self.onStickerLaunch?()
536+
523537
if let animationView, animationView !== sticker {
524538
animationView.removeFromSuperview()
525539
self.warpSnapshot = nil
@@ -697,7 +711,8 @@ final class CubeAnimationView: UIView {
697711
if !self.hasFiredFinishApproach && absRemaining <= self.finishApproachTriggerAngle {
698712
self.hasFiredFinishApproach = true
699713
let upsideDown = abs(shortestAngleDelta(from: self.rotation.x, to: Float.pi)) < (Float.pi / 2)
700-
self.onFinishApproach?(upsideDown)
714+
let isClockwise = self.finishDirectionY > 0
715+
self.onFinishApproach?(upsideDown, isClockwise)
701716
}
702717
if self.isSuccess, absRemaining <= self.finishSuccessScaleTriggerAngle {
703718
let raw = (self.finishSuccessScaleTriggerAngle - absRemaining) / self.finishSuccessScaleTriggerAngle

submodules/TelegramUI/Components/Gifts/GiftCraftScreen/Sources/DialIndicatorComponent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ final class ColorSwatchComponent: Component {
271271
if let image = UIImage(bundleImageName: "Premium/Craft/DialColorMask"), let cgImage = image.cgImage {
272272
context.clip(to: CGRect(origin: .zero, size: size), mask: cgImage)
273273
}
274-
var locations: [CGFloat] = [1.0, 0.0]
275-
let colors: [CGColor] = [component.innerColor.cgColor, component.outerColor.cgColor]
274+
var locations: [CGFloat] = [1.0, 0.95, 0.1, 0.0]
275+
let colors: [CGColor] = [component.innerColor.cgColor, component.innerColor.cgColor, component.outerColor.cgColor, component.outerColor.cgColor]
276276

277277
let colorSpace = CGColorSpaceCreateDeviceRGB()
278278
let gradient = CGGradient(colorsSpace: colorSpace, colors: colors as CFArray, locations: &locations)!

submodules/TelegramUI/Components/Gifts/GiftCraftScreen/Sources/GiftCraftScreen.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,9 @@ private final class CraftGiftPageContent: Component {
12151215

12161216
HapticFeedback().success()
12171217
} else {
1218-
HapticFeedback().error()
1218+
Queue.mainQueue().after(0.35) {
1219+
HapticFeedback().error()
1220+
}
12191221
}
12201222
}
12211223
)

submodules/TelegramUI/Components/Gifts/GiftCraftScreen/Sources/SelectCraftGiftScreen.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,13 @@ final class SelectGiftPageContent: Component {
406406

407407
contentHeight = self.updateScrolling(interactive: false, transition: transition)
408408

409+
let resaleCount = component.genericGift.availability?.resale ?? 0
410+
let saleTitle = environment.strings.Gift_Craft_Select_SaleGiftsCount(Int32(clamping: resaleCount)).uppercased()
411+
409412
let storeGiftsTitleSize = self.storeGiftsTitle.update(
410413
transition: transition,
411414
component: AnyComponent(
412-
MultilineTextComponent(text: .plain(NSAttributedString(string: environment.strings.Gift_Craft_Select_SaleGifts.uppercased(), font: Font.semibold(14.0), textColor: environment.theme.actionSheet.secondaryTextColor)))
415+
MultilineTextComponent(text: .plain(NSAttributedString(string: saleTitle, font: Font.semibold(14.0), textColor: environment.theme.actionSheet.secondaryTextColor)))
413416
),
414417
environment: {},
415418
containerSize: CGSize(width: availableSize.width - sideInset * 2.0, height: 100.0)

submodules/TelegramUI/Components/Gifts/GiftStoreScreen/Sources/GiftStoreScreen.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,10 @@ public final class GiftStoreContentComponent: Component {
552552

553553
let attributes = self.starGiftsState?.attributes ?? []
554554
let modelAttributes = attributes.filter { attribute in
555-
if case .model = attribute {
555+
if case let .model(_, _, _, crafted) = attribute {
556+
if component.resaleGiftsContext.forCrafting && crafted {
557+
return false
558+
}
556559
return true
557560
} else {
558561
return false

0 commit comments

Comments
 (0)