-
Notifications
You must be signed in to change notification settings - Fork 19
feat: followed activity #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BugenZhao
wants to merge
5
commits into
main
Choose a base branch
from
bz/enormous-pike
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,63 @@ | ||
| // | ||
| // FollowedActivityListView.swift | ||
| // MNGA | ||
| // | ||
| // Created by Bugen Zhao on 2025/12/18. | ||
| // | ||
|
|
||
| import Foundation | ||
| import SwiftUI | ||
| import SwiftUIX | ||
|
|
||
| struct FollowedActivityListView: View { | ||
| typealias DataSource = PagingDataSource<ActivityListResponse, Activity> | ||
|
|
||
| @StateObject var dataSource: DataSource | ||
|
|
||
| static func build() -> Self { | ||
| let dataSource = DataSource( | ||
| buildRequest: { page in | ||
| .activityList(.with { $0.page = UInt32(page) }) | ||
| }, | ||
| onResponse: { response in | ||
| (response.activities, Int(response.pages)) | ||
| }, | ||
| id: \.id | ||
| ) | ||
|
|
||
| return Self(dataSource: dataSource) | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| func destination(for activity: Activity) -> some View { | ||
| if activity.postID.pid == "0" || activity.postID.pid.isEmpty { | ||
| TopicDetailsView.build(topic: activity.topic) | ||
| } else { | ||
| TopicDetailsView.build(topic: activity.topic, onlyPost: (id: activity.postID, atPage: nil)) | ||
| } | ||
| } | ||
|
|
||
| var body: some View { | ||
| Group { | ||
| if dataSource.notLoaded { | ||
| ProgressView() | ||
| .onAppear { dataSource.initialLoad() } | ||
| } else if dataSource.items.isEmpty { | ||
| ContentUnavailableView("No Activity", systemImage: "dot.radiowaves.left.and.right") | ||
| } else { | ||
| List { | ||
| ForEach(dataSource.items, id: \.id) { activity in | ||
| CrossStackNavigationLinkHack(id: activity.id, destination: { | ||
| destination(for: activity) | ||
| }) { | ||
| FollowedActivityRowView(activity: activity) | ||
| }.onAppear { dataSource.loadMoreIfNeeded(currentItem: activity) } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| .navigationTitle("Followed Activity") | ||
| .mayGroupedListStyle() | ||
| .refreshable(dataSource: dataSource) | ||
| } | ||
| } |
This file contains hidden or 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,58 @@ | ||
| // | ||
| // FollowedActivityRowView.swift | ||
| // MNGA | ||
| // | ||
| // Created by Bugen Zhao on 2025/12/18. | ||
| // | ||
|
|
||
| import Foundation | ||
| import SwiftUI | ||
|
|
||
| struct FollowedActivityRowView: View { | ||
| let activity: Activity | ||
|
|
||
| var body: some View { | ||
| VStack(alignment: .leading, spacing: 8) { | ||
| HStack { | ||
| Image(systemName: activity.type.icon) | ||
| TopicSubjectView(topic: activity.topic) | ||
| } | ||
| .topicSubjectDimmed(activity.topic.read) | ||
| .foregroundColor(activity.topic.read ? .secondary : .primary) | ||
|
|
||
| HStack { | ||
| HStack(alignment: .center) { | ||
| Image(systemName: "person") | ||
| Text(activity.actor.nameDisplayCompat) | ||
| } | ||
| Text(activity.type.description) | ||
| Spacer() | ||
| DateTimeTextView.build(timestamp: activity.timestamp, switchable: false) | ||
| } | ||
| .foregroundColor(.secondary) | ||
| .font(.footnote) | ||
| } | ||
| .padding(.vertical, 2) | ||
| } | ||
| } | ||
|
|
||
| struct FollowedActivityRowView_Previews: PreviewProvider { | ||
| static var previews: some View { | ||
| FollowedActivityRowView(activity: .with { | ||
| $0.id = "1" | ||
| $0.type = .postTopic | ||
| $0.actor = .with { $0.name.normal = "Bugen" } | ||
| $0.topic = .with { | ||
| $0.id = "123" | ||
| $0.subject = .with { $0.content = "Test Topic" } | ||
| } | ||
| $0.postID = .with { | ||
| $0.tid = "123" | ||
| $0.pid = "0" | ||
| } | ||
| $0.timestamp = UInt64(Date().timeIntervalSince1970 - 60) | ||
| }) | ||
| .background(.primary.opacity(0.1)) | ||
| .padding() | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The icon for the followedActivity feature is set to "sparkles" here, but the UI in UserMenuView.swift and FollowedActivityListView.swift uses "dot.radiowaves.left.and.right". Consider using the same icon in both places for consistency, or verify that the difference is intentional.