#62 Fix not working medium qr code

This commit is contained in:
Marcin Czachurski 2023-05-01 18:01:07 +02:00
parent c51c12da76
commit 6f87dbb203
4 changed files with 49 additions and 21 deletions

View File

@ -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;

View File

@ -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?

View File

@ -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"),

View File

@ -43,30 +43,55 @@ struct QRCodeMediumWidgetView: View {
@ViewBuilder
private func getWidgetBody(uiAvatar: Image, uiQRCode: Image) -> some View {
VStack(spacing: 0) {
VStack(alignment: .leading, spacing: 0) {
HStack(alignment: .center, spacing: 0) {
uiQRCode
.resizable()
.scaledToFit()
.widgetURL(URL(string: "\(AppConstants.accountUri)/\(entry.accountId)"))
HStack {
HStack(alignment: .center) {
uiAvatar
.avatar(size: 24)
.padding(.leading, 8)
VStack(alignment: .leading) {
Text(entry.displayName ?? "")
.font(.system(size: 16))
.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)
}
}