mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-02-22 12:36:17 +00:00
Various fixes + fix Explore navigation
This commit is contained in:
parent
d7f1ef45fe
commit
37ed178c3f
10 changed files with 47 additions and 52 deletions
|
@ -9,6 +9,7 @@ import Models
|
|||
import Status
|
||||
import SwiftUI
|
||||
import Timeline
|
||||
import Explore
|
||||
|
||||
@MainActor
|
||||
extension View {
|
||||
|
@ -43,6 +44,10 @@ extension View {
|
|||
AccountsListView(mode: .rebloggedBy(statusId: id))
|
||||
case let .accountsList(accounts):
|
||||
AccountsListView(mode: .accountsList(accounts: accounts))
|
||||
case .trendingTimeline:
|
||||
TimelineView(timeline: .constant(.trending), scrollToTopSignal: .constant(0))
|
||||
case let .tagsList(tags):
|
||||
TagsListView(tags: tags)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class EditAccountViewModel: ObservableObject {
|
|||
guard let client else { return }
|
||||
do {
|
||||
let account: Account = try await client.get(endpoint: Accounts.verifyCredentials)
|
||||
displayName = account.displayName
|
||||
displayName = account.displayName ?? ""
|
||||
note = account.source?.note ?? ""
|
||||
postPrivacy = account.source?.privacy ?? .pub
|
||||
isSensitive = account.source?.sensitive ?? false
|
||||
|
|
|
@ -10,10 +10,10 @@ public extension Account {
|
|||
}
|
||||
|
||||
var safeDisplayName: String {
|
||||
if displayName.isEmpty || displayName == "" {
|
||||
return "@\(username)"
|
||||
if let displayName, !displayName.isEmpty {
|
||||
return displayName
|
||||
}
|
||||
return displayName
|
||||
return "@\(username)"
|
||||
}
|
||||
|
||||
var displayNameWithoutEmojis: String {
|
||||
|
|
|
@ -19,6 +19,8 @@ public enum RouterDestination: Hashable {
|
|||
case favoritedBy(id: String)
|
||||
case rebloggedBy(id: String)
|
||||
case accountsList(accounts: [Account])
|
||||
case trendingTimeline
|
||||
case tagsList(tags: [Tag])
|
||||
}
|
||||
|
||||
public enum SheetDestination: Identifiable {
|
||||
|
|
|
@ -133,21 +133,7 @@ public struct ExploreView: View {
|
|||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
}
|
||||
}
|
||||
NavigationLink {
|
||||
List {
|
||||
ForEach(viewModel.suggestedAccounts) { account in
|
||||
if let relationship = viewModel.suggestedAccountsRelationShips.first(where: { $0.id == account.id }) {
|
||||
AccountsListRow(viewModel: .init(account: account, relationShip: relationship))
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.primaryBackgroundColor)
|
||||
.listStyle(.plain)
|
||||
.navigationTitle("explore.section.suggested-users")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
} label: {
|
||||
NavigationLink(value: RouterDestination.accountsList(accounts: viewModel.suggestedAccounts)) {
|
||||
Text("see-more")
|
||||
.foregroundColor(theme.tintColor)
|
||||
}
|
||||
|
@ -163,20 +149,7 @@ public struct ExploreView: View {
|
|||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
.padding(.vertical, 4)
|
||||
}
|
||||
NavigationLink {
|
||||
List {
|
||||
ForEach(viewModel.trendingTags) { tag in
|
||||
TagRowView(tag: tag)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
.padding(.vertical, 4)
|
||||
}
|
||||
}
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.primaryBackgroundColor)
|
||||
.listStyle(.plain)
|
||||
.navigationTitle("explore.section.trending.tags")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
} label: {
|
||||
NavigationLink(value: RouterDestination.tagsList(tags: viewModel.trendingTags)) {
|
||||
Text("see-more")
|
||||
.foregroundColor(theme.tintColor)
|
||||
}
|
||||
|
@ -193,20 +166,7 @@ public struct ExploreView: View {
|
|||
.padding(.vertical, 8)
|
||||
}
|
||||
|
||||
NavigationLink {
|
||||
List {
|
||||
ForEach(viewModel.trendingStatuses) { status in
|
||||
StatusRowView(viewModel: { .init(status: status, client: client, routerPath: routerPath) })
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
.padding(.vertical, 8)
|
||||
}
|
||||
}
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.primaryBackgroundColor)
|
||||
.listStyle(.plain)
|
||||
.navigationTitle("explore.section.trending.posts")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
} label: {
|
||||
NavigationLink(value: RouterDestination.trendingTimeline) {
|
||||
Text("see-more")
|
||||
.foregroundColor(theme.tintColor)
|
||||
}
|
||||
|
|
28
Packages/Explore/Sources/Explore/TagsListView.swift
Normal file
28
Packages/Explore/Sources/Explore/TagsListView.swift
Normal file
|
@ -0,0 +1,28 @@
|
|||
import SwiftUI
|
||||
import Models
|
||||
import DesignSystem
|
||||
|
||||
public struct TagsListView: View {
|
||||
@EnvironmentObject private var theme: Theme
|
||||
|
||||
let tags: [Tag]
|
||||
|
||||
public init(tags: [Tag]) {
|
||||
self.tags = tags
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
List {
|
||||
ForEach(tags) { tag in
|
||||
TagRowView(tag: tag)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
.padding(.vertical, 4)
|
||||
}
|
||||
}
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.primaryBackgroundColor)
|
||||
.listStyle(.plain)
|
||||
.navigationTitle("explore.section.trending.tags")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
}
|
||||
}
|
|
@ -46,7 +46,7 @@ public struct ListAddAccountView: View {
|
|||
}
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.navigationTitle("lists.add-remove-\(viewModel.account.displayName)")
|
||||
.navigationTitle("lists.add-remove-\(viewModel.account.safeDisplayName)")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem {
|
||||
|
|
|
@ -41,7 +41,7 @@ public final class Account: Codable, Identifiable, Hashable, Sendable, Equatable
|
|||
|
||||
public let id: String
|
||||
public let username: String
|
||||
public let displayName: String
|
||||
public let displayName: String?
|
||||
public let avatar: URL
|
||||
public let header: URL
|
||||
public let acct: String
|
||||
|
@ -67,7 +67,7 @@ public final class Account: Codable, Identifiable, Hashable, Sendable, Equatable
|
|||
return header.lastPathComponent != "missing.png"
|
||||
}
|
||||
|
||||
public init(id: String, username: String, displayName: String, avatar: URL, header: URL, acct: String, note: HTMLString, createdAt: ServerDate, followersCount: Int, followingCount: Int, statusesCount: Int, lastStatusAt: String? = nil, fields: [Account.Field], locked: Bool, emojis: [Emoji], url: URL? = nil, source: Account.Source? = nil, bot: Bool, discoverable: Bool? = nil) {
|
||||
public init(id: String, username: String, displayName: String?, avatar: URL, header: URL, acct: String, note: HTMLString, createdAt: ServerDate, followersCount: Int, followingCount: Int, statusesCount: Int, lastStatusAt: String? = nil, fields: [Account.Field], locked: Bool, emojis: [Emoji], url: URL? = nil, source: Account.Source? = nil, bot: Bool, discoverable: Bool? = nil) {
|
||||
self.id = id
|
||||
self.username = username
|
||||
self.displayName = displayName
|
||||
|
|
|
@ -145,7 +145,7 @@ public struct StatusRowView: View {
|
|||
-100
|
||||
}
|
||||
.environmentObject(
|
||||
StatusDataControllerProvider.shared.dataController(for: viewModel.status.reblog ?? viewModel.status,
|
||||
StatusDataControllerProvider.shared.dataController(for: viewModel.finalStatus,
|
||||
client: client)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ struct StatusRowHeaderView: View {
|
|||
}
|
||||
}
|
||||
.accessibilityElement()
|
||||
.accessibilityLabel(Text("\(viewModel.finalStatus.account.displayName)"))
|
||||
.accessibilityLabel(Text("\(viewModel.finalStatus.account.safeDisplayName)"))
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
|
Loading…
Reference in a new issue