2025-12-21 13:40:42 -05:00
|
|
|
// TodoItem - Data model for a todo item
|
|
|
|
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
|
|
|
|
namespace TodoApp;
|
|
|
|
|
|
|
|
|
|
public class TodoItem : INotifyPropertyChanged
|
|
|
|
|
{
|
|
|
|
|
private string _title = "";
|
|
|
|
|
private string _notes = "";
|
|
|
|
|
private bool _isCompleted;
|
|
|
|
|
private DateTime _dueDate;
|
|
|
|
|
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Index in the collection for alternating row colors.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Index { get; set; }
|
|
|
|
|
|
|
|
|
|
public string Title
|
|
|
|
|
{
|
|
|
|
|
get => _title;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_title != value)
|
|
|
|
|
{
|
|
|
|
|
_title = value;
|
|
|
|
|
OnPropertyChanged(nameof(Title));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Notes
|
|
|
|
|
{
|
|
|
|
|
get => _notes;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_notes != value)
|
|
|
|
|
{
|
|
|
|
|
_notes = value;
|
|
|
|
|
OnPropertyChanged(nameof(Notes));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsCompleted
|
|
|
|
|
{
|
|
|
|
|
get => _isCompleted;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_isCompleted != value)
|
|
|
|
|
{
|
|
|
|
|
_isCompleted = value;
|
|
|
|
|
OnPropertyChanged(nameof(IsCompleted));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DateTime DueDate
|
|
|
|
|
{
|
|
|
|
|
get => _dueDate;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_dueDate != value)
|
|
|
|
|
{
|
|
|
|
|
_dueDate = value;
|
|
|
|
|
OnPropertyChanged(nameof(DueDate));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DateTime CreatedAt { get; set; } = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
|
|
|
|
|
|
|
|
protected void OnPropertyChanged(string propertyName)
|
|
|
|
|
{
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
|
}
|
2026-01-17 15:06:30 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Forces all bindings to re-evaluate by notifying all properties changed.
|
|
|
|
|
/// Used when external factors (like app theme) change.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void RefreshBindings()
|
|
|
|
|
{
|
|
|
|
|
OnPropertyChanged(nameof(IsCompleted));
|
|
|
|
|
OnPropertyChanged(nameof(Title));
|
|
|
|
|
OnPropertyChanged(nameof(Notes));
|
|
|
|
|
}
|
2025-12-21 13:40:42 -05:00
|
|
|
}
|