Add SwiftUI iOS app shell
This commit is contained in:
168
apps/ios/TeleTuiIOS/Sources/TeleTuiIOSCore/Models.swift
Normal file
168
apps/ios/TeleTuiIOS/Sources/TeleTuiIOSCore/Models.swift
Normal file
@@ -0,0 +1,168 @@
|
||||
import Foundation
|
||||
|
||||
public struct Account: Identifiable, Equatable, Sendable {
|
||||
public var id: String
|
||||
public var displayName: String
|
||||
public var databasePath: URL
|
||||
|
||||
public init(id: String, displayName: String, databasePath: URL) {
|
||||
self.id = id
|
||||
self.displayName = displayName
|
||||
self.databasePath = databasePath
|
||||
}
|
||||
}
|
||||
|
||||
public enum AuthState: Equatable, Sendable {
|
||||
case waitTdlibParameters
|
||||
case waitPhoneNumber
|
||||
case waitCode
|
||||
case waitPassword
|
||||
case ready
|
||||
case closed
|
||||
case error(String)
|
||||
}
|
||||
|
||||
public struct Folder: Identifiable, Equatable, Sendable {
|
||||
public var id: Int32
|
||||
public var name: String
|
||||
|
||||
public init(id: Int32, name: String) {
|
||||
self.id = id
|
||||
self.name = name
|
||||
}
|
||||
}
|
||||
|
||||
public struct Draft: Hashable, Sendable {
|
||||
public var chatId: Int64
|
||||
public var text: String
|
||||
|
||||
public init(chatId: Int64, text: String) {
|
||||
self.chatId = chatId
|
||||
self.text = text
|
||||
}
|
||||
}
|
||||
|
||||
public struct ChatSummary: Identifiable, Hashable, Sendable {
|
||||
public var id: Int64
|
||||
public var title: String
|
||||
public var username: String?
|
||||
public var lastMessage: String
|
||||
public var unreadCount: Int32
|
||||
public var unreadMentionCount: Int32
|
||||
public var isPinned: Bool
|
||||
public var folderIds: [Int32]
|
||||
public var isMuted: Bool
|
||||
public var draft: Draft?
|
||||
|
||||
public init(
|
||||
id: Int64,
|
||||
title: String,
|
||||
username: String? = nil,
|
||||
lastMessage: String,
|
||||
unreadCount: Int32 = 0,
|
||||
unreadMentionCount: Int32 = 0,
|
||||
isPinned: Bool = false,
|
||||
folderIds: [Int32] = [0],
|
||||
isMuted: Bool = false,
|
||||
draft: Draft? = nil
|
||||
) {
|
||||
self.id = id
|
||||
self.title = title
|
||||
self.username = username
|
||||
self.lastMessage = lastMessage
|
||||
self.unreadCount = unreadCount
|
||||
self.unreadMentionCount = unreadMentionCount
|
||||
self.isPinned = isPinned
|
||||
self.folderIds = folderIds
|
||||
self.isMuted = isMuted
|
||||
self.draft = draft
|
||||
}
|
||||
}
|
||||
|
||||
public struct Reaction: Equatable, Sendable {
|
||||
public var emoji: String
|
||||
public var count: Int32
|
||||
public var isChosen: Bool
|
||||
|
||||
public init(emoji: String, count: Int32, isChosen: Bool) {
|
||||
self.emoji = emoji
|
||||
self.count = count
|
||||
self.isChosen = isChosen
|
||||
}
|
||||
}
|
||||
|
||||
public struct Message: Identifiable, Equatable, Sendable {
|
||||
public var id: Int64
|
||||
public var chatId: Int64
|
||||
public var senderName: String
|
||||
public var text: String
|
||||
public var isOutgoing: Bool
|
||||
public var isRead: Bool
|
||||
public var editDate: Int32?
|
||||
public var replyText: String?
|
||||
public var forwardSenderName: String?
|
||||
public var reactions: [Reaction]
|
||||
|
||||
public init(
|
||||
id: Int64,
|
||||
chatId: Int64,
|
||||
senderName: String,
|
||||
text: String,
|
||||
isOutgoing: Bool,
|
||||
isRead: Bool = true,
|
||||
editDate: Int32? = nil,
|
||||
replyText: String? = nil,
|
||||
forwardSenderName: String? = nil,
|
||||
reactions: [Reaction] = []
|
||||
) {
|
||||
self.id = id
|
||||
self.chatId = chatId
|
||||
self.senderName = senderName
|
||||
self.text = text
|
||||
self.isOutgoing = isOutgoing
|
||||
self.isRead = isRead
|
||||
self.editDate = editDate
|
||||
self.replyText = replyText
|
||||
self.forwardSenderName = forwardSenderName
|
||||
self.reactions = reactions
|
||||
}
|
||||
}
|
||||
|
||||
public struct Profile: Equatable, Sendable {
|
||||
public var chatId: Int64
|
||||
public var title: String
|
||||
public var username: String?
|
||||
public var bio: String?
|
||||
public var isGroup: Bool
|
||||
public var memberCount: Int32?
|
||||
|
||||
public init(
|
||||
chatId: Int64,
|
||||
title: String,
|
||||
username: String? = nil,
|
||||
bio: String? = nil,
|
||||
isGroup: Bool = false,
|
||||
memberCount: Int32? = nil
|
||||
) {
|
||||
self.chatId = chatId
|
||||
self.title = title
|
||||
self.username = username
|
||||
self.bio = bio
|
||||
self.isGroup = isGroup
|
||||
self.memberCount = memberCount
|
||||
}
|
||||
}
|
||||
|
||||
public enum SessionEvent: Equatable, Sendable {
|
||||
case authChanged(AuthState)
|
||||
case chatListChanged([ChatSummary])
|
||||
case messageAdded(Int64, Message)
|
||||
case profileLoaded(Profile)
|
||||
}
|
||||
|
||||
public enum NetworkState: Equatable, Sendable {
|
||||
case waitingForNetwork
|
||||
case connecting
|
||||
case updating
|
||||
case ready
|
||||
}
|
||||
Reference in New Issue
Block a user