Skip to content

Commit eb28226

Browse files
committed
Refactoring.
1 parent 3479729 commit eb28226

35 files changed

+848
-350
lines changed

samples/Unity.Mvvm.Counter/Assets/UI Toolkit/Styles/theme-animations.uss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* {
1+
:root {
22
--animation-property: color, background-color, border-color;
33
--animation-duration: 250ms, 250ms, 250ms;
44
--ease-function: ease-out-cubic, ease-out-cubic, ease-out-cubic;

samples/Unity.Mvvm.ToDoList/Assets/Scenes/MainScene.unity

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/Unity.Mvvm.ToDoList/Assets/Scripts/AppContext.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@
1010

1111
public class AppContext : MonoBehaviour, IAppContext, IDisposable
1212
{
13-
[SerializeField] private MainView _mainView;
14-
[SerializeField] private AddTaskDialogView _addTaskDialogView;
15-
16-
[Space]
1713
[SerializeField] private VisualTreeAsset _taskItemAsset;
14+
[SerializeField] private AddTaskDialogView _addTaskView;
1815

1916
private List<IDisposable> _disposables;
2017
private Dictionary<Type, object> _registeredTypes;
@@ -23,9 +20,8 @@ public void Construct()
2320
{
2421
_disposables = new List<IDisposable>();
2522
_registeredTypes = new Dictionary<Type, object>();
26-
27-
RegisterInstance(_mainView);
28-
RegisterInstance(_addTaskDialogView);
23+
24+
RegisterInstance(_addTaskView);
2925

3026
RegisterInstance(new TaskBroker());
3127
RegisterInstance<IDialogsService>(new DialogsService(this));

samples/Unity.Mvvm.ToDoList/Assets/Scripts/BindableUIElementWrappers/BindableAddTaskButtonWrapper.cs

Lines changed: 0 additions & 48 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System;
2+
using BindableUIElements;
3+
using UnityMvvmToolkit.Core.Interfaces;
4+
using UnityMvvmToolkit.UniTask.Interfaces;
5+
6+
namespace BindableUIElementWrappers
7+
{
8+
public class BindableBinaryStateButtonWrapper : BindableBinaryStateElementWrapper, IInitializable, IDisposable
9+
{
10+
private readonly BindableBinaryStateButton _binaryStateButton;
11+
private readonly IAsyncCommand _command;
12+
13+
public BindableBinaryStateButtonWrapper(BindableBinaryStateButton binaryStateButton,
14+
IObjectProvider objectProvider) : base(binaryStateButton, objectProvider)
15+
{
16+
_binaryStateButton = binaryStateButton;
17+
_command = GetCommand<IAsyncCommand>(binaryStateButton.Command);
18+
}
19+
20+
public bool CanInitialize => _command != null;
21+
22+
public void Initialize()
23+
{
24+
_binaryStateButton.clicked += OnClicked;
25+
}
26+
27+
public void Dispose()
28+
{
29+
_binaryStateButton.clicked -= OnClicked;
30+
}
31+
32+
private void OnClicked()
33+
{
34+
_command.Execute();
35+
}
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Interfaces;
2+
using UnityMvvmToolkit.Core;
3+
using UnityMvvmToolkit.Core.Interfaces;
4+
5+
namespace BindableUIElementWrappers
6+
{
7+
public class BindableBinaryStateElementWrapper : BindablePropertyElement
8+
{
9+
private readonly IBindableBinaryStateElement _binaryStateElement;
10+
private readonly IReadOnlyProperty<bool> _stateProperty;
11+
12+
public BindableBinaryStateElementWrapper(IBindableBinaryStateElement binaryStateElement,
13+
IObjectProvider objectProvider) : base(objectProvider)
14+
{
15+
_binaryStateElement = binaryStateElement;
16+
_stateProperty = GetReadOnlyProperty<bool>(binaryStateElement.BindingStatePath);
17+
}
18+
19+
public override void UpdateValues()
20+
{
21+
if (_stateProperty.Value)
22+
{
23+
_binaryStateElement.Activate();
24+
}
25+
else
26+
{
27+
_binaryStateElement.Deactivate();
28+
}
29+
}
30+
}
31+
}

samples/Unity.Mvvm.ToDoList/Assets/Scripts/BindableUIElementWrappers/BindableBinaryStateElementWrapper.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/Unity.Mvvm.ToDoList/Assets/Scripts/BindableUIElementWrappers/BindableTaskListWrapper.cs

Lines changed: 0 additions & 39 deletions
This file was deleted.

samples/Unity.Mvvm.ToDoList/Assets/Scripts/BindableUIElementWrappers/BindableTaskListWrapper.cs.meta

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)