View fix maybe hopefully

This commit is contained in:
Lumaa 2024-07-09 17:32:15 +02:00
parent 9b33495718
commit 6d3d32704c
1 changed files with 60 additions and 107 deletions

View File

@ -38,59 +38,7 @@ struct TimelineView: View {
if statuses != nil { if statuses != nil {
if !statuses!.isEmpty { if !statuses!.isEmpty {
ScrollView(showsIndicators: false) { ScrollView(showsIndicators: false) {
if showHero { picker
Button {
withAnimation(.easeInOut) {
showPicker.toggle()
}
} label: {
Image("HeroIcon")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 30)
.padding(.bottom)
}
}
if showPicker {
ViewThatFits {
HStack {
ForEach(timelines, id: \.self) { t in
Button {
Task {
await reloadTimeline(t)
}
} label: {
Text(t.localizedTitle())
.padding(.horizontal)
}
.buttonStyle(LargeButton(filled: t == filter, height: 7.5))
.disabled(t == filter)
}
}
.padding(.horizontal, 7.5)
ScrollView(.horizontal) {
HStack {
ForEach(timelines, id: \.self) { t in
Button {
Task {
await reloadTimeline(t)
}
} label: {
Text(t.localizedTitle())
.padding(.horizontal)
}
.buttonStyle(LargeButton(filled: t == filter, height: 7.5))
.disabled(t == filter)
}
}
.padding(.horizontal, 7.5)
}
.padding(.vertical)
.scrollIndicators(.hidden)
}
}
ForEach(statuses!, id: \.id) { status in ForEach(statuses!, id: \.id) { status in
LazyVStack(alignment: .leading, spacing: 2) { LazyVStack(alignment: .leading, spacing: 2) {
@ -149,60 +97,7 @@ struct TimelineView: View {
.ignoresSafeArea() .ignoresSafeArea()
VStack { VStack {
if showHero { picker
Button {
withAnimation(.easeInOut) {
showPicker.toggle()
}
} label: {
Image("HeroIcon")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 30)
.padding(.bottom)
}
}
if showPicker {
ViewThatFits {
HStack {
ForEach(timelines, id: \.self) { t in
Button {
Task {
await reloadTimeline(t)
}
} label: {
Text(t.localizedTitle())
.frame(width: 20)
.lineLimit(1)
}
.buttonStyle(LargeButton(filled: t == filter, height: 7.5))
.disabled(t == filter)
}
}
.padding(.horizontal, 7.5)
ScrollView(.horizontal) {
HStack {
ForEach(timelines, id: \.self) { t in
Button {
Task {
await reloadTimeline(t)
}
} label: {
Text(t.localizedTitle())
.padding(.horizontal)
}
.buttonStyle(LargeButton(filled: t == filter, height: 7.5))
.disabled(t == filter)
}
}
.padding(.horizontal, 7.5)
}
.padding(.vertical)
.scrollIndicators(.hidden)
}
}
ContentUnavailableView { ContentUnavailableView {
Text("timeline.empty") Text("timeline.empty")
@ -255,6 +150,64 @@ struct TimelineView: View {
.safeAreaPadding() .safeAreaPadding()
} }
private var picker: some View {
VStack {
if showHero {
Button {
withAnimation(.easeInOut) {
showPicker.toggle()
}
} label: {
Image("HeroIcon")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 30)
.padding(.bottom)
}
}
if showPicker {
ViewThatFits {
HStack {
ForEach(timelines, id: \.self) { t in
Button {
Task {
await reloadTimeline(t)
}
} label: {
Text(t.localizedTitle())
.padding(.horizontal)
}
.buttonStyle(LargeButton(filled: t == filter, height: 7.5))
.disabled(t == filter)
}
}
.padding(.horizontal, 7.5)
ScrollView(.horizontal) {
HStack {
ForEach(timelines, id: \.self) { t in
Button {
Task {
await reloadTimeline(t)
}
} label: {
Text(t.localizedTitle())
.padding(.horizontal)
}
.buttonStyle(LargeButton(filled: t == filter, height: 7.5))
.disabled(t == filter)
}
}
.padding(.horizontal, 7.5)
}
.padding(.vertical)
.scrollIndicators(.hidden)
}
}
}
}
private func reloadTimeline(_ filter: TimelineFilter) async { private func reloadTimeline(_ filter: TimelineFilter) async {
guard let client = accountManager.getClient() else { return } guard let client = accountManager.getClient() else { return }
statuses = nil statuses = nil