66 lines
1.5 KiB
Swift
66 lines
1.5 KiB
Swift
//
|
|
// ComposeUIState.swift
|
|
// Tusker
|
|
//
|
|
// Created by Shadowfacts on 8/24/20.
|
|
// Copyright © 2020 Shadowfacts. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
protocol ComposeUIStateDelegate: class {
|
|
var assetPickerDelegate: AssetPickerViewControllerDelegate? { get }
|
|
|
|
func dismissCompose(mode: ComposeUIState.DismissMode)
|
|
func presentAssetPickerSheet()
|
|
func presentComposeDrawing()
|
|
|
|
func keyboardWillShow(accessoryView: UIView, notification: Notification)
|
|
func keyboardWillHide(accessoryView: UIView, notification: Notification)
|
|
func keyboardDidHide(accessoryView: UIView, notification: Notification)
|
|
}
|
|
|
|
class ComposeUIState: ObservableObject {
|
|
|
|
weak var delegate: ComposeUIStateDelegate?
|
|
|
|
@Published var draft: Draft
|
|
@Published var isShowingSaveDraftSheet = false
|
|
@Published var attachmentsMissingDescriptions = Set<UUID>()
|
|
@Published var autocompleteState: AutocompleteState? = nil
|
|
|
|
var composeDrawingMode: ComposeDrawingMode?
|
|
|
|
weak var autocompleteHandler: ComposeAutocompleteHandler?
|
|
|
|
init(draft: Draft) {
|
|
self.draft = draft
|
|
}
|
|
|
|
}
|
|
|
|
extension ComposeUIState {
|
|
enum ComposeDrawingMode {
|
|
case createNew
|
|
case edit(id: UUID)
|
|
}
|
|
}
|
|
|
|
extension ComposeUIState {
|
|
enum AutocompleteState {
|
|
case mention(String)
|
|
case emoji(String)
|
|
case hashtag(String)
|
|
}
|
|
}
|
|
|
|
extension ComposeUIState {
|
|
enum DismissMode {
|
|
case cancel, post
|
|
}
|
|
}
|
|
|
|
protocol ComposeAutocompleteHandler: class {
|
|
func autocomplete(with string: String)
|
|
}
|