diff --git a/MicrosoftFluentUI.podspec b/MicrosoftFluentUI.podspec index 61e4f87d8..9c5905960 100644 --- a/MicrosoftFluentUI.podspec +++ b/MicrosoftFluentUI.podspec @@ -183,6 +183,14 @@ fi', :execution_position => :before_compile } label_ios.source_files = ["ios/FluentUI/Label/**/*.{swift,h}"] end + s.subspec 'ListItem_ios' do |listitem_ios| + listitem_ios.platform = :ios + listitem_ios.dependency 'MicrosoftFluentUI/OtherCells_ios' + listitem_ios.dependency 'MicrosoftFluentUI/Separator_ios' + listitem_ios.dependency 'MicrosoftFluentUI/TableViewListShared_ios' + listitem_ios.source_files = ["ios/FluentUI/List/**/*.swift"] + end + s.subspec 'MultilineCommandBar_ios' do |multilinecommandbar_ios| multilinecommandbar_ios.platform = :ios multilinecommandbar_ios.dependency 'MicrosoftFluentUI/BottomSheet_ios' @@ -302,10 +310,18 @@ fi', :execution_position => :before_compile } tableview_ios.platform = :ios tableview_ios.dependency 'MicrosoftFluentUI/Label_ios' tableview_ios.dependency 'MicrosoftFluentUI/Separator_ios' + tableview_ios.dependency 'MicrosoftFluentUI/TableViewListShared_ios' tableview_ios.preserve_paths = ["ios/FluentUI/Table View/TableView.resources.xcfilelist"] tableview_ios.source_files = ["ios/FluentUI/Table View/**/*.{swift,h}"] end + s.subspec 'TableViewListShared_ios' do |tableviewlistshared_ios| + tableviewlistshared_ios.platform = :ios + tableviewlistshared_ios.dependency 'MicrosoftFluentUI/Core_ios' + tableviewlistshared_ios.preserve_paths = ["ios/FluentUI/TableViewListShared/TableViewListShared.resources.xcfilelist"] + tableviewlistshared_ios.source_files = ["ios/FluentUI/TableViewListShared/**/*.{swift,h}"] + end + s.subspec 'TextField_ios' do |textfield_ios| textfield_ios.platform = :ios textfield_ios.dependency 'MicrosoftFluentUI/Button_ios' diff --git a/Package.swift b/Package.swift index 3d38139c8..b3b396920 100644 --- a/Package.swift +++ b/Package.swift @@ -42,6 +42,7 @@ let package = Package( "Other Cells/OtherCells.resources.xcfilelist", "Resources/Localization/CultureMapping.json", "Table View/TableView.resources.xcfilelist", + "TableViewListShared/TableViewListShared.resources.xcfilelist", "TextField/TextField.resources.xcfilelist", "Tooltip/Tooltip.resources.xcfilelist", "TwoLineTitleView/TwoLineTitleView.resources.xcfilelist", diff --git a/ios/FluentUI.xcodeproj/project.pbxproj b/ios/FluentUI.xcodeproj/project.pbxproj index 01d8e315e..1ca8afb3d 100644 --- a/ios/FluentUI.xcodeproj/project.pbxproj +++ b/ios/FluentUI.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ 0A84A6F029EDC489005DBC3D /* SeparatorTokenSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A84A6EF29EDC489005DBC3D /* SeparatorTokenSet.swift */; }; 0A8E61FB291DC11F009E412D /* CommandBarTokenSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A8E61FA291DC11F009E412D /* CommandBarTokenSet.swift */; }; 0AE3041D29F721B2003CDDD9 /* TableViewHeaderFooterViewTokenSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE3041C29F721B2003CDDD9 /* TableViewHeaderFooterViewTokenSet.swift */; }; - 2A9745DE281733D700E1A1FD /* TableViewCellTokenSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A9745DD281733D700E1A1FD /* TableViewCellTokenSet.swift */; }; 3A9FC0F52A6AFAD40060A6BE /* BadgeFieldTokenSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A9FC0F42A6AFAD40060A6BE /* BadgeFieldTokenSet.swift */; }; 3A9FC0F72A705C090060A6BE /* PeoplePickerTokenSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A9FC0F62A705C090060A6BE /* PeoplePickerTokenSet.swift */; }; 3AFB0FD629C1365600FEC1A9 /* MultilineCommandBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AFB0FD529C1365600FEC1A9 /* MultilineCommandBar.swift */; }; @@ -242,6 +241,7 @@ F3DFD3612A7B210100014C6E /* ListActionItemModifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3DFD3602A7B210100014C6E /* ListActionItemModifiers.swift */; }; F3F113892A705AD500DA852A /* ListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3F113882A705AD500DA852A /* ListItem.swift */; }; F3F1138D2A705B6900DA852A /* ListItemModifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3F1138C2A705B6900DA852A /* ListItemModifiers.swift */; }; + F5854ED12C220AC100938291 /* TableViewCellTokenSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5854ECF2C220AC100938291 /* TableViewCellTokenSet.swift */; }; FD053A352224CA33009B6378 /* DatePickerControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD053A342224CA33009B6378 /* DatePickerControllerTests.swift */; }; /* End PBXBuildFile section */ @@ -277,7 +277,6 @@ 1168630222E131CF0088B302 /* TabBarItemView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TabBarItemView.swift; sourceTree = ""; }; 1168630322E131CF0088B302 /* TabBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TabBarView.swift; sourceTree = ""; }; 118D9847230BBA2300BC0B72 /* TabBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarItem.swift; sourceTree = ""; }; - 2A9745DD281733D700E1A1FD /* TableViewCellTokenSet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewCellTokenSet.swift; sourceTree = ""; }; 3A9FC0F42A6AFAD40060A6BE /* BadgeFieldTokenSet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeFieldTokenSet.swift; sourceTree = ""; }; 3A9FC0F62A705C090060A6BE /* PeoplePickerTokenSet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeoplePickerTokenSet.swift; sourceTree = ""; }; 3AFB0FD529C1365600FEC1A9 /* MultilineCommandBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultilineCommandBar.swift; sourceTree = ""; }; @@ -465,6 +464,7 @@ F3F113882A705AD500DA852A /* ListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListItem.swift; sourceTree = ""; }; F3F1138C2A705B6900DA852A /* ListItemModifiers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListItemModifiers.swift; sourceTree = ""; }; F5784DB9285D031800DBEAD6 /* docs */ = {isa = PBXFileReference; lastKnownFileType = folder; path = docs; sourceTree = ""; }; + F5854ECF2C220AC100938291 /* TableViewCellTokenSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableViewCellTokenSet.swift; sourceTree = ""; }; FC414E1E258876FB00069E73 /* CommandBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommandBar.swift; sourceTree = ""; }; FC414E242588798000069E73 /* CommandBarButtonGroupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommandBarButtonGroupView.swift; sourceTree = ""; }; FC414E2A25887A4B00069E73 /* CommandBarButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommandBarButton.swift; sourceTree = ""; }; @@ -996,6 +996,7 @@ C0A0D75D233AEA9900F432FD /* Shimmer */, 1168630122E131A20088B302 /* Tab Bar */, B444D6B421825B510002B4D4 /* Table View */, + F5854ED02C220AC100938291 /* TableViewListShared */, EC98E2AB2980C0C000B9DF91 /* TextField */, FD7DF05A21FA7F3200857267 /* Tooltip */, 5314DFF325F006060099271A /* TouchForwardingView */, @@ -1088,7 +1089,6 @@ isa = PBXGroup; children = ( B498141321E424920077B48D /* TableViewCell.swift */, - 2A9745DD281733D700E1A1FD /* TableViewCellTokenSet.swift */, B4EF66502294A664007FEAB0 /* TableViewHeaderFooterView.swift */, 0AE3041C29F721B2003CDDD9 /* TableViewHeaderFooterViewTokenSet.swift */, ); @@ -1209,6 +1209,14 @@ path = List; sourceTree = ""; }; + F5854ED02C220AC100938291 /* TableViewListShared */ = { + isa = PBXGroup; + children = ( + F5854ECF2C220AC100938291 /* TableViewCellTokenSet.swift */, + ); + path = TableViewListShared; + sourceTree = ""; + }; FC414E1D258876D400069E73 /* Command Bar */ = { isa = PBXGroup; children = ( @@ -1571,6 +1579,7 @@ 3A9FC0F52A6AFAD40060A6BE /* BadgeFieldTokenSet.swift in Sources */, 5314E30325F0260E0099271A /* AccessibleViewDelegate.swift in Sources */, 6EB4B25F270ED6B30005B808 /* BadgeLabel.swift in Sources */, + F5854ED12C220AC100938291 /* TableViewCellTokenSet.swift in Sources */, EC98E2B2298D97EC00B9DF91 /* TextFieldTokenSet.swift in Sources */, 9231491528BF026A001B033E /* HUD.swift in Sources */, 5314E1A725F01A7C0099271A /* ActionsCell.swift in Sources */, @@ -1660,7 +1669,6 @@ EC5982D827BF348700FD048D /* MSFAvatar.swift in Sources */, 5314E0AA25F010070099271A /* DrawerShadowView.swift in Sources */, 4BDBE18928EC9E6F00314696 /* ShimmerTokenSet.swift in Sources */, - 2A9745DE281733D700E1A1FD /* TableViewCellTokenSet.swift in Sources */, 530D9C5127EE388200BDCBBF /* SwiftUI+ViewPresentation.swift in Sources */, 92ECB2DD2BE069D100404D79 /* Color+DynamicColor.swift in Sources */, 6F050B6D29D3D1A90070D3D5 /* TabBarTokenSet.swift in Sources */, diff --git a/ios/FluentUI/Table View/TableView.resources.xcfilelist b/ios/FluentUI/Table View/TableView.resources.xcfilelist index b15012e23..0725233e4 100644 --- a/ios/FluentUI/Table View/TableView.resources.xcfilelist +++ b/ios/FluentUI/Table View/TableView.resources.xcfilelist @@ -1,6 +1 @@ -checkmark-24x24.imageset chevron-right-20x20.imageset -iOS-chevron-right-20x20.imageset -more-24x24.imageset -selection-off.imageset -selection-on.imageset diff --git a/ios/FluentUI/Table View/TableViewCell.swift b/ios/FluentUI/Table View/TableViewCell.swift index 9bd2ff97f..134294d74 100644 --- a/ios/FluentUI/Table View/TableViewCell.swift +++ b/ios/FluentUI/Table View/TableViewCell.swift @@ -5,85 +5,6 @@ import UIKit -// MARK: TableViewCellAccessoryType - -@objc(MSFTableViewCellAccessoryType) -public enum TableViewCellAccessoryType: Int { - case none - case disclosureIndicator - case detailButton - case checkmark - - private struct Constants { - static let horizontalSpacing: CGFloat = 16 - static let height: CGFloat = 44 - } - - var icon: UIImage? { - let icon: UIImage? - switch self { - case .none: - icon = nil - case .disclosureIndicator: - icon = UIImage.staticImageNamed("iOS-chevron-right-20x20") - case .detailButton: - icon = UIImage.staticImageNamed("more-24x24") - case .checkmark: - icon = UIImage.staticImageNamed("checkmark-24x24") - } - return icon - } - - func iconColor(tokenSet: TableViewCellTokenSet, fluentTheme: FluentTheme) -> UIColor? { - switch self { - case .none: - return nil - case .disclosureIndicator: - return tokenSet[.accessoryDisclosureIndicatorColor].uiColor - case .detailButton: - return tokenSet[.accessoryDetailButtonColor].uiColor - case .checkmark: - return tokenSet[.accessoryCheckmarkColor].uiColor - } - } - - var size: CGSize { - if self == .none { - return .zero - } - // Horizontal spacing includes 16pt spacing from content to icon and 16pt spacing from icon to trailing edge of cell - let horizontalSpacing: CGFloat = Constants.horizontalSpacing * 2 - let iconWidth: CGFloat = icon?.size.width ?? 0 - return CGSize(width: horizontalSpacing + iconWidth, height: Constants.height) - } -} - -// Different background color is used for `TableViewCell` by getting the appropriate tokens and integrate with the cell's `UIBackgroundConfiguration` -@objc(MSFTableViewCellBackgroundStyleType) -public enum TableViewCellBackgroundStyleType: Int { - // use for flat list of cells - case plain - // use for grouped list of cells - case grouped - // clear background so that TableView's background can be shown - case clear - // in case clients want to override the background on their own without using token system - case custom - - func defaultColor(tokenSet: TableViewCellTokenSet) -> UIColor? { - switch self { - case .plain: - return tokenSet[.cellBackgroundColor].uiColor - case .grouped: - return tokenSet[.cellBackgroundGroupedColor].uiColor - case .clear: - return .clear - case .custom: - return nil - } - } -} - // Supported vertical alignment for accessory views in `TableViewCell` @objc(MSFTableViewCellAccessoryViewVerticalAlignment) public enum TableViewCellAccessoryViewVerticalAlignment: Int { diff --git a/ios/FluentUI/Table View/TableViewCellTokenSet.swift b/ios/FluentUI/TableViewListShared/TableViewCellTokenSet.swift similarity index 79% rename from ios/FluentUI/Table View/TableViewCellTokenSet.swift rename to ios/FluentUI/TableViewListShared/TableViewCellTokenSet.swift index 321dad9f9..87e4bc5b4 100644 --- a/ios/FluentUI/Table View/TableViewCellTokenSet.swift +++ b/ios/FluentUI/TableViewListShared/TableViewCellTokenSet.swift @@ -284,3 +284,82 @@ extension TableViewCellTokenSet { case small case medium } + +// MARK: TableViewCellAccessoryType + +@objc(MSFTableViewCellAccessoryType) +public enum TableViewCellAccessoryType: Int { + case none + case disclosureIndicator + case detailButton + case checkmark + + private struct Constants { + static let horizontalSpacing: CGFloat = 16 + static let height: CGFloat = 44 + } + + var icon: UIImage? { + let icon: UIImage? + switch self { + case .none: + icon = nil + case .disclosureIndicator: + icon = UIImage.staticImageNamed("iOS-chevron-right-20x20") + case .detailButton: + icon = UIImage.staticImageNamed("more-24x24") + case .checkmark: + icon = UIImage.staticImageNamed("checkmark-24x24") + } + return icon + } + + func iconColor(tokenSet: TableViewCellTokenSet, fluentTheme: FluentTheme) -> UIColor? { + switch self { + case .none: + return nil + case .disclosureIndicator: + return tokenSet[.accessoryDisclosureIndicatorColor].uiColor + case .detailButton: + return tokenSet[.accessoryDetailButtonColor].uiColor + case .checkmark: + return tokenSet[.accessoryCheckmarkColor].uiColor + } + } + + var size: CGSize { + if self == .none { + return .zero + } + // Horizontal spacing includes 16pt spacing from content to icon and 16pt spacing from icon to trailing edge of cell + let horizontalSpacing: CGFloat = Constants.horizontalSpacing * 2 + let iconWidth: CGFloat = icon?.size.width ?? 0 + return CGSize(width: horizontalSpacing + iconWidth, height: Constants.height) + } +} + +// Different background color is used for `TableViewCell` by getting the appropriate tokens and integrate with the cell's `UIBackgroundConfiguration` +@objc(MSFTableViewCellBackgroundStyleType) +public enum TableViewCellBackgroundStyleType: Int { + // use for flat list of cells + case plain + // use for grouped list of cells + case grouped + // clear background so that TableView's background can be shown + case clear + // in case clients want to override the background on their own without using token system + case custom + + func defaultColor(tokenSet: TableViewCellTokenSet) -> UIColor? { + switch self { + case .plain: + return tokenSet[.cellBackgroundColor].uiColor + case .grouped: + return tokenSet[.cellBackgroundGroupedColor].uiColor + case .clear: + return .clear + case .custom: + return nil + } + } +} diff --git a/ios/FluentUI/TableViewListShared/TableViewListShared.resources.xcfilelist b/ios/FluentUI/TableViewListShared/TableViewListShared.resources.xcfilelist new file mode 100644 index 000000000..ff870ded8 --- /dev/null +++ b/ios/FluentUI/TableViewListShared/TableViewListShared.resources.xcfilelist @@ -0,0 +1,5 @@ +checkmark-24x24.imageset +iOS-chevron-right-20x20.imageset +more-24x24.imageset +selection-off.imageset +selection-on.imageset