mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Various fixes
This commit is contained in:
parent
2551584941
commit
b33d7888b8
@ -20,12 +20,14 @@ import UndoUI
|
||||
private final class InviteLinkEditControllerArguments {
|
||||
let context: AccountContext
|
||||
let updateState: ((InviteLinkEditControllerState) -> InviteLinkEditControllerState) -> Void
|
||||
let scrollToUsage: () -> Void
|
||||
let dismissInput: () -> Void
|
||||
let revoke: () -> Void
|
||||
|
||||
init(context: AccountContext, updateState: @escaping ((InviteLinkEditControllerState) -> InviteLinkEditControllerState) -> Void, dismissInput: @escaping () -> Void, revoke: @escaping () -> Void) {
|
||||
init(context: AccountContext, updateState: @escaping ((InviteLinkEditControllerState) -> InviteLinkEditControllerState) -> Void, scrollToUsage: @escaping () -> Void, dismissInput: @escaping () -> Void, revoke: @escaping () -> Void) {
|
||||
self.context = context
|
||||
self.updateState = updateState
|
||||
self.scrollToUsage = scrollToUsage
|
||||
self.dismissInput = dismissInput
|
||||
self.revoke = revoke
|
||||
}
|
||||
@ -39,6 +41,18 @@ private enum InviteLinksEditSection: Int32 {
|
||||
case revoke
|
||||
}
|
||||
|
||||
private enum InviteLinksEditEntryTag: ItemListItemTag {
|
||||
case usage
|
||||
|
||||
func isEqual(to other: ItemListItemTag) -> Bool {
|
||||
if let other = other as? InviteLinksEditEntryTag, self == other {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private let invalidAmountCharacters = CharacterSet(charactersIn: "01234567890.,").inverted
|
||||
func isValidNumberOfUsers(_ number: String) -> Bool {
|
||||
if number.isEmpty {
|
||||
@ -298,7 +312,7 @@ private enum InviteLinksEditEntry: ItemListNodeEntry {
|
||||
} else {
|
||||
text = focused ? "" : presentationData.strings.InviteLink_Create_UsersLimitNumberOfUsersUnlimited
|
||||
}
|
||||
return ItemListSingleLineInputItem(presentationData: presentationData, title: NSAttributedString(string: presentationData.strings.InviteLink_Create_UsersLimitNumberOfUsers, textColor: theme.list.itemPrimaryTextColor), text: text, placeholder: "", type: .number, alignment: .right, selectAllOnFocus: true, secondaryStyle: !customValue, tag: nil, sectionId: self.section, textUpdated: { updatedText in
|
||||
return ItemListSingleLineInputItem(presentationData: presentationData, title: NSAttributedString(string: presentationData.strings.InviteLink_Create_UsersLimitNumberOfUsers, textColor: theme.list.itemPrimaryTextColor), text: text, placeholder: "", type: .number, alignment: .right, selectAllOnFocus: true, secondaryStyle: !customValue, tag: InviteLinksEditEntryTag.usage, sectionId: self.section, textUpdated: { updatedText in
|
||||
arguments.updateState { state in
|
||||
var updatedState = state
|
||||
if updatedText.isEmpty {
|
||||
@ -318,6 +332,7 @@ private enum InviteLinksEditEntry: ItemListNodeEntry {
|
||||
updatedState.pickingUsageLimit = true
|
||||
return updatedState
|
||||
}
|
||||
arguments.scrollToUsage()
|
||||
} else {
|
||||
arguments.updateState { state in
|
||||
var updatedState = state
|
||||
@ -436,9 +451,12 @@ public func inviteLinkEditController(context: AccountContext, updatedPresentatio
|
||||
|
||||
var dismissImpl: (() -> Void)?
|
||||
var dismissInputImpl: (() -> Void)?
|
||||
var scrollToUsageImpl: (() -> Void)?
|
||||
|
||||
let arguments = InviteLinkEditControllerArguments(context: context, updateState: { f in
|
||||
updateState(f)
|
||||
}, scrollToUsage: {
|
||||
scrollToUsageImpl?()
|
||||
}, dismissInput: {
|
||||
dismissInputImpl?()
|
||||
}, revoke: {
|
||||
@ -599,6 +617,27 @@ public func inviteLinkEditController(context: AccountContext, updatedPresentatio
|
||||
controller.present(c, in: .window(.root), with: p)
|
||||
}
|
||||
}
|
||||
scrollToUsageImpl = { [weak controller] in
|
||||
controller?.afterLayout({
|
||||
guard let controller = controller else {
|
||||
return
|
||||
}
|
||||
|
||||
var resultItemNode: ListViewItemNode?
|
||||
let _ = controller.frameForItemNode({ itemNode in
|
||||
if let itemNode = itemNode as? ItemListSingleLineInputItemNode {
|
||||
if let tag = itemNode.tag as? InviteLinksEditEntryTag, tag == .usage {
|
||||
resultItemNode = itemNode
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
if let resultItemNode = resultItemNode {
|
||||
controller.ensureItemNodeVisible(resultItemNode)
|
||||
}
|
||||
})
|
||||
}
|
||||
dismissInputImpl = { [weak controller] in
|
||||
controller?.view.endEditing(true)
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ public final class InviteLinkViewController: ViewController {
|
||||
|
||||
private let context: AccountContext
|
||||
private let peerId: EnginePeer.Id
|
||||
private let invite: ExportedInvitation
|
||||
private var invite: ExportedInvitation
|
||||
|
||||
private let importersContext: PeerInvitationImportersContext
|
||||
private let requestsContext: PeerInvitationImportersContext?
|
||||
@ -823,6 +823,11 @@ public final class InviteLinkViewController: ViewController {
|
||||
self?.controller?.dismiss()
|
||||
} else {
|
||||
invitationsContext?.update(invite)
|
||||
|
||||
if let strongSelf = self, let layout = strongSelf.validLayout {
|
||||
strongSelf.invite = invite
|
||||
strongSelf.containerLayoutUpdated(layout, transition: .immediate)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -936,7 +941,6 @@ public final class InviteLinkViewController: ViewController {
|
||||
|
||||
var titleText = self.presentationData.strings.InviteLink_InviteLink
|
||||
|
||||
|
||||
var subtitleText = ""
|
||||
var subtitleColor = self.presentationData.theme.list.itemSecondaryTextColor
|
||||
if self.invite.isRevoked {
|
||||
|
Loading…
x
Reference in New Issue
Block a user