Remove unused ComposeUIConfig properties

This commit is contained in:
Shadowfacts 2025-02-07 11:17:50 -05:00
parent a7049d224c
commit 558675842a
7 changed files with 12 additions and 35 deletions

View File

@ -13,15 +13,15 @@ import UniformTypeIdentifiers
@MainActor
final class PostService: ObservableObject {
private let mastodonController: any ComposeMastodonContext
private let config: ComposeUIConfig
private let contentType: StatusContentType
private let draft: Draft
@Published var currentStep = 1
@Published private(set) var totalSteps = 2
init(mastodonController: any ComposeMastodonContext, config: ComposeUIConfig, draft: Draft) {
init(mastodonController: any ComposeMastodonContext, contentType: StatusContentType, draft: Draft) {
self.mastodonController = mastodonController
self.config = config
self.contentType = contentType
self.draft = draft
}
@ -56,7 +56,7 @@ final class PostService: ObservableObject {
request = Client.editStatus(
id: editedStatusID,
text: textForPosting(),
contentType: config.contentType,
contentType: contentType,
spoilerText: contentWarning,
sensitive: sensitive,
language: mastodonController.instanceFeatures.createStatusWithLanguage ? draft.language : nil,
@ -87,7 +87,7 @@ final class PostService: ObservableObject {
request = Client.createStatus(
text: textForPosting(),
contentType: config.contentType,
contentType: contentType,
inReplyTo: draft.inReplyToID,
mediaIDs: uploadedAttachments,
sensitive: sensitive,

View File

@ -25,13 +25,6 @@ public struct ComposeUIConfig {
public var groupedCellBackgroundColor = Color(uiColor: .systemBackground)
public var fillColor = Color(uiColor: .systemFill)
// TODO: remove these in favor of @PreferenceObserving
// Preferences
public var avatarStyle = AvatarImageView.Style.roundRect
public var useTwitterKeyboard = false
public var contentType = StatusContentType.plain
public var requireAttachmentDescriptions = false
// Host callbacks
public var dismiss: @MainActor (DismissMode) -> Void = { _ in }
public var presentAssetPicker: ((@MainActor @escaping ([PHPickerResult]) -> Void) -> Void)?

View File

@ -8,6 +8,7 @@
import SwiftUI
import Combine
import InstanceFeatures
import TuskerPreferences
struct ComposeNavigationBarActions: ToolbarContent {
@ObservedObject var draft: Draft
@ -100,7 +101,7 @@ private struct PostButton: View {
let isPosting: Bool
let postStatus: () async -> Void
@EnvironmentObject private var instanceFeatures: InstanceFeatures
@Environment(\.composeUIConfig.requireAttachmentDescriptions) private var requireAttachmentDescriptions
@PreferenceObserving(\.$requireAttachmentDescriptions) private var requireAttachmentDescriptions
var body: some View {
Button {

View File

@ -9,6 +9,7 @@ import SwiftUI
import CoreData
import Pachyderm
import TuskerComponents
import TuskerPreferences
// State owned by the compose UI but that needs to be accessible from outside.
public final class ComposeViewState: ObservableObject {
@ -87,7 +88,8 @@ private struct ComposeViewBody: View {
@State private var isDismissing = false
@State private var userConfirmedDelete = false
@Environment(\.composeUIConfig) private var config
@PreferenceObserving(\.$statusContentType) private var statusContentType
public var body: some View {
navigation
.environmentObject(mastodonController.instanceFeatures)
@ -215,7 +217,7 @@ private struct ComposeViewBody: View {
return
}
let poster = PostService(mastodonController: mastodonController, config: config, draft: draft)
let poster = PostService(mastodonController: mastodonController, contentType: statusContentType, draft: draft)
state.poster = poster
do {

View File

@ -37,7 +37,7 @@ private struct NewMainTextViewRepresentable: UIViewRepresentable {
@Environment(\.isEnabled) private var isEnabled
@Environment(\.colorScheme) private var colorScheme
@Environment(\.composeUIConfig.fillColor) private var fillColor
@Environment(\.composeUIConfig.useTwitterKeyboard) private var useTwitterKeyboard
@PreferenceObserving(\.$useTwitterKeyboard) private var useTwitterKeyboard
@Environment(\.composeUIConfig.textSelectionStartsAtBeginning) private var textSelectionStartsAtBeginning
@PreferenceObserving(\.$statusContentType) private var statusContentType

View File

@ -58,15 +58,6 @@ class ShareHostingController: UIHostingController<ShareHostingController.View> {
config.groupedBackgroundColor = Color(uiColor: .appGroupedBackground)
config.groupedCellBackgroundColor = Color(uiColor: .appGroupedCellBackground)
config.fillColor = Color(uiColor: .appFill)
switch Preferences.shared.avatarStyle {
case .roundRect:
config.avatarStyle = .roundRect
case .circle:
config.avatarStyle = .circle
}
config.useTwitterKeyboard = Preferences.shared.useTwitterKeyboard
config.contentType = Preferences.shared.statusContentType
config.requireAttachmentDescriptions = Preferences.shared.requireAttachmentDescriptions
config.dismiss = { [unowned self] in self.dismiss(mode: $0) }
config.fetchAvatar = Self.fetchAvatar

View File

@ -81,16 +81,6 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
config.groupedBackgroundColor = .appGroupedBackground
config.groupedCellBackgroundColor = .appGroupedCellBackground
config.fillColor = .appFill
switch Preferences.shared.avatarStyle {
case .roundRect:
config.avatarStyle = .roundRect
case .circle:
config.avatarStyle = .circle
}
config.useTwitterKeyboard = Preferences.shared.useTwitterKeyboard
config.contentType = Preferences.shared.statusContentType
config.requireAttachmentDescriptions = Preferences.shared.requireAttachmentDescriptions
config.dismiss = { [weak self] in self?.dismiss(mode: $0) }
config.presentAssetPicker = { [unowned self] in self.presentAssetPicker(completion: $0) }