IceCubesApp/IceCubesApp/App/Tabs/Settings/ContentSettingsView.swift
Nathan Reed ffe9e7a714
Add setting to control share button default behavior (#1421)
* Add setting to control share button default behavior

This adds a setting to control the behavior of the share button on the status row actions view.
Currently, it always shares the link to the post as well as the post text.
In iOS 16.4, Apple added iMessage unfurling for Mastodon URLs.
When sharing posts from Ice Cubes via iMessage, this leads to the recipient seeing two copies of the post: one from the unfurled link and one from Ice Cubes including the post text.
Users will now have the option to exclude the post text from their sharing.
This is easier than tapping the 3-dots button on the post (which is kind of small) and then expanding the Share menu in the context menu, which is the other way to access this functionality at the
moment.

The default value for the new option will be "Link and Text", which is the current behavior - so we won't change the behavior on existing users.

* Add new strings to other language localizations
2023-06-26 11:45:14 +02:00

100 lines
3.5 KiB
Swift

import AppAccount
import DesignSystem
import Env
import Models
import Network
import NukeUI
import SwiftUI
import UserNotifications
struct ContentSettingsView: View {
@EnvironmentObject private var userPreferences: UserPreferences
@EnvironmentObject private var theme: Theme
var body: some View {
Form {
Section("settings.content.boosts") {
Toggle(isOn: $userPreferences.suppressDupeReblogs) {
Text("settings.content.hide-repeated-boosts")
}
}.listRowBackground(theme.primaryBackgroundColor)
Section("settings.content.media") {
Toggle(isOn: $userPreferences.autoPlayVideo) {
Text("settings.other.autoplay-video")
}
Toggle(isOn: $userPreferences.showAltTextForMedia) {
Text("settings.content.media.show.alt")
}
}.listRowBackground(theme.primaryBackgroundColor)
Section("settings.content.sharing") {
Picker("settings.content.sharing.share-button-behavior", selection: $userPreferences.shareButtonBehavior) {
ForEach(PreferredShareButtonBehavior.allCases, id: \.rawValue) { option in
Text(option.title)
.tag(option)
}
}
}
.listRowBackground(theme.primaryBackgroundColor)
Section("settings.content.instance-settings") {
Toggle(isOn: $userPreferences.useInstanceContentSettings) {
Text("settings.content.use-instance-settings")
}
}
.listRowBackground(theme.primaryBackgroundColor)
.onChange(of: userPreferences.useInstanceContentSettings) { newVal in
if newVal {
userPreferences.appAutoExpandSpoilers = userPreferences.autoExpandSpoilers
userPreferences.appAutoExpandMedia = userPreferences.autoExpandMedia
userPreferences.appDefaultPostsSensitive = userPreferences.postIsSensitive
userPreferences.appDefaultPostVisibility = userPreferences.postVisibility
}
}
Section {
Toggle(isOn: $userPreferences.appAutoExpandSpoilers) {
Text("settings.content.expand-spoilers")
}
.disabled(userPreferences.useInstanceContentSettings)
Picker("settings.content.expand-media", selection: $userPreferences.appAutoExpandMedia) {
ForEach(ServerPreferences.AutoExpandMedia.allCases, id: \.rawValue) { media in
Text(media.description).tag(media)
}
}
.disabled(userPreferences.useInstanceContentSettings)
Toggle(isOn: $userPreferences.collapseLongPosts) {
Text("settings.content.collapse-long-posts")
}
} header: {
Text("settings.content.reading")
} footer: {
Text("settings.content.collapse-long-posts-hint")
}
.listRowBackground(theme.primaryBackgroundColor)
Section("settings.content.posting") {
Picker("settings.content.default-visibility", selection: $userPreferences.appDefaultPostVisibility) {
ForEach(Visibility.allCases, id: \.rawValue) { vis in
Text(vis.title).tag(vis)
}
}
.disabled(userPreferences.useInstanceContentSettings)
Toggle(isOn: $userPreferences.appDefaultPostsSensitive) {
Text("settings.content.default-sensitive")
}
.disabled(userPreferences.useInstanceContentSettings)
}
.listRowBackground(theme.primaryBackgroundColor)
}
.navigationTitle("settings.content.navigation-title")
.scrollContentBackground(.hidden)
.background(theme.secondaryBackgroundColor)
}
}