Skip to content

Commit c5a0ad2

Browse files
committed
Various improvements
1 parent b3aef93 commit c5a0ad2

10 files changed

Lines changed: 84 additions & 29 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15679,7 +15679,6 @@ Error: %8$@";
1567915679
"Gift.Craft.ViewVariants" = "View all craftable models";
1568015680
"Gift.Craft.BackdropTooltip" = "**%1$@%** chance the crafted gift will have **%2$@** backdrop.";
1568115681
"Gift.Craft.SymbolTooltip" = "**%1$@%** chance the crafted gift will have **%2$@** symbol.";
15682-
"Gift.Craft.SuccessChanceSuffix" = "% Success Chance";
1568315682
"Gift.Craft.Craft" = "Craft %@";
1568415683
"Gift.Craft.Crafting.Title" = "Crafting";
1568515684
"Gift.Craft.Crafting.Description" = "If crafting fails, all used gifts\nwill be lost.";
@@ -15768,3 +15767,5 @@ Error: %8$@";
1576815767
"AppointAnotherOwner.Title" = "Choose New Owner";
1576915768

1577015769
"Gift.View.Context.Craft" = "Craft";
15770+
15771+
"Group.OwnershipTransfer.DescriptionShortInfo" = "This will transfer the full **owner rights** for **%1$@** to **%2$@**.";

submodules/ChatListUI/Sources/ChatListControllerLeaveChannelConfirmation.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ extension ChatListControllerImpl {
135135
updatedPresentationData: nil,
136136
peer: chatPeer,
137137
member: user,
138+
onLeave: true,
138139
initialError: error,
139140
present: { c, a in
140141
presentController(c)

submodules/Components/ResizableSheetComponent/Sources/ResizableSheetComponent.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import TelegramPresentationData
99
import EdgeEffect
1010

1111
public final class ResizableSheetComponentEnvironment: Equatable {
12+
public struct BoundsUpdate {
13+
public let bounds: CGRect
14+
public let isInteractive: Bool
15+
}
16+
1217
public let theme: PresentationTheme
1318
public let statusBarHeight: CGFloat
1419
public let safeInsets: UIEdgeInsets
@@ -19,7 +24,7 @@ public final class ResizableSheetComponentEnvironment: Equatable {
1924
public let screenSize: CGSize
2025
public let regularMetricsSize: CGSize?
2126
public let dismiss: (Bool) -> Void
22-
public let boundsUpdated: ActionSlot<CGRect>
27+
public let boundsUpdated: ActionSlot<BoundsUpdate>
2328

2429
public init(
2530
theme: PresentationTheme,
@@ -32,7 +37,7 @@ public final class ResizableSheetComponentEnvironment: Equatable {
3237
screenSize: CGSize,
3338
regularMetricsSize: CGSize?,
3439
dismiss: @escaping (Bool) -> Void,
35-
boundsUpdated: ActionSlot<CGRect> = ActionSlot<CGRect>()
40+
boundsUpdated: ActionSlot<BoundsUpdate> = ActionSlot<BoundsUpdate>()
3641
) {
3742
self.theme = theme
3843
self.statusBarHeight = statusBarHeight
@@ -479,7 +484,7 @@ public final class ResizableSheetComponent<ChildEnvironmentType: Sendable & Equa
479484

480485
var bounds = self.scrollView.bounds
481486
bounds.size.width = itemLayout.fillingSize
482-
self.environment?.boundsUpdated.invoke(bounds)
487+
self.environment?.boundsUpdated.invoke(ResizableSheetComponentEnvironment.BoundsUpdate(bounds: bounds, isInteractive: self.scrollView.isTracking))
483488
}
484489

485490
private var didPlayAppearanceAnimation = false

submodules/PeerInfoUI/Sources/ChannelAdminController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,7 @@ public func channelAdminController(context: AccountContext, updatedPresentationD
11091109
updatedPresentationData: updatedPresentationData,
11101110
peer: peer,
11111111
member: member,
1112+
onLeave: false,
11121113
initialError: error,
11131114
present: { c, a in
11141115
presentControllerImpl?(c, a)

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

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ private final class CraftGiftPageContent: Component {
263263

264264
self.craftStateDisposable = (component.craftContext.state
265265
|> deliverOnMainQueue).start(next: { [weak self] state in
266-
guard let self else {
266+
guard let self, let component = self.component else {
267267
return
268268
}
269269
self.craftState = state
@@ -297,6 +297,10 @@ private final class CraftGiftPageContent: Component {
297297
self.component?.externalState.giftsMap = self.giftMap
298298

299299
self.state?.updated(transition: .spring(duration: 0.4))
300+
301+
if state.gifts.count < 18, case .ready(true, _) = state.dataState {
302+
component.craftContext.loadMore()
303+
}
300304
})
301305

302306
self.upgradePreviewDisposable.add((component.context.engine.payments.getStarGiftUpgradeAttributes(giftId: initialGiftItem.gift.giftId)
@@ -1622,9 +1626,31 @@ private final class SheetContainerComponent: CombinedComponent {
16221626
))
16231627
} else {
16241628
var buttonAnimatedItems: [AnimatedTextComponent.Item] = []
1625-
buttonAnimatedItems.append(AnimatedTextComponent.Item(id: "percent", content: .number(Int(permilleValue / 10), minDigits: 1)))
1626-
buttonAnimatedItems.append(AnimatedTextComponent.Item(id: "suffix", content: .text(environment.strings.Gift_Craft_SuccessChanceSuffix)))
16271629

1630+
let rawString = environment.strings.Gift_Craft_Crafting_SuccessChance("{p}").string
1631+
var startIndex = rawString.startIndex
1632+
while true {
1633+
if let range = rawString.range(of: "{", range: startIndex ..< rawString.endIndex) {
1634+
if range.lowerBound != startIndex {
1635+
buttonAnimatedItems.append(AnimatedTextComponent.Item(id: AnyHashable(buttonAnimatedItems.count), content: .text(String(rawString[startIndex ..< range.lowerBound]))))
1636+
}
1637+
1638+
startIndex = range.upperBound
1639+
if let endRange = rawString.range(of: "}", range: startIndex ..< rawString.endIndex) {
1640+
let controlString = rawString[range.upperBound ..< endRange.lowerBound]
1641+
if controlString == "p" {
1642+
buttonAnimatedItems.append(AnimatedTextComponent.Item(id: AnyHashable(buttonAnimatedItems.count), content: .number(Int(permilleValue / 10), minDigits: 1)))
1643+
}
1644+
startIndex = endRange.upperBound
1645+
}
1646+
} else {
1647+
break
1648+
}
1649+
}
1650+
if startIndex != rawString.endIndex {
1651+
buttonAnimatedItems.append(AnimatedTextComponent.Item(id: AnyHashable(buttonAnimatedItems.count), content: .text(String(rawString[startIndex ..< rawString.endIndex]))))
1652+
}
1653+
16281654
buttonContent = AnyComponentWithIdentity(id: "craft", component: AnyComponent(
16291655
VStack([
16301656
AnyComponentWithIdentity(

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class SelectGiftPageContent: Component {
3535
let starsTopUpOptions: Signal<[StarsTopUpOption]?, NoError>
3636
let selectGift: (GiftItem) -> Void
3737
let dismiss: () -> Void
38-
let boundsUpdated: ActionSlot<CGRect>
38+
let boundsUpdated: ActionSlot<ResizableSheetComponentEnvironment.BoundsUpdate>
3939

4040
init(
4141
context: AccountContext,
@@ -47,7 +47,7 @@ final class SelectGiftPageContent: Component {
4747
starsTopUpOptions: Signal<[StarsTopUpOption]?, NoError>,
4848
selectGift: @escaping (GiftItem) -> Void,
4949
dismiss: @escaping () -> Void,
50-
boundsUpdated: ActionSlot<CGRect>
50+
boundsUpdated: ActionSlot<ResizableSheetComponentEnvironment.BoundsUpdate>
5151
) {
5252
self.context = context
5353
self.craftContext = craftContext
@@ -310,6 +310,13 @@ final class SelectGiftPageContent: Component {
310310
storeGiftsView.updateScrolling(bounds: bounds.offsetBy(dx: 0.0, dy: -contentHeight), interactive: interactive, transition: .immediate)
311311
}
312312

313+
let bottomContentOffset = max(0.0, contentHeight - bounds.origin.y - bounds.height)
314+
if interactive, bottomContentOffset < 800.0 {
315+
Queue.mainQueue().justDispatch {
316+
component.craftContext.loadMore()
317+
}
318+
}
319+
313320
return contentHeight
314321
}
315322

@@ -323,12 +330,12 @@ final class SelectGiftPageContent: Component {
323330
if self.component == nil {
324331
self.currentBounds = CGRect(origin: .zero, size: availableSize)
325332

326-
component.boundsUpdated.connect { [weak self] bounds in
333+
component.boundsUpdated.connect { [weak self] update in
327334
guard let self else {
328335
return
329336
}
330-
self.currentBounds = bounds
331-
let _ = self.updateScrolling(interactive: true, transition: .immediate)
337+
self.currentBounds = update.bounds
338+
let _ = self.updateScrolling(interactive: update.isInteractive, transition: .immediate)
332339
}
333340

334341
let initialGiftItem = GiftItem(
@@ -370,7 +377,9 @@ final class SelectGiftPageContent: Component {
370377
self.availableGifts = items
371378
self.giftMap = giftMap
372379

373-
self.state?.updated(transition: .spring(duration: 0.4))
380+
if !self.isUpdating {
381+
self.state?.updated(transition: .spring(duration: 0.4))
382+
}
374383
})
375384
}
376385

@@ -545,7 +554,7 @@ private final class SheetContainerComponent: CombinedComponent {
545554
let sheet = Child(ResizableSheetComponent<EnvironmentType>.self)
546555
let animateOut = StoredActionSlot(Action<Void>.self)
547556

548-
let boundsUpdated = ActionSlot<CGRect>()
557+
let boundsUpdated = ActionSlot<ResizableSheetComponentEnvironment.BoundsUpdate>()
549558

550559
return { context in
551560
let component = context.component

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ public final class GiftStoreContentComponent: Component {
103103
if lhs.gift != rhs.gift {
104104
return false
105105
}
106+
if lhs.safeInsets != rhs.safeInsets {
107+
return false
108+
}
109+
if lhs.statusBarHeight != rhs.statusBarHeight {
110+
return false
111+
}
112+
if lhs.navigationHeight != rhs.navigationHeight {
113+
return false
114+
}
106115
return true
107116
}
108117

submodules/TelegramUI/Components/PeerManagement/OwnershipTransferController/Sources/ChannelOwnershipTransferController.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ private func confirmChannelOwnershipTransferController(
169169
updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil,
170170
peer: EnginePeer,
171171
member: TelegramUser,
172+
onLeave: Bool,
172173
present: @escaping (ViewController, Any?) -> Void,
173174
push: @escaping (ViewController) -> Void,
174175
completion: @escaping (EnginePeer.Id?) -> Void
@@ -184,7 +185,7 @@ private func confirmChannelOwnershipTransferController(
184185
var text: String
185186
if isGroup {
186187
title = presentationData.strings.Group_OwnershipTransfer_Title
187-
text = presentationData.strings.Group_OwnershipTransfer_DescriptionInfo(peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), EnginePeer.user(member).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string
188+
text = onLeave ? presentationData.strings.Group_OwnershipTransfer_DescriptionShortInfo(peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), EnginePeer.user(member).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string : presentationData.strings.Group_OwnershipTransfer_DescriptionInfo(peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), EnginePeer.user(member).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string
188189
} else {
189190
title = presentationData.strings.Channel_OwnershipTransfer_Title
190191
text = presentationData.strings.Channel_OwnershipTransfer_DescriptionInfo(peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), EnginePeer.user(member).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string
@@ -211,6 +212,7 @@ public func channelOwnershipTransferController(
211212
updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil,
212213
peer: EnginePeer,
213214
member: TelegramUser,
215+
onLeave: Bool,
214216
initialError: ChannelOwnershipTransferError,
215217
present: @escaping (ViewController, Any?) -> Void,
216218
push: @escaping (ViewController) -> Void,
@@ -232,7 +234,7 @@ public func channelOwnershipTransferController(
232234
]
233235
switch initialError {
234236
case .requestPassword:
235-
return confirmChannelOwnershipTransferController(context: context, updatedPresentationData: updatedPresentationData, peer: peer, member: member, present: present, push: push, completion: completion)
237+
return confirmChannelOwnershipTransferController(context: context, updatedPresentationData: updatedPresentationData, peer: peer, member: member, onLeave: onLeave, present: present, push: push, completion: completion)
236238
case .twoStepAuthTooFresh, .authSessionTooFresh:
237239
text = text + strings.OwnershipTransfer_ComeBackLater
238240
case .twoStepAuthMissing:

submodules/WebUI/Sources/WebAppController.swift

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,13 @@ public final class WebAppController: ViewController, AttachmentContainable {
290290
}
291291
}
292292
}
293-
if #available(iOS 13.0, *) {
294-
if self.presentationData.theme.overallDarkAppearance {
295-
webView.overrideUserInterfaceStyle = .dark
296-
} else {
297-
webView.overrideUserInterfaceStyle = .unspecified
298-
}
293+
294+
if self.presentationData.theme.overallDarkAppearance {
295+
webView.overrideUserInterfaceStyle = .dark
296+
} else {
297+
webView.overrideUserInterfaceStyle = .unspecified
299298
}
299+
300300
self.webView = webView
301301

302302
self.addSubnode(self.backgroundNode)
@@ -1093,6 +1093,9 @@ public final class WebAppController: ViewController, AttachmentContainable {
10931093
guard let controller = self.controller else {
10941094
return
10951095
}
1096+
guard message.frameInfo.isMainFrame else {
1097+
return
1098+
}
10961099
guard let body = message.body as? [String: Any] else {
10971100
return
10981101
}
@@ -2028,12 +2031,10 @@ public final class WebAppController: ViewController, AttachmentContainable {
20282031
self.updateHeaderBackgroundColor(transition: .immediate)
20292032
self.sendThemeChangedEvent()
20302033

2031-
if #available(iOS 13.0, *) {
2032-
if self.presentationData.theme.overallDarkAppearance {
2033-
self.webView?.overrideUserInterfaceStyle = .dark
2034-
} else {
2035-
self.webView?.overrideUserInterfaceStyle = .unspecified
2036-
}
2034+
if self.presentationData.theme.overallDarkAppearance {
2035+
self.webView?.overrideUserInterfaceStyle = .dark
2036+
} else {
2037+
self.webView?.overrideUserInterfaceStyle = .unspecified
20372038
}
20382039
}
20392040

submodules/WebUI/Sources/WebAppWebView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ final class WebAppWebView: WKWebView {
134134
let contentController = WKUserContentController()
135135

136136
var handleScriptMessageImpl: ((WKScriptMessage) -> Void)?
137-
let eventProxyScript = WKUserScript(source: eventProxySource, injectionTime: .atDocumentStart, forMainFrameOnly: false)
137+
let eventProxyScript = WKUserScript(source: eventProxySource, injectionTime: .atDocumentStart, forMainFrameOnly: true)
138138
contentController.addUserScript(eventProxyScript)
139139
contentController.add(WeakGameScriptMessageHandler { message in
140140
handleScriptMessageImpl?(message)

0 commit comments

Comments
 (0)