Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[List Item] Add animation when adding or removing subtitle/footer #2046

Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 52 additions & 33 deletions ios/FluentUI/List/ListItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,42 +47,60 @@ public struct ListItem<LeadingContent: View,
tokenSet.update(fluentTheme)

@ViewBuilder
var labelStack: some View {
let titleView = Text(title)
.foregroundColor(Color(uiColor: tokenSet[.titleColor].uiColor))
.font(Font(tokenSet[.titleFont].uiFont))
.frame(minHeight: ListItemTokenSet.titleHeight)
.lineLimit(titleLineLimit)
.truncationMode(titleTruncationMode)
.accessibilityIdentifier(AccessibilityIdentifiers.title)
var titleView: some View {
Text(title)
.foregroundColor(Color(uiColor: tokenSet[.titleColor].uiColor))
.font(Font(tokenSet[.titleFont].uiFont))
.frame(minHeight: ListItemTokenSet.titleHeight)
.lineLimit(titleLineLimit)
.truncationMode(titleTruncationMode)
.accessibilityIdentifier(AccessibilityIdentifiers.title)
}

@ViewBuilder
var subtitleView: some View {
let subtitleView = Text(subtitle)
.foregroundColor(Color(uiColor: tokenSet[.subtitleColor].uiColor))
.lineLimit(subtitleLineLimit)
.truncationMode(subtitleTruncationMode)
.accessibilityIdentifier(AccessibilityIdentifiers.subtitle)

switch layoutType {
case .oneLine:
titleView
case .twoLines, .threeLines:
let subtitleView = Text(subtitle)
.foregroundColor(Color(uiColor: tokenSet[.subtitleColor].uiColor))
.lineLimit(subtitleLineLimit)
.truncationMode(subtitleTruncationMode)
.accessibilityIdentifier(AccessibilityIdentifiers.subtitle)
VStack(alignment: .leading, spacing: ListItemTokenSet.labelVerticalSpacing) {
case .oneLine, .twoLines:
subtitleView
alexanderboswell marked this conversation as resolved.
Show resolved Hide resolved
.font(Font(tokenSet[.subtitleTwoLinesFont].uiFont))
.frame(minHeight: ListItemTokenSet.subtitleTwoLineHeight)
case .threeLines:
subtitleView
.font(Font(tokenSet[.subtitleThreeLinesFont].uiFont))
.frame(minHeight: ListItemTokenSet.subtitleThreeLineHeight)
}
}

@ViewBuilder
var footerView: some View {
Text(footer)
.foregroundColor(Color(uiColor: tokenSet[.footerColor].uiColor))
.font(Font(tokenSet[.footerFont].uiFont))
.frame(minHeight: ListItemTokenSet.footerHeight)
.lineLimit(footerLineLimit)
.truncationMode(footerTruncationMode)
.accessibilityIdentifier(AccessibilityIdentifiers.footer)
}

@ViewBuilder
var labelStack: some View {
VStack(alignment: .leading, spacing: ListItemTokenSet.labelVerticalSpacing) {
switch layoutType {
case .oneLine:
titleView
if layoutType == .twoLines {
subtitleView
.font(Font(tokenSet[.subtitleTwoLinesFont].uiFont))
.frame(minHeight: ListItemTokenSet.subtitleTwoLineHeight)
} else {
subtitleView
.font(Font(tokenSet[.subtitleThreeLinesFont].uiFont))
.frame(minHeight: ListItemTokenSet.subtitleThreeLineHeight)
Text(footer)
.foregroundColor(Color(uiColor: tokenSet[.footerColor].uiColor))
.font(Font(tokenSet[.footerFont].uiFont))
.frame(minHeight: ListItemTokenSet.footerHeight)
.lineLimit(footerLineLimit)
.truncationMode(footerTruncationMode)
.accessibilityIdentifier(AccessibilityIdentifiers.footer)
}
case .twoLines:
titleView
subtitleView
case .threeLines:
titleView
subtitleView
footerView
}
}
}
Expand Down Expand Up @@ -158,6 +176,7 @@ public struct ListItem<LeadingContent: View,
HStack(spacing: 0) {
leadingContentView
labelStack
.animation(.default, value: layoutType)
Spacer(minLength: 0)
if combineTrailingContentAccessibilityElement {
trailingContentView
Expand Down
Loading