List tasks feature (#4)
This PR contains the work done to implement the **List Tasks** feature, and to integrate it into the main content view of the app. Reviewed-on: rock-n-code/todos-app#4 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #4.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
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 }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user