From 6f87dbb203ea48e40389ad385a9290b6f2ff2c97 Mon Sep 17 00:00:00 2001 From: Marcin Czachurski Date: Mon, 1 May 2023 18:01:07 +0200 Subject: [PATCH] #62 Fix not working medium qr code --- Vernissage.xcodeproj/project.pbxproj | 12 ++-- .../QRCodeWidget/QRCodeWidgetEntry.swift | 1 + .../QRCodeWidget/Service/AccountFetcher.swift | 2 + .../Views/QRCodeMediumWidgetView.swift | 55 ++++++++++++++----- 4 files changed, 49 insertions(+), 21 deletions(-) diff --git a/Vernissage.xcodeproj/project.pbxproj b/Vernissage.xcodeproj/project.pbxproj index 69a3e52..98fb2d0 100644 --- a/Vernissage.xcodeproj/project.pbxproj +++ b/Vernissage.xcodeproj/project.pbxproj @@ -1299,7 +1299,7 @@ CODE_SIGN_ENTITLEMENTS = VernissageWidget/VernissageWidgetExtension.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 134; + CURRENT_PROJECT_VERSION = 135; DEVELOPMENT_TEAM = B2U9FEKYP8; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = VernissageWidget/Info.plist; @@ -1327,7 +1327,7 @@ ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; CODE_SIGN_ENTITLEMENTS = VernissageWidget/VernissageWidgetExtension.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 134; + CURRENT_PROJECT_VERSION = 135; DEVELOPMENT_TEAM = B2U9FEKYP8; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = VernissageWidget/Info.plist; @@ -1354,7 +1354,7 @@ CODE_SIGN_ENTITLEMENTS = VernissageShare/VernissageShareExtension.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 134; + CURRENT_PROJECT_VERSION = 135; DEVELOPMENT_TEAM = B2U9FEKYP8; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = VernissageShare/Info.plist; @@ -1381,7 +1381,7 @@ buildSettings = { CODE_SIGN_ENTITLEMENTS = VernissageShare/VernissageShareExtension.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 134; + CURRENT_PROJECT_VERSION = 135; DEVELOPMENT_TEAM = B2U9FEKYP8; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = VernissageShare/Info.plist; @@ -1530,7 +1530,7 @@ CODE_SIGN_ENTITLEMENTS = Vernissage/Vernissage.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 134; + CURRENT_PROJECT_VERSION = 135; DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\""; DEVELOPMENT_TEAM = B2U9FEKYP8; ENABLE_PREVIEWS = YES; @@ -1572,7 +1572,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CODE_SIGN_ENTITLEMENTS = Vernissage/Vernissage.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 134; + CURRENT_PROJECT_VERSION = 135; DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\""; DEVELOPMENT_TEAM = B2U9FEKYP8; ENABLE_PREVIEWS = YES; diff --git a/VernissageWidget/QRCodeWidget/QRCodeWidgetEntry.swift b/VernissageWidget/QRCodeWidget/QRCodeWidgetEntry.swift index 3fed223..096cf2f 100644 --- a/VernissageWidget/QRCodeWidget/QRCodeWidgetEntry.swift +++ b/VernissageWidget/QRCodeWidget/QRCodeWidgetEntry.swift @@ -10,6 +10,7 @@ import SwiftUI struct QRCodeWidgetEntry: TimelineEntry { let date: Date let accountId: String + let acct: String let avatar: UIImage? let displayName: String? let profileUrl: URL? diff --git a/VernissageWidget/QRCodeWidget/Service/AccountFetcher.swift b/VernissageWidget/QRCodeWidget/Service/AccountFetcher.swift index 05e9849..8a6fc0b 100644 --- a/VernissageWidget/QRCodeWidget/Service/AccountFetcher.swift +++ b/VernissageWidget/QRCodeWidget/Service/AccountFetcher.swift @@ -27,6 +27,7 @@ public class AccountFetcher { return [ QRCodeWidgetEntry(date: Date(), accountId: accountId, + acct: account.acct, avatar: uiAvatar, displayName: account.displayName, profileUrl: account.url, @@ -38,6 +39,7 @@ public class AccountFetcher { func placeholder() -> QRCodeWidgetEntry { QRCodeWidgetEntry(date: Date(), accountId: "", + acct: "@caroline", avatar: nil, displayName: "Caroline Rick", profileUrl: URL(string: "https://pixelfed.org"), diff --git a/VernissageWidget/QRCodeWidget/Views/QRCodeMediumWidgetView.swift b/VernissageWidget/QRCodeWidget/Views/QRCodeMediumWidgetView.swift index c70ecfd..90eb168 100644 --- a/VernissageWidget/QRCodeWidget/Views/QRCodeMediumWidgetView.swift +++ b/VernissageWidget/QRCodeWidget/Views/QRCodeMediumWidgetView.swift @@ -43,30 +43,55 @@ struct QRCodeMediumWidgetView: View { @ViewBuilder private func getWidgetBody(uiAvatar: Image, uiQRCode: Image) -> some View { - VStack(spacing: 0) { - uiQRCode - .resizable() - .widgetURL(URL(string: "\(AppConstants.accountUri)/\(entry.accountId)")) + VStack(alignment: .leading, spacing: 0) { + HStack(alignment: .center, spacing: 0) { + uiQRCode + .resizable() + .scaledToFit() + .widgetURL(URL(string: "\(AppConstants.accountUri)/\(entry.accountId)")) - HStack { - uiAvatar - .avatar(size: 24) - .padding(.leading, 8) + HStack(alignment: .center) { + uiAvatar + .avatar(size: 24) - Text(entry.displayName ?? "") - .font(.system(size: 16)) - .foregroundColor(Color.primary) - .fontWeight(.semibold) + VStack(alignment: .leading) { + Text(entry.displayName ?? "") + .font(.system(size: 12)) + .foregroundColor(Color.primary) + .fontWeight(.semibold) + .lineLimit(1) + .truncationMode(.tail) + + Text("@\(entry.acct)") + .font(.system(size: 12)) + .foregroundColor(Color.primary.opacity(0.6)) + .fontWeight(.semibold) + .lineLimit(1) + .truncationMode(.tail) + } + + Spacer() + } + .padding(.leading, 8) + } + + HStack(alignment: .center, spacing: 0) { + if let profileUrl = entry.profileUrl { + Text(profileUrl.absoluteString) + .font(.system(size: 10)) + .foregroundColor(Color.primary.opacity(0.6)) + } Spacer() Image("Pixelfed") .resizable() .scaledToFit() - .frame(height: 32) + .frame(height: 26) } - .padding(.top, 4) + .padding(.leading, 3) + .offset(y: -4) } - .padding(8) + .padding([.leading, .trailing, .top], 12) } }