Native macOS app for posting to Mastodon, WordPress (self-hosted), and Micro.blog. Features: global hotkey (Ctrl+Option+Cmd+T), multiple accounts with selection, image attachments (up to 4, drag-and-drop), floating panel UI, Keychain storage.
39 lines
840 B
Swift
39 lines
840 B
Swift
import SwiftUI
|
|
|
|
@Observable
|
|
@MainActor
|
|
final class AppState {
|
|
var inputText: String = ""
|
|
var attachedImages: [ImageAttachment] = []
|
|
var selectedAccountIDs: Set<UUID> = []
|
|
var isSubmitting: Bool = false
|
|
var isPanelVisible: Bool = false
|
|
var statusMessage: StatusMessage?
|
|
|
|
static let maxImages = 4
|
|
|
|
var canPost: Bool {
|
|
!inputText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
|
|
&& !selectedAccountIDs.isEmpty
|
|
&& !isSubmitting
|
|
}
|
|
|
|
func reset() {
|
|
inputText = ""
|
|
attachedImages = []
|
|
statusMessage = nil
|
|
}
|
|
}
|
|
|
|
struct ImageAttachment: Identifiable {
|
|
let id = UUID()
|
|
let image: NSImage
|
|
let data: Data
|
|
let filename: String
|
|
}
|
|
|
|
struct StatusMessage: Identifiable {
|
|
let id = UUID()
|
|
let text: String
|
|
let isError: Bool
|
|
}
|