mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Use participants names for group title placeholder
This commit is contained in:
parent
927af7afe7
commit
eed0f5cee6
@ -9073,3 +9073,11 @@ Sorry for the inconvenience.";
|
||||
"DataUsage.Reset" = "Reset Statistics";
|
||||
|
||||
"Conversation.SendWhenOnlineTooltip" = "Long tap to send the message later.";
|
||||
|
||||
"Bot.Active" = "bot is active now";
|
||||
"Bot.Inactive" = "bot is not active";
|
||||
"Bot.Slow" = "bot replies slowly";
|
||||
"Bot.TapToUse" = "Tap here to use this bot";
|
||||
|
||||
"CreateGroup.PeersTitleDelimeter" = ", ";
|
||||
"CreateGroup.PeersTitleLastDelimeter" = " and ";
|
||||
|
@ -507,6 +507,10 @@ class CreatePollOptionItemNode: ItemListRevealOptionsItemNode, ItemListItemNode,
|
||||
self.textNode.becomeFirstResponder()
|
||||
}
|
||||
|
||||
func selectAll() {
|
||||
self.textNode.textView.selectAll(nil)
|
||||
}
|
||||
|
||||
override func isReorderable(at point: CGPoint) -> Bool {
|
||||
if self.reorderControlNode.frame.contains(point), !self.reorderControlNode.isHidden, !self.isDisplayingRevealedOptions {
|
||||
return true
|
||||
|
@ -617,6 +617,10 @@ public class CreatePollTextInputItemNode: ListViewItemNode, ASEditableTextNodeDe
|
||||
}
|
||||
}
|
||||
|
||||
public func selectAll() {
|
||||
self.textNode.textView.selectAll(nil)
|
||||
}
|
||||
|
||||
public func animateError() {
|
||||
self.textNode.layer.addShakeAnimation()
|
||||
}
|
||||
|
@ -1118,6 +1118,10 @@ public class ItemListAvatarAndNameInfoItemNode: ListViewItemNode, ItemListItemNo
|
||||
self.inputFirstField?.becomeFirstResponder()
|
||||
}
|
||||
|
||||
public func selectAll() {
|
||||
self.inputFirstField?.selectAll(nil)
|
||||
}
|
||||
|
||||
override public func longTapped() {
|
||||
self.item?.longTapAction?()
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ public protocol ItemListItemNode {
|
||||
|
||||
public protocol ItemListItemFocusableNode {
|
||||
func focus()
|
||||
func selectAll()
|
||||
}
|
||||
|
||||
public enum ItemListInsetWithOtherSection {
|
||||
|
@ -472,6 +472,10 @@ public class ItemListMultilineInputItemNode: ListViewItemNode, ASEditableTextNod
|
||||
}
|
||||
}
|
||||
|
||||
public func selectAll() {
|
||||
self.textNode.textView.selectAll(nil)
|
||||
}
|
||||
|
||||
public func animateError() {
|
||||
self.textNode.layer.addShakeAnimation()
|
||||
}
|
||||
|
@ -473,6 +473,10 @@ public class ItemListSingleLineInputItemNode: ListViewItemNode, UITextFieldDeleg
|
||||
}
|
||||
}
|
||||
|
||||
public func selectAll() {
|
||||
self.textNode.textField.selectAll(nil)
|
||||
}
|
||||
|
||||
@objc public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
|
||||
if let item = self.item {
|
||||
let newText = ((textField.text ?? "") as NSString).replacingCharacters(in: range, with: string)
|
||||
|
@ -347,4 +347,8 @@ class UserInfoEditingPhoneItemNode: ItemListRevealOptionsItemNode, ItemListItemN
|
||||
func focus() {
|
||||
self.phoneNode.numberField?.becomeFirstResponder()
|
||||
}
|
||||
|
||||
func selectAll() {
|
||||
self.phoneNode.numberField?.textField.selectAll(nil)
|
||||
}
|
||||
}
|
||||
|
@ -553,6 +553,7 @@ public func createGroupControllerImpl(context: AccountContext, peerIds: [PeerId]
|
||||
var endEditingImpl: (() -> Void)?
|
||||
var ensureItemVisibleImpl: ((CreateGroupEntryTag, Bool) -> Void)?
|
||||
var findAutoremoveReferenceNode: (() -> ItemListDisclosureItemNode?)?
|
||||
var selectTitleImpl: (() -> Void)?
|
||||
|
||||
let actionsDisposable = DisposableSet()
|
||||
|
||||
@ -564,6 +565,50 @@ public func createGroupControllerImpl(context: AccountContext, peerIds: [PeerId]
|
||||
let uploadedAvatar = Promise<UploadedPeerPhotoData>()
|
||||
var uploadedVideoAvatar: (Promise<UploadedPeerPhotoData?>, Double?)? = nil
|
||||
|
||||
if initialTitle == nil && peerIds.count > 0 && peerIds.count < 5 {
|
||||
let _ = (context.engine.data.get(
|
||||
TelegramEngine.EngineData.Item.Peer.Peer(id: context.account.peerId),
|
||||
EngineDataList(
|
||||
peerIds.map(TelegramEngine.EngineData.Item.Peer.Peer.init)
|
||||
)
|
||||
)
|
||||
|> deliverOnMainQueue).start(next: { accountPeer, peers in
|
||||
var allNames: [String] = []
|
||||
if case let .user(user) = accountPeer, let firstName = user.firstName, !firstName.isEmpty {
|
||||
allNames.append(firstName)
|
||||
}
|
||||
for peer in peers {
|
||||
if case let .user(user) = peer, let firstName = user.firstName, !firstName.isEmpty {
|
||||
allNames.append(firstName)
|
||||
}
|
||||
}
|
||||
|
||||
if allNames.count > 1 {
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
var title: String = ""
|
||||
for i in 0 ..< allNames.count {
|
||||
if i == 0 {
|
||||
} else if i < allNames.count - 1 {
|
||||
title.append(presentationData.strings.CreateGroup_PeersTitleDelimeter)
|
||||
} else {
|
||||
title.append(presentationData.strings.CreateGroup_PeersTitleLastDelimeter)
|
||||
}
|
||||
title.append(allNames[i])
|
||||
}
|
||||
|
||||
updateState { current in
|
||||
var current = current
|
||||
current.editingName = .title(title: title, type: .group)
|
||||
return current
|
||||
}
|
||||
|
||||
Queue.mainQueue().after(0.3) {
|
||||
selectTitleImpl?()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
let addressPromise = Promise<String?>(nil)
|
||||
let venuesPromise = Promise<[TelegramMediaMap]?>(nil)
|
||||
if case let .locatedGroup(latitude, longitude, address) = mode {
|
||||
@ -1341,6 +1386,14 @@ public func createGroupControllerImpl(context: AccountContext, peerIds: [PeerId]
|
||||
}
|
||||
}
|
||||
|
||||
selectTitleImpl = { [weak controller] in
|
||||
controller?.forEachItemNode({ itemNode in
|
||||
if let itemNode = itemNode as? ItemListAvatarAndNameInfoItemNode {
|
||||
itemNode.selectAll()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return controller
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user