From b0873f2d1a6afc98e9e79df85faacc4dde9718e9 Mon Sep 17 00:00:00 2001 From: Marcin Czachursk Date: Tue, 28 Feb 2023 06:28:00 +0100 Subject: [PATCH] Improve autocomplete fonts sizes. --- Vernissage.xcodeproj/project.pbxproj | 4 +-- .../Services/AuthorizationService.swift | 32 +++++++++++-------- .../Views/ComposeView/ComposeView.swift | 21 ++++++++---- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/Vernissage.xcodeproj/project.pbxproj b/Vernissage.xcodeproj/project.pbxproj index 5a161ae..9f6681f 100644 --- a/Vernissage.xcodeproj/project.pbxproj +++ b/Vernissage.xcodeproj/project.pbxproj @@ -1059,7 +1059,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 40; + CURRENT_PROJECT_VERSION = 41; DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\""; DEVELOPMENT_TEAM = B2U9FEKYP8; ENABLE_PREVIEWS = YES; @@ -1096,7 +1096,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 40; + CURRENT_PROJECT_VERSION = 41; DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\""; DEVELOPMENT_TEAM = B2U9FEKYP8; ENABLE_PREVIEWS = YES; diff --git a/Vernissage/Services/AuthorizationService.swift b/Vernissage/Services/AuthorizationService.swift index ea7ab34..5fa8342 100644 --- a/Vernissage/Services/AuthorizationService.swift +++ b/Vernissage/Services/AuthorizationService.swift @@ -26,10 +26,10 @@ public class AuthorizationService { do { let account = try await client.verifyCredentials() - try await self.update(account: currentAccount, - basedOn: account, - accessToken: accessToken, - refreshToken: currentAccount.refreshToken) + await self.update(accountId: currentAccount.id, + basedOn: account, + accessToken: accessToken, + refreshToken: currentAccount.refreshToken) result(currentAccount) } catch { @@ -165,10 +165,10 @@ public class AuthorizationService { // Get account information from server. let account = try await authenticatedClient.verifyCredentials() - try await self.update(account: accountData, - basedOn: account, - accessToken: oAuthSwiftCredential.oauthToken, - refreshToken: oAuthSwiftCredential.oauthRefreshToken) + await self.update(accountId: accountData.id, + basedOn: account, + accessToken: oAuthSwiftCredential.oauthToken, + refreshToken: oAuthSwiftCredential.oauthRefreshToken) } private func refreshCredentials(for accountData: AccountData, @@ -193,17 +193,21 @@ public class AuthorizationService { // Get account information from server. let account = try await authenticatedClient.verifyCredentials() - try await self.update(account: accountData, - basedOn: account, - accessToken: oAuthSwiftCredential.oauthToken, - refreshToken: oAuthSwiftCredential.oauthRefreshToken) + await self.update(accountId: accountData.id, + basedOn: account, + accessToken: oAuthSwiftCredential.oauthToken, + refreshToken: oAuthSwiftCredential.oauthRefreshToken) } - private func update(account dbAccount: AccountData, + private func update(accountId: String, basedOn account: Account, accessToken: String, refreshToken: String? - ) async throws { + ) async { + guard let dbAccount = AccountDataHandler.shared.getAccountData(accountId: accountId) else { + return + } + dbAccount.username = account.username dbAccount.acct = account.acct dbAccount.displayName = account.displayNameWithoutEmojis diff --git a/Vernissage/Views/ComposeView/ComposeView.swift b/Vernissage/Views/ComposeView/ComposeView.swift index 0df25de..c7263a8 100644 --- a/Vernissage/Views/ComposeView/ComposeView.swift +++ b/Vernissage/Views/ComposeView/ComposeView.swift @@ -64,6 +64,7 @@ struct ComposeView: View { private let contentWidth = Int(UIScreen.main.bounds.width) - 50 private let keyboardFontImageSize = 20.0 private let keyboardFontTextSize = 16.0 + private let autocompleteFontTextSize = 12.0 public init(statusViewModel: StatusModel? = nil) { _textModel = StateObject(wrappedValue: .init()) @@ -343,12 +344,18 @@ struct ComposeView: View { Button { textModel.selectMentionSuggestion(account: account) } label: { - UsernameRow( - accountId: account.id, - accountAvatar: account.avatar, - accountDisplayName: account.displayNameWithoutEmojis, - accountUsername: account.acct, - size: .comment) + HStack (alignment: .center) { + UserAvatar(accountAvatar: account.avatar, size: .comment) + + VStack (alignment: .leading) { + Text(account.displayNameWithoutEmojis) + .foregroundColor(.mainTextColor) + Text("@\(account.acct)") + .foregroundColor(.lightGrayColor) + } + .padding(.leading, 8) + } + .font(.system(size: self.autocompleteFontTextSize)) .padding(.trailing, 8) } Divider() @@ -359,7 +366,7 @@ struct ComposeView: View { textModel.selectHashtagSuggestion(tag: tag) } label: { Text("#\(tag.name)") - .font(.callout) + .font(.system(size: self.autocompleteFontTextSize)) .foregroundColor(self.applicationState.tintColor.color()) } Divider()