Files
2025-05-31 11:12:14 +02:00

39 lines
1.1 KiB
Swift

//
// ListVStack.swift
// Nextcloud Cookbook iOS Client
//
// Created by Vincent Meilinger on 29.05.25.
//
import SwiftUI
struct ListVStack<Element, HeaderContent: View, RowContent: View>: View {
@Binding var items: [Element]
let header: () -> HeaderContent
let rows: (Int, Binding<Element>) -> RowContent
init(_ items: Binding<[Element]>, header: @escaping () -> HeaderContent, rows: @escaping (Int, Binding<Element>) -> RowContent) {
self._items = items
self.header = header
self.rows = rows
}
var body: some View {
VStack(alignment: .leading) {
header()
.padding(.horizontal, 30)
VStack(alignment: .leading, spacing: 0) {
ForEach(items.indices, id: \.self) { index in
rows(index, $items[index])
.padding(10)
}
}
.padding(4)
.background(Color.secondary.opacity(0.1))
.clipShape(RoundedRectangle(cornerRadius: 15))
.padding(.horizontal)
}
}
}