Files
2022-04-27 09:39:24 +09:00

41 lines
1.2 KiB
Swift

//
// PatternCategoryList.swift
// LifeGameApp (iOS)
//
// Created by Yusuke Hosonuma on 2020/09/18.
//
import SwiftUI
import Core
struct PatternCategoryListView: View {
@ObservedObject var patternSelectManager: PatternSelectManager
var body: some View {
List {
Section {
navigationLink(title: "All", patternURLs: patternSelectManager.allURLs)
}
Section(header: Text("Find by type")) {
ForEach(PatternCategory.allCases) { category in
navigationLink(title: category.rawValue, patternURLs: patternSelectManager.urlsByCategory[category] ?? [])
}
}
}
.listStyle(GroupedListStyle())
}
private func navigationLink(title: String, patternURLs: [PatternURL]) -> some View {
NavigationLink(title, destination:
PatternGridListView(
style: .grid,
patternURLs: patternURLs.map(\.url),
didTapItem: patternSelectManager.select,
didToggleStar: patternSelectManager.toggleStar
)
.padding()
.navigationTitle(title)
)
}
}