From c4d0c05c4cdc56db2a62fac154ebac7a7b76943b Mon Sep 17 00:00:00 2001 From: Alexander Boswell Date: Fri, 21 Nov 2025 15:58:36 -0800 Subject: [PATCH 1/4] save changes --- .../FluentUI_iOS/Components/List/ListItem.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Sources/FluentUI_iOS/Components/List/ListItem.swift b/Sources/FluentUI_iOS/Components/List/ListItem.swift index bc6f10f1b..0b936840e 100644 --- a/Sources/FluentUI_iOS/Components/List/ListItem.swift +++ b/Sources/FluentUI_iOS/Components/List/ListItem.swift @@ -217,6 +217,7 @@ public struct ListItem Color { + let tokenSet = ListItemTokenSet(customViewSize: { .default }) + switch backgroundStyle { + case .grouped: + return Color(uiColor: tokenSet[.cellBackgroundGroupedColor].uiColor) + case .plain: + return Color(uiColor: tokenSet[.cellBackgroundColor].uiColor) + case .clear, .custom: + return .clear + } + } } public extension ListItem { From 8066bc246fc9a365df9bf434956513858f3cd99b Mon Sep 17 00:00:00 2001 From: Alexander Boswell Date: Mon, 24 Nov 2025 10:15:45 -0800 Subject: [PATCH 2/4] address comments --- .../Components/List/FluentList.swift | 6 +-- .../Components/List/ListItem.swift | 16 +------ .../ListItemTokenSet.swift | 42 +++++++++++++++++++ 3 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 Sources/FluentUI_iOS/Components/TableViewListShared/ListItemTokenSet.swift diff --git a/Sources/FluentUI_iOS/Components/List/FluentList.swift b/Sources/FluentUI_iOS/Components/List/FluentList.swift index bee4edd8e..524289d77 100644 --- a/Sources/FluentUI_iOS/Components/List/FluentList.swift +++ b/Sources/FluentUI_iOS/Components/List/FluentList.swift @@ -48,16 +48,14 @@ public struct FluentList: View { list .listStyle(.insetGrouped) .scrollContentBackground(.hidden) - // TODO: Directly use `FluentList` token set instead of `ListItem` - .background(ListItem.listBackgroundColor(for: .grouped)) + .background(ListItemTokenSet.listBackgroundColor(for: .grouped)) .listSectionSpacing(GlobalTokens.spacing(.size160)) .environment(\.defaultMinListHeaderHeight, GlobalTokens.spacing(.size320)) case .plain: list .listStyle(.plain) .scrollContentBackground(.hidden) - // TODO: Directly use `FluentList` token set instead of `ListItem` - .background(ListItem.listBackgroundColor(for: .plain)) + .background(ListItemTokenSet.listBackgroundColor(for: .plain)) } } diff --git a/Sources/FluentUI_iOS/Components/List/ListItem.swift b/Sources/FluentUI_iOS/Components/List/ListItem.swift index 0b936840e..7b4351a4f 100644 --- a/Sources/FluentUI_iOS/Components/List/ListItem.swift +++ b/Sources/FluentUI_iOS/Components/List/ListItem.swift @@ -502,24 +502,10 @@ public extension ListItem where DetailedContent == EmptyView { /// Provide defaults for generic types so static methods can be called without needing to specify them. public extension ListItem where LeadingContent == EmptyView, TrailingContent == EmptyView, DetailedContent == EmptyView, Title == String, Subtitle == String, Footer == String { - /// The background color of `List` based on the style. - /// - Parameter backgroundStyle: The background style of the `List`. - /// - Returns: The color to use for the background of `List`. - static func listBackgroundColor(for backgroundStyle: ListItemBackgroundStyleType) -> Color { - let tokenSet = ListItemTokenSet(customViewSize: { .default }) - switch backgroundStyle { - case .grouped: - return Color(uiColor: tokenSet[.backgroundGroupedColor].uiColor) - case .plain: - return Color(uiColor: tokenSet[.backgroundColor].uiColor) - case .clear, .custom: - return .clear - } - } - /// The background color of `ListItem` based on the style. /// - Parameter backgroundStyle: The background style of the `List`. /// - Returns: The color to use for the background of `ListItem`. + @available(*, deprecated, renamed: "ListItemTokenSet.listItemBackgroundColor(for:)") static func listItemBackgroundColor(for backgroundStyle: ListItemBackgroundStyleType) -> Color { let tokenSet = ListItemTokenSet(customViewSize: { .default }) switch backgroundStyle { diff --git a/Sources/FluentUI_iOS/Components/TableViewListShared/ListItemTokenSet.swift b/Sources/FluentUI_iOS/Components/TableViewListShared/ListItemTokenSet.swift new file mode 100644 index 000000000..285fdf880 --- /dev/null +++ b/Sources/FluentUI_iOS/Components/TableViewListShared/ListItemTokenSet.swift @@ -0,0 +1,42 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// + +#if canImport(FluentUI_common) +import FluentUI_common +#endif +import SwiftUI + +// SwiftUI specific APIs on top of TableViewCellTokenSet +extension ListItemTokenSet { + /// The background color of `List` based on the style. + /// - Parameter backgroundStyle: The background style of the `List`. + /// - Returns: The color to use for the background of `List`. + static func listBackgroundColor(for backgroundStyle: ListItemBackgroundStyleType) -> Color { + let tokenSet = ListItemTokenSet(customViewSize: { .default }) + switch backgroundStyle { + case .grouped: + return Color(uiColor: tokenSet[.backgroundGroupedColor].uiColor) + case .plain: + return Color(uiColor: tokenSet[.backgroundColor].uiColor) + case .clear, .custom: + return .clear + } + } + + /// The background color of `ListItem` based on the style. + /// - Parameter backgroundStyle: The background style of the `List`. + /// - Returns: The color to use for the background of `ListItem`. + static func listItemBackgroundColor(for backgroundStyle: ListItemBackgroundStyleType) -> Color { + let tokenSet = ListItemTokenSet(customViewSize: { .default }) + switch backgroundStyle { + case .grouped: + return Color(uiColor: tokenSet[.cellBackgroundGroupedColor].uiColor) + case .plain: + return Color(uiColor: tokenSet[.cellBackgroundColor].uiColor) + case .clear, .custom: + return .clear + } + } +} From e255abae2bbad26a6805af35f399fd5e0c28176e Mon Sep 17 00:00:00 2001 From: Alexander Boswell Date: Mon, 24 Nov 2025 10:18:08 -0800 Subject: [PATCH 3/4] fix --- Sources/FluentUI_iOS/Components/List/ListItem.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/FluentUI_iOS/Components/List/ListItem.swift b/Sources/FluentUI_iOS/Components/List/ListItem.swift index 7b4351a4f..9c7e7c2cd 100644 --- a/Sources/FluentUI_iOS/Components/List/ListItem.swift +++ b/Sources/FluentUI_iOS/Components/List/ListItem.swift @@ -502,17 +502,17 @@ public extension ListItem where DetailedContent == EmptyView { /// Provide defaults for generic types so static methods can be called without needing to specify them. public extension ListItem where LeadingContent == EmptyView, TrailingContent == EmptyView, DetailedContent == EmptyView, Title == String, Subtitle == String, Footer == String { - /// The background color of `ListItem` based on the style. + /// The background color of `List` based on the style. /// - Parameter backgroundStyle: The background style of the `List`. - /// - Returns: The color to use for the background of `ListItem`. - @available(*, deprecated, renamed: "ListItemTokenSet.listItemBackgroundColor(for:)") - static func listItemBackgroundColor(for backgroundStyle: ListItemBackgroundStyleType) -> Color { + /// - Returns: The color to use for the background of `List`. + @available(*, deprecated, renamed: "ListItemTokenSet.listBackgroundColor(for:)") + static func listBackgroundColor(for backgroundStyle: ListItemBackgroundStyleType) -> Color { let tokenSet = ListItemTokenSet(customViewSize: { .default }) switch backgroundStyle { case .grouped: - return Color(uiColor: tokenSet[.cellBackgroundGroupedColor].uiColor) + return Color(uiColor: tokenSet[.backgroundGroupedColor].uiColor) case .plain: - return Color(uiColor: tokenSet[.cellBackgroundColor].uiColor) + return Color(uiColor: tokenSet[.backgroundColor].uiColor) case .clear, .custom: return .clear } From 335bac796f9e07bfde61208502a51b1659f7177b Mon Sep 17 00:00:00 2001 From: Alexander Boswell Date: Mon, 24 Nov 2025 11:57:32 -0800 Subject: [PATCH 4/4] remove public alias --- Sources/FluentUI_iOS/Components/List/ListItem.swift | 6 ------ .../Components/TableViewListShared/ListItemTokenSet.swift | 7 ++++++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Sources/FluentUI_iOS/Components/List/ListItem.swift b/Sources/FluentUI_iOS/Components/List/ListItem.swift index 9c7e7c2cd..7995e16d7 100644 --- a/Sources/FluentUI_iOS/Components/List/ListItem.swift +++ b/Sources/FluentUI_iOS/Components/List/ListItem.swift @@ -8,12 +8,6 @@ import FluentUI_common #endif import SwiftUI -public typealias ListItemAccessoryType = TableViewCellAccessoryType -public typealias ListItemBackgroundStyleType = TableViewCellBackgroundStyleType -public typealias ListItemLeadingContentSize = MSFTableViewCellCustomViewSize -public typealias ListItemTokenSet = TableViewCellTokenSet -public typealias ListItemToken = TableViewCellToken - /// View that represents an item in a List. public struct ListItem