Skip to content

Commit 9025c8f

Browse files
committed
Various improvements
1 parent 888fd02 commit 9025c8f

File tree

18 files changed

+346
-148
lines changed

18 files changed

+346
-148
lines changed

submodules/AccountContext/Sources/PeerSelectionController.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public final class PeerSelectionControllerParams {
6363
public let hasTypeHeaders: Bool
6464
public let selectForumThreads: Bool
6565
public let hasCreation: Bool
66+
public let immediatelyActivateMultipleSelection: Bool
6667

6768
public init(
6869
context: AccountContext,
@@ -82,7 +83,8 @@ public final class PeerSelectionControllerParams {
8283
forwardedMessageIds: [EngineMessage.Id] = [],
8384
hasTypeHeaders: Bool = false,
8485
selectForumThreads: Bool = false,
85-
hasCreation: Bool = false
86+
hasCreation: Bool = false,
87+
immediatelyActivateMultipleSelection: Bool = false
8688
) {
8789
self.context = context
8890
self.updatedPresentationData = updatedPresentationData
@@ -102,6 +104,7 @@ public final class PeerSelectionControllerParams {
102104
self.hasTypeHeaders = hasTypeHeaders
103105
self.selectForumThreads = selectForumThreads
104106
self.hasCreation = hasCreation
107+
self.immediatelyActivateMultipleSelection = immediatelyActivateMultipleSelection
105108
}
106109
}
107110

submodules/ChatListUI/Sources/Node/ChatListNode.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,13 +644,17 @@ private func mappedInsertEntries(context: AccountContext, nodeInteraction: ChatL
644644
status: status,
645645
requiresPremiumForMessaging: peerEntry.requiresPremiumForMessaging,
646646
enabled: true,
647-
selection: .none,
647+
selection: editing ? .selectable(selected: selected) : .none,
648648
editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false),
649649
index: nil,
650650
header: nil,
651651
action: { _ in
652652
if let chatPeer = chatPeer {
653-
nodeInteraction.peerSelected(chatPeer, nil, nil, nil)
653+
if editing {
654+
nodeInteraction.togglePeerSelected(chatPeer, nil)
655+
} else {
656+
nodeInteraction.peerSelected(chatPeer, nil, nil, nil)
657+
}
654658
}
655659
}, disabledAction: peerEntry.requiresPremiumForMessaging ? { _ in
656660
if let chatPeer {
@@ -984,13 +988,17 @@ private func mappedUpdateEntries(context: AccountContext, nodeInteraction: ChatL
984988
status: status,
985989
requiresPremiumForMessaging: peerEntry.requiresPremiumForMessaging,
986990
enabled: true,
987-
selection: .none,
991+
selection: editing ? .selectable(selected: selected) : .none,
988992
editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false),
989993
index: nil,
990994
header: nil,
991995
action: { _ in
992996
if let chatPeer = chatPeer {
993-
nodeInteraction.peerSelected(chatPeer, nil, nil, nil)
997+
if editing {
998+
nodeInteraction.togglePeerSelected(chatPeer, nil)
999+
} else {
1000+
nodeInteraction.peerSelected(chatPeer, nil, nil, nil)
1001+
}
9941002
}
9951003
}, disabledAction: peerEntry.requiresPremiumForMessaging ? { _ in
9961004
if let chatPeer {

submodules/SolidRoundedButtonNode/Sources/SolidRoundedButtonNode.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ public final class SolidRoundedButtonNode: ASDisplayNode {
737737
var nextContentOrigin = floor((buttonFrame.width - contentWidth) / 2.0)
738738

739739
let iconFrame: CGRect
740-
let titleFrame: CGRect
740+
var titleFrame: CGRect
741741
switch self.iconPosition {
742742
case .left:
743743
iconFrame = CGRect(origin: CGPoint(x: buttonFrame.minX + nextContentOrigin, y: floor((buttonFrame.height - iconSize.height) / 2.0)), size: iconSize)
@@ -757,7 +757,6 @@ public final class SolidRoundedButtonNode: ASDisplayNode {
757757
if let animationNode = self.animationNode {
758758
transition.updateFrame(node: animationNode, frame: iconFrame)
759759
}
760-
transition.updateFrame(node: self.titleNode, frame: titleFrame)
761760

762761
if let badge = self.badge {
763762
let badgeNode: BadgeNode
@@ -770,12 +769,15 @@ public final class SolidRoundedButtonNode: ASDisplayNode {
770769
}
771770
badgeNode.text = badge
772771
let badgeSize = badgeNode.update(CGSize(width: 100.0, height: 100.0))
773-
transition.updateFrame(node: badgeNode, frame: CGRect(origin: CGPoint(x: titleFrame.maxX + 4.0, y: titleFrame.minY + floor((titleFrame.height - badgeSize.height) * 0.5)), size: badgeSize))
772+
titleFrame.origin.x -= badgeSize.width / 2.0
773+
transition.updateFrame(node: badgeNode, frame: CGRect(origin: CGPoint(x: titleFrame.maxX + 6.0, y: titleFrame.minY + floorToScreenPixels((titleFrame.height - badgeSize.height) * 0.5)), size: badgeSize))
774774
} else if let badgeNode = self.badgeNode {
775775
self.badgeNode = nil
776776
badgeNode.removeFromSupernode()
777777
}
778778

779+
transition.updateFrame(node: self.titleNode, frame: titleFrame)
780+
779781
if self.subtitle != self.subtitleNode.attributedText?.string {
780782
self.subtitleNode.attributedText = NSAttributedString(string: self.subtitle ?? "", font: Font.regular(14.0), textColor: self.theme.foregroundColor)
781783
}

submodules/TelegramApi/Sources/Api0.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
8383
dict[1262359766] = { return Api.Boost.parse_boost($0) }
8484
dict[-1778593322] = { return Api.BotApp.parse_botApp($0) }
8585
dict[1571189943] = { return Api.BotApp.parse_botAppNotModified($0) }
86-
dict[-2103898979] = { return Api.BotAppSettings.parse_botAppSettings($0) }
86+
dict[-912582320] = { return Api.BotAppSettings.parse_botAppSettings($0) }
8787
dict[-1989921868] = { return Api.BotBusinessConnection.parse_botBusinessConnection($0) }
8888
dict[-1032140601] = { return Api.BotCommand.parse_botCommand($0) }
8989
dict[-1180016534] = { return Api.BotCommandScope.parse_botCommandScopeChatAdmins($0) }

submodules/TelegramApi/Sources/Api1.swift

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,16 +1114,16 @@ public extension Api {
11141114
}
11151115
public extension Api {
11161116
enum BotAppSettings: TypeConstructorDescription {
1117-
case botAppSettings(flags: Int32, placeholderDocument: Api.Document?, backgroundColor: Int32?, backgroundDarkColor: Int32?, headerColor: Int32?, headerDarkColor: Int32?)
1117+
case botAppSettings(flags: Int32, placeholderPath: Buffer?, backgroundColor: Int32?, backgroundDarkColor: Int32?, headerColor: Int32?, headerDarkColor: Int32?)
11181118

11191119
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
11201120
switch self {
1121-
case .botAppSettings(let flags, let placeholderDocument, let backgroundColor, let backgroundDarkColor, let headerColor, let headerDarkColor):
1121+
case .botAppSettings(let flags, let placeholderPath, let backgroundColor, let backgroundDarkColor, let headerColor, let headerDarkColor):
11221122
if boxed {
1123-
buffer.appendInt32(-2103898979)
1123+
buffer.appendInt32(-912582320)
11241124
}
11251125
serializeInt32(flags, buffer: buffer, boxed: false)
1126-
if Int(flags) & Int(1 << 0) != 0 {placeholderDocument!.serialize(buffer, true)}
1126+
if Int(flags) & Int(1 << 0) != 0 {serializeBytes(placeholderPath!, buffer: buffer, boxed: false)}
11271127
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(backgroundColor!, buffer: buffer, boxed: false)}
11281128
if Int(flags) & Int(1 << 2) != 0 {serializeInt32(backgroundDarkColor!, buffer: buffer, boxed: false)}
11291129
if Int(flags) & Int(1 << 3) != 0 {serializeInt32(headerColor!, buffer: buffer, boxed: false)}
@@ -1134,18 +1134,16 @@ public extension Api {
11341134

11351135
public func descriptionFields() -> (String, [(String, Any)]) {
11361136
switch self {
1137-
case .botAppSettings(let flags, let placeholderDocument, let backgroundColor, let backgroundDarkColor, let headerColor, let headerDarkColor):
1138-
return ("botAppSettings", [("flags", flags as Any), ("placeholderDocument", placeholderDocument as Any), ("backgroundColor", backgroundColor as Any), ("backgroundDarkColor", backgroundDarkColor as Any), ("headerColor", headerColor as Any), ("headerDarkColor", headerDarkColor as Any)])
1137+
case .botAppSettings(let flags, let placeholderPath, let backgroundColor, let backgroundDarkColor, let headerColor, let headerDarkColor):
1138+
return ("botAppSettings", [("flags", flags as Any), ("placeholderPath", placeholderPath as Any), ("backgroundColor", backgroundColor as Any), ("backgroundDarkColor", backgroundDarkColor as Any), ("headerColor", headerColor as Any), ("headerDarkColor", headerDarkColor as Any)])
11391139
}
11401140
}
11411141

11421142
public static func parse_botAppSettings(_ reader: BufferReader) -> BotAppSettings? {
11431143
var _1: Int32?
11441144
_1 = reader.readInt32()
1145-
var _2: Api.Document?
1146-
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
1147-
_2 = Api.parse(reader, signature: signature) as? Api.Document
1148-
} }
1145+
var _2: Buffer?
1146+
if Int(_1!) & Int(1 << 0) != 0 {_2 = parseBytes(reader) }
11491147
var _3: Int32?
11501148
if Int(_1!) & Int(1 << 1) != 0 {_3 = reader.readInt32() }
11511149
var _4: Int32?
@@ -1161,7 +1159,7 @@ public extension Api {
11611159
let _c5 = (Int(_1!) & Int(1 << 3) == 0) || _5 != nil
11621160
let _c6 = (Int(_1!) & Int(1 << 4) == 0) || _6 != nil
11631161
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
1164-
return Api.BotAppSettings.botAppSettings(flags: _1!, placeholderDocument: _2, backgroundColor: _3, backgroundDarkColor: _4, headerColor: _5, headerDarkColor: _6)
1162+
return Api.BotAppSettings.botAppSettings(flags: _1!, placeholderPath: _2, backgroundColor: _3, backgroundDarkColor: _4, headerColor: _5, headerDarkColor: _6)
11651163
}
11661164
else {
11671165
return nil

submodules/TelegramCore/Sources/ApiUtils/BotInfo.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ extension BotMenuButton {
1616
extension BotAppSettings {
1717
init(apiBotAppSettings: Api.BotAppSettings) {
1818
switch apiBotAppSettings {
19-
case let .botAppSettings(_, placeholderDocument, backgroundColor, backgroundDarkColor, headerColor, headerDarkColor):
19+
case let .botAppSettings(_, placeholder, backgroundColor, backgroundDarkColor, headerColor, headerDarkColor):
2020
self.init(
21-
placeholder: placeholderDocument.flatMap { telegramMediaFileFromApiDocument($0, altDocuments: []) },
21+
placeholderData: placeholder.flatMap { $0.makeData() },
2222
backgroundColor: backgroundColor,
2323
backgroundDarkColor: backgroundDarkColor,
2424
headerColor: headerColor,

submodules/TelegramCore/Sources/SyncCore/SyncCore_BotInfo.swift

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Foundation
12
import Postbox
23

34
public struct BotCommand: PostboxCoding, Hashable {
@@ -46,37 +47,33 @@ public enum BotMenuButton: PostboxCoding, Hashable {
4647
}
4748

4849
public struct BotAppSettings: PostboxCoding, Equatable {
49-
public let placeholder: TelegramMediaFile?
50+
public let placeholderData: Data?
5051
public let backgroundColor: Int32?
5152
public let backgroundDarkColor: Int32?
5253
public let headerColor: Int32?
5354
public let headerDarkColor: Int32?
5455

55-
public init(placeholder: TelegramMediaFile?, backgroundColor: Int32?, backgroundDarkColor: Int32?, headerColor: Int32?, headerDarkColor: Int32?) {
56-
self.placeholder = placeholder
56+
public init(placeholderData: Data?, backgroundColor: Int32?, backgroundDarkColor: Int32?, headerColor: Int32?, headerDarkColor: Int32?) {
57+
self.placeholderData = placeholderData
5758
self.backgroundColor = backgroundColor
5859
self.backgroundDarkColor = backgroundDarkColor
5960
self.headerColor = headerColor
6061
self.headerDarkColor = headerDarkColor
6162
}
6263

6364
public init(decoder: PostboxDecoder) {
64-
if let placeholder = decoder.decodeObjectForKey("p", decoder: { TelegramMediaFile(decoder: $0) }) as? TelegramMediaFile {
65-
self.placeholder = placeholder
66-
} else {
67-
self.placeholder = nil
68-
}
65+
self.placeholderData = decoder.decodeDataForKey("pd")
6966
self.backgroundColor = decoder.decodeOptionalInt32ForKey("b")
7067
self.backgroundDarkColor = decoder.decodeOptionalInt32ForKey("bd")
7168
self.headerColor = decoder.decodeOptionalInt32ForKey("h")
7269
self.headerDarkColor = decoder.decodeOptionalInt32ForKey("hd")
7370
}
7471

7572
public func encode(_ encoder: PostboxEncoder) {
76-
if let placeholder = self.placeholder {
77-
encoder.encodeObject(placeholder, forKey: "p")
73+
if let placeholderData = self.placeholderData {
74+
encoder.encodeData(placeholderData, forKey: "pd")
7875
} else {
79-
encoder.encodeNil(forKey: "p")
76+
encoder.encodeNil(forKey: "pd")
8077
}
8178
if let backgroundColor = self.backgroundColor {
8279
encoder.encodeInt32(backgroundColor, forKey: "b")

submodules/TelegramCore/Sources/TelegramEngine/Messages/BotWebView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func _internal_requestWebView(postbox: Postbox, network: Network, stateManager:
244244
if (webViewFlags & (1 << 1)) != 0 {
245245
resultFlags.insert(.fullSize)
246246
}
247-
if (flags & (1 << 2)) != 0 {
247+
if (webViewFlags & (1 << 2)) != 0 {
248248
resultFlags.insert(.fullScreen)
249249
}
250250
let keepAlive: Signal<Never, KeepWebViewError>?

submodules/TelegramUI/Components/PeerSelectionController/Sources/PeerSelectionController.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public final class PeerSelectionControllerImpl: ViewController, PeerSelectionCon
6565
private let hasTypeHeaders: Bool
6666
private let requestPeerType: [ReplyMarkupButtonRequestPeerType]?
6767
private let hasCreation: Bool
68+
let immediatelyActivateMultipleSelection: Bool
6869

6970
override public var _presentedInModal: Bool {
7071
get {
@@ -105,6 +106,7 @@ public final class PeerSelectionControllerImpl: ViewController, PeerSelectionCon
105106
self.selectForumThreads = params.selectForumThreads
106107
self.requestPeerType = params.requestPeerType
107108
self.hasCreation = params.hasCreation
109+
self.immediatelyActivateMultipleSelection = params.immediatelyActivateMultipleSelection
108110

109111
super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationData: self.presentationData))
110112

@@ -167,7 +169,11 @@ public final class PeerSelectionControllerImpl: ViewController, PeerSelectionCon
167169
})
168170
self.navigationBar?.setContentNode(self.searchContentNode, animated: false)
169171

170-
if params.multipleSelection {
172+
if params.immediatelyActivateMultipleSelection {
173+
Queue.mainQueue().after(0.1) {
174+
self.beginSelection()
175+
}
176+
} else if params.multipleSelection {
171177
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Select, style: .plain, target: self, action: #selector(self.beginSelection))
172178
}
173179

0 commit comments

Comments
 (0)