-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1736 from planetary-social/bdm/155-list-detail
added list detail view #155
- Loading branch information
Showing
6 changed files
with
144 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import Dependencies | ||
import SwiftUI | ||
|
||
struct AuthorListDetailView: View { | ||
|
||
@Dependency(\.relayService) private var relayService | ||
@EnvironmentObject private var router: Router | ||
|
||
@ObservedObject var list: AuthorList | ||
|
||
/// Subscriptions for metadata requests from the relay service, keyed by author ID. | ||
@State private var subscriptions = [ObjectIdentifier: SubscriptionCancellable]() | ||
|
||
@State private var showingEditListInfo = false | ||
|
||
var body: some View { | ||
ScrollView { | ||
VStack(spacing: 16) { | ||
ListCircle() | ||
|
||
VStack(spacing: 3) { | ||
Text(list.title ?? "") | ||
.font(.headline.weight(.bold)) | ||
.multilineTextAlignment(.center) | ||
|
||
Text(String.localizedStringWithFormat(String(localized: "xUsers"), list.allAuthors.count)) | ||
.foregroundStyle(Color.secondaryTxt) | ||
.font(.footnote) | ||
|
||
if let description = list.listDescription, !description.isEmpty { | ||
Text(description) | ||
.foregroundStyle(Color.secondaryTxt) | ||
.font(.footnote) | ||
.padding(.top, 8) | ||
} | ||
} | ||
} | ||
.padding(.top, 24) | ||
|
||
LazyVStack { | ||
ForEach(list.allAuthors.sorted(by: { ($0.displayName ?? "") < ($1.displayName ?? "") })) { author in | ||
NavigationLink { | ||
ProfileView(author: author) | ||
} label: { | ||
AuthorObservationView(authorID: author.hexadecimalPublicKey) { author in | ||
AuthorCard(author: author) | ||
.padding(.horizontal, 13) | ||
.padding(.top, 5) | ||
.readabilityPadding() | ||
.task { | ||
subscriptions[author.id] = | ||
await relayService.requestMetadata( | ||
for: author.hexadecimalPublicKey, | ||
since: author.lastUpdatedMetadata | ||
) | ||
} | ||
.disabled(true) // skips the onTap action in AuthorCard | ||
} | ||
} | ||
} | ||
} | ||
.padding(.vertical, 12) | ||
} | ||
.nosNavigationBar("") | ||
.background(Color.appBg) | ||
.toolbar { | ||
ToolbarItem(placement: .primaryAction) { | ||
Menu { | ||
Button("editListInfo") { | ||
showingEditListInfo = true | ||
} | ||
Button("manageUsers") { | ||
// TODO: Manage Users | ||
} | ||
Button("deleteList", role: .destructive) { | ||
// TODO: Delete List | ||
} | ||
} label: { | ||
Image(systemName: "ellipsis") | ||
.foregroundStyle(Color.secondaryTxt) | ||
.fontWeight(.bold) | ||
.padding(.vertical, 12) | ||
} | ||
} | ||
} | ||
.sheet(isPresented: $showingEditListInfo) { | ||
NavigationStack { | ||
EditAuthorListView(list: list) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import SwiftUI | ||
|
||
/// A white circle with a group icon in it for representing an ``AuthorList``. | ||
struct ListCircle: View { | ||
var body: some View { | ||
ZStack { | ||
Circle() | ||
.fill(Color.white) | ||
.frame(width: 80, height: 80) | ||
|
||
Image(systemName: "person.2") | ||
.resizable() | ||
.fontWeight(.semibold) | ||
.aspectRatio(contentMode: .fit) | ||
.frame(width: 48) | ||
.foregroundStyle(Color.black) | ||
} | ||
} | ||
} |