From cdfb06f4a7c16a2fe7a06d41507b7d001609cc7f Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 18 Nov 2023 11:08:35 -0500 Subject: [PATCH] Render IDN domains in for logged-in accounts --- .../Fast Account Switcher/FastSwitchingAccountView.swift | 9 +++++++-- Tusker/Screens/Preferences/PreferencesView.swift | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Tusker/Screens/Fast Account Switcher/FastSwitchingAccountView.swift b/Tusker/Screens/Fast Account Switcher/FastSwitchingAccountView.swift index e800ecbc..61b5b47a 100644 --- a/Tusker/Screens/Fast Account Switcher/FastSwitchingAccountView.swift +++ b/Tusker/Screens/Fast Account Switcher/FastSwitchingAccountView.swift @@ -8,6 +8,7 @@ import UIKit import UserAccounts +import WebURL class FastSwitchingAccountView: UIView { @@ -126,7 +127,11 @@ class FastSwitchingAccountView: UIView { private func setupAccount(account: UserAccountInfo) { usernameLabel.text = account.username - instanceLabel.text = account.instanceURL.host! + if let domain = WebURL.Domain(account.instanceURL.host!) { + instanceLabel.text = domain.render(.uncheckedUnicodeString) + } else { + instanceLabel.text = account.instanceURL.host! + } let controller = MastodonController.getForAccount(account) controller.getOwnAccount { [weak self] (result) in guard let self = self, @@ -140,7 +145,7 @@ class FastSwitchingAccountView: UIView { } } - accessibilityLabel = "\(account.username!)@\(account.instanceURL.host!)" + accessibilityLabel = "\(account.username!)@\(instanceLabel.text!)" } private func setupPlaceholder() { diff --git a/Tusker/Screens/Preferences/PreferencesView.swift b/Tusker/Screens/Preferences/PreferencesView.swift index 6ee2f61a..6739d89e 100644 --- a/Tusker/Screens/Preferences/PreferencesView.swift +++ b/Tusker/Screens/Preferences/PreferencesView.swift @@ -7,6 +7,7 @@ import SwiftUI import UserAccounts +import WebURL struct PreferencesView: View { let mastodonController: MastodonController @@ -41,7 +42,12 @@ struct PreferencesView: View { VStack(alignment: .leading) { Text(verbatim: account.username) .foregroundColor(.primary) - Text(verbatim: account.instanceURL.host!) + let instance = if let domain = WebURL.Domain(account.instanceURL.host!) { + domain.render(.uncheckedUnicodeString) + } else { + account.instanceURL.host! + } + Text(verbatim: instance) .font(.caption) .foregroundColor(.primary) }