44 lines
1.3 KiB
Swift
44 lines
1.3 KiB
Swift
import SwiftData
|
|
import SwiftUI
|
|
|
|
extension TaskListView {
|
|
|
|
/// View model for managing the logic for the task list view.
|
|
///
|
|
/// This observable class encapsulates the state and business logic for the task list view.
|
|
/// It follows the MVVM pattern to separate presentation logic from the view layer.
|
|
///
|
|
/// ## Responsibilities
|
|
/// - Providing the navigation title for the current group
|
|
@Observable
|
|
final class ViewModel {
|
|
|
|
// MARK: Properties
|
|
|
|
/// The task group to display tasks for.
|
|
///
|
|
/// This property determines which tasks are fetched and displayed in the list.
|
|
private let group: TodoGroup
|
|
|
|
// MARK: Initialization
|
|
|
|
/// Initializes a new view model instance for a specific task group.
|
|
///
|
|
/// - Parameter group: The task group to display tasks for.
|
|
init(group: TodoGroup) {
|
|
self.group = group
|
|
}
|
|
|
|
// MARK: Computed
|
|
|
|
/// The navigation title for the current task group.
|
|
///
|
|
/// This computed property provides the localized title for the current group,
|
|
/// suitable for display in a navigation bar.
|
|
///
|
|
/// - Returns: The localized title key for the current group.
|
|
var navigationTitle: LocalizedStringKey { group.title }
|
|
|
|
}
|
|
}
|