Skip to content

Commit 9597a53

Browse files
ludovic35Copilotpylapp
committed
feat: add inline alert component (#1307) (#1319)
Add inline alert component with tests and documentations. Improve documentation and fix typos. Closes #1307 Assisted-by: GitHub Copilot Reviewed-by: Copilot <198982749+Copilot@users.noreply.github.com> Reviewed-by: Pierre-Yves Lapersonne <pierreyves.lapersonne@orange.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Pierre-Yves Lapersonne <pierreyves.lapersonne@orange.com> Co-authored-by: Ludovic Pinel <ludovic.pinel@orange.com> Signed-off-by: Pierre-Yves Lapersonne <pierreyves.lapersonne@orange.com>
1 parent 58b34e3 commit 9597a53

29 files changed

+400
-83
lines changed

AGENTS.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ Alert message is a UI element that displays system feedback, status changes or r
794794
Its documentation is [available online](https://ios.unified-design-system.orange.com/documentation/oudscomponents/oudsalertmessage).
795795
Alert message can have 1 status between 6: `neutral`, `accent`, `positive`, `info`, `warning`, `negative`. `neutral` and `accent` status can have custom icon.
796796

797-
Alert message bvy default are positive:
797+
Alert message are positive by default:
798798
```swift
799799
OUDSAlertMessage(label: "Label")
800800
```
@@ -806,7 +806,7 @@ OUDSAlertMessage(label: "Warning", status: .warning, description: "Some details
806806
}
807807
```
808808

809-
Alerts can have custom icons, bullet lists and detaim link:
809+
Alerts can have custom icons, bullet lists and detail link:
810810
```swift
811811
OUDSAlertMessage(label: "Label",
812812
status: .neutral(icon: OUDSIcon(asset: Image("ic_heart"))))
@@ -815,6 +815,29 @@ OUDSAlertMessage(label: "Label",
815815
onClose: {})
816816
```
817817

818+
#### Inline Alert
819+
820+
Inline alert is a lightweight UI element, placed in the content flow, that displays information, system feedback, status changes throughout short, prominent,
821+
persistent and non actionable communication.
822+
Inline alert includes functional icon and semantic colour, and does not include a close button and/or action link.
823+
Inline alert does not disappear and remains visible.
824+
825+
It can have only a label (by default at neutral status):
826+
```swift
827+
OUDSInlineAlert(label: "Label")
828+
```
829+
830+
The status can be changed (within `neutral`, `accent`, `positive`, `info`, `warning`, `negative`. `neutral` and `accent`)
831+
```swift
832+
OUDSInlineAlert(label: "Warning", status: .warning)
833+
```
834+
835+
Custom icon can be used for accent and neutral status:
836+
```
837+
OUDSInlineAlert(label: "Label", status: .accent(icon: OUDSIcon(asset: Image("ic_heart"))))
838+
OUDSInlineAlert(label: "Label", status: .neutral(icon: OUDSIcon(asset: Image("ic_heart"))))
839+
```
840+
818841
#### Indicators
819842

820843
##### Badge

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
### Added
1010

11+
- `inline alert` component (Orange-OpenSource/ouds-ios#1307)
1112
- `alert message` component (Orange-OpenSource/ouds-ios#1159)
1213

1314
### Changed

OUDS/Core/Components/Sources/Controls/Checkbox/OUDSCheckboxItem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ import SwiftUI
101101
/// // Never disable a read only or an error-related checkbox as it will crash
102102
/// // This is forbidden by design!
103103
/// OUDSCheckboxItem("Hello world", isOn: $isOn, isError: true).disabled(true) // fatal error
104-
/// OUDSCheckboxItem("Hello world", isOn: $isOn, isReadyOnly: true).disabled(true) // fatal error
104+
/// OUDSCheckboxItem("Hello world", isOn: $isOn, isReadOnly: true).disabled(true) // fatal error
105105
/// ```
106106
///
107107
/// If you need to flip your icon depending to the layout direction or not (e.g. if RTL mode lose semantics / meanings):

OUDS/Core/Components/Sources/Controls/Checkbox/OUDSCheckboxItemIndeterminate.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,18 @@ import SwiftUI
107107
/// // Never disable a read only or an error-related checkbox as it will crash
108108
/// // This is forbidden by design!
109109
/// OUDSCheckboxItemIndeterminate("Hello world", selection: $selection, isError: true).disabled(true) // fatal error
110-
/// OUDSCheckboxItemIndeterminate("Hello world", selection: $selection, isReadyOnly: true).disabled(true) // fatal error
110+
/// OUDSCheckboxItemIndeterminate("Hello world", selection: $selection, isReadOnly: true).disabled(true) // fatal error
111111
/// ```
112112
///
113113
/// If you want to manage the RTL mode quite easily and switch your layouts (flip image, indicator in RTL leading i.e. in the right):
114114
/// ```swift
115115
/// @Environment(\.layoutDirection) var layoutDirection
116116
///
117117
/// OUDSCheckboxItemIndeterminate("Cocorico !",
118-
/// isOn: $selection,
118+
/// selection: $selection,
119119
/// icon: Image(systemName: "figure.handball"),
120120
/// flipIcon: layoutDirection == .rightToLeft,
121-
/// isInversed: layoutDirection == .rightToLeft)
121+
/// isReversed: layoutDirection == .rightToLeft)
122122
/// ```
123123
///
124124
/// ## Suggestions

OUDS/Core/Components/Sources/Controls/Radio/OUDSRadioItem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ import SwiftUI
108108
/// // Never disable a read only or an error-related radio as it will crash
109109
/// // This is forbidden by design!
110110
/// OUDSRadioItem("Kaboom!", isOn: $selection, isError: true).disabled(true) // fatal error
111-
/// OUDSRadioItem("Kaboom!", isOn: $selection, isReadyOnly: true).disabled(true) // fatal error
111+
/// OUDSRadioItem("Kaboom!", isOn: $selection, isReadOnly: true).disabled(true) // fatal error
112112
/// ```
113113
///
114114
/// If you need to flip your icon depending to the layout direction or not (e.g. if RTL mode lose semantics / meanings):

OUDS/Core/Components/Sources/Controls/Switch/OUDSSwitchItem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ import SwiftUI
105105
/// // Never disable a read only or an error-related switch as it will crash
106106
/// // This is forbidden by design!
107107
/// OUDSSwitchItem("Kaboom!", isOn: $isOn, isError: true).disabled(true) // fatal error
108-
/// OUDSSwitchItem("Kaboom!", isOn: $isOn, isReadyOnly: true).disabled(true) // fatal error
108+
/// OUDSSwitchItem("Kaboom!", isOn: $isOn, isReadOnly: true).disabled(true) // fatal error
109109
/// ```
110110
///
111111
/// If you need to flip your icon depending to the layout direction or not (e.g. if RTL mode lose semantics / meanings):

OUDS/Core/Components/Sources/Dialogs/Alert/Internal/AlertMessageLeadingIcon.swift renamed to OUDS/Core/Components/Sources/Dialogs/Alert/Internal/AlertLeadingIcon.swift

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,27 @@
1414
import OUDSTokensSemantic
1515
import SwiftUI
1616

17-
struct AlertMessageLeadingIcon: View {
17+
// MARK: - Alert Leading Icon
18+
struct AlertLeadingIcon: View {
1819

19-
// MARK: - Properties
20+
// MARK: Properties
21+
22+
private let status: OUDSAlertStatus
2023

21-
private let status: OUDSAlertMessage.Status
2224
@Environment(\.theme) private var theme
2325
@Environment(\.dynamicTypeSize) private var dynamicTypeSize: DynamicTypeSize
2426

25-
// MARK: - Initilizer
27+
// MARK: Initilizer
2628

27-
init?(status: OUDSAlertMessage.Status) {
29+
init?(status: OUDSAlertStatus) {
2830
if status.hasIcon {
2931
self.status = status
3032
} else {
3133
return nil
3234
}
3335
}
3436

35-
// MARK: - Body
37+
// MARK: Body
3638

3739
var body: some View {
3840
HStack {
@@ -55,15 +57,16 @@ struct AlertMessageLeadingIcon: View {
5557
}
5658
}
5759
.frame(width: size, height: size)
58-
.padding(.top, theme.alert.spacePaddingBlock)
5960
}
6061

6162
private var size: CGFloat {
6263
theme.alert.sizeIcon * dynamicTypeSize.percentageRate / 100
6364
}
6465
}
6566

66-
extension OUDSAlertMessage.Status {
67+
// MARK: - Extension of OUDS Alert Status
68+
69+
extension OUDSAlertStatus {
6770
var hasIcon: Bool {
6871
switch self {
6972
case let .neutral(icon), let .accent(icon):

OUDS/Core/Components/Sources/Dialogs/Alert/Internal/AlertMessageAction.swift renamed to OUDS/Core/Components/Sources/Dialogs/Alert/Internal/AlertMessage/AlertMessageAction.swift

File renamed without changes.

OUDS/Core/Components/Sources/Dialogs/Alert/Internal/AlertMessageBackgroundModifier.swift renamed to OUDS/Core/Components/Sources/Dialogs/Alert/Internal/AlertMessage/AlertMessageBackgroundModifier.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct AlertMessageBackgroundModifier: ViewModifier {
1818

1919
// MARK: - Properties
2020

21-
let status: OUDSAlertMessage.Status
21+
let status: OUDSAlertStatus
2222

2323
@Environment(\.theme) private var theme
2424

OUDS/Core/Components/Sources/Dialogs/Alert/Internal/AlertMessageBorderModifier.swift renamed to OUDS/Core/Components/Sources/Dialogs/Alert/Internal/AlertMessage/AlertMessageBorderModifier.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct AlertMessageBorderModifier: ViewModifier {
1818

1919
// MARK: - Properties
2020

21-
let status: OUDSAlertMessage.Status
21+
let status: OUDSAlertStatus
2222

2323
@Environment(\.theme) private var theme
2424

0 commit comments

Comments
 (0)