parent
b6a5a60066
commit
24fb0e0e7b
|
@ -26,7 +26,6 @@ public struct ComposeUIConfig {
|
||||||
// Preferences
|
// Preferences
|
||||||
public var useTwitterKeyboard = false
|
public var useTwitterKeyboard = false
|
||||||
public var contentType = StatusContentType.plain
|
public var contentType = StatusContentType.plain
|
||||||
public var automaticallySaveDrafts = false
|
|
||||||
public var requireAttachmentDescriptions = false
|
public var requireAttachmentDescriptions = false
|
||||||
|
|
||||||
// Host callbacks
|
// Host callbacks
|
||||||
|
|
|
@ -148,15 +148,11 @@ public final class ComposeController: ViewController {
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
func cancel() {
|
func cancel() {
|
||||||
if config.automaticallySaveDrafts {
|
if draft.hasContent {
|
||||||
config.dismiss(.cancel)
|
isShowingSaveDraftSheet = true
|
||||||
} else {
|
} else {
|
||||||
if draft.hasContent {
|
deleteDraftOnDisappear = true
|
||||||
isShowingSaveDraftSheet = true
|
config.dismiss(.cancel)
|
||||||
} else {
|
|
||||||
deleteDraftOnDisappear = true
|
|
||||||
config.dismiss(.cancel)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,6 @@ public class Preferences: Codable, ObservableObject {
|
||||||
|
|
||||||
self.defaultPostVisibility = try container.decode(Visibility.self, forKey: .defaultPostVisibility)
|
self.defaultPostVisibility = try container.decode(Visibility.self, forKey: .defaultPostVisibility)
|
||||||
self.defaultReplyVisibility = try container.decodeIfPresent(ReplyVisibility.self, forKey: .defaultReplyVisibility) ?? .sameAsPost
|
self.defaultReplyVisibility = try container.decodeIfPresent(ReplyVisibility.self, forKey: .defaultReplyVisibility) ?? .sameAsPost
|
||||||
self.automaticallySaveDrafts = try container.decode(Bool.self, forKey: .automaticallySaveDrafts)
|
|
||||||
self.requireAttachmentDescriptions = try container.decode(Bool.self, forKey: .requireAttachmentDescriptions)
|
self.requireAttachmentDescriptions = try container.decode(Bool.self, forKey: .requireAttachmentDescriptions)
|
||||||
self.contentWarningCopyMode = try container.decode(ContentWarningCopyMode.self, forKey: .contentWarningCopyMode)
|
self.contentWarningCopyMode = try container.decode(ContentWarningCopyMode.self, forKey: .contentWarningCopyMode)
|
||||||
self.mentionReblogger = try container.decode(Bool.self, forKey: .mentionReblogger)
|
self.mentionReblogger = try container.decode(Bool.self, forKey: .mentionReblogger)
|
||||||
|
@ -120,7 +119,6 @@ public class Preferences: Codable, ObservableObject {
|
||||||
|
|
||||||
try container.encode(defaultPostVisibility, forKey: .defaultPostVisibility)
|
try container.encode(defaultPostVisibility, forKey: .defaultPostVisibility)
|
||||||
try container.encode(defaultReplyVisibility, forKey: .defaultReplyVisibility)
|
try container.encode(defaultReplyVisibility, forKey: .defaultReplyVisibility)
|
||||||
try container.encode(automaticallySaveDrafts, forKey: .automaticallySaveDrafts)
|
|
||||||
try container.encode(requireAttachmentDescriptions, forKey: .requireAttachmentDescriptions)
|
try container.encode(requireAttachmentDescriptions, forKey: .requireAttachmentDescriptions)
|
||||||
try container.encode(contentWarningCopyMode, forKey: .contentWarningCopyMode)
|
try container.encode(contentWarningCopyMode, forKey: .contentWarningCopyMode)
|
||||||
try container.encode(mentionReblogger, forKey: .mentionReblogger)
|
try container.encode(mentionReblogger, forKey: .mentionReblogger)
|
||||||
|
@ -172,7 +170,6 @@ public class Preferences: Codable, ObservableObject {
|
||||||
// MARK: Composing
|
// MARK: Composing
|
||||||
@Published public var defaultPostVisibility = Visibility.public
|
@Published public var defaultPostVisibility = Visibility.public
|
||||||
@Published public var defaultReplyVisibility = ReplyVisibility.sameAsPost
|
@Published public var defaultReplyVisibility = ReplyVisibility.sameAsPost
|
||||||
@Published public var automaticallySaveDrafts = true
|
|
||||||
@Published public var requireAttachmentDescriptions = false
|
@Published public var requireAttachmentDescriptions = false
|
||||||
@Published public var contentWarningCopyMode = ContentWarningCopyMode.asIs
|
@Published public var contentWarningCopyMode = ContentWarningCopyMode.asIs
|
||||||
@Published public var mentionReblogger = false
|
@Published public var mentionReblogger = false
|
||||||
|
@ -236,7 +233,6 @@ public class Preferences: Codable, ObservableObject {
|
||||||
|
|
||||||
case defaultPostVisibility
|
case defaultPostVisibility
|
||||||
case defaultReplyVisibility
|
case defaultReplyVisibility
|
||||||
case automaticallySaveDrafts
|
|
||||||
case requireAttachmentDescriptions
|
case requireAttachmentDescriptions
|
||||||
case contentWarningCopyMode
|
case contentWarningCopyMode
|
||||||
case mentionReblogger
|
case mentionReblogger
|
||||||
|
|
|
@ -74,8 +74,6 @@ class ShareHostingController: UIHostingController<ShareHostingController.View> {
|
||||||
var config = ComposeUIConfig()
|
var config = ComposeUIConfig()
|
||||||
config.allowSwitchingDrafts = false
|
config.allowSwitchingDrafts = false
|
||||||
config.textSelectionStartsAtBeginning = true
|
config.textSelectionStartsAtBeginning = true
|
||||||
// note: in the share sheet, we ignore this preference
|
|
||||||
config.automaticallySaveDrafts = false
|
|
||||||
|
|
||||||
config.backgroundColor = Color(uiColor: .appBackground)
|
config.backgroundColor = Color(uiColor: .appBackground)
|
||||||
config.groupedBackgroundColor = Color(uiColor: .appGroupedBackground)
|
config.groupedBackgroundColor = Color(uiColor: .appGroupedBackground)
|
||||||
|
|
|
@ -79,7 +79,6 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
|
||||||
|
|
||||||
config.useTwitterKeyboard = Preferences.shared.useTwitterKeyboard
|
config.useTwitterKeyboard = Preferences.shared.useTwitterKeyboard
|
||||||
config.contentType = Preferences.shared.statusContentType
|
config.contentType = Preferences.shared.statusContentType
|
||||||
config.automaticallySaveDrafts = Preferences.shared.automaticallySaveDrafts
|
|
||||||
config.requireAttachmentDescriptions = Preferences.shared.requireAttachmentDescriptions
|
config.requireAttachmentDescriptions = Preferences.shared.requireAttachmentDescriptions
|
||||||
|
|
||||||
config.dismiss = { [unowned self] in self.dismiss(mode: $0) }
|
config.dismiss = { [unowned self] in self.dismiss(mode: $0) }
|
||||||
|
|
|
@ -58,9 +58,6 @@ struct ComposingPrefsView: View {
|
||||||
|
|
||||||
var composingSection: some View {
|
var composingSection: some View {
|
||||||
Section(header: Text("Composing")) {
|
Section(header: Text("Composing")) {
|
||||||
Toggle(isOn: $preferences.automaticallySaveDrafts) {
|
|
||||||
Text("Automatically Save Drafts")
|
|
||||||
}
|
|
||||||
Toggle(isOn: $preferences.requireAttachmentDescriptions) {
|
Toggle(isOn: $preferences.requireAttachmentDescriptions) {
|
||||||
Text("Require Attachment Descriptions")
|
Text("Require Attachment Descriptions")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue