From 13d20113090a512d18cd97e8c0f613b72ff1cef3 Mon Sep 17 00:00:00 2001 From: LudovicPinel Date: Thu, 25 Jan 2024 11:54:26 +0100 Subject: [PATCH] [#642] Update Banners to align buttons when text is too long (#645) * Update flow * Update chagelog Reviewed-by: Pierre-Yves Lapersonne --- CHANGELOG.md | 3 ++- .../Components/Banner/ODSBanner.swift | 20 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fde2965..5209fc44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased](https://github.com/Orange-OpenSource/ods-ios/compare/0.16.0...qualif) -- [SDK] Update cards to align buttons when text is too long ([#630](https://github.com/Orange-OpenSource/ods-ios/issues/6380)) +- [SDK] Update Banners to align buttons when text is too long ([#642](https://github.com/Orange-OpenSource/ods-ios/issues/642)) +- [SDK] Update Cards to align buttons when text is too long ([#630](https://github.com/Orange-OpenSource/ods-ios/issues/630)) - [Tooling] Upgrate to xcode 15 ([#638](https://github.com/Orange-OpenSource/ods-ios/issues/638)) - [DemoApp/SDK] ODSSmallCard and GridOfSmallCards a11i issue if accessible text sizes in use ([#598](https://github.com/Orange-OpenSource/ods-ios/issues/598)) - [Tooling] Upgrade to Xcode 15 ([#638](https://github.com/Orange-OpenSource/ods-ios/issues/638)) diff --git a/OrangeDesignSystem/Sources/OrangeDesignSystem/Components/Banner/ODSBanner.swift b/OrangeDesignSystem/Sources/OrangeDesignSystem/Components/Banner/ODSBanner.swift index 570a47a0..f71324da 100644 --- a/OrangeDesignSystem/Sources/OrangeDesignSystem/Components/Banner/ODSBanner.swift +++ b/OrangeDesignSystem/Sources/OrangeDesignSystem/Components/Banner/ODSBanner.swift @@ -12,6 +12,7 @@ // import SwiftUI +import Flow /// A banner displays an important message which requires an /// action to be dismissed. @@ -105,7 +106,7 @@ public struct ODSBanner: View { .padding(.bottom, firstButton == nil ? ODSSpacing.m : ODSSpacing.none) .padding(.horizontal, ODSSpacing.m) - bottomButtons() + buttons() } Divider() @@ -117,13 +118,18 @@ public struct ODSBanner: View { // ============= @ViewBuilder - private func bottomButtons() -> some View { + private func buttons() -> some View { if let firstButton = firstButton { - HStack(spacing: ODSSpacing.none) { - firstButton() - .odsEmphasisButtonStyle(emphasis: .lowest) - secondButton?() - .odsEmphasisButtonStyle(emphasis: .lowest) + if #available(iOS 16.0, *) { + HFlow(alignment: .top, spacing: ODSSpacing.none) { + firstButton().odsEmphasisButtonStyle(emphasis: .lowest) + secondButton?().odsEmphasisButtonStyle(emphasis: .lowest) + } + } else { + HStack(alignment: .center, spacing: ODSSpacing.none) { + firstButton().odsEmphasisButtonStyle(emphasis: .lowest) + secondButton?().odsEmphasisButtonStyle(emphasis: .lowest) + } } } }