Skip to content

Commit cbf23d0

Browse files
committed
Various fixes
1 parent 1d351a0 commit cbf23d0

File tree

8 files changed

+66
-18
lines changed

8 files changed

+66
-18
lines changed

submodules/ComponentFlow/Source/Components/Button.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import UIKit
44
public final class Button: Component {
55
public let content: AnyComponent<Empty>
66
public let minSize: CGSize?
7+
public let hitTestEdgeInsets: UIEdgeInsets?
78
public let tag: AnyObject?
89
public let automaticHighlight: Bool
910
public let isEnabled: Bool
@@ -22,6 +23,7 @@ public final class Button: Component {
2223
self.init(
2324
content: content,
2425
minSize: nil,
26+
hitTestEdgeInsets: nil,
2527
tag: nil,
2628
automaticHighlight: automaticHighlight,
2729
isEnabled: isEnabled,
@@ -34,6 +36,7 @@ public final class Button: Component {
3436
private init(
3537
content: AnyComponent<Empty>,
3638
minSize: CGSize? = nil,
39+
hitTestEdgeInsets: UIEdgeInsets? = nil,
3740
tag: AnyObject? = nil,
3841
automaticHighlight: Bool = true,
3942
isEnabled: Bool = true,
@@ -44,6 +47,7 @@ public final class Button: Component {
4447
) {
4548
self.content = content
4649
self.minSize = minSize
50+
self.hitTestEdgeInsets = hitTestEdgeInsets
4751
self.tag = tag
4852
self.automaticHighlight = automaticHighlight
4953
self.isEnabled = isEnabled
@@ -57,6 +61,22 @@ public final class Button: Component {
5761
return Button(
5862
content: self.content,
5963
minSize: minSize,
64+
hitTestEdgeInsets: self.hitTestEdgeInsets,
65+
tag: self.tag,
66+
automaticHighlight: self.automaticHighlight,
67+
isEnabled: self.isEnabled,
68+
isExclusive: self.isExclusive,
69+
action: self.action,
70+
holdAction: self.holdAction,
71+
highlightedAction: self.highlightedAction
72+
)
73+
}
74+
75+
public func withHitTestEdgeInsets(_ hitTestEdgeInsets: UIEdgeInsets?) -> Button {
76+
return Button(
77+
content: self.content,
78+
minSize: self.minSize,
79+
hitTestEdgeInsets: hitTestEdgeInsets,
6080
tag: self.tag,
6181
automaticHighlight: self.automaticHighlight,
6282
isEnabled: self.isEnabled,
@@ -71,6 +91,7 @@ public final class Button: Component {
7191
return Button(
7292
content: self.content,
7393
minSize: self.minSize,
94+
hitTestEdgeInsets: self.hitTestEdgeInsets,
7495
tag: self.tag,
7596
automaticHighlight: self.automaticHighlight,
7697
isEnabled: self.isEnabled,
@@ -86,6 +107,7 @@ public final class Button: Component {
86107
return Button(
87108
content: self.content,
88109
minSize: self.minSize,
110+
hitTestEdgeInsets: self.hitTestEdgeInsets,
89111
tag: self.tag,
90112
automaticHighlight: self.automaticHighlight,
91113
isEnabled: self.isEnabled,
@@ -100,6 +122,7 @@ public final class Button: Component {
100122
return Button(
101123
content: self.content,
102124
minSize: self.minSize,
125+
hitTestEdgeInsets: self.hitTestEdgeInsets,
103126
tag: tag,
104127
automaticHighlight: self.automaticHighlight,
105128
isEnabled: self.isEnabled,
@@ -117,6 +140,9 @@ public final class Button: Component {
117140
if lhs.minSize != rhs.minSize {
118141
return false
119142
}
143+
if lhs.hitTestEdgeInsets != rhs.hitTestEdgeInsets {
144+
return false
145+
}
120146
if lhs.tag !== rhs.tag {
121147
return false
122148
}
@@ -174,6 +200,14 @@ public final class Button: Component {
174200
private var holdActionTriggerred: Bool = false
175201
private var holdActionTimer: Timer?
176202

203+
public override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
204+
var bounds = self.bounds
205+
if let hitTestEdgeInsets = self.component?.hitTestEdgeInsets {
206+
bounds = bounds.insetBy(dx: hitTestEdgeInsets.left, dy: hitTestEdgeInsets.top)
207+
}
208+
return bounds.contains(point)
209+
}
210+
177211
override init(frame: CGRect) {
178212
self.contentView = ComponentHostView<Empty>()
179213
self.contentView.isUserInteractionEnabled = false

submodules/StatisticsUI/Sources/StarsTransactionItem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ final class StarsTransactionItemNode: ListViewItemNode, ItemListItemNode {
347347
theme: item.presentationData.theme,
348348
title: AnyComponent(VStack(titleComponents, alignment: .left, spacing: 2.0)),
349349
contentInsets: UIEdgeInsets(top: 9.0, left: 0.0, bottom: 8.0, right: 0.0),
350-
leftIcon: .custom(AnyComponentWithIdentity(id: "avatar", component: AnyComponent(StarsAvatarComponent(context: item.context, theme: item.presentationData.theme, peer: .transactionPeer(item.transaction.peer), photo: nil, media: [], uniqueGift: nil, backgroundColor: item.presentationData.theme.list.itemBlocksBackgroundColor))), false),
350+
leftIcon: .custom(AnyComponentWithIdentity(id: "avatar", component: AnyComponent(StarsAvatarComponent(context: item.context, theme: item.presentationData.theme, peer: .transactionPeer(item.transaction.peer), photo: nil, media: [], gift: nil, backgroundColor: item.presentationData.theme.list.itemBlocksBackgroundColor))), false),
351351
icon: nil,
352352
accessory: .custom(ListActionItemComponent.CustomAccessory(component: AnyComponentWithIdentity(id: "label", component: AnyComponent(StarsLabelComponent(text: itemLabel, iconName: itemIconName, iconColor: itemIconColor))), insets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 16.0))),
353353
action: { [weak self] _ in

submodules/TelegramUI/Components/CameraScreen/Sources/CaptureControlsComponent.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,7 @@ final class CaptureControlsComponent: Component {
14111411
transition.setAlpha(view: bottomSettingsButtonView, alpha: !isLiveStream || isLiveActive || isRecording || isTransitioning || hideControls ? 0.0 : 1.0)
14121412
}
14131413

1414+
var hitTestEdgeInsets: UIEdgeInsets?
14141415
var blobState: ShutterBlobView.BlobState
14151416
switch component.shutterState {
14161417
case .generic, .disabled:
@@ -1423,6 +1424,7 @@ final class CaptureControlsComponent: Component {
14231424
blobState = self.panBlobState ?? .video
14241425
case .live:
14251426
blobState = .live
1427+
hitTestEdgeInsets = UIEdgeInsets(top: 0.0, left: -130.0, bottom: 0.0, right: -130.0)
14261428
}
14271429

14281430
let shutterButtonSize = self.shutterButtonView.update(
@@ -1451,7 +1453,7 @@ final class CaptureControlsComponent: Component {
14511453
component.shutterTapped()
14521454
},
14531455
highlightedAction: self.shutterHightlightedAction
1454-
).minSize(maximumShutterSize)
1456+
).minSize(maximumShutterSize).withHitTestEdgeInsets(hitTestEdgeInsets)
14551457
),
14561458
environment: {},
14571459
containerSize: availableSize

submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftWithdrawAlertController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ private final class GiftWithdrawAlertContentNode: AlertContentNode {
177177
peer: .transactionPeer(.fragment),
178178
photo: nil,
179179
media: [],
180-
uniqueGift: nil,
180+
gift: nil,
181181
backgroundColor: .clear,
182182
size: avatarSize
183183
)

submodules/TelegramUI/Components/Stars/StarsAvatarComponent/Sources/StarsAvatarComponent.swift

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public final class StarsAvatarComponent: Component {
2424
let peer: StarsAvatarComponent.Peer?
2525
let photo: TelegramMediaWebFile?
2626
let media: [Media]
27-
let uniqueGift: StarGift.UniqueGift?
27+
let gift: StarGift?
2828
let backgroundColor: UIColor
2929
let size: CGSize?
3030

@@ -34,7 +34,7 @@ public final class StarsAvatarComponent: Component {
3434
peer: StarsAvatarComponent.Peer?,
3535
photo: TelegramMediaWebFile?,
3636
media: [Media],
37-
uniqueGift: StarGift.UniqueGift?,
37+
gift: StarGift?,
3838
backgroundColor: UIColor,
3939
size: CGSize? = nil
4040
) {
@@ -43,7 +43,7 @@ public final class StarsAvatarComponent: Component {
4343
self.peer = peer
4444
self.photo = photo
4545
self.media = media
46-
self.uniqueGift = uniqueGift
46+
self.gift = gift
4747
self.backgroundColor = backgroundColor
4848
self.size = size
4949
}
@@ -64,7 +64,7 @@ public final class StarsAvatarComponent: Component {
6464
if !areMediaArraysEqual(lhs.media, rhs.media) {
6565
return false
6666
}
67-
if lhs.uniqueGift != rhs.uniqueGift {
67+
if lhs.gift != rhs.gift {
6868
return false
6969
}
7070
if lhs.backgroundColor != rhs.backgroundColor {
@@ -121,8 +121,17 @@ public final class StarsAvatarComponent: Component {
121121
var dimensions = size
122122

123123
var didSetup = false
124-
if let gift = component.uniqueGift {
124+
if let gift = component.gift {
125125
let giftFrame = CGRect(origin: .zero, size: size)
126+
127+
var subject: GiftItemComponent.Subject
128+
switch gift {
129+
case let .generic(gift):
130+
subject = .starGift(gift: gift, price: "")
131+
case let .unique(gift):
132+
subject = .uniqueGift(gift: gift, price: nil)
133+
}
134+
126135
let _ = self.giftView.update(
127136
transition: .immediate,
128137
component: AnyComponent(
@@ -131,7 +140,7 @@ public final class StarsAvatarComponent: Component {
131140
theme: component.theme,
132141
strings: component.context.sharedContext.currentPresentationData.with { $0 }.strings,
133142
peer: nil,
134-
subject: .uniqueGift(gift: gift, price: nil),
143+
subject: subject,
135144
mode: .thumbnail
136145
)
137146
),

submodules/TelegramUI/Components/Stars/StarsTransactionScreen/Sources/StarsTransactionScreen.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ private final class StarsTransactionSheetContent: CombinedComponent {
214214
var photo: TelegramMediaWebFile?
215215
var transactionStatus: (String, UIColor)? = nil
216216
var isGift = false
217+
var isGiftAuctionBid = false
217218
var isSubscription = false
218219
var isSubscriber = false
219220
var isSubscriptionFee = false
@@ -356,6 +357,7 @@ private final class StarsTransactionSheetContent: CombinedComponent {
356357
case .generic:
357358
if transaction.flags.contains(.isStarGiftAuctionBid) {
358359
titleText = strings.Stars_Transaction_GiftAuctionBid
360+
isGiftAuctionBid = true
359361
} else {
360362
titleText = strings.Stars_Transaction_Gift_Title
361363
}
@@ -927,7 +929,7 @@ private final class StarsTransactionSheetContent: CombinedComponent {
927929
))
928930
}
929931

930-
if isGift, toPeer == nil {
932+
if isGift && !isGiftAuctionBid, toPeer == nil {
931933
tableItems.append(.init(
932934
id: "from",
933935
title: strings.Stars_Transaction_From,
@@ -950,7 +952,7 @@ private final class StarsTransactionSheetContent: CombinedComponent {
950952
)
951953
)
952954
))
953-
} else if let toPeer, !isRefProgram {
955+
} else if let toPeer, !isRefProgram && !isGiftAuctionBid {
954956
let title: String
955957
if isGiftUpgrade {
956958
title = strings.Stars_Transaction_GiftFrom
@@ -2438,7 +2440,7 @@ private final class PeerCellComponent: Component {
24382440
let avatarNaturalSize = self.avatar.update(
24392441
transition: .immediate,
24402442
component: AnyComponent(
2441-
StarsAvatarComponent(context: component.context, theme: component.theme, peer: .transactionPeer(peer), photo: nil, media: [], uniqueGift: nil, backgroundColor: .clear)
2443+
StarsAvatarComponent(context: component.context, theme: component.theme, peer: .transactionPeer(peer), photo: nil, media: [], gift: nil, backgroundColor: .clear)
24422444
),
24432445
environment: {},
24442446
containerSize: CGSize(width: 40.0, height: 40.0)

submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsListPanelComponent.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ final class StarsTransactionsListPanelComponent: Component {
301301
var itemDate: String
302302
var itemPeer: StarsAvatarComponent.Peer = .transactionPeer(item.peer)
303303
var itemFile: TelegramMediaFile?
304-
var uniqueGift: StarGift.UniqueGift?
304+
var itemGift: StarGift?
305305
switch item.peer {
306306
case let .peer(peer):
307307
if let months = item.premiumGiftMonths {
@@ -325,17 +325,18 @@ final class StarsTransactionsListPanelComponent: Component {
325325
if item.flags.contains(.isStarGiftAuctionBid), case let .generic(gift) = starGift {
326326
itemTitle = gift.title ?? "Gift"
327327
itemSubtitle = environment.strings.Stars_Intro_Transaction_GiftAuctionBid
328+
itemGift = starGift
328329
} else if item.flags.contains(.isStarGiftPrepaidUpgrade) {
329330
itemTitle = peer.displayTitle(strings: environment.strings, displayOrder: .firstLast)
330331
itemSubtitle = environment.strings.Stars_Intro_Transaction_PrepaidGiftUpgrade
331332
} else if item.flags.contains(.isStarGiftDropOriginalDetails), case let .unique(gift) = starGift {
332333
itemTitle = "\(gift.title) #\(presentationStringsFormattedNumber(gift.number, environment.dateTimeFormat.groupingSeparator))"
333334
itemSubtitle = environment.strings.Stars_Intro_Transaction_GiftDropOriginalDetails
334-
uniqueGift = gift
335+
itemGift = starGift
335336
} else if item.flags.contains(.isStarGiftUpgrade), case let .unique(gift) = starGift {
336337
itemTitle = "\(gift.title) #\(presentationStringsFormattedNumber(gift.number, environment.dateTimeFormat.groupingSeparator))"
337338
itemSubtitle = environment.strings.Stars_Intro_Transaction_GiftUpgrade
338-
uniqueGift = gift
339+
itemGift = starGift
339340
} else {
340341
itemTitle = peer.displayTitle(strings: environment.strings, displayOrder: .firstLast)
341342
switch starGift {
@@ -526,7 +527,7 @@ final class StarsTransactionsListPanelComponent: Component {
526527
theme: environment.theme,
527528
title: AnyComponent(VStack(titleComponents, alignment: .left, spacing: 2.0)),
528529
contentInsets: UIEdgeInsets(top: 9.0, left: environment.containerInsets.left, bottom: 8.0, right: environment.containerInsets.right),
529-
leftIcon: .custom(AnyComponentWithIdentity(id: "avatar", component: AnyComponent(StarsAvatarComponent(context: component.context, theme: environment.theme, peer: itemPeer, photo: item.photo, media: item.media, uniqueGift: uniqueGift, backgroundColor: environment.theme.list.plainBackgroundColor))), false),
530+
leftIcon: .custom(AnyComponentWithIdentity(id: "avatar", component: AnyComponent(StarsAvatarComponent(context: component.context, theme: environment.theme, peer: itemPeer, photo: item.photo, media: item.media, gift: itemGift, backgroundColor: environment.theme.list.plainBackgroundColor))), false),
530531
icon: nil,
531532
accessory: .custom(ListActionItemComponent.CustomAccessory(component: AnyComponentWithIdentity(id: "label", component: AnyComponent(StarsLabelComponent(text: itemLabel, iconName: itemIconName, iconColor: itemIconColor))), insets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 16.0))),
532533
action: { [weak self] _ in

submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ final class StarsTransactionsScreenComponent: Component {
929929
if let photo = subscription.photo {
930930
nameGroupComponent = AnyComponent(
931931
HStack([
932-
AnyComponentWithIdentity(id: AnyHashable(0), component: AnyComponent(StarsAvatarComponent(context: component.context, theme: environment.theme, peer: nil, photo: photo, media: [], uniqueGift: nil, backgroundColor: .clear, size: CGSize(width: 19.0, height: 19.0)))),
932+
AnyComponentWithIdentity(id: AnyHashable(0), component: AnyComponent(StarsAvatarComponent(context: component.context, theme: environment.theme, peer: nil, photo: photo, media: [], gift: nil, backgroundColor: .clear, size: CGSize(width: 19.0, height: 19.0)))),
933933
AnyComponentWithIdentity(id: AnyHashable(1), component: nameComponent)
934934
], spacing: 6.0)
935935
)
@@ -972,7 +972,7 @@ final class StarsTransactionsScreenComponent: Component {
972972
style: .glass,
973973
title: AnyComponent(VStack(titleComponents, alignment: .left, spacing: 2.0)),
974974
contentInsets: UIEdgeInsets(top: 9.0, left: 0.0, bottom: 8.0, right: 0.0),
975-
leftIcon: .custom(AnyComponentWithIdentity(id: "avatar", component: AnyComponent(StarsAvatarComponent(context: component.context, theme: environment.theme, peer: .transactionPeer(.peer(subscription.peer)), photo: nil, media: [], uniqueGift: nil, backgroundColor: environment.theme.list.plainBackgroundColor))), false),
975+
leftIcon: .custom(AnyComponentWithIdentity(id: "avatar", component: AnyComponent(StarsAvatarComponent(context: component.context, theme: environment.theme, peer: .transactionPeer(.peer(subscription.peer)), photo: nil, media: [], gift: nil, backgroundColor: environment.theme.list.plainBackgroundColor))), false),
976976
icon: nil,
977977
accessory: .custom(ListActionItemComponent.CustomAccessory(component: labelComponent, insets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 16.0))),
978978
action: { [weak self] _ in

0 commit comments

Comments
 (0)