Skip to content

Commit

Permalink
Move localisation out of SingleChoiceList to the client
Browse files Browse the repository at this point in the history
  • Loading branch information
acb-mv committed Nov 14, 2024
1 parent 72ad9bf commit a311888
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ struct UDPTCPObfuscationSettingsView<VM>: View where VM: UDPTCPObfuscationSettin
SingleChoiceList(
title: portString,
options: [WireGuardObfuscationUdpOverTcpPort.automatic, .port80, .port5001],
value: $viewModel.value
value: $viewModel.value,
itemDescription: { item in NSLocalizedString(
"UDP_TCP_PORT_VALUE_\(item)",
tableName: "UdpToTcp",
value: "\(item)",
comment: ""
) }
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,20 @@ struct SingleChoiceList<Item>: View where Item: Hashable {
let title: String
let options: [Item]
var value: Binding<Item>
let itemDescription: (Item) -> String

init(title: String, options: [Item], value: Binding<Item>, itemDescription: ((Item) -> String)? = nil) {
self.title = title
self.options = options
self.value = value
self.itemDescription = itemDescription ?? { "\($0)" }
}

func row(_ v: Item) -> some View {
let isSelected = value.wrappedValue == v
return HStack {
Image("IconTick").opacity(isSelected ? 1.0 : 0.0)
Text(verbatim: NSLocalizedString("\(v)", comment: ""))
Text(verbatim: itemDescription(v))
Spacer()
}
.padding(16)
Expand Down

0 comments on commit a311888

Please sign in to comment.