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

View File

@ -25,13 +25,6 @@ public struct ComposeUIConfig {
public var groupedCellBackgroundColor = Color(uiColor: .systemBackground) public var groupedCellBackgroundColor = Color(uiColor: .systemBackground)
public var fillColor = Color(uiColor: .systemFill) 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 // Host callbacks
public var dismiss: @MainActor (DismissMode) -> Void = { _ in } public var dismiss: @MainActor (DismissMode) -> Void = { _ in }
public var presentAssetPicker: ((@MainActor @escaping ([PHPickerResult]) -> Void) -> Void)? public var presentAssetPicker: ((@MainActor @escaping ([PHPickerResult]) -> Void) -> Void)?

View File

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

View File

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

View File

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

View File

@ -58,15 +58,6 @@ class ShareHostingController: UIHostingController<ShareHostingController.View> {
config.groupedBackgroundColor = Color(uiColor: .appGroupedBackground) config.groupedBackgroundColor = Color(uiColor: .appGroupedBackground)
config.groupedCellBackgroundColor = Color(uiColor: .appGroupedCellBackground) config.groupedCellBackgroundColor = Color(uiColor: .appGroupedCellBackground)
config.fillColor = Color(uiColor: .appFill) 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.dismiss = { [unowned self] in self.dismiss(mode: $0) }
config.fetchAvatar = Self.fetchAvatar config.fetchAvatar = Self.fetchAvatar

View File

@ -81,16 +81,6 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
config.groupedBackgroundColor = .appGroupedBackground config.groupedBackgroundColor = .appGroupedBackground
config.groupedCellBackgroundColor = .appGroupedCellBackground config.groupedCellBackgroundColor = .appGroupedCellBackground
config.fillColor = .appFill 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.dismiss = { [weak self] in self?.dismiss(mode: $0) }
config.presentAssetPicker = { [unowned self] in self.presentAssetPicker(completion: $0) } config.presentAssetPicker = { [unowned self] in self.presentAssetPicker(completion: $0) }