mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-10 19:20:59 +00:00
Fixes
This commit is contained in:
parent
122e57d8ac
commit
8f71f6649a
2 changed files with 46 additions and 38 deletions
|
@ -115,8 +115,11 @@ struct AppView: View {
|
||||||
|
|
||||||
#if !os(visionOS)
|
#if !os(visionOS)
|
||||||
var sidebarView: some View {
|
var sidebarView: some View {
|
||||||
SideBarView(selectedTab: $selectedTab,
|
SideBarView(selectedTab: .init(get: {
|
||||||
tabs: availableTabs)
|
selectedTab
|
||||||
|
}, set: { newTab in
|
||||||
|
updateTab(with: newTab)
|
||||||
|
}), tabs: availableTabs)
|
||||||
{
|
{
|
||||||
HStack(spacing: 0) {
|
HStack(spacing: 0) {
|
||||||
if #available(iOS 18.0, *) {
|
if #available(iOS 18.0, *) {
|
||||||
|
@ -142,6 +145,7 @@ struct AppView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.environment(appRouterPath)
|
.environment(appRouterPath)
|
||||||
|
.environment(\.selectedTabScrollToTop, selectedTabScrollToTop)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -47,42 +47,7 @@ public struct TimelineView: View {
|
||||||
|
|
||||||
public var body: some View {
|
public var body: some View {
|
||||||
ZStack(alignment: .top) {
|
ZStack(alignment: .top) {
|
||||||
ScrollViewReader { proxy in
|
listView
|
||||||
List {
|
|
||||||
scrollToTopView
|
|
||||||
TimelineTagGroupheaderView(group: $selectedTagGroup, timeline: $timeline)
|
|
||||||
TimelineTagHeaderView(tag: $viewModel.tag)
|
|
||||||
switch viewModel.timeline {
|
|
||||||
case .remoteLocal:
|
|
||||||
StatusesListView(fetcher: viewModel, client: client, routerPath: routerPath, isRemote: true)
|
|
||||||
default:
|
|
||||||
StatusesListView(fetcher: viewModel, client: client, routerPath: routerPath)
|
|
||||||
.environment(\.isHomeTimeline, timeline == .home)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.id(client.id)
|
|
||||||
.environment(\.defaultMinListRowHeight, 1)
|
|
||||||
.listStyle(.plain)
|
|
||||||
.onChange(of: selectedTabScrollToTop) { _, newValue in
|
|
||||||
if newValue == 0, routerPath.path.isEmpty {
|
|
||||||
withAnimation {
|
|
||||||
proxy.scrollTo(ScrollToView.Constants.scrollToTop, anchor: .top)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#if !os(visionOS)
|
|
||||||
.scrollContentBackground(.hidden)
|
|
||||||
.background(theme.primaryBackgroundColor)
|
|
||||||
#endif
|
|
||||||
.introspect(.list, on: .iOS(.v17, .v18)) { (collectionView: UICollectionView) in
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
self.collectionView = collectionView
|
|
||||||
}
|
|
||||||
prefetcher.viewModel = viewModel
|
|
||||||
collectionView.isPrefetchingEnabled = true
|
|
||||||
collectionView.prefetchDataSource = prefetcher
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if viewModel.timeline.supportNewestPagination {
|
if viewModel.timeline.supportNewestPagination {
|
||||||
TimelineUnreadStatusesView(observer: viewModel.pendingStatusesObserver)
|
TimelineUnreadStatusesView(observer: viewModel.pendingStatusesObserver)
|
||||||
}
|
}
|
||||||
|
@ -211,6 +176,45 @@ public struct TimelineView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var listView: some View {
|
||||||
|
ScrollViewReader { proxy in
|
||||||
|
List {
|
||||||
|
scrollToTopView
|
||||||
|
TimelineTagGroupheaderView(group: $selectedTagGroup, timeline: $timeline)
|
||||||
|
TimelineTagHeaderView(tag: $viewModel.tag)
|
||||||
|
switch viewModel.timeline {
|
||||||
|
case .remoteLocal:
|
||||||
|
StatusesListView(fetcher: viewModel, client: client, routerPath: routerPath, isRemote: true)
|
||||||
|
default:
|
||||||
|
StatusesListView(fetcher: viewModel, client: client, routerPath: routerPath)
|
||||||
|
.environment(\.isHomeTimeline, timeline == .home)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.id(client.id)
|
||||||
|
.environment(\.defaultMinListRowHeight, 1)
|
||||||
|
.listStyle(.plain)
|
||||||
|
#if !os(visionOS)
|
||||||
|
.scrollContentBackground(.hidden)
|
||||||
|
.background(theme.primaryBackgroundColor)
|
||||||
|
#endif
|
||||||
|
.introspect(.list, on: .iOS(.v17, .v18)) { (collectionView: UICollectionView) in
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.collectionView = collectionView
|
||||||
|
}
|
||||||
|
prefetcher.viewModel = viewModel
|
||||||
|
collectionView.isPrefetchingEnabled = true
|
||||||
|
collectionView.prefetchDataSource = prefetcher
|
||||||
|
}
|
||||||
|
.onChange(of: selectedTabScrollToTop) { _, newValue in
|
||||||
|
if newValue == 0, routerPath.path.isEmpty {
|
||||||
|
withAnimation {
|
||||||
|
proxy.scrollTo(ScrollToView.Constants.scrollToTop, anchor: .top)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ToolbarContentBuilder
|
@ToolbarContentBuilder
|
||||||
private var toolbarTitleView: some ToolbarContent {
|
private var toolbarTitleView: some ToolbarContent {
|
||||||
ToolbarItem(placement: .principal) {
|
ToolbarItem(placement: .principal) {
|
||||||
|
|
Loading…
Reference in a new issue