Skip to content

Commit 8d787fc

Browse files
refactor: used computed properties for string localisation
1 parent d0c20c3 commit 8d787fc

5 files changed

Lines changed: 98 additions & 13 deletions

File tree

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Utils/StringUtils.swift

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,89 @@ public class StringUtils {
7979
return error.localizedDescription
8080
}
8181
}
82+
83+
/// Auth Picker title
84+
/// found in:
85+
/// - AuthPickerView
86+
public var authPickerTitle: String {
87+
return localizedString(for: kAuthPickerTitle)
88+
}
89+
90+
/// Email input label
91+
/// found in:
92+
/// - EmailAuthView
93+
/// - PasswordRecoveryView
94+
public var emailInputLabel: String {
95+
return localizedString(for: kEnterYourEmail)
96+
}
97+
98+
/// Password button action label
99+
/// found in:
100+
/// - EmailAuthView
101+
public var passwordButtonLabel: String {
102+
return localizedString(for: kForgotPasswordButtonLabel)
103+
}
104+
105+
/// Password input label
106+
/// found in:
107+
/// - EmailAuthView
108+
public var passwordInputLabel: String {
109+
return localizedString(for: kEnterYourPassword)
110+
}
111+
112+
/// Password recovery title
113+
/// found in:
114+
/// - PasswordRecoveryView
115+
public var passwordRecoveryTitle: String {
116+
return localizedString(for: kPasswordRecoveryTitle)
117+
}
118+
119+
/// Password recovery email sent title
120+
/// found in:
121+
/// - PasswordRecoveryView
122+
public var passwordRecoveryEmailSentTitle: String {
123+
return localizedString(for: kPasswordRecoveryEmailSentTitle)
124+
}
125+
126+
/// Password recovery helper message
127+
/// found in:
128+
/// - PasswordRecoveryView
129+
public var passwordRecoveryHelperMessage: String {
130+
return localizedString(for: kPasswordRecoveryMessage)
131+
}
132+
133+
/// Password recovery email sent message
134+
/// found in:
135+
/// - PasswordRecoveryView
136+
public var passwordRecoveryEmailSentMessage: String {
137+
return localizedString(for: kPasswordRecoveryEmailSentMessage)
138+
}
139+
140+
/// Forgot password input label
141+
/// found in:
142+
/// - PasswordRecoveryView
143+
public var forgotPasswordInputLabel: String {
144+
return localizedString(for: kForgotPasswordInputLabel)
145+
}
146+
147+
/// Signed in title
148+
/// found in:
149+
/// - SignedInView
150+
public var signedInTitle: String {
151+
return localizedString(for: kSignedInTitle)
152+
}
153+
154+
/// General string - Back button label
155+
/// found in:
156+
/// - PasswordRecoveryView
157+
public var backButtonLabel: String {
158+
return localizedString(for: kBack)
159+
}
160+
161+
/// General string - OK button label
162+
/// found in:
163+
/// - PasswordRecoveryView
164+
public var okButtonLabel: String {
165+
return localizedString(for: kOK)
166+
}
82167
}

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/AuthPickerView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public struct AuthPickerView<Content: View> {
1818
extension AuthPickerView: View {
1919
public var body: some View {
2020
VStack {
21-
Text(authService.string.localizedString(for: kAuthPickerTitle))
21+
Text(authService.string.authPickerTitle)
2222
.font(.largeTitle)
2323
.fontWeight(.bold)
2424
.padding()

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/EmailAuthView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ extension EmailAuthView: View {
5050
public var body: some View {
5151
VStack {
5252
LabeledContent {
53-
TextField(authService.string.localizedString(for: kEnterYourEmail), text: $email)
53+
TextField(authService.string.emailInputLabel, text: $email)
5454
.textInputAutocapitalization(.never)
5555
.disableAutocorrection(true)
5656
.focused($focus, equals: .email)
@@ -66,7 +66,7 @@ extension EmailAuthView: View {
6666
.padding(.bottom, 4)
6767

6868
LabeledContent {
69-
SecureField(authService.string.localizedString(for: kEnterYourPassword), text: $password)
69+
SecureField(authService.string.passwordInputLabel, text: $password)
7070
.focused($focus, equals: .password)
7171
.submitLabel(.go)
7272
.onSubmit {
@@ -83,7 +83,7 @@ extension EmailAuthView: View {
8383
Button(action: {
8484
authService.authView = .passwordRecovery
8585
}) {
86-
Text(authService.string.localizedString(for: kForgotPasswordButtonLabel))
86+
Text(authService.string.passwordButtonLabel)
8787
}
8888
}
8989

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/PasswordRecoveryView.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ public struct PasswordRecoveryView {
1818
extension PasswordRecoveryView: View {
1919
public var body: some View {
2020
VStack {
21-
Text(authService.string.localizedString(for: kPasswordRecoveryTitle))
21+
Text(authService.string.passwordRecoveryTitle)
2222
.font(.largeTitle)
2323
.fontWeight(.bold)
2424
.padding()
2525

2626
Divider()
2727

2828
LabeledContent {
29-
TextField(authService.string.localizedString(for: kEnterYourEmail), text: $email)
29+
TextField(authService.string.emailInputLabel, text: $email)
3030
.textInputAutocapitalization(.never)
3131
.disableAutocorrection(true)
3232
.submitLabel(.next)
@@ -40,7 +40,7 @@ extension PasswordRecoveryView: View {
4040
await sendPasswordRecoveryEmail()
4141
}
4242
}) {
43-
Text(authService.string.localizedString(for: kForgotPasswordInputLabel))
43+
Text(authService.string.forgotPasswordInputLabel)
4444
.padding(.vertical, 8)
4545
.frame(maxWidth: .infinity)
4646
}
@@ -50,18 +50,18 @@ extension PasswordRecoveryView: View {
5050
.buttonStyle(.borderedProminent)
5151
}.sheet(isPresented: $showModal) {
5252
VStack {
53-
Text(authService.string.localizedString(for: kPasswordRecoveryEmailSentTitle))
53+
Text(authService.string.passwordRecoveryEmailSentTitle)
5454
.font(.largeTitle)
5555
.fontWeight(.bold)
5656
.padding()
57-
Text(authService.string.localizedString(for: kPasswordRecoveryMessage))
57+
Text(authService.string.passwordRecoveryMessage)
5858
.padding()
5959

6060
Divider()
6161

62-
Text(authService.string.localizedString(for: kPasswordRecoveryEmailSentMessage))
62+
Text(authService.string.passwordRecoveryEmailSentMessage)
6363
.padding()
64-
Button(authService.string.localizedString(for: kOK)) {
64+
Button(authService.string.okButtonLabel) {
6565
showModal = false
6666
}
6767
.padding()
@@ -75,7 +75,7 @@ extension PasswordRecoveryView: View {
7575
}) {
7676
Image(systemName: "chevron.left")
7777
.foregroundColor(.blue)
78-
Text(authService.string.localizedString(for: kBack))
78+
Text(authService.string.backButtonLabel)
7979
.foregroundColor(.blue)
8080
})
8181
}

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/SignedInView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extension SignedInView: View {
1515

1616
public var body: some View {
1717
VStack {
18-
Text(authService.string.localizedString(for: kSignedInTitle))
18+
Text(authService.string.signedInTitle)
1919
.font(.largeTitle)
2020
.fontWeight(.bold)
2121
.padding()

0 commit comments

Comments
 (0)