← All repositories

listless

A simple list app for Apple platforms

git clone https://code.inqk.net/listless.git


ListlessWatch/Views/ItemRowView.swift (1562B)

1import SwiftUI
2
3struct ItemRowView: View {
4    let item: ItemValue
5    let index: Int
6    let totalActive: Int
7    let colorTheme: ColorTheme
8    let onToggle: (ItemValue) -> Void
9
10    var body: some View {
11        Button {
12            onToggle(item)
13        } label: {
14            HStack(spacing: 8) {
15                Image(systemName: item.isCompleted ? "checkmark.circle.fill" : "circle")
16                    .foregroundColor(
17                        item.isCompleted
18                            ? .secondary
19                            : cachedItemColor(forIndex: index, total: totalActive, theme: colorTheme)
20                    )
21                    .font(.system(size: 17))
22
23                Text(item.title)
24                    .strikethrough(item.isCompleted)
25                    .foregroundStyle(item.isCompleted ? .secondary : .primary)
26                    .lineLimit(3)
27            }
28            .padding(.vertical, 4)
29        }
30        .listRowBackground(
31            item.isCompleted
32                ? AnyView(Color(white: 0.15)
33                    .clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous)))
34                : AnyView(
35                    ZStack(alignment: .top) {
36                        Color(white: 0.15)
37                        cachedItemColor(forIndex: index, total: totalActive, theme: colorTheme)
38                            .frame(height: 3)
39                    }
40                    .clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous))
41                )
42        )
43        .buttonStyle(.plain)
44    }
45}