Render IDN domains in for logged-in accounts

This commit is contained in:
Shadowfacts 2023-11-18 11:08:35 -05:00
parent 4e98e569eb
commit cdfb06f4a7
2 changed files with 14 additions and 3 deletions

View File

@ -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() {

View File

@ -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)
}