From e398e176ce0d1a5fc722c94311caffe2f77b1877 Mon Sep 17 00:00:00 2001 From: LudovicPinel Date: Thu, 25 Jan 2024 11:13:06 +0100 Subject: [PATCH] [#630] Update cards to align buttons when text is too long (#641) * Update all cards with the same Flow * Update chagelog Reviewed-by: Pierre-Yves Lapersonne --- CHANGELOG.md | 1 + .../Components/Cards/ODSCardHorizontal.swift | 21 +++++++++++-------- .../Cards/ODSCardVerticalHeaderFirst.swift | 19 ++++++++++------- .../Cards/ODSCardVerticalImageFirst.swift | 19 ++++++++++------- 4 files changed, 37 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d4ecc25..512c8b13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ 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)) - [Tooling] Upgrate to xcode 15 ([#638](https://github.com/Orange-OpenSource/ods-ios/issues/638)) - [Tooling] Upgrade tools versions and internal librairies ([#639](https://github.com/Orange-OpenSource/ods-ios/issues/639)) - [Docs] Update documentation with illustration ([#602](https://github.com/Orange-OpenSource/ods-ios/issues/602)) diff --git a/OrangeDesignSystem/Sources/OrangeDesignSystem/Components/Cards/ODSCardHorizontal.swift b/OrangeDesignSystem/Sources/OrangeDesignSystem/Components/Cards/ODSCardHorizontal.swift index ee7f6317..9e946686 100644 --- a/OrangeDesignSystem/Sources/OrangeDesignSystem/Components/Cards/ODSCardHorizontal.swift +++ b/OrangeDesignSystem/Sources/OrangeDesignSystem/Components/Cards/ODSCardHorizontal.swift @@ -12,6 +12,7 @@ // import SwiftUI +import Flow /// /// ODS Card. @@ -139,7 +140,7 @@ public struct ODSCardHorizontal: View { public var body: some View { - VStack(spacing: ODSSpacing.none) { + VStack(alignment: .leading, spacing: ODSSpacing.none) { HStack(alignment: .center, spacing: ODSSpacing.none) { if case .leading = imagePosition { image @@ -192,14 +193,16 @@ public struct ODSCardHorizontal: View { if dividerEnabled { Divider() } - - HStack(alignment: .center, spacing: ODSSpacing.none) { - firstButton() - .odsEmphasisButtonStyle(emphasis: .lowest) - secondButton?() - .odsEmphasisButtonStyle(emphasis: .lowest) - - Spacer() + 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) + } } } } diff --git a/OrangeDesignSystem/Sources/OrangeDesignSystem/Components/Cards/ODSCardVerticalHeaderFirst.swift b/OrangeDesignSystem/Sources/OrangeDesignSystem/Components/Cards/ODSCardVerticalHeaderFirst.swift index 9026c926..4ed26b6e 100644 --- a/OrangeDesignSystem/Sources/OrangeDesignSystem/Components/Cards/ODSCardVerticalHeaderFirst.swift +++ b/OrangeDesignSystem/Sources/OrangeDesignSystem/Components/Cards/ODSCardVerticalHeaderFirst.swift @@ -12,6 +12,7 @@ // import SwiftUI +import Flow /// /// ODS Card. @@ -173,13 +174,17 @@ public struct ODSCardVerticalHeaderFirst: View { @ViewBuilder private func buttons() -> some View { if let firstButton = firstButton { - HStack(alignment: .center, spacing: ODSSpacing.none) { - firstButton() - .odsEmphasisButtonStyle(emphasis: .lowest) - secondButton?() - .odsEmphasisButtonStyle(emphasis: .lowest) - - Spacer() + 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) + Spacer() + } } } } diff --git a/OrangeDesignSystem/Sources/OrangeDesignSystem/Components/Cards/ODSCardVerticalImageFirst.swift b/OrangeDesignSystem/Sources/OrangeDesignSystem/Components/Cards/ODSCardVerticalImageFirst.swift index 921a2476..bd9e7c1d 100644 --- a/OrangeDesignSystem/Sources/OrangeDesignSystem/Components/Cards/ODSCardVerticalImageFirst.swift +++ b/OrangeDesignSystem/Sources/OrangeDesignSystem/Components/Cards/ODSCardVerticalImageFirst.swift @@ -12,6 +12,7 @@ // import SwiftUI +import Flow /// /// ODS Card. @@ -145,13 +146,17 @@ public struct ODSCardVerticalImageFirst: View { @ViewBuilder private func buttons() -> some View { if let firstButton = firstButton { - HStack(alignment: .center, spacing: ODSSpacing.none) { - firstButton() - .odsEmphasisButtonStyle(emphasis: .lowest) - secondButton?() - .odsEmphasisButtonStyle(emphasis: .lowest) - - Spacer() + 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) + Spacer() + } } } }