From fe8c799ebb324b629a02e63f0f7a380a5929c3eb Mon Sep 17 00:00:00 2001 From: Sjmarf <78750526+Sjmarf@users.noreply.github.com> Date: Sun, 14 Jan 2024 19:28:59 +0000 Subject: [PATCH] Show instance version --- Mlem/Models/Content/Instance/InstanceModel.swift | 2 ++ Mlem/Views/Shared/Instance/InstanceView.swift | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Mlem/Models/Content/Instance/InstanceModel.swift b/Mlem/Models/Content/Instance/InstanceModel.swift index bc9627b5f..10ca52888 100644 --- a/Mlem/Models/Content/Instance/InstanceModel.swift +++ b/Mlem/Models/Content/Instance/InstanceModel.swift @@ -15,6 +15,7 @@ struct InstanceModel { var banner: URL? var administrators: [UserModel]? var url: URL! + var version: SiteVersion? init(from response: SiteResponse) { self.update(with: response) @@ -30,6 +31,7 @@ struct InstanceModel { user.isAdmin = true return user } + self.version = SiteVersion(response.version) self.update(with: response.siteView.site) } diff --git a/Mlem/Views/Shared/Instance/InstanceView.swift b/Mlem/Views/Shared/Instance/InstanceView.swift index 38ceab550..a2a562ef6 100644 --- a/Mlem/Views/Shared/Instance/InstanceView.swift +++ b/Mlem/Views/Shared/Instance/InstanceView.swift @@ -44,6 +44,14 @@ struct InstanceView: View { _instance = State(wrappedValue: instance) } + var subtitleText: String { + if let version = instance?.version { + "\(domainName) • \(String(describing: version))" + } else { + domainName + } + } + var body: some View { ScrollView { ScrollToView(appeared: $scrollToTopAppeared) @@ -60,10 +68,10 @@ struct InstanceView: View { .fontWeight(.semibold) .lineLimit(1) .minimumScaleFactor(0.01) - Text(domainName) + + Text(subtitleText) .font(.footnote) .foregroundStyle(.secondary) - .padding(.bottom, 5) } } else { Text(domainName) @@ -73,9 +81,9 @@ struct InstanceView: View { .minimumScaleFactor(0.01) .padding(.bottom, 5) Divider() - } } + .padding(.bottom, 5) if let instance { VStack(spacing: 0) { VStack(spacing: 4) {