feat: sort the language list in details

This commit is contained in:
pan93412 2023-08-21 03:34:54 +08:00
parent 7225052413
commit ae7d8b1379
No known key found for this signature in database
GPG key ID: 42154B1B1CFE3377
2 changed files with 5 additions and 1 deletions

View file

@ -52,7 +52,7 @@ struct BuildConfigView: View {
}.padding(.bottom, 5)
Section("Language") {
Picker("", selection: $selectedLocale) {
ForEach(details.languages) { language in
ForEach(details.sortedLanguages) { language in
Text(language.display).tag(language.code)
}
}.onChange(of: selectedLocale) { newValue in

View file

@ -32,6 +32,10 @@ struct BuildDetails {
let arch: String
let build: String
let created: Date
var sortedLanguages: [Language] {
return languages.sorted(using: KeyPathComparator(\.display))
}
static var empty = BuildDetails()