mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
no message
This commit is contained in:
@@ -4,12 +4,6 @@ import SwiftSignalKit
|
||||
import Display
|
||||
import TelegramCore
|
||||
|
||||
private let composeButtonImage = generateImage(CGSize(width: 24.0, height: 24.0), rotatedContext: { size, context in
|
||||
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||
context.setFillColor(UIColor(0x007ee5).cgColor)
|
||||
try? drawSvgPath(context, path: "M0,4 L15,4 L14,5 L1,5 L1,22 L18,22 L18,9 L19,8 L19,23 L0,23 L0,4 Z M18.5944456,1.70209754 L19.5995507,2.70718758 L10.0510517,12.255543 L9.54849908,13.7631781 L11.0561568,13.2606331 L20.6046559,3.71227763 L21.6097611,4.71736767 L11.5587094,14.7682681 L7.53828874,15.7733582 L9.04594649,11.250453 L18.5944456,1.70209754 Z M19.0969982,1.19955251 L20.0773504,0.21921503 C20.3690844,-0.0725145755 20.8398084,-0.0729335627 21.1298838,0.217137419 L23.0947435,2.18196761 C23.3833646,2.47058439 23.3838887,2.94326675 23.0926659,3.23448517 L22.1123136,4.21482265 L19.0969982,1.19955251 Z ")
|
||||
})
|
||||
|
||||
public class ChatListController: TelegramController, UIViewControllerPreviewingDelegate {
|
||||
private let account: Account
|
||||
|
||||
@@ -29,23 +23,30 @@ public class ChatListController: TelegramController, UIViewControllerPreviewingD
|
||||
|
||||
private let passcodeDisposable = MetaDisposable()
|
||||
|
||||
private var presentationData: PresentationData
|
||||
private var presentationDataDisposable: Disposable?
|
||||
|
||||
public override init(account: Account) {
|
||||
self.account = account
|
||||
|
||||
self.titleView = NetworkStatusTitleView()
|
||||
self.presentationData = (account.telegramApplicationContext.currentPresentationData.with { $0 })
|
||||
|
||||
self.titleView = NetworkStatusTitleView(theme: self.presentationData.theme)
|
||||
|
||||
super.init(account: account)
|
||||
|
||||
self.navigationBar.item = nil
|
||||
self.statusBar.statusBarStyle = self.presentationData.theme.rootController.statusBar.style.style
|
||||
|
||||
self.titleView.title = NetworkStatusTitle(text: "Chats", activity: false)
|
||||
self.navigationBar?.item = nil
|
||||
|
||||
self.titleView.title = NetworkStatusTitle(text: self.presentationData.strings.DialogList_Title, activity: false)
|
||||
self.navigationItem.titleView = self.titleView
|
||||
self.tabBarItem.title = "Chats"
|
||||
self.tabBarItem.title = self.presentationData.strings.DialogList_Title
|
||||
self.tabBarItem.image = UIImage(bundleImageName: "Chat List/Tabs/IconChats")
|
||||
self.tabBarItem.selectedImage = UIImage(bundleImageName: "Chat List/Tabs/IconChatsSelected")
|
||||
|
||||
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Edit", style: .plain, target: self, action: #selector(self.editPressed))
|
||||
self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: composeButtonImage, style: .plain, target: self, action: #selector(self.composePressed))
|
||||
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Edit, style: .plain, target: self, action: #selector(self.editPressed))
|
||||
self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationComposeIcon(self.presentationData.theme), style: .plain, target: self, action: #selector(self.composePressed))
|
||||
|
||||
self.scrollToTop = { [weak self] in
|
||||
if let strongSelf = self {
|
||||
@@ -57,13 +58,13 @@ public class ChatListController: TelegramController, UIViewControllerPreviewingD
|
||||
if let strongSelf = self {
|
||||
switch state {
|
||||
case .waitingForNetwork:
|
||||
strongSelf.titleView.title = NetworkStatusTitle(text: "Waiting For Network...", activity: true)
|
||||
strongSelf.titleView.title = NetworkStatusTitle(text: strongSelf.presentationData.strings.State_WaitingForNetwork, activity: true)
|
||||
case .connecting:
|
||||
strongSelf.titleView.title = NetworkStatusTitle(text: "Connecting...", activity: true)
|
||||
strongSelf.titleView.title = NetworkStatusTitle(text: strongSelf.presentationData.strings.State_Connecting, activity: true)
|
||||
case .updating:
|
||||
strongSelf.titleView.title = NetworkStatusTitle(text: "Updating...", activity: true)
|
||||
strongSelf.titleView.title = NetworkStatusTitle(text: strongSelf.presentationData.strings.State_Updating, activity: true)
|
||||
case .online:
|
||||
strongSelf.titleView.title = NetworkStatusTitle(text: "Chats", activity: false)
|
||||
strongSelf.titleView.title = NetworkStatusTitle(text: strongSelf.presentationData.strings.DialogList_Title, activity: false)
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -108,6 +109,20 @@ public class ChatListController: TelegramController, UIViewControllerPreviewingD
|
||||
}).start()
|
||||
}
|
||||
}
|
||||
|
||||
self.presentationDataDisposable = (account.telegramApplicationContext.presentationData
|
||||
|> deliverOnMainQueue).start(next: { [weak self] presentationData in
|
||||
if let strongSelf = self {
|
||||
let previousTheme = strongSelf.presentationData.theme
|
||||
let previousStrings = strongSelf.presentationData.strings
|
||||
|
||||
strongSelf.presentationData = presentationData
|
||||
|
||||
if previousTheme !== presentationData.theme || previousStrings !== presentationData.strings {
|
||||
strongSelf.updateThemeAndStrings()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
required public init(coder aDecoder: NSCoder) {
|
||||
@@ -119,10 +134,25 @@ public class ChatListController: TelegramController, UIViewControllerPreviewingD
|
||||
self.titleDisposable?.dispose()
|
||||
self.badgeDisposable?.dispose()
|
||||
self.passcodeDisposable.dispose()
|
||||
self.presentationDataDisposable?.dispose()
|
||||
}
|
||||
|
||||
private func updateThemeAndStrings() {
|
||||
self.tabBarItem.title = self.presentationData.strings.DialogList_Title
|
||||
self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationComposeIcon(self.presentationData.theme), style: .plain, target: self, action: #selector(self.composePressed))
|
||||
|
||||
self.titleView.theme = self.presentationData.theme
|
||||
|
||||
self.statusBar.statusBarStyle = self.presentationData.theme.rootController.statusBar.style.style
|
||||
self.navigationBar?.updateTheme(NavigationBarTheme(rootControllerTheme: self.presentationData.theme))
|
||||
|
||||
if self.isNodeLoaded {
|
||||
self.chatListDisplayNode.updateThemeAndStrings(theme: self.presentationData.theme, strings: self.presentationData.strings)
|
||||
}
|
||||
}
|
||||
|
||||
override public func loadDisplayNode() {
|
||||
self.displayNode = ChatListControllerNode(account: self.account)
|
||||
self.displayNode = ChatListControllerNode(account: self.account, theme: self.presentationData.theme, strings: self.presentationData.strings)
|
||||
|
||||
self.chatListDisplayNode.navigationBar = self.navigationBar
|
||||
|
||||
@@ -138,7 +168,7 @@ public class ChatListController: TelegramController, UIViewControllerPreviewingD
|
||||
if let strongSelf = self {
|
||||
let actionSheet = ActionSheetController()
|
||||
actionSheet.setItemGroups([ActionSheetItemGroup(items: [
|
||||
ActionSheetButtonItem(title: "Delete", color: .destructive, action: { [weak actionSheet] in
|
||||
ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Delete, color: .destructive, action: { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
|
||||
if let strongSelf = self {
|
||||
@@ -146,7 +176,7 @@ public class ChatListController: TelegramController, UIViewControllerPreviewingD
|
||||
}
|
||||
})
|
||||
]), ActionSheetItemGroup(items: [
|
||||
ActionSheetButtonItem(title: "Cancel", color: .accent, action: { [weak actionSheet] in
|
||||
ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Cancel, color: .accent, action: { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
})
|
||||
])])
|
||||
@@ -219,14 +249,14 @@ public class ChatListController: TelegramController, UIViewControllerPreviewingD
|
||||
}
|
||||
|
||||
@objc func editPressed() {
|
||||
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Done", style: .done, target: self, action: #selector(self.donePressed))
|
||||
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Done, style: .done, target: self, action: #selector(self.donePressed))
|
||||
self.chatListDisplayNode.chatListNode.updateState { state in
|
||||
return state.withUpdatedEditing(true)
|
||||
}
|
||||
}
|
||||
|
||||
@objc func donePressed() {
|
||||
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Edit", style: .plain, target: self, action: #selector(self.editPressed))
|
||||
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Edit, style: .plain, target: self, action: #selector(self.editPressed))
|
||||
self.chatListDisplayNode.chatListNode.updateState { state in
|
||||
return state.withUpdatedEditing(false).withUpdatedPeerIdWithRevealedOptions(nil)
|
||||
}
|
||||
@@ -265,7 +295,7 @@ public class ChatListController: TelegramController, UIViewControllerPreviewingD
|
||||
|
||||
let chatController = ChatController(account: self.account, peerId: peerId)
|
||||
chatController.canReadHistory.set(false)
|
||||
chatController.containerLayoutUpdated(ContainerViewLayout(size: CGSize(width: self.view.bounds.size.width, height: self.view.bounds.size.height - (self.view.bounds.size.height > self.view.bounds.size.width ? 50.0 : 10.0)), intrinsicInsets: UIEdgeInsets(), statusBarHeight: nil, inputHeight: nil), transition: .immediate)
|
||||
chatController.containerLayoutUpdated(ContainerViewLayout(size: CGSize(width: self.view.bounds.size.width, height: self.view.bounds.size.height - (self.view.bounds.size.height > self.view.bounds.size.width ? 50.0 : 10.0)), metrics: LayoutMetrics(), intrinsicInsets: UIEdgeInsets(), statusBarHeight: nil, inputHeight: nil), transition: .immediate)
|
||||
return chatController
|
||||
} else if let messageId = action as? MessageId {
|
||||
if #available(iOSApplicationExtension 9.0, *) {
|
||||
@@ -276,7 +306,7 @@ public class ChatListController: TelegramController, UIViewControllerPreviewingD
|
||||
|
||||
let chatController = ChatController(account: self.account, peerId: messageId.peerId, messageId: messageId)
|
||||
chatController.canReadHistory.set(false)
|
||||
chatController.containerLayoutUpdated(ContainerViewLayout(size: CGSize(width: self.view.bounds.size.width, height: self.view.bounds.size.height - (self.view.bounds.size.height > self.view.bounds.size.width ? 50.0 : 10.0)), intrinsicInsets: UIEdgeInsets(), statusBarHeight: nil, inputHeight: nil), transition: .immediate)
|
||||
chatController.containerLayoutUpdated(ContainerViewLayout(size: CGSize(width: self.view.bounds.size.width, height: self.view.bounds.size.height - (self.view.bounds.size.height > self.view.bounds.size.width ? 50.0 : 10.0)), metrics: LayoutMetrics(), intrinsicInsets: UIEdgeInsets(), statusBarHeight: nil, inputHeight: nil), transition: .immediate)
|
||||
return chatController
|
||||
}
|
||||
}
|
||||
@@ -299,7 +329,7 @@ public class ChatListController: TelegramController, UIViewControllerPreviewingD
|
||||
}
|
||||
let chatController = ChatController(account: self.account, peerId: item.peer.peerId)
|
||||
chatController.canReadHistory.set(false)
|
||||
chatController.containerLayoutUpdated(ContainerViewLayout(size: CGSize(width: self.view.bounds.size.width, height: self.view.bounds.size.height - (self.view.bounds.size.height > self.view.bounds.size.width ? 50.0 : 10.0)), intrinsicInsets: UIEdgeInsets(), statusBarHeight: nil, inputHeight: nil), transition: .immediate)
|
||||
chatController.containerLayoutUpdated(ContainerViewLayout(size: CGSize(width: self.view.bounds.size.width, height: self.view.bounds.size.height - (self.view.bounds.size.height > self.view.bounds.size.width ? 50.0 : 10.0)), metrics: LayoutMetrics(), intrinsicInsets: UIEdgeInsets(), statusBarHeight: nil, inputHeight: nil), transition: .immediate)
|
||||
return chatController
|
||||
} else {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user