From e9090c411336044c1c1effdd3ec897cfc2895323 Mon Sep 17 00:00:00 2001 From: Sjmarf <78750526+Sjmarf@users.noreply.github.com> Date: Sun, 15 Dec 2024 19:31:29 +0000 Subject: [PATCH 1/4] Update --- Mlem.xcodeproj/project.pbxproj | 4 +- Mlem/App/Views/Pages/Person/PersonView.swift | 40 +++++++++++++++++++ .../Components/SquircleLabelStyle.swift | 1 + Mlem/Localizable.xcstrings | 3 ++ 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/Mlem.xcodeproj/project.pbxproj b/Mlem.xcodeproj/project.pbxproj index b10d68493..317774ff6 100644 --- a/Mlem.xcodeproj/project.pbxproj +++ b/Mlem.xcodeproj/project.pbxproj @@ -2942,8 +2942,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/mlemgroup/MlemMiddleware"; requirement = { - kind = upToNextMajorVersion; - minimumVersion = 0.52.0; + branch = "sjmarf/purge-community"; + kind = branch; }; }; CDE4AC402CA3706400981010 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */ = { diff --git a/Mlem/App/Views/Pages/Person/PersonView.swift b/Mlem/App/Views/Pages/Person/PersonView.swift index f3849fe80..dd01662dc 100644 --- a/Mlem/App/Views/Pages/Person/PersonView.swift +++ b/Mlem/App/Views/Pages/Person/PersonView.swift @@ -5,6 +5,7 @@ // Created by Sjmarf on 30/05/2024. // +import Flow import LemmyMarkdownUI import MlemMiddleware import SwiftUI @@ -125,6 +126,7 @@ struct PersonView: View { VStack(spacing: 0) { VStack(spacing: Constants.main.standardSpacing) { ProfileHeaderView(person, fallback: .person) + flairsView(person: person) bio(person: person) } .padding([.horizontal], Constants.main.standardSpacing) @@ -175,6 +177,27 @@ struct PersonView: View { } } + @ViewBuilder + func flairsView(person: any Person) -> some View { + if person.isBot || person.isMlemDeveloper || person.isAdmin_ ?? false { + HFlow(spacing: Constants.main.halfSpacing) { + if person.isMlemDeveloper { + Label("Mlem Developer", systemImage: Icons.developerFlair) + .tint(palette.colorfulAccent(4)) + } + if person.isAdmin_ ?? false { + Label("\(person.host ?? "") Administrator", systemImage: Icons.adminFlair) + .tint(palette.administration) + } + if person.isBot { + Label("Bot Account", systemImage: Icons.botFlair) + .tint(palette.colorfulAccent(5)) + } + } + .labelStyle(FlairLabelStyle()) + } + } + @ViewBuilder func dateLabel(person: any Person) -> some View { ProfileDateView(profilable: person) @@ -233,3 +256,20 @@ struct PersonView: View { .padding([.horizontal, .bottom], Constants.main.standardSpacing) } } + +private struct FlairLabelStyle: LabelStyle { + @Environment(Palette.self) private var palette + + func makeBody(configuration: Configuration) -> some View { + HStack(spacing: 5) { + configuration.icon + .imageScale(.small) + configuration.title + } + .font(.footnote) + .padding(.vertical, 2) + .padding(.horizontal, 8) + .foregroundStyle(.tint) + .background(.tint.opacity(0.2), in: .capsule) + } +} diff --git a/Mlem/App/Views/Root/Tabs/Settings/Components/SquircleLabelStyle.swift b/Mlem/App/Views/Root/Tabs/Settings/Components/SquircleLabelStyle.swift index 651f56aaa..c8e202168 100644 --- a/Mlem/App/Views/Root/Tabs/Settings/Components/SquircleLabelStyle.swift +++ b/Mlem/App/Views/Root/Tabs/Settings/Components/SquircleLabelStyle.swift @@ -9,6 +9,7 @@ import SwiftUI struct SquircleLabelStyle: LabelStyle { @Environment(Palette.self) private var palette + func makeBody(configuration: Configuration) -> some View { HStack(alignment: .center, spacing: 16) { configuration.icon diff --git a/Mlem/Localizable.xcstrings b/Mlem/Localizable.xcstrings index 0e94e522b..055ac3291 100644 --- a/Mlem/Localizable.xcstrings +++ b/Mlem/Localizable.xcstrings @@ -30,6 +30,9 @@ } } } + }, + "%@ Administrator" : { + }, "%@ has been unresponsive recently." : { From 553a2929fde80af546e5be59d8efc06729636e6c Mon Sep 17 00:00:00 2001 From: Sjmarf <78750526+Sjmarf@users.noreply.github.com> Date: Sun, 15 Dec 2024 19:31:32 +0000 Subject: [PATCH 2/4] Update Package.resolved --- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Mlem.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Mlem.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 53c8be7e0..b6f0a67fc 100644 --- a/Mlem.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Mlem.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -51,8 +51,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/mlemgroup/MlemMiddleware", "state" : { - "revision" : "51db2875046e216fb01c8233cc43eadd147dd240", - "version" : "0.52.0" + "branch" : "sjmarf/purge-community", + "revision" : "2c757c2955db466c4b0d04f52599a620e7e70eac" } }, { From d92423b9d0a230888108beb862ba5091c335d5f6 Mon Sep 17 00:00:00 2001 From: Sjmarf <78750526+Sjmarf@users.noreply.github.com> Date: Sun, 15 Dec 2024 19:55:49 +0000 Subject: [PATCH 3/4] Bug fix --- Mlem/App/Views/Pages/Person/PersonView.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Mlem/App/Views/Pages/Person/PersonView.swift b/Mlem/App/Views/Pages/Person/PersonView.swift index dd01662dc..79d811c84 100644 --- a/Mlem/App/Views/Pages/Person/PersonView.swift +++ b/Mlem/App/Views/Pages/Person/PersonView.swift @@ -37,10 +37,12 @@ struct PersonView: View { @State private var selectedContentType: PersonContentType = .all @State private var isAtTop: Bool = true @State var feedLoader: PersonContentFeedLoader? + @State var isAdmin: Bool let isProfileTab: Bool init(person: AnyPerson, isProfileTab: Bool = false) { self._person = .init(wrappedValue: person) + self._isAdmin = .init(wrappedValue: person.wrappedValue.isAdmin_ ?? false) self.isProfileTab = isProfileTab if let person1 = person.wrappedValue as? any Person1Providing, person1.api === AppState.main.firstApi { @@ -115,6 +117,12 @@ struct PersonView: View { } return try await entity.upgrade() } + // This prevents the admin flair from disappearing if the `ContentLoader` + // switches from an external ApiClient to the active ApiClient, e.g. when + // navigating to `PersonView` from the administrator list in `InstanceView`. + if model.wrappedValue.isAdmin_ ?? false { + isAdmin = true + } } .navigationTitle(isAtTop ? "" : (person.wrappedValue.displayName_ ?? person.wrappedValue.name)) .navigationBarTitleDisplayMode(.inline) @@ -179,13 +187,13 @@ struct PersonView: View { @ViewBuilder func flairsView(person: any Person) -> some View { - if person.isBot || person.isMlemDeveloper || person.isAdmin_ ?? false { + if person.isBot || person.isMlemDeveloper || isAdmin { HFlow(spacing: Constants.main.halfSpacing) { if person.isMlemDeveloper { Label("Mlem Developer", systemImage: Icons.developerFlair) .tint(palette.colorfulAccent(4)) } - if person.isAdmin_ ?? false { + if isAdmin { Label("\(person.host ?? "") Administrator", systemImage: Icons.adminFlair) .tint(palette.administration) } From f0e65aec4118448a4927196d3ed038ab12aad00a Mon Sep 17 00:00:00 2001 From: Sjmarf <78750526+Sjmarf@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:35:37 +0000 Subject: [PATCH 4/4] MlemMiddleware version --- Mlem.xcodeproj/project.pbxproj | 4 ++-- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Mlem.xcodeproj/project.pbxproj b/Mlem.xcodeproj/project.pbxproj index 317774ff6..6d402fb58 100644 --- a/Mlem.xcodeproj/project.pbxproj +++ b/Mlem.xcodeproj/project.pbxproj @@ -2942,8 +2942,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/mlemgroup/MlemMiddleware"; requirement = { - branch = "sjmarf/purge-community"; - kind = branch; + kind = upToNextMinorVersion; + minimumVersion = 0.53.0; }; }; CDE4AC402CA3706400981010 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */ = { diff --git a/Mlem.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Mlem.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index b6f0a67fc..47278bd4e 100644 --- a/Mlem.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Mlem.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -51,8 +51,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/mlemgroup/MlemMiddleware", "state" : { - "branch" : "sjmarf/purge-community", - "revision" : "2c757c2955db466c4b0d04f52599a620e7e70eac" + "revision" : "a4dc838d0ff82ea76b71ee9e9568743d957e15a0", + "version" : "0.53.0" } }, {