Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix decorating error with dependencies bound with FastBind() #12

Merged
merged 3 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
- 'master'
- 'develop'
- 'release/*'
- 'feature/*'
- 'fix/*'

jobs:
build:
Expand Down Expand Up @@ -36,6 +38,11 @@ jobs:
then
git remote set-url origin https://$RUNNER_USERNAME:$PAT_TOKEN@${REPO_URL:6}
CURRENT_TAG_VERSION=$(python3 getVersion.py ./VERSION $UMVVM_BUILD_DATA_PATH/buildVersionV1.txt)
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ $CURRENT_BRANCH == feature* || $CURRENT_BRANCH == fix* ]];
then
CURRENT_TAG_VERSION=$CURRENT_TAG_VERSION-raw
fi
git tag $CURRENT_TAG_VERSION
git push origin --tags
fi
Expand Down
5 changes: 5 additions & 0 deletions MvvmUnityProj/CCG/Assets/Code/Core/CoreInstaller.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CCG.Core.Camera;
using CCG.Core.CustomViewManager;
using CCG.Core.Installers;
using CCG.Core.Screen;
using CCG.Models.Hand.Model;
Expand All @@ -21,6 +22,7 @@
using SurvivedWarrior.MVVM.Models.Time;
using UnityEngine;
using UnityMVVM.DI;
using UnityMVVM.ViewManager;
using UnityMVVM.ViewModelCore;
using Zenject;

Expand All @@ -30,6 +32,9 @@ public class CoreInstaller : Installer
{
public override void InstallBindings()
{

Container.Decorate<IViewManager>().With<LogViewManagerDecorator>();

Container.InstallPoolableView<MainScreenView, IMainScreenViewModel, MainScreenViewModel>(ViewNames.MainScreen,
() => Resources.Load<GameObject>("Prefabs/Views/MainScreenView"));
Container.InstallView<MainScreen3dView, IViewModel, ViewModel>(ViewNames.MainScreen3d,
Expand Down
3 changes: 3 additions & 0 deletions MvvmUnityProj/CCG/Assets/Code/Core/CustomViewManager.meta

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,86 @@
using System;
using System.Collections.Generic;
using AsyncReactAwait.Bindable;
using AsyncReactAwait.Promises;
using UnityEngine;
using UnityMVVM.ViewManager;
using UnityMVVM.ViewManager.ViewLayer;
using UnityMVVM.ViewModelCore;

namespace CCG.Core.CustomViewManager
{
public class LogViewManagerDecorator : IViewManager
{

public event Action<(string layerId, string viewName, IPayload viewPayload)> ViewOpened
{
add => _viewManager.ViewOpened += value;
remove => _viewManager.ViewOpened -= value;
}

public event Action<(string layerId, string viewName)> ViewClosedImplicitly
{
add => _viewManager.ViewClosedImplicitly += value;
remove => _viewManager.ViewClosedImplicitly -= value;
}

private readonly IViewManager _viewManager;

public IBindable<string> HighestBusyLayer => _viewManager.HighestBusyLayer;

public LogViewManagerDecorator(IViewManager viewManager)
{
_viewManager = viewManager;
}

public IReadOnlyList<string> GetLayerIds() => _viewManager.GetLayerIds();

public IViewModel Create(IViewModel parent, string viewName, Transform container, IPayload payload = null)
{
Debug.Log("View was created!");
return _viewManager.Create(parent, viewName, container, payload);
}

public IPromise<IViewModel> Open(string viewLayerId, string viewName, IPayload payload = null)
{
Debug.Log("View was opened!");
return _viewManager.Open(viewLayerId, viewName, payload);
}

public IPromise OpenExact(string viewLayerId, string viewName, IPayload payload = null)
{
Debug.Log("View was opened on exact layer!");
return _viewManager.OpenExact(viewLayerId, viewName, payload);
}

public IPromise CloseExact(string viewLayerId)
{
Debug.Log("View was closed on exact layer!");
return _viewManager.CloseExact(viewLayerId);
}

public IPromise Close(string viewLayerId)
{
Debug.Log("View was closed!");
return _viewManager.Close(viewLayerId);
}

public string GetViewName(string viewLayerId)
{
Debug.Log("View name was got!");
return _viewManager.GetViewName(viewLayerId);
}

public IViewLayer GetLayer(string viewLayerId)
{
Debug.Log("Layer was got!");
return _viewManager.GetLayer(viewLayerId);
}

public IViewModel GetView(string viewLayerId)
{
Debug.Log("View was got!");
return _viewManager.GetView(viewLayerId);
}
}
}

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

Binary file not shown.
Binary file modified MvvmUnityProj/QuickStartUnityMVVM/Assets/Libs/UnityMVVM.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion src/UnityMVVM/DI/DiContainerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public static void FastBind<TImpl>(this DiContainer container, IReadOnlyCollecti
commonAccessInterfaces = modelAccessInterfaces;
}
env.ViewsModelsContainerAdapter.Container.Bind(commonAccessInterfaces)
.FromMethod<TImpl>(_ => (TImpl)container.Resolve(modelAccessInterfaces.First())).AsSingle();
.FromMethodUntyped(_ => container.Resolve(modelAccessInterfaces.First())).AsSingle();
}

/// <summary>
Expand Down