54 lines
1.9 KiB
Swift
54 lines
1.9 KiB
Swift
import SwiftUI
|
|
import Bedrock
|
|
|
|
struct TodayHabitRowView: View {
|
|
private let title: String
|
|
private let symbolName: String
|
|
private let isCompleted: Bool
|
|
private let horizontalPadding: CGFloat
|
|
private let action: () -> Void
|
|
|
|
init(
|
|
title: String,
|
|
symbolName: String,
|
|
isCompleted: Bool,
|
|
horizontalPadding: CGFloat = Design.Spacing.large,
|
|
action: @escaping () -> Void
|
|
) {
|
|
self.title = title
|
|
self.symbolName = symbolName
|
|
self.isCompleted = isCompleted
|
|
self.horizontalPadding = horizontalPadding
|
|
self.action = action
|
|
}
|
|
|
|
var body: some View {
|
|
Button(action: action) {
|
|
HStack(spacing: Design.Spacing.medium) {
|
|
SymbolIcon(symbolName, size: .row, color: isCompleted ? AppStatus.success : AppAccent.primary)
|
|
.frame(width: AppMetrics.Size.iconLarge)
|
|
.accessibilityHidden(true)
|
|
|
|
StyledLabel(title, .subheading, emphasis: .primary)
|
|
|
|
Spacer(minLength: Design.Spacing.medium)
|
|
|
|
SymbolIcon(
|
|
isCompleted ? "checkmark.circle.fill" : "circle",
|
|
size: .row,
|
|
color: isCompleted ? AppStatus.success : AppBorder.subtle
|
|
)
|
|
.accessibilityHidden(true)
|
|
}
|
|
.padding(.horizontal, horizontalPadding)
|
|
.padding(.vertical, Design.Spacing.medium)
|
|
.background(AppSurface.card)
|
|
.clipShape(.rect(cornerRadius: Design.CornerRadius.medium))
|
|
}
|
|
.accessibilityLabel(Text(title))
|
|
.accessibilityValue(isCompleted ? String(localized: "Completed") : String(localized: "Not completed"))
|
|
.accessibilityHint(isCompleted ? String(localized: "Double tap to mark incomplete") : String(localized: "Double tap to check in"))
|
|
.buttonStyle(.plain)
|
|
}
|
|
}
|