Skip to content

Commit

Permalink
improve view localization
Browse files Browse the repository at this point in the history
  • Loading branch information
cbaker6 committed Dec 24, 2024
1 parent b66e3ef commit 3c2c69b
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 43 deletions.
39 changes: 23 additions & 16 deletions OCKSample/Main/Login/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct LoginView: View {
var body: some View {
VStack {
// Change the title to the name of your application
Text("CareKit Sample App")
Text("APP_NAME")
.font(.largeTitle)
.foregroundColor(.white)
.padding()
Expand All @@ -51,36 +51,36 @@ struct LoginView: View {
https://www.swiftkickmobile.com/creating-a-segmented-control-in-swiftui/
*/
Picker(selection: $signupLoginSegmentValue,
label: Text("Login Picker")) {
Text("Login").tag(0)
Text("Sign Up").tag(1)
label: Text("LOGIN_PICKER")) {
Text("LOGIN").tag(0)
Text("SIGN_UP").tag(1)
}
.pickerStyle(.segmented)
.background(Color(tintColorFlip))
.cornerRadius(20.0)
.padding()

VStack(alignment: .leading) {
TextField("Username", text: $usersname)
TextField("USERNAME", text: $usersname)
.padding()
.background(.white)
.cornerRadius(20.0)
.shadow(radius: 10.0, x: 20, y: 10)
SecureField("Password", text: $password)
SecureField("PASSWORD", text: $password)
.padding()
.background(.white)
.cornerRadius(20.0)
.shadow(radius: 10.0, x: 20, y: 10)

switch signupLoginSegmentValue {
case 1:
TextField("First Name", text: $firstName)
TextField("FIRST_NAME", text: $firstName)
.padding()
.background(.white)
.cornerRadius(20.0)
.shadow(radius: 10.0, x: 20, y: 10)

TextField("Last Name", text: $lastName)
TextField("LAST_NAME", text: $lastName)
.padding()
.background(.white)
.cornerRadius(20.0)
Expand Down Expand Up @@ -114,13 +114,13 @@ struct LoginView: View {
}, label: {
switch signupLoginSegmentValue {
case 1:
Text("Sign Up")
Text("SIGN_UP")
.font(.headline)
.foregroundColor(.white)
.padding()
.frame(width: 300)
default:
Text("Login")
Text("LOGIN")
.font(.headline)
.foregroundColor(.white)
.padding()
Expand All @@ -137,7 +137,7 @@ struct LoginView: View {
}, label: {
switch signupLoginSegmentValue {
case 0:
Text("Login Anonymously")
Text("LOGIN_ANONYMOUSLY")
.font(.headline)
.foregroundColor(.white)
.padding()
Expand All @@ -151,15 +151,22 @@ struct LoginView: View {

// If an error occurs show it on the screen
if let error = viewModel.loginError {
Text("Error: \(error.message)")
Text("\(String(localized: "ERROR")): \(error.message)")
.foregroundColor(.red)
}
Spacer()
}
.background(LinearGradient(gradient: Gradient(colors: [Color(tintColorFlip),
Color(tintColor)]),
startPoint: .top,
endPoint: .bottom))
.background(
LinearGradient(
gradient: Gradient(
colors: [
Color(tintColorFlip),
Color(tintColor)]
),
startPoint: .top,
endPoint: .bottom
)
)
}
}

Expand Down
62 changes: 36 additions & 26 deletions OCKSample/Main/Profile/ProfileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,30 @@ struct ProfileView: View {
var body: some View {
VStack {
VStack(alignment: .leading) {
TextField("First Name",
text: $viewModel.firstName)
.padding()
.cornerRadius(20.0)
.shadow(radius: 10.0, x: 20, y: 10)
TextField(
"FIRST_NAME",
text: $viewModel.firstName
)
.padding()
.cornerRadius(20.0)
.shadow(radius: 10.0, x: 20, y: 10)

TextField("Last Name",
text: $viewModel.lastName)
.padding()
.cornerRadius(20.0)
.shadow(radius: 10.0, x: 20, y: 10)
TextField(
"LAST_NAME",
text: $viewModel.lastName
)
.padding()
.cornerRadius(20.0)
.shadow(radius: 10.0, x: 20, y: 10)

DatePicker("Birthday",
selection: $viewModel.birthday,
displayedComponents: [DatePickerComponents.date])
.padding()
.cornerRadius(20.0)
.shadow(radius: 10.0, x: 20, y: 10)
DatePicker(
"BIRTHDAY",
selection: $viewModel.birthday,
displayedComponents: [DatePickerComponents.date]
)
.padding()
.cornerRadius(20.0)
.shadow(radius: 10.0, x: 20, y: 10)
}

Button(action: {
Expand All @@ -50,11 +56,13 @@ struct ProfileView: View {
}
}
}, label: {
Text("Save Profile")
.font(.headline)
.foregroundColor(.white)
.padding()
.frame(width: 300, height: 50)
Text(
"SAVE_PROFILE"
)
.font(.headline)
.foregroundColor(.white)
.padding()
.frame(width: 300, height: 50)
})
.background(Color(.green))
.cornerRadius(15)
Expand All @@ -66,11 +74,13 @@ struct ProfileView: View {
await loginViewModel.logout()
}
}, label: {
Text("Log Out")
.font(.headline)
.foregroundColor(.white)
.padding()
.frame(width: 300, height: 50)
Text(
"LOG_OUT"
)
.font(.headline)
.foregroundColor(.white)
.padding()
.frame(width: 300, height: 50)
})
.background(Color(.red))
.cornerRadius(15)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,28 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"THREE_FINGER_SWIPE_WEEK" = "Three-finger swipe to go to next or previous week";
"TODAY" = "Today";
"START_SURVEY" = "Start Survey";

// MARK: Login
"APP_NAME" = "CareKit Sample App";
"LOGIN_PICKER" = "Login Picker";
"LOGIN" = "Login";
"LOGIN_ANONYMOUSLY" = "Login Anonymously";
"SIGN_UP" = "Sign Up";
"USERNAME" = "Username";
"PASSWORD" = "Password";
"FIRST_NAME" = "First Name";
"LAST_NAME" = "Last Name";
"ERROR" = "Error";
"OPEN_APP_IPHONE" = "Please open the app on your iPhone";

// MARK: Care View
"NAUSEA_DOXYLAMINE_INTAKE" = "Nausea & Doxylamine Intake";
"THIS_WEEK" = "This Week";
"NAUSEA" = "Nausea";
"DOXYLAMINE" = "Doxylamine";

// MARK: Profile

"BIRTHDAY" = "Birthday";
"SAVE_PROFILE" = "Save Profile";
"LOG_OUT" = "Log Out";
2 changes: 1 addition & 1 deletion OCKWatchSample Extension/Main/Login/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct LoginView: View {
@ObservedObject var viewModel: LoginViewModel

var body: some View {
Text("Please open the OCKSample app on your iPhone")
Text("OPEN_APP_IPHONE")
.multilineTextAlignment(.center)
.padding()
Image(systemName: "apps.iphone")
Expand Down

0 comments on commit 3c2c69b

Please sign in to comment.