mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-02-18 10:45:15 +00:00
Account: Show nav bar title for main, followers, following
This commit is contained in:
parent
8ee5da319c
commit
f0061b36ca
3 changed files with 33 additions and 1 deletions
|
@ -28,6 +28,8 @@ public struct AccountDetailView: View {
|
||||||
@State private var isEditingFilters: Bool = false
|
@State private var isEditingFilters: Bool = false
|
||||||
@State private var isEditingRelationshipNote: Bool = false
|
@State private var isEditingRelationshipNote: Bool = false
|
||||||
|
|
||||||
|
@State private var displayTitle: Bool = false
|
||||||
|
|
||||||
@Binding var scrollToTopSignal: Int
|
@Binding var scrollToTopSignal: Int
|
||||||
|
|
||||||
/// When coming from a URL like a mention tap in a status.
|
/// When coming from a URL like a mention tap in a status.
|
||||||
|
@ -45,10 +47,12 @@ public struct AccountDetailView: View {
|
||||||
public var body: some View {
|
public var body: some View {
|
||||||
ScrollViewReader { proxy in
|
ScrollViewReader { proxy in
|
||||||
List {
|
List {
|
||||||
|
ScrollToView()
|
||||||
|
.onAppear { displayTitle = false }
|
||||||
|
.onDisappear { displayTitle = true }
|
||||||
makeHeaderView(proxy: proxy)
|
makeHeaderView(proxy: proxy)
|
||||||
.applyAccountDetailsRowStyle(theme: theme)
|
.applyAccountDetailsRowStyle(theme: theme)
|
||||||
.padding(.bottom, -20)
|
.padding(.bottom, -20)
|
||||||
.id(ScrollToView.Constants.scrollToTop)
|
|
||||||
familiarFollowers
|
familiarFollowers
|
||||||
.applyAccountDetailsRowStyle(theme: theme)
|
.applyAccountDetailsRowStyle(theme: theme)
|
||||||
featuredTagsView
|
featuredTagsView
|
||||||
|
@ -311,6 +315,16 @@ public struct AccountDetailView: View {
|
||||||
|
|
||||||
@ToolbarContentBuilder
|
@ToolbarContentBuilder
|
||||||
private var toolbarContent: some ToolbarContent {
|
private var toolbarContent: some ToolbarContent {
|
||||||
|
ToolbarItem(placement: .principal) {
|
||||||
|
if let account = viewModel.account, displayTitle {
|
||||||
|
VStack {
|
||||||
|
Text(account.displayName ?? "").font(.headline)
|
||||||
|
Text("account.detail.featured-tags-n-posts \(account.statusesCount ?? 0)")
|
||||||
|
.font(.footnote)
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
ToolbarItemGroup(placement: .navigationBarTrailing) {
|
ToolbarItemGroup(placement: .navigationBarTrailing) {
|
||||||
if !viewModel.isCurrentUser {
|
if !viewModel.isCurrentUser {
|
||||||
Button {
|
Button {
|
||||||
|
|
|
@ -102,6 +102,19 @@ public struct AccountsListView: View {
|
||||||
.background(theme.primaryBackgroundColor)
|
.background(theme.primaryBackgroundColor)
|
||||||
#endif
|
#endif
|
||||||
.listStyle(.plain)
|
.listStyle(.plain)
|
||||||
|
.toolbar {
|
||||||
|
ToolbarItem(placement: .principal) {
|
||||||
|
VStack {
|
||||||
|
Text(viewModel.mode.title)
|
||||||
|
.font(.headline)
|
||||||
|
if let count = viewModel.totalCount {
|
||||||
|
Text(String(count))
|
||||||
|
.font(.footnote)
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
.navigationTitle(viewModel.mode.title)
|
.navigationTitle(viewModel.mode.title)
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.task {
|
.task {
|
||||||
|
|
|
@ -46,6 +46,7 @@ public enum AccountsListMode {
|
||||||
private var relationships: [Relationship] = []
|
private var relationships: [Relationship] = []
|
||||||
|
|
||||||
var state = State.loading
|
var state = State.loading
|
||||||
|
var totalCount: Int?
|
||||||
|
|
||||||
private var nextPageId: String?
|
private var nextPageId: String?
|
||||||
|
|
||||||
|
@ -60,9 +61,13 @@ public enum AccountsListMode {
|
||||||
let link: LinkHandler?
|
let link: LinkHandler?
|
||||||
switch mode {
|
switch mode {
|
||||||
case let .followers(accountId):
|
case let .followers(accountId):
|
||||||
|
var account: Account = try await client.get(endpoint: Accounts.accounts(id: accountId))
|
||||||
|
totalCount = account.followersCount
|
||||||
(accounts, link) = try await client.getWithLink(endpoint: Accounts.followers(id: accountId,
|
(accounts, link) = try await client.getWithLink(endpoint: Accounts.followers(id: accountId,
|
||||||
maxId: nil))
|
maxId: nil))
|
||||||
case let .following(accountId):
|
case let .following(accountId):
|
||||||
|
var account: Account = try await client.get(endpoint: Accounts.accounts(id: accountId))
|
||||||
|
totalCount = account.followingCount
|
||||||
(accounts, link) = try await client.getWithLink(endpoint: Accounts.following(id: accountId,
|
(accounts, link) = try await client.getWithLink(endpoint: Accounts.following(id: accountId,
|
||||||
maxId: nil))
|
maxId: nil))
|
||||||
case let .rebloggedBy(statusId):
|
case let .rebloggedBy(statusId):
|
||||||
|
|
Loading…
Reference in a new issue