forked from shadowfacts/Tusker
Lift pinned timelines modifiers up to CustomizeTimelinesList
.sheet on a Section with a header does not work, and produces warnings about trying to present on a VC that already has a presentation. It seems like the .sheet modifier is being applied to both the Section content and header? Fixes #514
This commit is contained in:
parent
d4057adf4d
commit
ca65f84137
|
@ -13,7 +13,7 @@ struct CustomizeTimelinesView: View {
|
||||||
let mastodonController: MastodonController
|
let mastodonController: MastodonController
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
CustomizeTimelinesList()
|
CustomizeTimelinesList(pinnedTimelines: mastodonController.accountPreferences.pinnedTimelines)
|
||||||
.environmentObject(mastodonController)
|
.environmentObject(mastodonController)
|
||||||
.environment(\.managedObjectContext, mastodonController.persistentContainer.viewContext)
|
.environment(\.managedObjectContext, mastodonController.persistentContainer.viewContext)
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,14 @@ struct CustomizeTimelinesList: View {
|
||||||
@FetchRequest(sortDescriptors: []) private var filters: FetchedResults<FilterMO>
|
@FetchRequest(sortDescriptors: []) private var filters: FetchedResults<FilterMO>
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
@State private var deletionError: (any Error)?
|
@State private var deletionError: (any Error)?
|
||||||
|
// store this separately from AccountPreferences in the view, b/c the @LazilyDecoding wrapper breaks animations
|
||||||
|
@State private var pinnedTimelines: [PinnedTimeline]
|
||||||
|
@State private var isShowingAddHashtagSheet = false
|
||||||
|
@State private var isShowingAddInstanceSheet = false
|
||||||
|
|
||||||
|
init(pinnedTimelines: [PinnedTimeline]) {
|
||||||
|
self.pinnedTimelines = pinnedTimelines
|
||||||
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if #available(iOS 16.0, *) {
|
if #available(iOS 16.0, *) {
|
||||||
|
@ -50,7 +58,11 @@ struct CustomizeTimelinesList: View {
|
||||||
|
|
||||||
private var navigationBody: some View {
|
private var navigationBody: some View {
|
||||||
List {
|
List {
|
||||||
PinnedTimelinesView(accountPreferences: mastodonController.accountPreferences)
|
PinnedTimelinesView(
|
||||||
|
pinnedTimelines: $pinnedTimelines,
|
||||||
|
isShowingAddHashtagSheet: $isShowingAddHashtagSheet,
|
||||||
|
isShowingAddInstanceSheet: $isShowingAddInstanceSheet
|
||||||
|
)
|
||||||
.appGroupedListRowBackground()
|
.appGroupedListRowBackground()
|
||||||
|
|
||||||
Section {
|
Section {
|
||||||
|
@ -99,6 +111,12 @@ struct CustomizeTimelinesList: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.modifier(PinnedTimelinesModifier(
|
||||||
|
accountPreferences: mastodonController.accountPreferences,
|
||||||
|
pinnedTimelines: $pinnedTimelines,
|
||||||
|
isShowingAddHashtagSheet: $isShowingAddHashtagSheet,
|
||||||
|
isShowingAddInstanceSheet: $isShowingAddInstanceSheet
|
||||||
|
))
|
||||||
.alertWithData("Error Deleting Filter", data: $deletionError, actions: { _ in
|
.alertWithData("Error Deleting Filter", data: $deletionError, actions: { _ in
|
||||||
Button("OK") {
|
Button("OK") {
|
||||||
self.deletionError = nil
|
self.deletionError = nil
|
||||||
|
|
|
@ -11,17 +11,10 @@ import Pachyderm
|
||||||
|
|
||||||
struct PinnedTimelinesView: View {
|
struct PinnedTimelinesView: View {
|
||||||
@EnvironmentObject private var mastodonController: MastodonController
|
@EnvironmentObject private var mastodonController: MastodonController
|
||||||
@ObservedObject private var accountPreferences: AccountPreferences
|
|
||||||
|
|
||||||
@State private var isShowingAddHashtagSheet = false
|
@Binding var pinnedTimelines: [PinnedTimeline]
|
||||||
@State private var isShowingAddInstanceSheet = false
|
@Binding var isShowingAddHashtagSheet: Bool
|
||||||
// store this separately from AccountPreferences in the view, b/c the @LazilyDecoding wrapper breaks animations
|
@Binding var isShowingAddInstanceSheet: Bool
|
||||||
@State private var pinnedTimelines: [PinnedTimeline]
|
|
||||||
|
|
||||||
init(accountPreferences: AccountPreferences) {
|
|
||||||
self.accountPreferences = accountPreferences
|
|
||||||
self.pinnedTimelines = accountPreferences.pinnedTimelines
|
|
||||||
}
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Section {
|
Section {
|
||||||
|
@ -110,6 +103,17 @@ struct PinnedTimelinesView: View {
|
||||||
} header: {
|
} header: {
|
||||||
Text("Pinned Timelines")
|
Text("Pinned Timelines")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct PinnedTimelinesModifier: ViewModifier {
|
||||||
|
let accountPreferences: AccountPreferences
|
||||||
|
@Binding var pinnedTimelines: [PinnedTimeline]
|
||||||
|
@Binding var isShowingAddHashtagSheet: Bool
|
||||||
|
@Binding var isShowingAddInstanceSheet: Bool
|
||||||
|
|
||||||
|
func body(content: Content) -> some View {
|
||||||
|
content
|
||||||
.sheet(isPresented: $isShowingAddHashtagSheet, content: {
|
.sheet(isPresented: $isShowingAddHashtagSheet, content: {
|
||||||
#if os(visionOS)
|
#if os(visionOS)
|
||||||
AddHashtagPinnedTimelineView(pinnedTimelines: $pinnedTimelines)
|
AddHashtagPinnedTimelineView(pinnedTimelines: $pinnedTimelines)
|
||||||
|
|
Loading…
Reference in New Issue