-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathViewModel.cs
81 lines (69 loc) · 2.23 KB
/
ViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using DevExpress.Maui.Core;
using DevExpress.Maui.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace CollectionViewSwipe
{
public partial class ViewModel : DXObservableObject
{
[ObservableProperty]
ObservableCollection<Task> data;
public ViewModel()
{
Data = new ObservableCollection<Task>() {
new Task("Prepare Financial"),
new Task("Prepare Marketing Plan"),
new Task("QA Strategy Report"),
new Task("Update Personnel Files"),
new Task("Provide New Health Insurance Docs"),
new Task("Choose between PPO and HMO Health Plan"),
new Task("New Brochures"),
new Task("Brochure Designs"),
new Task("Brochure Design Review"),
new Task("Create Sales Report"),
new Task("Deliver R&D Plans"),
};
}
[RelayCommand]
void DeleteTask(Task taskToDelete)
{
Data.Remove(taskToDelete);
}
}
public partial class Task : DXObservableObject
{
[ObservableProperty]
bool isTaskCompleted;
[ObservableProperty]
string description;
[ObservableProperty]
Color itemColor;
[ObservableProperty]
string actionText;
[ObservableProperty]
string actionIcon;
partial void OnIsTaskCompletedChanged(bool oldValue, bool newValue)
=> UpdateState();
[RelayCommand]
void ChangeState() => IsTaskCompleted = !IsTaskCompleted;
public Task(string description)
{
Description = description;
UpdateState();
}
void UpdateState()
{
ItemColor = IsTaskCompleted ? Color.FromArgb("#c6eccb") : Color.FromArgb("#e6e6e6");
ActionText = IsTaskCompleted ? "To Do" : "Done";
ActionIcon = IsTaskCompleted ? "uncompletetask" : "completetask";
}
}
}