Add unread counter to unread button

This commit is contained in:
Maciej Gomółka
2026-04-30 12:45:11 +02:00
committed by Maciej Gomółka
parent 4926802bb8
commit 9e99c4251f
2 changed files with 25 additions and 22 deletions
@@ -135,7 +135,7 @@ extension MailboxListView {
},
liquidUnreadButton: {
LiquidUnreadButton(
isSelected: model.state.barsState.unreadButtonState.isSelected,
unreadButtonState: model.state.barsState.unreadButtonState,
action: { model.onUnreadFilterChange() }
)
}
@@ -19,35 +19,35 @@ import InboxDesignSystem
import SwiftUI
struct LiquidUnreadButton: ToolbarContent {
let isSelected: Bool
let unreadButtonState: UnreadButtonState
let action: () -> Void
var body: some ToolbarContent {
if isSelected {
ToolbarItem(placement: .bottomBar) {
Button(action: action) {
HStack(spacing: DS.Spacing.standard) {
ToolbarItem(placement: .bottomBar) {
Button(action: action) {
HStack(spacing: DS.Spacing.compact) {
HStack(spacing: DS.Spacing.small) {
Text(L10n.Mailbox.unread)
.font(.body)
Image(symbol: .xmark)
.font(.callout)
.fontWeight(.medium)
Text(unreadButtonState.counterState.string)
.fontWeight(.semibold)
}
}
.fontWeight(.medium)
.modify { view in
if #available(iOS 26, *) {
view.buttonStyle(.glassProminent)
.tint(DS.Color.InteractionBrand.norm)
} else {
view
if unreadButtonState.isSelected {
Image(symbol: .xmark)
.fontWeight(.heavy)
.font(.caption)
}
}
}
} else {
ToolbarItem(placement: .bottomBar) {
Button(L10n.Mailbox.unread, action: action)
.font(.body)
.fontWeight(.medium)
.modify { view in
if #available(iOS 26, *), unreadButtonState.isSelected {
view
.buttonStyle(.glassProminent)
.tint(DS.Color.InteractionBrand.norm)
} else {
view
}
}
}
}
@@ -60,7 +60,10 @@ struct LiquidUnreadButton: ToolbarContent {
Color.clear
.toolbar {
LiquidUnreadButton(
isSelected: isSelected,
unreadButtonState: .init(
isSelected: isSelected,
counterState: .known(unreadCount: 100)
),
action: { isSelected.toggle() }
)
}