Skip to content

Commit

Permalink
Add OnSetupInternal method
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolai Selivanov committed Dec 15, 2024
1 parent 623aae6 commit 9f9306a
Show file tree
Hide file tree
Showing 20 changed files with 395 additions and 2 deletions.
3 changes: 3 additions & 0 deletions MvvmUnityProj/CCG/Assets/Code/Core/CoreInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using CCG.MVVM.HandController;
using CCG.MVVM.LoadingPopup;
using CCG.MVVM.MainMenu;
using CCG.MVVM.MainScreen.Subviews.TextView;
using CCG.MVVM.MainScreen.View;
using CCG.MVVM.MainScreen.ViewModel;
using CCG.MVVM.MainScreen3d;
Expand Down Expand Up @@ -57,6 +58,8 @@ public override void InstallBindings()
_ => Resources.Load<GameObject>("Prefabs/Views/CoolPopup/CoolPopup"));
Container.InstallView<CoolPopupView, ICoolPopupViewModel, CoolPopupViewModel>(ViewNames.SameCoolPopupButWithOtherName,
_ => Resources.Load<GameObject>("Prefabs/Views/CoolPopup/CoolPopup"));
Container.InstallView<TextView, ITextViewModel, TextViewModel>(ViewNames.TextView,
_ => Resources.Load<GameObject>("Prefabs/Views/TextView"));
Container.InstallView<TimeCounterView, ITimeCounterViewModel, TimeCounterViewModel>();

Container.Install<ImageSystemInstaller>();
Expand Down
1 change: 1 addition & 0 deletions MvvmUnityProj/CCG/Assets/Code/Core/ViewNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public static class ViewNames
public static string LoadingPopup => "LoadingPopup";
public static string CoolPopup => "CoolPopup";
public static string SameCoolPopupButWithOtherName => "CoolPopup2";
public static string TextView => "TextView";
}
}
3 changes: 3 additions & 0 deletions MvvmUnityProj/CCG/Assets/Code/MVVM/MainScreen/Subviews.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using AsyncReactAwait.Bindable;
using UnityMVVM.ViewModelCore;

namespace CCG.MVVM.MainScreen.Subviews.TextView
{
public interface ITextViewModel : IViewModel
{
IBindable<string> Text { get; }
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using TMPro;
using UnityEngine;
using UnityMVVM;

namespace CCG.MVVM.MainScreen.Subviews.TextView
{
public class TextView : ViewBehaviour<ITextViewModel>
{

[SerializeField]
protected TMP_Text _text;

protected override void OnViewModelSet()
{
base.OnViewModelSet();
SmartBind(ViewModel!.Text, x => _text.text = x);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using AsyncReactAwait.Bindable;

namespace CCG.MVVM.MainScreen.Subviews.TextView
{
public class TextViewModel : UnityMVVM.ViewModelCore.ViewModel, ITextViewModel
{

private readonly Mutable<string> _text = new();

public IBindable<string> Text => _text;

public TextViewModel(TextViewPayload payload)
{
_text.Value = payload.text;
}

}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using UnityMVVM.ViewModelCore;

namespace CCG.MVVM.MainScreen.Subviews.TextView
{
public struct TextViewPayload : IPayload
{
public readonly string text;

public TextViewPayload(string text)
{
this.text = text;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using CCG.MVVM.Card.Model;
using CCG.MVVM.Card.ViewModel;
using CCG.MVVM.CoolPopup.Payload;
using CCG.MVVM.MainScreen.Subviews.TextView;
using CCG.Services.Game;
using UnityEngine;
using UnityMVVM.ViewManager;
Expand Down Expand Up @@ -49,7 +50,12 @@ private void OnCardAdded(ICardModel card)
{
CreateSubView(ViewNames.Card, _cardsContainer, new CardPayload(card));
}


protected override void OnSetupInternal()
{
CreateSubView(ViewNames.TextView, _cardsContainer, new TextViewPayload("SOME_TEXT"));
}

private void IntiGame()
{
_imageService.LoadImages().OnSuccess(() =>
Expand Down
Binary file modified MvvmUnityProj/CCG/Assets/Packages/com.kekchpek.umvvm/UnityMVVM.dll
Binary file not shown.
Loading

0 comments on commit 9f9306a

Please sign in to comment.