Skip to content
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

New Profile Page #834

Merged
merged 18 commits into from
Jan 2, 2024
28 changes: 20 additions & 8 deletions Mlem.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
03C897F82ABF652D005F3403 /* SearchRoot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03C897F72ABF652D005F3403 /* SearchRoot.swift */; };
03C898012AC04EF9005F3403 /* SearchResultsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03C898002AC04EF9005F3403 /* SearchResultsView.swift */; };
03C898032AC04F61005F3403 /* RecentSearchesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03C898022AC04F61005F3403 /* RecentSearchesView.swift */; };
03C905C82B3C70E200B9082F /* UserView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03C905C72B3C70E200B9082F /* UserView.swift */; };
03C905CA2B3C834C00B9082F /* UserHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03C905C92B3C834C00B9082F /* UserHeaderView.swift */; };
03C905CC2B3C88F700B9082F /* SearchTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03C905CB2B3C88F700B9082F /* SearchTab.swift */; };
03C905CE2B3C8DC400B9082F /* UserView+Logic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03C905CD2B3C8DC400B9082F /* UserView+Logic.swift */; };
03CB329E2A6D8E910021EF27 /* PostComposerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03CB329D2A6D8E910021EF27 /* PostComposerView.swift */; };
03E0B9C82A61F0F400FED265 /* AdvancedSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E0B9C72A61F0F400FED265 /* AdvancedSettingsView.swift */; };
03E0B9CA2A62B4A400FED265 /* ContributorsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E0B9C92A62B4A400FED265 /* ContributorsView.swift */; };
Expand All @@ -82,7 +86,7 @@
03EC92972AC069CE007BBE7E /* SearchResultListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EC92962AC069CE007BBE7E /* SearchResultListView.swift */; };
03EC92992AC0BF8A007BBE7E /* APIClient+Pictrs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EC92982AC0BF8A007BBE7E /* APIClient+Pictrs.swift */; };
03EEEAF32AB8DCDF0087F8D8 /* CommunityResultView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EEEAF22AB8DCDF0087F8D8 /* CommunityResultView.swift */; };
03EEEAF72AB8ED3C0087F8D8 /* SearchTabPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EEEAF62AB8ED3C0087F8D8 /* SearchTabPicker.swift */; };
03EEEAF72AB8ED3C0087F8D8 /* BubblePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EEEAF62AB8ED3C0087F8D8 /* BubblePicker.swift */; };
03EEEAF92ABB985D0087F8D8 /* CommunityModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EEEAF82ABB985D0087F8D8 /* CommunityModel.swift */; };
03F4DC9D2B193F4C00556C67 /* MatrixLinkView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03F4DC9C2B193F4C00556C67 /* MatrixLinkView.swift */; };
03F4DC9F2B1A8AD500556C67 /* SignInAndSecuritySettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03F4DC9E2B1A8AD500556C67 /* SignInAndSecuritySettingsView.swift */; };
Expand Down Expand Up @@ -260,7 +264,6 @@
6386E03A2A0455BC006B3C1D /* String+Contains.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6386E0392A0455BC006B3C1D /* String+Contains.swift */; };
6386E0402A045723006B3C1D /* Website Icon Complex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6386E03F2A045723006B3C1D /* Website Icon Complex.swift */; };
63A09B69285F53E9004F0032 /* Error View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63A09B68285F53E9004F0032 /* Error View.swift */; };
63ABCE0E27F894060047A7D0 /* User View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63ABCE0D27F894060047A7D0 /* User View.swift */; };
63CE4E732A06F5A100405271 /* Access Token.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63CE4E722A06F5A100405271 /* Access Token.swift */; };
63D24ED92A169A5F005CCA81 /* UIApplication+FirstKeyWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63D24ED82A169A5F005CCA81 /* UIApplication+FirstKeyWindow.swift */; };
63D24EDC2A169F12005CCA81 /* MarkdownUI in Frameworks */ = {isa = PBXBuildFile; productRef = 63D24EDB2A169F12005CCA81 /* MarkdownUI */; };
Expand Down Expand Up @@ -621,6 +624,10 @@
03C897F72ABF652D005F3403 /* SearchRoot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchRoot.swift; sourceTree = "<group>"; };
03C898002AC04EF9005F3403 /* SearchResultsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultsView.swift; sourceTree = "<group>"; };
03C898022AC04F61005F3403 /* RecentSearchesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecentSearchesView.swift; sourceTree = "<group>"; };
03C905C72B3C70E200B9082F /* UserView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserView.swift; sourceTree = "<group>"; };
03C905C92B3C834C00B9082F /* UserHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserHeaderView.swift; sourceTree = "<group>"; };
03C905CB2B3C88F700B9082F /* SearchTab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchTab.swift; sourceTree = "<group>"; };
03C905CD2B3C8DC400B9082F /* UserView+Logic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserView+Logic.swift"; sourceTree = "<group>"; };
03CB329D2A6D8E910021EF27 /* PostComposerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostComposerView.swift; sourceTree = "<group>"; };
03E0B9C72A61F0F400FED265 /* AdvancedSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedSettingsView.swift; sourceTree = "<group>"; };
03E0B9C92A62B4A400FED265 /* ContributorsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContributorsView.swift; sourceTree = "<group>"; };
Expand All @@ -632,7 +639,7 @@
03EC92962AC069CE007BBE7E /* SearchResultListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultListView.swift; sourceTree = "<group>"; };
03EC92982AC0BF8A007BBE7E /* APIClient+Pictrs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "APIClient+Pictrs.swift"; sourceTree = "<group>"; };
03EEEAF22AB8DCDF0087F8D8 /* CommunityResultView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityResultView.swift; sourceTree = "<group>"; };
03EEEAF62AB8ED3C0087F8D8 /* SearchTabPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchTabPicker.swift; sourceTree = "<group>"; };
03EEEAF62AB8ED3C0087F8D8 /* BubblePicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BubblePicker.swift; sourceTree = "<group>"; };
03EEEAF82ABB985D0087F8D8 /* CommunityModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityModel.swift; sourceTree = "<group>"; };
03F4DC9C2B193F4C00556C67 /* MatrixLinkView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatrixLinkView.swift; sourceTree = "<group>"; };
03F4DC9E2B1A8AD500556C67 /* SignInAndSecuritySettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignInAndSecuritySettingsView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -812,7 +819,6 @@
6386E0392A0455BC006B3C1D /* String+Contains.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Contains.swift"; sourceTree = "<group>"; };
6386E03F2A045723006B3C1D /* Website Icon Complex.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Website Icon Complex.swift"; sourceTree = "<group>"; };
63A09B68285F53E9004F0032 /* Error View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Error View.swift"; sourceTree = "<group>"; };
63ABCE0D27F894060047A7D0 /* User View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "User View.swift"; sourceTree = "<group>"; };
63CE4E722A06F5A100405271 /* Access Token.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Access Token.swift"; sourceTree = "<group>"; };
63D24ED82A169A5F005CCA81 /* UIApplication+FirstKeyWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIApplication+FirstKeyWindow.swift"; sourceTree = "<group>"; };
63D24EDD2A169F2A005CCA81 /* Markdown View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Markdown View.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2111,6 +2117,7 @@
6317ABCA2A37292700603D76 /* FeedType.swift */,
6307378C2A1CEB7C00039852 /* My Vote.swift */,
CD6483352A39F20800EE6CA3 /* Post Type.swift */,
03C905CB2B3C88F700B9082F /* SearchTab.swift */,
6DCE71282A53C26600CFEB5E /* ServerInstanceLocation.swift */,
CDDCF6522A677F45003DA3AC /* TabSelection.swift */,
CDE9CE4E2A7B0B1B002B97DD /* Haptic.swift */,
Expand Down Expand Up @@ -2142,7 +2149,7 @@
03C898022AC04F61005F3403 /* RecentSearchesView.swift */,
03EC92942AC064AE007BBE7E /* SearchHomeView.swift */,
036ED3BB2ABF1058009664BC /* SearchModel.swift */,
03EEEAF62AB8ED3C0087F8D8 /* SearchTabPicker.swift */,
03EEEAF62AB8ED3C0087F8D8 /* BubblePicker.swift */,
030D00832AD0842900953B1D /* Results */,
);
path = Search;
Expand All @@ -2160,7 +2167,9 @@
isa = PBXGroup;
children = (
6DE1183B2A4A217400810C7E /* Profile View.swift */,
63ABCE0D27F894060047A7D0 /* User View.swift */,
03C905C72B3C70E200B9082F /* UserView.swift */,
03C905CD2B3C8DC400B9082F /* UserView+Logic.swift */,
03C905C92B3C834C00B9082F /* UserHeaderView.swift */,
6DEB0FFA2A4F87BF007CAB99 /* User Moderator View.swift */,
039439902A98FA6100463032 /* UserFeedView.swift */,
);
Expand Down Expand Up @@ -3033,6 +3042,7 @@
63F0C7A82A0522FC00A18C5D /* Saved Account Tracker.swift in Sources */,
E449C5972B35239500E3BCF4 /* InboxReplyView.swift in Sources */,
6372186A2A3A2AAD008C4816 /* GetComment.swift in Sources */,
03C905CA2B3C834C00B9082F /* UserHeaderView.swift in Sources */,
03F76FA42B2F5F3500E2B54A /* UploadProgressView.swift in Sources */,
03EC92972AC069CE007BBE7E /* SearchResultListView.swift in Sources */,
637218472A3A2AAD008C4816 /* APICommentView.swift in Sources */,
Expand Down Expand Up @@ -3128,6 +3138,7 @@
6354F30A2A2E20040074C08D /* View+Alert.swift in Sources */,
6318EDC727EE4E1500BFCAE8 /* Post.swift in Sources */,
03EC92992AC0BF8A007BBE7E /* APIClient+Pictrs.swift in Sources */,
03C905C82B3C70E200B9082F /* UserView.swift in Sources */,
6372186C2A3A2AAD008C4816 /* SaveComment.swift in Sources */,
CD4368B62AE23F4700BD8BD1 /* ParentTracker.swift in Sources */,
6DD8677A2A5083A200BEB00F /* Community Sidebar Link.swift in Sources */,
Expand Down Expand Up @@ -3161,7 +3172,7 @@
03A2767B2AFE560000C0D66B /* CommunityModel+SwipeActions.swift in Sources */,
CDF1EF142A6B6D6E003594B6 /* Feed View Logic.swift in Sources */,
6DFF50432A48DED3001E648D /* Inbox View.swift in Sources */,
03EEEAF72AB8ED3C0087F8D8 /* SearchTabPicker.swift in Sources */,
03EEEAF72AB8ED3C0087F8D8 /* BubblePicker.swift in Sources */,
CD2053102AC878B50000AA38 /* UpdatedTimestampView.swift in Sources */,
CD1446232A5B336900610EF1 /* LicensesView.swift in Sources */,
CD4368D02AE245F400BD8BD1 /* MessageTracker.swift in Sources */,
Expand Down Expand Up @@ -3269,6 +3280,7 @@
038A16E92A7A9C640087987E /* LayoutWidget.swift in Sources */,
CD9A03C82B389F7000C16276 /* EnvironmentValues+FeedType.swift in Sources */,
50811B2E2A92046D006BA3F2 /* URL+Mock.swift in Sources */,
03C905CC2B3C88F700B9082F /* SearchTab.swift in Sources */,
E409E16E2AFEFB8C0026FDC2 /* ImageDetailSheetState.swift in Sources */,
CD3FBCE52A4A89B900B2063F /* Mentions Feed View.swift in Sources */,
CD391F962A535F5400E213B5 /* ResponseEditorView.swift in Sources */,
Expand Down Expand Up @@ -3447,6 +3459,7 @@
03E79F3F2AE3E7100006700D /* SortingSettingsView.swift in Sources */,
039C8DB92B35A81C0096BAAF /* AccountIconStack.swift in Sources */,
CDCBD7262A8D69A200387A2C /* Instance Picker View.swift in Sources */,
03C905CE2B3C8DC400B9082F /* UserView+Logic.swift in Sources */,
6372185B2A3A2AAD008C4816 /* APICommunityView.swift in Sources */,
030E86442AC6F6D5000283A6 /* SearchBar+NavigationView.swift in Sources */,
637218552A3A2AAD008C4816 /* APITagline.swift in Sources */,
Expand All @@ -3468,7 +3481,6 @@
637218632A3A2AAD008C4816 /* CreatePost.swift in Sources */,
CDE6A80B2A43E9F00062D161 /* CommentSortType.swift in Sources */,
503BA26F2A2C94540052516C /* URL+Identifiable.swift in Sources */,
63ABCE0E27F894060047A7D0 /* User View.swift in Sources */,
CD6483322A38D3A600EE6CA3 /* ScoreCounterView.swift in Sources */,
50CC4A7A2A9CC45D0074C845 /* InstanceMetadata+Mock.swift in Sources */,
6318DE5427FB958800CC2AD6 /* Stickied Tag.swift in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions Mlem/API/Models/Person/APIPersonAggregates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct APIPersonAggregates: Decodable {
let id: Int? // TODO: 0.18 Deprecation remove this field
let personId: Int
let postCount: Int
let postScore: Int?
let postScore: Int? // TODO: 0.18 Deprecation remove this field
let commentCount: Int
let commentScore: Int?
let commentScore: Int? // TODO: 0.18 Deprecation remove this field
}
35 changes: 22 additions & 13 deletions Mlem/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct ContentView: View {
@Dependency(\.errorHandler) var errorHandler
@Dependency(\.personRepository) var personRepository
@Dependency(\.hapticManager) var hapticManager
@Dependency(\.siteInformation) var siteInformation
@Dependency(\.accountsTracker) var accountsTracker

@Environment(\.setAppFlow) private var setFlow
Expand Down Expand Up @@ -41,6 +42,14 @@ struct ContentView: View {

var accessibilityFont: Bool { UIApplication.shared.preferredContentSizeCategory.isAccessibilityCategory }

var myUser: UserModel? {
if let person = siteInformation.myUserInfo?.localUserView.person {
return UserModel(from: person)
} else {
return nil
}
}

var body: some View {
FancyTabBar(selection: $tabSelection, navigationSelection: $tabNavigation, dragUpGestureCallback: showAccountSwitcherDragCallback) {
Group {
Expand All @@ -64,20 +73,20 @@ struct ContentView: View {
badgeCount: showInboxUnreadBadge ? unreadTracker.total : 0
)
}
}

ProfileView(userID: account.id)
.fancyTabItem(tag: TabSelection.profile) {
FancyTabBarLabel(
tag: TabSelection.profile,
customText: appState.tabDisplayName,
symbolConfiguration: .init(
symbol: FancyTabBarLabel.SymbolConfiguration.profile.symbol,
activeSymbol: FancyTabBarLabel.SymbolConfiguration.profile.activeSymbol,
remoteSymbolUrl: appState.profileTabRemoteSymbolUrl
)
)
.simultaneousGesture(accountSwitchLongPress)
}
ProfileView(user: myUser)
.fancyTabItem(tag: TabSelection.profile) {
FancyTabBarLabel(
tag: TabSelection.profile,
customText: appState.tabDisplayName,
symbolConfiguration: .init(
symbol: FancyTabBarLabel.SymbolConfiguration.profile.symbol,
activeSymbol: FancyTabBarLabel.SymbolConfiguration.profile.activeSymbol,
remoteSymbolUrl: appState.profileTabRemoteSymbolUrl
)
)
.simultaneousGesture(accountSwitchLongPress)
}

SearchRoot()
Expand Down
38 changes: 32 additions & 6 deletions Mlem/Enums/FeedType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,34 @@
// Created by Jonathan de Jong on 12.06.2023.
//

import Foundation
import SwiftUI

enum FeedType: String, Encodable, SettingsOptions {
enum FeedType: String, Encodable, SettingsOptions, AssociatedColor {
var id: Self { self }

var label: String {
return rawValue
}

var description: String {
switch self {
case .all:
return "Subscribed communities from all instances"
case .local:
return "Local communities from your server"
case .subscribed:
return "All communities that federate with your server"
}
}

var color: Color? {
switch self {
case .all: return rawValue
case .local: return rawValue
case .subscribed: return rawValue
case .all:
return .blue
case .local:
return .green
case .subscribed:
return .red
}
}

Expand All @@ -34,12 +52,20 @@ extension FeedType: AssociatedIcon {

var iconNameFill: String {
switch self {
case .all: return Icons.federatedFeed
case .all: return Icons.federatedFeedFill
case .local: return Icons.localFeedFill
case .subscribed: return Icons.subscribedFeedFill
}
}

var iconNameCircle: String {
switch self {
case .all: return Icons.federatedFeedCircle
case .local: return Icons.localFeedCircle
case .subscribed: return Icons.subscribedFeedCircle
}
}

/// Icon to use in system settings. This should be removed when the "unified symbol handling" is closed
var settingsIconName: String {
switch self {
Expand Down
23 changes: 23 additions & 0 deletions Mlem/Enums/SearchTab.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// SearchTab.swift
// Mlem
//
// Created by Sjmarf on 27/12/2023.
//

enum SearchTab: String, CaseIterable, Identifiable {
case topResults, communities, users

var id: Self { self }

var label: String {
switch self {
case .topResults:
return "Top Results"
default:
return rawValue.capitalized
}
}

static var homePageCases: [SearchTab] = [.communities, .users]
}
6 changes: 1 addition & 5 deletions Mlem/Enums/User/UserViewTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@
import Foundation

enum UserViewTab: String, CaseIterable, Identifiable {
case overview, comments, posts, saved
case overview, comments, posts, communities, saved

var id: Self { self }

var label: String {
rawValue.capitalized
}

var onlyShowInOwnProfile: Bool {
self == UserViewTab.saved
}
}
4 changes: 2 additions & 2 deletions Mlem/Extensions/Date/Date+RelativeTime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import SwiftUI

extension Date {
// Returns strings like "3 seconds ago" and "10 days ago"
func getRelativeTime(date: Date) -> String {
func getRelativeTime(date: Date, unitsStyle: RelativeDateTimeFormatter.UnitsStyle = .full) -> String {
let formatter = RelativeDateTimeFormatter()
formatter.unitsStyle = .full
formatter.unitsStyle = unitsStyle

return formatter.localizedString(for: self, relativeTo: date)
}
Expand Down
9 changes: 5 additions & 4 deletions Mlem/Extensions/View Modifiers/View+HandleLemmyLinks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,15 @@ struct HandleLemmyLinksDisplay: ViewModifier {
LazyLoadExpandedPost(post: post)
.environmentObject(quickLookState)
case let .apiPerson(user):
UserView(userID: user.id)
UserView(user: UserModel(from: user))
.environmentObject(appState)
.environmentObject(quickLookState)
case let .userProfile(user):
UserView(userID: user.userId)
case let .userProfile(user, communityContext):
UserView(user: user, communityContext: communityContext)
.environmentObject(appState)
.environmentObject(quickLookState)
case let .postLinkWithContext(post):
ExpandedPost(post: post.post, scrollTarget: post.scrollTarget)
ExpandedPost(post: post.post, community: post.community, scrollTarget: post.scrollTarget)
.environmentObject(post.postTracker)
.environmentObject(appState)
.environmentObject(quickLookState)
Expand Down
Loading