mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-14 06:16:12 +01:00
WIP: docs
This commit is contained in:
@@ -67,7 +67,7 @@ final class CollectionViewDemoViewController: UICollectionViewController {
|
||||
|
||||
case UICollectionView.elementKindSectionHeader:
|
||||
let view = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "PaletteCollectionSectionHeaderView", for: indexPath) as! PaletteCollectionSectionHeaderView
|
||||
view.label?.text = ColorsDemo.palettes.sectionIdentifiers[indexPath.section]
|
||||
view.label?.text = ColorsDemo.palettes.snapshot.sectionIDs[indexPath.section]
|
||||
return view
|
||||
|
||||
default:
|
||||
@@ -110,7 +110,7 @@ final class CollectionViewDemoViewController: UICollectionViewController {
|
||||
|
||||
self.performSegue(
|
||||
withIdentifier: "ObjectObserverDemoViewController",
|
||||
sender: ColorsDemo.palettes[indexPath: indexPath]
|
||||
sender: ColorsDemo.palettes.snapshot[indexPath]
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +45,11 @@ struct ColorsDemo {
|
||||
|
||||
didSet {
|
||||
|
||||
self.palettes.refetch(
|
||||
self.filter.whereClause(),
|
||||
OrderBy<Palette>(.ascending(\.hue))
|
||||
try! self.palettes.refetch(
|
||||
From<Palette>()
|
||||
.sectionBy(\.colorName)
|
||||
.where(self.filter.whereClause())
|
||||
.orderBy(.ascending(\.hue))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ final class ListObserverDemoViewController: UITableViewController {
|
||||
switch editingStyle {
|
||||
|
||||
case .delete:
|
||||
let palette = ColorsDemo.palettes[indexPath: indexPath]
|
||||
let palette = ColorsDemo.palettes.snapshot[indexPath]
|
||||
ColorsDemo.stack.perform(
|
||||
asynchronous: { (transaction) in
|
||||
|
||||
@@ -122,7 +122,7 @@ final class ListObserverDemoViewController: UITableViewController {
|
||||
|
||||
self.performSegue(
|
||||
withIdentifier: "ObjectObserverDemoViewController",
|
||||
sender: ColorsDemo.palettes[indexPath: indexPath]
|
||||
sender: ColorsDemo.palettes.snapshot[indexPath]
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -23,20 +23,23 @@ struct SwiftUIView: View {
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
List {
|
||||
ForEach(palettes.sectionIdentifiers, id: \.self) { (sectionID) in
|
||||
ForEach(palettes.snapshot.sectionIDs, id: \.self) { (sectionID) in
|
||||
Section(header: Text(sectionID)) {
|
||||
ForEach(self.palettes[section: sectionID], id: \.self) { palette in
|
||||
ForEach(self.palettes.snapshot.items(inSectionWithID: sectionID), id: \.self) { palette in
|
||||
NavigationLink(
|
||||
destination: DetailView(palette: palette),
|
||||
label: { ColorCell(palette: palette) }
|
||||
)
|
||||
}
|
||||
.onDelete { itemIndices in
|
||||
let objectsToDelete = self.palettes[section: sectionID, itemIndices: itemIndices]
|
||||
let objectIDsToDelete = self.palettes.snapshot.itemIDs(
|
||||
inSectionWithID: sectionID,
|
||||
atIndices: itemIndices
|
||||
)
|
||||
self.dataStack.perform(
|
||||
asynchronous: { transaction in
|
||||
|
||||
transaction.delete(objectsToDelete)
|
||||
transaction.delete(objectIDs: objectIDsToDelete)
|
||||
},
|
||||
completion: { _ in }
|
||||
)
|
||||
@@ -44,7 +47,7 @@ struct SwiftUIView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationBarTitle(Text("SwiftUI (\(palettes.numberOfItems) objects)"))
|
||||
.navigationBarTitle(Text("SwiftUI (\(palettes.snapshot.numberOfItems) objects)"))
|
||||
.navigationBarItems(
|
||||
leading: EditButton(),
|
||||
trailing: HStack {
|
||||
|
||||
Reference in New Issue
Block a user