Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

iOS-3265 Version history | Update grouped icon + add counter #1872

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@ struct IconsGroupView: View {
let icons: [ObjectIcon]

var body: some View {
HStack(spacing: 4) {
iconsView
countView
}
}

private var iconsView: some View {
HStack(spacing: -Constants.imageShift) {
ForEach(icons, id: \.hashValue) { icon in
ForEach(icons.suffix(Constants.maxVisibleIcons), id: \.hashValue) { icon in
objectIconViewWithBorder(for: icon)
}
}
.environment(\.layoutDirection, .rightToLeft)
}

private func objectIconViewWithBorder(for icon: ObjectIcon) ->some View {
Expand All @@ -22,6 +30,14 @@ struct IconsGroupView: View {
.frame(width: Constants.backgroundDiameter, height: Constants.backgroundDiameter)
}
}

@ViewBuilder
private var countView: some View {
if icons.count > Constants.maxVisibleIcons {
AnytypeText("+\(icons.count - Constants.maxVisibleIcons)", style: .caption1Regular)
.foregroundColor(.Text.secondary)
}
}
}

extension IconsGroupView {
Expand All @@ -30,5 +46,6 @@ extension IconsGroupView {
static let backgroundDiameter = iconDiameter + lineWidth * 2
static let lineWidth: CGFloat = 2
static let imageShift = lineWidth * 2
static let maxVisibleIcons = 3
}
}
Loading