-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTodoView.cs
42 lines (32 loc) · 1.08 KB
/
TodoView.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
using UniMob.UI;
using UnityEngine;
using UnityEngine.UI;
namespace Samples.SimpleTodoList.Views
{
public class TodoView : View<ITodoState>
{
[SerializeField] private Text todoText = default;
[SerializeField] private Toggle completedToggle = default;
[SerializeField] private Button deleteButton = default;
[SerializeField] private Color activeTextColor = Color.black;
[SerializeField] private Color completedTextColor = Color.gray;
protected override void Awake()
{
base.Awake();
deleteButton.Click(() => State.Delete);
completedToggle.onValueChanged.Bind(completed => State.Completed = completed);
}
protected override void Render()
{
todoText.color = State.Completed ? completedTextColor : activeTextColor;
todoText.text = State.Text;
completedToggle.isOn = State.Completed;
}
}
public interface ITodoState : IViewState
{
string Text { get; }
bool Completed { get; set; }
void Delete();
}
}