Skip to content

Commit

Permalink
Add text field for Button
Browse files Browse the repository at this point in the history
  • Loading branch information
ludovic35 committed Feb 3, 2025
1 parent 2c79e5a commit 61011bd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased](https://github.com/Orange-OpenSource/ouds-ios/compare/0.10.0...develop)

### Added
- [DesignToolbox] Add Text field in component configuration to customize text ([#436](https://github.com/Orange-OpenSource/ouds-ios/issues/436))

## [0.10.0](https://github.com/Orange-OpenSource/ouds-ios/compare/0.9.0...0.10.0) - 2025-01-30

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ final class ButtonConfigurationModel: ComponentConfiguration {
didSet { updateCode() }
}

@Published var text: String {
didSet { updateCode() }
}

@Published var layout: ButtonLayout {
didSet { updateCode() }
}
Expand All @@ -41,6 +45,7 @@ final class ButtonConfigurationModel: ComponentConfiguration {

override init() {
self.enabled = true
self.text = String(localized: "app_components_button_label")
self.layout = .textOnly
self.hierarchy = .default
self.style = .`default`
Expand Down Expand Up @@ -194,6 +199,21 @@ struct ButtonConfiguration: View {
}
.pickerStyle(.segmented)
}

if model.layout == .iconAndText || model.layout == .textOnly {
VStack(alignment: .leading) {
Text(LocalizedStringKey("app_component_common_userText_text"))
.typeHeadingMedium(theme)
.foregroundStyle(theme.colors.colorContentDefault.color(for: colorScheme))

TextField(text: $model.text) {
Text("app_component_common_userText_prompt")
}
}
.accessibilityElement(children: .combine)
.accessibilityLabel(Text("app_component_common_userText_prompt"))
.accessibilityValue(model.text)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ private struct ButtonDemo: View {
case .iconOnly:
OUDSButton(icon: Image(decorative: "ic_heart"), hierarchy: model.hierarchy, style: model.style) {}
case .textOnly:
OUDSButton(text: "app_components_button_label", hierarchy: model.hierarchy, style: model.style) {}
OUDSButton(text: model.text, hierarchy: model.hierarchy, style: model.style) {}
case .iconAndText:
OUDSButton(icon: Image(decorative: "ic_heart"), text: "app_components_button_label", hierarchy: model.hierarchy, style: model.style) {}
OUDSButton(icon: Image(decorative: "ic_heart"), text: model.text, hierarchy: model.hierarchy, style: model.style) {}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@

"app_component_emptyContent_text" = "No content";
"app_component_emptyContent_description_text" = "This content is under construction and will be available very soon";

"app_component_common_userText_prompt" = "Enter a text";
"app_component_common_userText_text" = "Text";

// MARK: Components: button
"app_components_button_label" = "Button";
Expand Down

0 comments on commit 61011bd

Please sign in to comment.