2019-06-14 00:53:17 +00:00
// B e h a v i o r P r e f s V i e w . s w i f t
// T u s k e r
//
// C r e a t e d b y S h a d o w f a c t s o n 6 / 1 3 / 1 9 .
// C o p y r i g h t © 2 0 1 9 S h a d o w f a c t s . A l l r i g h t s r e s e r v e d .
//
import SwiftUI
import Pachyderm
2024-04-13 22:44:43 +00:00
import TuskerPreferences
2019-06-14 00:53:17 +00:00
2019-11-15 00:53:00 +00:00
struct BehaviorPrefsView : View {
@ ObservedObject var preferences = Preferences . shared
2019-06-14 00:53:17 +00:00
var body : some View {
List {
2021-04-05 21:48:03 +00:00
untitledSection
2022-12-05 22:24:01 +00:00
timelineSection
2020-01-20 04:23:00 +00:00
linksSection
2020-09-16 01:37:08 +00:00
contentWarningsSection
2020-09-16 00:46:49 +00:00
}
2023-02-03 04:29:44 +00:00
. listStyle ( . insetGrouped )
2023-02-06 23:42:55 +00:00
. appGroupedListBackground ( container : PreferencesNavigationController . self )
2020-09-16 00:46:49 +00:00
. navigationBarTitle ( Text ( " Behavior " ) )
2019-07-28 01:43:08 +00:00
}
2021-04-05 21:48:03 +00:00
private var untitledSection : some View {
Section {
Toggle ( isOn : $ preferences . confirmBeforeReblog ) {
Text ( " Require Confirmation Before Reblogging " )
}
}
2023-02-06 23:42:55 +00:00
. appGroupedListRowBackground ( )
2021-04-05 21:48:03 +00:00
}
2022-12-05 22:24:01 +00:00
private var timelineSection : some View {
Section {
Toggle ( isOn : $ preferences . timelineStateRestoration ) {
Text ( " Maintain Position Across App Launches " )
}
2023-02-15 02:37:43 +00:00
Picker ( selection : $ preferences . timelineSyncMode ) {
2024-04-13 22:44:43 +00:00
Text ( " iCloud " ) . tag ( TimelineSyncMode . icloud )
Text ( " Mastodon " ) . tag ( TimelineSyncMode . mastodon )
2023-02-15 02:37:43 +00:00
} label : {
Text ( " Sync Timeline Position via " )
}
2022-12-05 22:24:01 +00:00
} header : {
Text ( " Timeline " )
2023-02-15 02:37:43 +00:00
} footer : {
2023-02-25 23:28:19 +00:00
Text ( " Syncing via the Mastodon API can be more reliable than iCloud, but is not compatible with the Mastodon web interface. Only the Home timeline can be synced via the Mastodon API. " )
2022-12-05 22:24:01 +00:00
}
2023-02-06 23:42:55 +00:00
. appGroupedListRowBackground ( )
2022-12-05 22:24:01 +00:00
}
2020-02-22 18:19:31 +00:00
2021-04-05 21:48:03 +00:00
private var linksSection : some View {
2020-08-16 18:58:02 +00:00
Section ( header : Text ( " Links " ) ) {
2019-11-15 00:53:00 +00:00
Toggle ( isOn : $ preferences . openLinksInApps ) {
2019-07-28 01:43:08 +00:00
Text ( " Open Links in Apps " )
2019-06-14 00:53:17 +00:00
}
2024-04-15 13:34:44 +00:00
#if ! targetEnvironment ( macCatalyst ) && ! os ( visionOS )
if ! ProcessInfo . processInfo . isiOSAppOnMac {
Toggle ( isOn : $ preferences . useInAppSafari ) {
Text ( " Use In-App Safari " )
}
Toggle ( isOn : $ preferences . inAppSafariAutomaticReaderMode ) {
Text ( " Always Use Reader Mode in In-App Safari " )
} . disabled ( ! preferences . useInAppSafari )
2019-11-15 00:53:27 +00:00
}
2024-02-03 17:03:41 +00:00
#endif
2019-06-14 00:53:17 +00:00
}
2023-02-06 23:42:55 +00:00
. appGroupedListRowBackground ( )
2019-06-14 00:53:17 +00:00
}
2020-09-16 01:37:08 +00:00
2021-04-05 21:48:03 +00:00
private var contentWarningsSection : some View {
2020-09-16 01:37:08 +00:00
Section ( header : Text ( " Content Warnings " ) ) {
2020-11-03 20:39:02 +00:00
Toggle ( isOn : $ preferences . collapseLongPosts ) {
Text ( " Collapse Long Posts " )
}
2020-09-16 01:37:08 +00:00
Toggle ( isOn : $ preferences . expandAllContentWarnings ) {
Text ( " Expand All Content Warnings " )
}
2020-11-03 20:39:02 +00:00
NavigationLink ( destination : OppositeCollapseKeywordsView ( ) ) {
Text ( preferences . expandAllContentWarnings ? " Collapse Posts with Keywords in CWs " : " Expand Posts with Keywords in CWs " )
2020-09-16 01:37:08 +00:00
}
}
2023-02-06 23:42:55 +00:00
. appGroupedListRowBackground ( )
2020-09-16 01:37:08 +00:00
}
2019-06-14 00:53:17 +00:00
}
#if DEBUG
struct BehaviorPrefsView_Previews : PreviewProvider {
static var previews : some View {
BehaviorPrefsView ( )
}
}
#endif