Better post detail transition

This commit is contained in:
Thomas Ricouard 2023-09-17 19:56:39 +02:00
parent 2ac7f7f342
commit c4e4339d4a
2 changed files with 16 additions and 7 deletions

View file

@ -32,8 +32,7 @@ import SwiftUI
var isLoadingTranslation: Bool = false
var showDeleteAlert: Bool = false
@ObservationIgnored
private var actionsAccountsFetched: Bool = false
private(set) var actionsAccountsFetched: Bool = false
var favoriters: [Account] = []
var rebloggers: [Account] = []
@ -289,9 +288,15 @@ import SwiftUI
func fetchActionsAccounts() async {
guard !actionsAccountsFetched else { return }
do {
favoriters = try await client.get(endpoint: Statuses.favoritedBy(id: status.id, maxId: nil))
rebloggers = try await client.get(endpoint: Statuses.rebloggedBy(id: status.id, maxId: nil))
actionsAccountsFetched = true
withAnimation(.snappy) {
actionsAccountsFetched = true
}
let favoriters: [Account] = try await client.get(endpoint: Statuses.favoritedBy(id: status.id, maxId: nil))
let rebloggers: [Account] = try await client.get(endpoint: Statuses.rebloggedBy(id: status.id, maxId: nil))
withAnimation(.snappy) {
self.favoriters = favoriters
self.rebloggers = rebloggers
}
} catch {}
}

View file

@ -58,7 +58,7 @@ struct StatusRowDetailView: View {
.foregroundColor(.gray)
}
if statusDataController.favoritesCount > 0 {
if viewModel.actionsAccountsFetched, statusDataController.favoritesCount > 0 {
Divider()
Button {
viewModel.routerPath.navigate(to: .favoritedBy(id: viewModel.status.id))
@ -73,8 +73,10 @@ struct StatusRowDetailView: View {
.frame(height: 20)
}
.buttonStyle(.borderless)
.transition(.move(edge: .leading))
}
if statusDataController.reblogsCount > 0 {
if viewModel.actionsAccountsFetched, statusDataController.reblogsCount > 0 {
Divider()
Button {
viewModel.routerPath.navigate(to: .rebloggedBy(id: viewModel.status.id))
@ -89,6 +91,7 @@ struct StatusRowDetailView: View {
.frame(height: 20)
}
.buttonStyle(.borderless)
.transition(.move(edge: .leading))
}
}
.task {
@ -103,6 +106,7 @@ struct StatusRowDetailView: View {
AvatarView(url: account.avatar, size: .list)
.padding(.leading, -4)
}
.transition(.scale)
}
.padding(.leading, .layoutPadding)
}