initial pre-viable version of watch app
This commit is contained in:
27
Workouts/_ATTIC_/Cepo/EditableEntity.swift
Normal file
27
Workouts/_ATTIC_/Cepo/EditableEntity.swift
Normal file
@ -0,0 +1,27 @@
|
||||
import SwiftUI
|
||||
import SwiftData
|
||||
|
||||
/// A protocol for entities that can be managed in a generic list view.
|
||||
protocol EditableEntity: PersistentModel, Identifiable, Hashable {
|
||||
/// The name of the entity to be displayed in the list.
|
||||
var name: String { get set }
|
||||
|
||||
/// A view for adding or editing the entity.
|
||||
associatedtype FormView: View
|
||||
@ViewBuilder static func formView(for model: Self) -> FormView
|
||||
|
||||
/// Creates a new, empty instance of the entity.
|
||||
static func createNew() -> Self
|
||||
|
||||
/// The title for the navigation bar in the list view.
|
||||
static var navigationTitle: String { get }
|
||||
|
||||
/// An optional property to specify a count to be displayed in the list item.
|
||||
var count: Int? { get }
|
||||
}
|
||||
|
||||
extension EditableEntity {
|
||||
var count: Int? {
|
||||
return nil
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user