mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
56 lines
2.3 KiB
Swift
56 lines
2.3 KiB
Swift
import Foundation
|
|
import UIKit
|
|
import TelegramPresentationData
|
|
|
|
enum ApplicationShortcutItemType: String {
|
|
case search
|
|
case compose
|
|
case camera
|
|
case savedMessages
|
|
case account
|
|
}
|
|
|
|
struct ApplicationShortcutItem: Equatable {
|
|
let type: ApplicationShortcutItemType
|
|
let title: String
|
|
let subtitle: String?
|
|
}
|
|
|
|
@available(iOS 9.1, *)
|
|
extension ApplicationShortcutItem {
|
|
func shortcutItem() -> UIApplicationShortcutItem {
|
|
let icon: UIApplicationShortcutIcon
|
|
switch self.type {
|
|
case .search:
|
|
icon = UIApplicationShortcutIcon(type: .search)
|
|
case .compose:
|
|
icon = UIApplicationShortcutIcon(type: .compose)
|
|
case .camera:
|
|
icon = UIApplicationShortcutIcon(templateImageName: "Shortcuts/Camera")
|
|
case .savedMessages:
|
|
icon = UIApplicationShortcutIcon(templateImageName: "Shortcuts/SavedMessages")
|
|
case .account:
|
|
icon = UIApplicationShortcutIcon(templateImageName: "Shortcuts/Account")
|
|
}
|
|
return UIApplicationShortcutItem(type: self.type.rawValue, localizedTitle: self.title, localizedSubtitle: self.subtitle, icon: icon, userInfo: nil)
|
|
}
|
|
}
|
|
|
|
func applicationShortcutItems(strings: PresentationStrings, otherAccountName: String?) -> [ApplicationShortcutItem] {
|
|
if let otherAccountName = otherAccountName {
|
|
return [
|
|
ApplicationShortcutItem(type: .search, title: strings.Common_Search, subtitle: nil),
|
|
ApplicationShortcutItem(type: .compose, title: strings.Compose_NewMessage, subtitle: nil),
|
|
ApplicationShortcutItem(type: .savedMessages, title: strings.Conversation_SavedMessages, subtitle: nil),
|
|
ApplicationShortcutItem(type: .account, title: strings.Shortcut_SwitchAccount, subtitle: otherAccountName)
|
|
]
|
|
} else {
|
|
return [
|
|
ApplicationShortcutItem(type: .search, title: strings.Common_Search, subtitle: nil),
|
|
ApplicationShortcutItem(type: .compose, title: strings.Compose_NewMessage, subtitle: nil),
|
|
ApplicationShortcutItem(type: .camera, title: strings.Camera_Title, subtitle: nil),
|
|
ApplicationShortcutItem(type: .savedMessages, title: strings.Conversation_SavedMessages, subtitle: nil)
|
|
]
|
|
}
|
|
}
|