Skip to content

Commit 37c91f8

Browse files
committed
Various improvements
1 parent 8ec6964 commit 37c91f8

File tree

46 files changed

+3418
-161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3418
-161
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13218,3 +13218,6 @@ Sorry for the inconvenience.";
1321813218
"Gift.Convert.Period.Unavailable.Text" = "Sorry, you can't convert this gift.\n\nStars can only be claimed within %@ after receiving a gift.";
1321913219
"Gift.Convert.Period.Unavailable.Days_1" = "%@ day";
1322013220
"Gift.Convert.Period.Unavailable.Days_any" = "%@ days";
13221+
13222+
"Gift.Send.TitleTo" = "Gift to %@";
13223+
"Gift.Send.SendShort" = "Send";

submodules/AttachmentUI/Sources/AttachmentContainer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ final class AttachmentContainer: ASDisplayNode, ASGestureRecognizerDelegate {
524524
}
525525

526526
var containerTopInset: CGFloat
527-
if isLandscape {
527+
if isLandscape || controllers.last?.isFullscreen == true {
528528
containerTopInset = 0.0
529529
containerLayout = layout
530530

submodules/AttachmentUI/Sources/AttachmentController.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public protocol AttachmentContainable: ViewController, MinimizableController {
124124
var isInnerPanGestureEnabled: (() -> Bool)? { get }
125125
var mediaPickerContext: AttachmentMediaPickerContext? { get }
126126
var getCurrentSendMessageContextMediaPreview: (() -> ChatSendMessageContextScreenMediaPreview?)? { get }
127-
127+
128128
func isContainerPanningUpdated(_ panning: Bool)
129129

130130
func resetForReuse()
@@ -165,6 +165,10 @@ public extension AttachmentContainable {
165165
return nil
166166
}
167167

168+
var isFullscreen: Bool {
169+
return false
170+
}
171+
168172
var minimizedTopEdgeOffset: CGFloat? {
169173
return nil
170174
}
@@ -363,6 +367,10 @@ public class AttachmentController: ViewController, MinimizableController {
363367
public var minimizedIcon: UIImage? {
364368
return self.mainController.minimizedIcon
365369
}
370+
371+
public var isFullscreen: Bool {
372+
return self.mainController.isFullscreen
373+
}
366374

367375
private final class Node: ASDisplayNode {
368376
private weak var controller: AttachmentController?
@@ -1268,6 +1276,10 @@ public class AttachmentController: ViewController, MinimizableController {
12681276

12691277
public var ensureUnfocused = true
12701278

1279+
public func requestMinimize(topEdgeOffset: CGFloat?, initialVelocity: CGFloat?) {
1280+
self.node.minimize()
1281+
}
1282+
12711283
public override func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) {
12721284
if self.ensureUnfocused {
12731285
self.view.endEditing(true)
@@ -1397,7 +1409,9 @@ public class AttachmentController: ViewController, MinimizableController {
13971409
public func makeContentSnapshotView() -> UIView? {
13981410
let snapshotView = self.view.snapshotView(afterScreenUpdates: false)
13991411
if let contentSnapshotView = self.mainController.makeContentSnapshotView() {
1400-
contentSnapshotView.frame = contentSnapshotView.frame.offsetBy(dx: 0.0, dy: 64.0 + 56.0)
1412+
if !self.mainController.isFullscreen {
1413+
contentSnapshotView.frame = contentSnapshotView.frame.offsetBy(dx: 0.0, dy: 64.0 + 56.0)
1414+
}
14011415
snapshotView?.addSubview(contentSnapshotView)
14021416
}
14031417
return snapshotView

submodules/BrowserUI/Sources/BrowserWebContent.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,11 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
638638
self.webView.reloadInputViews()
639639
}
640640

641-
self.webView.customBottomInset = safeInsets.bottom * (1.0 - insets.bottom / fullInsets.bottom)
642-
641+
if fullInsets.bottom.isZero {
642+
self.webView.customBottomInset = safeInsets.bottom
643+
} else {
644+
self.webView.customBottomInset = safeInsets.bottom * (1.0 - insets.bottom / fullInsets.bottom)
645+
}
643646
// self.webView.scrollView.scrollIndicatorInsets = UIEdgeInsets(top: 0.0, left: -insets.left, bottom: 0.0, right: -insets.right)
644647
// self.webView.scrollView.horizontalScrollIndicatorInsets = UIEdgeInsets(top: 0.0, left: -insets.left, bottom: 0.0, right: -insets.right)
645648

submodules/Display/Source/Navigation/MinimizedContainer.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public protocol MinimizableController: ViewController {
3030
var isMinimizable: Bool { get }
3131
var minimizedIcon: UIImage? { get }
3232
var minimizedProgress: Float? { get }
33+
var isFullscreen: Bool { get }
3334

3435
func requestMinimize(topEdgeOffset: CGFloat?, initialVelocity: CGFloat?)
3536
func makeContentSnapshotView() -> UIView?
@@ -41,6 +42,10 @@ public protocol MinimizableController: ViewController {
4142
}
4243

4344
public extension MinimizableController {
45+
var isFullscreen: Bool {
46+
return false
47+
}
48+
4449
var minimizedTopEdgeOffset: CGFloat? {
4550
return nil
4651
}

submodules/MoreButtonNode/Sources/MoreButtonNode.swift

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,27 @@ public final class MoreButtonNode: ASDisplayNode {
1313
case search
1414
}
1515

16+
private let encircled: Bool
1617
private let duration: Double = 0.21
1718
public var iconState: State = .search
1819

19-
init() {
20-
super.init(size: CGSize(width: 30.0, height: 30.0))
20+
init(size: CGSize = CGSize(width: 30.0, height: 30.0), encircled: Bool) {
21+
self.encircled = encircled
2122

22-
self.trackTo(item: ManagedAnimationItem(source: .local("anim_moretosearch"), frames: .range(startFrame: 90, endFrame: 90), duration: 0.0))
23+
super.init(size: size)
24+
25+
if self.encircled {
26+
self.trackTo(item: ManagedAnimationItem(source: .local("anim_moretosearch"), frames: .range(startFrame: 90, endFrame: 90), duration: 0.0))
27+
} else {
28+
self.iconState = .more
29+
self.trackTo(item: ManagedAnimationItem(source: .local("anim_baremoredots"), frames: .range(startFrame: 0, endFrame: 0), duration: 0.0))
30+
}
2331
}
2432

2533
func play() {
2634
if case .more = self.iconState {
27-
self.trackTo(item: ManagedAnimationItem(source: .local("anim_moredots"), frames: .range(startFrame: 0, endFrame: 46), duration: 0.76))
35+
let animationName = self.encircled ? "anim_moredots" : "anim_baremoredots"
36+
self.trackTo(item: ManagedAnimationItem(source: .local(animationName), frames: .range(startFrame: 0, endFrame: 46), duration: 0.76))
2837
}
2938
}
3039

@@ -81,6 +90,7 @@ public final class MoreButtonNode: ASDisplayNode {
8190
self.update()
8291
}
8392
}
93+
private let size: CGSize
8494

8595
public func updateColor(_ color: UIColor?, transition: ContainedViewLayoutTransition) {
8696
self.color = color
@@ -104,15 +114,16 @@ public final class MoreButtonNode: ASDisplayNode {
104114
self.iconNode.customColor = color
105115
}
106116

107-
public init(theme: PresentationTheme) {
117+
public init(theme: PresentationTheme, size: CGSize = CGSize(width: 30.0, height: 30.0), encircled: Bool = true) {
108118
self.theme = theme
119+
self.size = size
109120

110121
self.contextSourceNode = ContextReferenceContentNode()
111122
self.containerNode = ContextControllerSourceNode()
112123
self.containerNode.animateScale = false
113124

114125
self.buttonNode = HighlightableButtonNode()
115-
self.iconNode = MoreIconNode()
126+
self.iconNode = MoreIconNode(size: size, encircled: encircled)
116127
self.iconNode.customColor = self.theme.rootController.navigationBar.buttonColor
117128

118129
super.init()
@@ -143,7 +154,7 @@ public final class MoreButtonNode: ASDisplayNode {
143154
}
144155

145156
override public func calculateSizeThatFits(_ constrainedSize: CGSize) -> CGSize {
146-
let animationSize = CGSize(width: 30.0, height: 30.0)
157+
let animationSize = self.size
147158
let inset: CGFloat = 0.0
148159
let iconFrame = CGRect(origin: CGPoint(x: inset + 6.0, y: floor((constrainedSize.height - animationSize.height) / 2.0) + 1.0), size: animationSize)
149160

submodules/TelegramCore/Sources/Utils/JSON.swift

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ extension JSON {
5050
return nil
5151
}
5252
}
53+
54+
public init?(dictionary: [String: Any]) {
55+
var values: [String: JSON] = [:]
56+
for (key, value) in dictionary {
57+
if let v = JSON(value) {
58+
values[key] = v
59+
} else {
60+
return nil
61+
}
62+
}
63+
self = .dictionary(values)
64+
}
5365
}
5466

5567
extension JSON: Collection {
@@ -125,7 +137,7 @@ extension JSON {
125137
get {
126138
switch self {
127139
case .null:
128-
return 0
140+
return NSNull()
129141
case let .number(value):
130142
return value
131143
case let .string(value):
@@ -172,6 +184,18 @@ extension JSON {
172184
}
173185
}
174186

187+
extension JSON {
188+
public var string: String? {
189+
guard let jsonData = try? JSONSerialization.data(withJSONObject: self.value) else {
190+
return nil
191+
}
192+
guard let jsonDataString = String(data: jsonData, encoding: .utf8) else {
193+
return nil
194+
}
195+
return jsonDataString
196+
}
197+
}
198+
175199
extension JSON: ExpressibleByDictionaryLiteral {
176200
public init(dictionaryLiteral elements: (String, Any)...) {
177201
self = .dictionary(elements.reduce([String: JSON]()) { (dictionary, element) in
@@ -195,6 +219,12 @@ private protocol JSONValue {
195219
var jsonValue: JSON { get }
196220
}
197221

222+
extension NSNull: JSONElement, JSONValue {
223+
var jsonValue: JSON {
224+
return .null
225+
}
226+
}
227+
198228
extension Int: JSONElement, JSONValue {
199229
var jsonValue: JSON {
200230
return .number(Double(self))

submodules/TelegramStringFormatting/Sources/TonFormat.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ public func formatTonAmountText(_ value: Int64, dateTimeFormat: PresentationDate
4848
}
4949

5050
if let dotIndex = balanceText.range(of: dateTimeFormat.decimalSeparator) {
51-
balanceText = String(balanceText[balanceText.startIndex ..< min(balanceText.endIndex, balanceText.index(dotIndex.upperBound, offsetBy: 2))])
51+
if let endIndex = balanceText.index(dotIndex.upperBound, offsetBy: 2, limitedBy: balanceText.endIndex) {
52+
balanceText = String(balanceText[balanceText.startIndex..<endIndex])
53+
} else {
54+
balanceText = String(balanceText[balanceText.startIndex..<balanceText.endIndex])
55+
}
5256

5357
let integerPartString = balanceText[..<dotIndex.lowerBound]
5458
if let integerPart = Int32(integerPartString) {

submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsControllerNode.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
12901290
id: subscriptionFormId,
12911291
canSaveCredentials: false,
12921292
passwordMissing: false,
1293-
invoice: BotPaymentInvoice(isTest: false, requestedFields: [], currency: "XTR", prices: [BotPaymentPrice(label: "", amount: subscriptionPricing.amount)], tip: nil, termsInfo: nil),
1293+
invoice: BotPaymentInvoice(isTest: false, requestedFields: [], currency: "XTR", prices: [BotPaymentPrice(label: "", amount: subscriptionPricing.amount)], tip: nil, termsInfo: nil, subscriptionPeriod: subscriptionPricing.period),
12941294
paymentBotId: channel.id,
12951295
providerId: nil,
12961296
url: nil,

submodules/TelegramUI/Components/Gifts/GiftSetupScreen/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ swift_library(
4444
"//submodules/TelegramUI/Components/ChatEntityKeyboardInputNode",
4545
"//submodules/InAppPurchaseManager",
4646
"//submodules/Components/BlurredBackgroundComponent",
47+
"//submodules/ProgressNavigationButtonNode",
4748
],
4849
visibility = [
4950
"//visibility:public",

0 commit comments

Comments
 (0)