Skip to content

Commit b17fbf5

Browse files
authored
Merge pull request #531 from huihuisang/fix/AttributedText-layout-issue
Replace AttributedText with Text and markdown to fix the layout issues
2 parents dbf3000 + b5e50c6 commit b17fbf5

File tree

4 files changed

+85
-118
lines changed

4 files changed

+85
-118
lines changed

Xcodes/Frontend/Preferences/DownloadPreferencePane.swift

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ struct DownloadPreferencePane: View {
2020
.labelsHidden()
2121
.fixedSize()
2222

23-
AttributedText(dataSourceFootnote)
23+
Text("DataSourceDescription")
24+
.font(.footnote)
25+
.foregroundStyle(.secondary)
26+
.fixedSize(horizontal: false, vertical: true)
2427
}
25-
2628
}
2729
.groupBoxStyle(PreferencesGroupBoxStyle())
2830

@@ -37,40 +39,15 @@ struct DownloadPreferencePane: View {
3739
.labelsHidden()
3840
.fixedSize()
3941

40-
AttributedText(downloaderFootnote)
42+
Text("DownloaderDescription")
43+
.font(.footnote)
44+
.foregroundStyle(.secondary)
45+
.fixedSize(horizontal: false, vertical: true)
4146
}
42-
4347
}
4448
.groupBoxStyle(PreferencesGroupBoxStyle())
45-
4649
}
4750
}
48-
49-
private var dataSourceFootnote: NSAttributedString {
50-
let string = localizeString("DataSourceDescription")
51-
let attributedString = NSMutableAttributedString(
52-
string: string,
53-
attributes: [
54-
.font: NSFont.preferredFont(forTextStyle: .footnote, options: [:]),
55-
.foregroundColor: NSColor.secondaryLabelColor
56-
]
57-
)
58-
attributedString.addAttribute(.link, value: URL(string: "https://xcodereleases.com")!, range: NSRange(string.range(of: "Xcode Releases")!, in: string))
59-
return attributedString
60-
}
61-
62-
private var downloaderFootnote: NSAttributedString {
63-
let string = localizeString("DownloaderDescription")
64-
let attributedString = NSMutableAttributedString(
65-
string: string,
66-
attributes: [
67-
.font: NSFont.preferredFont(forTextStyle: .footnote, options: [:]),
68-
.foregroundColor: NSColor.secondaryLabelColor
69-
]
70-
)
71-
attributedString.addAttribute(.link, value: URL(string: "https://github.com/aria2/aria2")!, range: NSRange(string.range(of: "aria2")!, in: string))
72-
return attributedString
73-
}
7451
}
7552

7653
struct DownloadPreferencePane_Previews: PreviewProvider {

Xcodes/Frontend/Preferences/ExperiementsPreferencePane.swift

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import AppleAPI
2-
import SwiftUI
32
import Path
3+
import SwiftUI
44

55
struct ExperimentsPreferencePane: View {
66
@EnvironmentObject var appState: AppState
@@ -13,27 +13,16 @@ struct ExperimentsPreferencePane: View {
1313
"UseUnxipExperiment",
1414
isOn: $appState.unxipExperiment
1515
)
16-
AttributedText(unxipFootnote)
16+
Text("FasterUnxipDescription")
17+
.font(.footnote)
18+
.foregroundStyle(.secondary)
19+
.fixedSize(horizontal: false, vertical: true)
1720
}
1821
.fixedSize(horizontal: false, vertical: true)
1922
}
2023
.groupBoxStyle(PreferencesGroupBoxStyle())
2124
}
2225
}
23-
24-
private var unxipFootnote: NSAttributedString {
25-
let string = localizeString("FasterUnxipDescription")
26-
let attributedString = NSMutableAttributedString(
27-
string: string,
28-
attributes: [
29-
.font: NSFont.preferredFont(forTextStyle: .footnote, options: [:]),
30-
.foregroundColor: NSColor.secondaryLabelColor
31-
]
32-
)
33-
attributedString.addAttribute(.link, value: URL(string: "https://twitter.com/_saagarjha")!, range: NSRange(string.range(of: "@_saagarjha")!, in: string))
34-
attributedString.addAttribute(.link, value: URL(string: "https://github.com/saagarjha/unxip")!, range: NSRange(string.range(of: "https://github.com/saagarjha/unxip")!, in: string))
35-
return attributedString
36-
}
3726
}
3827

3928
struct ExperimentsPreferencePane_Previews: PreviewProvider {

Xcodes/Frontend/SignIn/SignInPhoneListView.swift

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import SwiftUI
21
import AppleAPI
2+
import SwiftUI
33

44
struct SignInPhoneListView: View {
55
@EnvironmentObject var appState: AppState
66
@Binding var isPresented: Bool
77
@State private var selectedPhoneNumberID: AuthOptionsResponse.TrustedPhoneNumber.ID?
88
let authOptions: AuthOptionsResponse
99
let sessionData: AppleSessionData
10-
10+
1111
var body: some View {
1212
VStack(alignment: .leading) {
1313
if let phoneNumbers = authOptions.trustedPhoneNumbers, !phoneNumbers.isEmpty {
1414
Text(String(format: localizeString("SelectTrustedPhone"), authOptions.securityCode.length))
15-
15+
1616
List(phoneNumbers, selection: $selectedPhoneNumberID) {
1717
Text($0.numberWithDialCode)
1818
}
@@ -22,19 +22,18 @@ struct SignInPhoneListView: View {
2222
}
2323
}
2424
} else {
25-
AttributedText(
26-
NSAttributedString(string: localizeString("NoTrustedPhones"))
27-
.convertingURLsToLinkAttributes()
28-
)
25+
Text("NoTrustedPhones")
26+
.font(.callout)
2927
Spacer()
3028
}
31-
29+
3230
HStack {
3331
Button("Cancel", action: { isPresented = false })
3432
.keyboardShortcut(.cancelAction)
3533
Spacer()
3634
ProgressButton(isInProgress: appState.isProcessingAuthRequest,
37-
action: { appState.requestSMS(to: authOptions.trustedPhoneNumbers!.first { $0.id == selectedPhoneNumberID }!, authOptions: authOptions, sessionData: sessionData) }) {
35+
action: { appState.requestSMS(to: authOptions.trustedPhoneNumbers!.first { $0.id == selectedPhoneNumberID }!, authOptions: authOptions, sessionData: sessionData) })
36+
{
3837
Text("Continue")
3938
}
4039
.keyboardShortcut(.defaultAction)
@@ -54,19 +53,21 @@ struct SignInPhoneListView_Previews: PreviewProvider {
5453
SignInPhoneListView(
5554
isPresented: .constant(true),
5655
authOptions: AuthOptionsResponse(
57-
trustedPhoneNumbers: [.init(id: 0, numberWithDialCode: "(•••) •••-••90")],
56+
trustedPhoneNumbers: [.init(id: 0, numberWithDialCode: "(•••) •••-••90")],
5857
trustedDevices: nil,
59-
securityCode: .init(length: 6)),
58+
securityCode: .init(length: 6)
59+
),
6060
sessionData: AppleSessionData(serviceKey: "", sessionID: "", scnt: "")
6161
)
6262
.environmentObject(AppState())
6363

6464
SignInPhoneListView(
6565
isPresented: .constant(true),
6666
authOptions: AuthOptionsResponse(
67-
trustedPhoneNumbers: [],
67+
trustedPhoneNumbers: [],
6868
trustedDevices: nil,
69-
securityCode: .init(length: 6)),
69+
securityCode: .init(length: 6)
70+
),
7071
sessionData: AppleSessionData(serviceKey: "", sessionID: "", scnt: "")
7172
)
7273
.environmentObject(AppState())

0 commit comments

Comments
 (0)