Skip to content

Commit

Permalink
review: rename Label to LabelText
Browse files Browse the repository at this point in the history
  • Loading branch information
ludovic35 committed Feb 5, 2025
1 parent dc7ccdf commit 637c45a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ final class SwitchConfigurationModel: ComponentConfiguration {
@Published var orientation: OUDSSwitch.Orientation {
didSet { updateCode() }
}
@Published var labelContent: String
@Published var labelTextContent: String
@Published var helperTextContent: String

// MARK: Initializer
Expand All @@ -55,7 +55,7 @@ final class SwitchConfigurationModel: ComponentConfiguration {
onError = false
divider = true
orientation = .default
labelContent = String(localized: "app_components_switch_label_text")
labelTextContent = String(localized: "app_components_switch_labelText_text")
helperTextContent = String(localized: "app_components_switch_helperText_text")
}

Expand Down Expand Up @@ -85,7 +85,7 @@ final class SwitchConfigurationModel: ComponentConfiguration {

private var helperTextPatern: String {
if helperText {
return ",helperText: \(String(localized: "app_components_switch_helperText_text"))"
return ", helperText: \(String(localized: "app_components_switch_helperText_text"))"
} else {
return ""
}
Expand Down Expand Up @@ -163,7 +163,7 @@ struct SwitchConfiguration: View {
}

DisclosureGroup("app_components_common_editContent_label") {
DesignToolboxTextField(text: $model.labelContent, prompt: "app_components_common_userText_prompt", title: "app_components_switch_label_text")
DesignToolboxTextField(text: $model.labelTextContent, prompt: "app_components_common_userText_prompt", title: "app_components_switch_labelText_label")
if model.helperText {
DesignToolboxTextField(text: $model.helperTextContent, prompt: "app_components_common_userText_prompt", title: "app_components_common_helperText_label")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private struct SwitchDemo: View {
} else {
OUDSSwitch(
isOn: $isOn,
label: model.labelContent,
labelText: model.labelTextContent,
helperText: helperTextContent,
icon: icon,
onError: model.onError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"app_components_common_style_label" = "Style";
"app_components_common_onColoredBackground_label" = "On colored background";
"app_components_common_helperText_label" = "Helper text";
"app_components_common_labelText_label" = "Label text";
"app_components_common_icon_label" = "Icon";
"app_components_common_divider_label" = "Divider";
"app_components_common_onError_label" = "On error";
Expand Down Expand Up @@ -143,6 +144,6 @@

"app_components_switch_label" = "Switch";
"app_components_switch_description_text" = "A switch is a component that allows the user to toggle between two states, typically \"on\" and \"off\". It is often represented as a button or a slider that changes position or color to indicate the current state. Switches are used to enable or disable features, options, or settings in an intuitive and visual manner.";
"app_components_switch_label_text" = "Label";
"app_components_switch_switchOnly_label" = "Switch only";
"app_components_switch_labelText_text" = "Label text";
"app_components_switch_helperText_text" = "Helper text";
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct OUDSSwitchLabel: View {
@Environment(\.colorScheme) private var colorScheme

struct Label {
let label: String
let labelText: String
let helperText: String?
let icon: Image?
let onError: Bool
Expand Down Expand Up @@ -68,7 +68,7 @@ struct OUDSSwitchLabel: View {
@ViewBuilder
private var texts: some View {
VStack(alignment: .leading, spacing: 0) {
Text(LocalizedStringKey(label.label))
Text(LocalizedStringKey(label.labelText))
.typeLabelDefaultLarge(theme)
.multilineTextAlignment(.leading)
.foregroundStyle(labelColor)
Expand Down
6 changes: 3 additions & 3 deletions OUDS/Core/Components/Sources/Switch/OUDSSwitch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ public struct OUDSSwitch: View {
/// - Parameters:
/// - isOn: A binding to a property that determines whether the switch is on
/// or off.
/// - label: The main label of the switch.
/// - labelText: The main label text of the switch.
/// - helperText: An additonal helper text.
/// - icon: An optional icon
/// - onError: It the option is on error
/// - divider: If true a divider is added at the bottom of the view.
/// - orientation: Specify the orientation of the layout. If Default the switch at the leading position, if inverse it is on trailing.
public init(isOn: Binding<Bool>, label: String, helperText: String? = nil, icon: Image? = nil, onError: Bool = false, divider: Bool = false, orientation: Orientation = .default) {
public init(isOn: Binding<Bool>, labelText: String, helperText: String? = nil, icon: Image? = nil, onError: Bool = false, divider: Bool = false, orientation: Orientation = .default) {
self.isOn = isOn
self.layout = .labeled(.init(label: label, helperText: helperText, icon: icon, onError: onError, divider: divider, orientation: orientation))
self.layout = .labeled(.init(labelText: labelText, helperText: helperText, icon: icon, onError: onError, divider: divider, orientation: orientation))
}
// swiftlint:enable line_length

Expand Down

0 comments on commit 637c45a

Please sign in to comment.