Skip to content

Commit

Permalink
Update placeholder for client token url
Browse files Browse the repository at this point in the history
  • Loading branch information
jnewc committed Feb 16, 2024
1 parent 3774b87 commit bc6b85b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"sourceLanguage" : "en",
"strings" : {
"" : {

},
"App.Title" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -92,16 +95,6 @@
}
}
},
"Settings.ClientTokenUrl.Placeholder" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Client Token URL"
}
}
}
},
"Start.Button.MakePayment" : {
"localizations" : {
"en" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct ExampleApp: App {
static var clientToken = ""

// 👇 You can point to a server that provides the client token here
static var clientTokenUrl = "https://localhost:3000"
static var clientTokenUrl = ""

let service = PrimerDataService(clientToken: Self.clientToken)

Expand All @@ -35,4 +35,5 @@ struct ExampleApp: App {
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct SettingsView: View {
@StateObject var settingsModel: SettingsModel

@State var isFetchingClientToken: Bool = false

var body: some View {
Group {
Section {
Expand All @@ -31,7 +31,11 @@ struct SettingsView: View {
}

Section {
TextField(LocalizedStringKey("Settings.ClientTokenUrl.Placeholder"), text: $settingsModel.clientTokenUrl)
TextField(
"",
text: $settingsModel.clientTokenUrl,
prompt: Text(verbatim: "https://my.glitch.server")
)
.keyboardType(.URL)
.textInputAutocapitalization(.never)
Button {
Expand Down Expand Up @@ -59,8 +63,15 @@ struct SettingsView: View {
}
}
}
.onAppear(perform: onAppear)
}


private func onAppear() {
if let _ = URL(string: settingsModel.clientTokenUrl) {
onFetchClientToken()
}
}

private func onFetchClientToken() {
Task {
settingsModel.fetchErrorMessage = nil
Expand Down

0 comments on commit bc6b85b

Please sign in to comment.