add localized strings to custom widget view

edit save / use buttons for custom widget
This commit is contained in:
Trey t
2022-02-27 15:58:47 -06:00
parent 0ff2ef8fba
commit 2e92d89faf
3 changed files with 42 additions and 62 deletions

View File

@@ -12,11 +12,11 @@ struct CreateWidgetView: View {
@Environment(\.dismiss) var dismiss
@StateObject private var customWidget: CustomWidgetModel
@State private var mouth: CustomWidgetMouthOptions = CustomWidgetMouthOptions.defaultOption
@State var widgetView: CustomWidgetView
private var randomElements: [AnyView]
init(customWidget: CustomWidgetModel, randomElements: [AnyView] = [AnyView]()) {
@@ -106,7 +106,7 @@ struct CreateWidgetView: View {
HStack(alignment: .center) {
Spacer()
VStack(alignment: .center) {
Menu("Left Eye") {
Menu(String(localized: "create_widget_view_left_eye")) {
ForEach(CustomWidgetEyeOptions.allCases, id: \.self) { option in
Button(action: {
update(eye: .left, eyeOption: option)
@@ -119,7 +119,7 @@ struct CreateWidgetView: View {
}
Spacer()
VStack(alignment: .center) {
Menu("Right Eye") {
Menu(String(localized: "create_widget_view_right_eye")) {
ForEach(CustomWidgetEyeOptions.allCases, id: \.self) { option in
Button(action: {
update(eye: .right, eyeOption: option)
@@ -132,7 +132,7 @@ struct CreateWidgetView: View {
}
Spacer()
VStack(alignment: .center) {
Menu("Mouth") {
Menu(String(localized: "create_widget_view_mouth")) {
ForEach(CustomWidgetMouthOptions.allCases, id: \.self) { option in
Button(action: {
update(mouthOption: option)
@@ -186,21 +186,21 @@ struct CreateWidgetView: View {
VStack {
HStack(spacing: 0) {
VStack(alignment: .center) {
Text("background")
Text(String(localized: "create_widget_background_color"))
ColorPicker("", selection: $customWidget.bgColor)
.labelsHidden()
}
.frame(minWidth: 0, maxWidth: .infinity)
VStack(alignment: .center) {
Text("Inner")
Text(String(localized: "create_widget_inner_color"))
ColorPicker("", selection: $customWidget.innerColor)
.labelsHidden()
}
.frame(minWidth: 0, maxWidth: .infinity)
VStack(alignment: .center) {
Text("Face Outline")
Text(String(localized: "create_widget_face_outline_color"))
ColorPicker("", selection: $customWidget.circleStrokeColor)
.labelsHidden()
}
@@ -209,21 +209,21 @@ struct CreateWidgetView: View {
HStack(spacing: 0) {
VStack(alignment: .center) {
Text("Left Eye")
Text(String(localized: "create_widget_view_left_eye_color"))
ColorPicker("", selection: $customWidget.leftEyeColor)
.labelsHidden()
}
.frame(minWidth: 0, maxWidth: .infinity)
VStack(alignment: .center) {
Text("right eye")
Text(String(localized: "create_widget_view_right_eye_color"))
ColorPicker("", selection: $customWidget.rightEyeColor)
.labelsHidden()
}
.frame(minWidth: 0, maxWidth: .infinity)
VStack(alignment: .center) {
Text("mouth")
Text(String(localized: "create_widget_view_mouth_color"))
ColorPicker("", selection: $customWidget.mouthColor)
.labelsHidden()
}
@@ -253,12 +253,12 @@ struct CreateWidgetView: View {
.background(.blue)
Button(action: {
UserDefaultsStore.saveCustomWidget(widgetModel: customWidget, inUse: true)
UserDefaultsStore.saveCustomWidget(widgetModel: customWidget, inUse: false)
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
impactMed.impactOccurred()
dismiss()
}, label: {
Text("Save")
Text(String(localized: "create_widget_save"))
.font(.title)
.fontWeight(.bold)
.foregroundColor(Color(UIColor.white))
@@ -268,23 +268,23 @@ struct CreateWidgetView: View {
.frame(height: 40)
.background(.green)
if customWidget.isSaved {
Button(action: {
UserDefaultsStore.makeWidgetCurrent(withUUID: customWidget.uuid)
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
impactMed.impactOccurred()
dismiss()
}, label: {
Text("Use")
.font(.title)
.fontWeight(.bold)
.foregroundColor(Color(UIColor.white))
})
.frame(height: 40)
.frame(minWidth: 0, maxWidth: .infinity)
.background(.pink)
Button(action: {
UserDefaultsStore.saveCustomWidget(widgetModel: customWidget, inUse: true)
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
impactMed.impactOccurred()
dismiss()
}, label: {
Text(String(localized: "create_widget_use"))
.font(.title)
.fontWeight(.bold)
.foregroundColor(Color(UIColor.white))
})
.frame(height: 40)
.frame(minWidth: 0, maxWidth: .infinity)
.background(.pink)
if customWidget.isSaved {
Button(action: {
UserDefaultsStore.deleteCustomWidget(withUUID: customWidget.uuid)
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
@@ -299,7 +299,6 @@ struct CreateWidgetView: View {
.frame(height: 40)
.frame(minWidth: 0, maxWidth: .infinity)
.background(.orange)
}
}
}