ui 추상화 로직 강제

This commit is contained in:
NTG 2025-08-29 12:53:54 +09:00
parent 8445640c20
commit 75f09e75d2
13 changed files with 318 additions and 392 deletions

View File

@ -25,24 +25,11 @@ public abstract class BaseUi : MonoBehaviour
public bool IsInitialized { get; protected set; }
public bool IsBlockingTime => false;
public bool IsOpen => _panel != null && _panel.activeSelf;
protected virtual void Awake()
{
_canvasGroup = GetComponent<CanvasGroup>();
_panel = transform.Find(CommonConstants.Panel).gameObject;
_blockImage = transform.Find(CommonConstants.BlockImage).gameObject;
if (_enableBlockImage)
{
_blockImage.SetActive(false);
}
_panel.SetActive(false);
}
protected virtual void OnEnable() { }
protected virtual void Start() { }
protected virtual void Update() { }
protected virtual void OnDisable() { }
protected virtual void OnDestroy()
{
_bindingContext?.Dispose();
@ -51,22 +38,29 @@ protected virtual void OnDestroy()
}
public void CreateInitialize()
{
OnCreatedInitialize();
}
protected virtual void OnCreatedInitialize()
{
UiManager.Instance.UiState.RegisterUI(this);
_bindingContext = new BindingContext();
SetupBindings();
}
protected virtual void OnOpenedEvents() { }
protected virtual void OnClosedEvents() { }
_canvasGroup = GetComponent<CanvasGroup>();
_panel = transform.Find(CommonConstants.Panel).gameObject;
_blockImage = transform.Find(CommonConstants.BlockImage).gameObject;
// BaseUi 메서드들을 직접 구현
public virtual void OpenPanel()
_panel.SetActive(false);
_bindingContext = new BindingContext();
OnCreatedInitialize();
if (_enableBlockImage)
{
_blockImage.SetActive(false);
}
}
protected abstract void OnCreatedInitialize();
protected abstract void OnOpenedEvents();
protected abstract void OnClosedEvents();
protected void OpenPanel()
{
if (_enableBlockImage)
{
@ -74,11 +68,10 @@ public virtual void OpenPanel()
}
_panel.SetActive(true);
OnOpenedEvents();
}
public virtual void ClosePanel()
protected void ClosePanel()
{
if (_enableBlockImage)
{
@ -91,7 +84,7 @@ public virtual void ClosePanel()
IsInitialized = false;
}
public virtual void SetUiInteractable(bool active)
public void SetUiInteractable(bool active)
{
if (_canvasGroup)
{
@ -102,15 +95,10 @@ public virtual void SetUiInteractable(bool active)
public bool IsOpenPanel() => _panel && _panel.activeInHierarchy;
/// <summary>
/// 추가 바인딩 설정 - 하위 클래스에서 구현
/// </summary>
protected virtual void SetupBindings() { }
/// <summary>
/// ViewModel 속성 변경 이벤트 핸들러
/// </summary>
protected virtual void OnViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
protected void OnViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
{
HandleCustomPropertyChanged(e.PropertyName);
}

View File

@ -1,74 +0,0 @@
namespace DDD
{
public class BaseViewModelUi<TViewModel> : BaseUi where TViewModel : SimpleViewModel
{
protected TViewModel _viewModel;
protected override void Awake()
{
base.Awake();
_viewModel = GetComponent<TViewModel>();
}
protected override void OnOpenedEvents()
{
base.OnOpenedEvents();
if (_viewModel && _bindingContext != null)
{
_bindingContext.SetDataContext(_viewModel);
_viewModel.PropertyChanged += OnViewModelPropertyChanged;
}
}
protected override void OnClosedEvents()
{
base.OnClosedEvents();
if (_viewModel != null)
{
_viewModel.PropertyChanged -= OnViewModelPropertyChanged;
}
}
public override void OpenPanel()
{
base.OpenPanel();
_viewModel?.Initialize();
}
public override void ClosePanel()
{
base.ClosePanel();
_viewModel?.Cleanup();
}
/// <summary>
/// ViewModel 메서드 호출 헬퍼
/// </summary>
protected void InvokeViewModelMethod(string methodName, params object[] parameters)
{
if (_viewModel == null) return;
var method = _viewModel.GetType().GetMethod(methodName);
method?.Invoke(_viewModel, parameters);
}
/// <summary>
/// ViewModel 속성 설정 헬퍼
/// </summary>
protected void SetViewModelProperty(string propertyName, object value)
{
if (_viewModel == null) return;
var property = _viewModel.GetType().GetProperty(propertyName);
if (property != null && property.CanWrite)
{
property.SetValue(_viewModel, value);
}
}
}
}

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: df6384ea09a44f188d636ca7ee47db13
timeCreated: 1755678434

View File

@ -15,14 +15,22 @@ protected override void OnDestroy()
protected override void OnCreatedInitialize()
{
base.OnCreatedInitialize();
_canvasGroup.alpha = 0f;
EventBus.Register<FadeInEvent>(this);
EventBus.Register<FadeOutEvent>(this);
}
protected override void OnOpenedEvents()
{
}
protected override void OnClosedEvents()
{
}
public void HandleEvent(FadeInEvent evt)
{
_ = FadeInAsync(evt);

View File

@ -23,14 +23,22 @@ protected override void OnDestroy()
protected override void OnCreatedInitialize()
{
base.OnCreatedInitialize();
_canvasGroup.alpha = 0;
_messageText.text = null;
EventBus.Register(this);
}
protected override void OnOpenedEvents()
{
}
protected override void OnClosedEvents()
{
}
public void HandleEvent(ShowGlobalMessageEvent evt)
{
_messageQueue.Enqueue(evt);

View File

@ -4,9 +4,17 @@ public class RestaurantHud : BaseUi
{
protected override void OnCreatedInitialize()
{
base.OnCreatedInitialize();
OpenPanel();
}
protected override void OnOpenedEvents()
{
}
protected override void OnClosedEvents()
{
}
}
}

View File

@ -27,14 +27,23 @@ protected override void OnDestroy()
protected override void OnCreatedInitialize()
{
base.OnCreatedInitialize();
_filledImage.fillAmount = 0f;
EventBus.Register<ShowInteractionUiEvent>(this);
EventBus.Register<HideInteractionUiEvent>(this);
}
protected override void OnOpenedEvents()
{
}
protected override void OnClosedEvents()
{
}
public void HandleEvent(ShowInteractionUiEvent evt)
{
ShowInteractionUiEvent(evt);
@ -47,14 +56,13 @@ public void HandleEvent(HideInteractionUiEvent evt)
private void ShowInteractionUiEvent(ShowInteractionUiEvent evt)
{
var currentLocalizedString = LocalizationManager.Instance.GetLocalizedString(evt.TextKey);
if (currentLocalizedString != _previousLocalizedString)
{
_textLabelLocalizeStringEvent.StringReference = currentLocalizedString;
_previousLocalizedString = LocalizationManager.Instance.GetLocalizedString(evt.TextKey);
}
_previousLocalizedString = LocalizationManager.Instance.GetLocalizedString(evt.TextKey);
_textLabel.color = evt.CanInteract ? _canInteractTextColor : _cannotInteractTextColor;
if (_textLabelLocalizeStringEvent.StringReference != _previousLocalizedString)
{
_textLabelLocalizeStringEvent.StringReference = _previousLocalizedString;
}
_filledImage.fillAmount = evt.HoldProgress;
if (_panel.activeInHierarchy == false)

View File

@ -8,13 +8,6 @@ public abstract class BasePopupUi : BaseUi
public bool IsTopPopup => UiManager.Instance.UiState.IsTopPopup(this);
public InputActionMaps InputActionMaps { get; protected set; }
protected override void Awake()
{
_enableBlockImage = true;
base.Awake();
}
protected override void Update()
{
base.Update();
@ -39,33 +32,46 @@ protected override void OnDestroy()
UiManager.Instance?.UiState?.UnregisterPopupUI(this);
}
protected abstract GameObject GetInitialSelected();
protected abstract void OnCreatedInitializeBasePopup();
protected abstract void OnOpenedEventsBasePopup(OpenPopupUiEvent evt);
protected abstract void OnClosedEventsBasePopup(ClosePopupUiEvent evt);
protected override void OnCreatedInitialize()
{
base.OnCreatedInitialize();
UiManager.Instance.UiState.RegisterPopupUI(this);
_enableBlockImage = true;
OnCreatedInitializeBasePopup();
}
public virtual void Open(OpenPopupUiEvent evt)
protected override void OnOpenedEvents() { }
protected override void OnClosedEvents() { }
public void OpenPopup(OpenPopupUiEvent evt)
{
OpenPanel();
var initialSelected = GetInitialSelected();
if (initialSelected != null)
if (initialSelected)
{
EventSystem.current.SetSelectedGameObject(initialSelected);
}
transform.SetAsLastSibling();
OnOpenedEventsBasePopup(evt);
IsInitialized = true;
}
public virtual void Close()
public void Close()
{
var evt = GameEvents.ClosePopupUiEvent;
evt.UiType = GetType();
OnClosedEventsBasePopup(evt);
ClosePanel();
EventBus.Broadcast(evt);
}
protected abstract GameObject GetInitialSelected();
}
}

View File

@ -19,17 +19,9 @@ protected override GameObject GetInitialSelected()
return _confirmButton.gameObject;
}
protected override void OnCreatedInitialize()
protected override void OnCreatedInitializePopup()
{
base.OnCreatedInitialize();
_messageLabelLocalizeStringEvent.OnUpdateString.Invoke(string.Empty);
SetupBindings();
}
protected override void SetupBindings()
{
base.SetupBindings();
BindingHelper.BindLocalizedStringEvent(_bindingContext, _messageLabelLocalizeStringEvent, nameof(_viewModel.MessageLocalizedString));
BindingHelper.BindActive(_bindingContext, _cancelButton.gameObject, nameof(_viewModel.IsCancelButtonVisible));
@ -46,28 +38,27 @@ protected override void SetupBindings()
Close();
});
}
public override void Open(OpenPopupUiEvent evt)
protected override void OnOpenedEventsPopup(OpenPopupUiEvent evt)
{
base.Open(evt);
UnityAction onConfirmAction = evt.OnConfirm != null ? new UnityAction(evt.OnConfirm) : null;
UnityAction onCancelAction = evt.OnCancel != null ? new UnityAction(evt.OnCancel) : null;
_viewModel?.SetupConfirm(evt.NewMessageKey, onConfirmAction, onCancelAction, evt.IsCancelButtonVisible);
}
protected override void OnOpenedEvents()
{
base.OnOpenedEvents();
IsInitialized = true;
}
protected override bool OnInputPerformed(RestaurantUiActions actionEnum, InputAction.CallbackContext context)
{
if (base.OnInputPerformed(actionEnum, context) == false) return false;
protected override void OnClosedEventsPopup(ClosePopupUiEvent evt)
{
}
protected override void OnInputStartedPopup(RestaurantUiActions actionEnum, InputAction.CallbackContext context)
{
}
protected override void OnInputPerformedPopup(RestaurantUiActions actionEnum, InputAction.CallbackContext context)
{
switch (actionEnum)
{
case RestaurantUiActions.Cancel:
@ -77,8 +68,11 @@ protected override bool OnInputPerformed(RestaurantUiActions actionEnum, InputAc
HandleInteract1Performed();
break;
}
}
return true;
protected override void OnInputCanceledPopup(RestaurantUiActions actionEnum, InputAction.CallbackContext context)
{
}
private void HandleCancelPerformed()

View File

@ -14,25 +14,30 @@ public abstract class PopupUi<TInputEnum, TViewModel> : BasePopupUi
protected readonly List<(InputAction action, Action<InputAction.CallbackContext> handler)> _registeredHandlers = new();
protected TViewModel _viewModel;
protected abstract void OnCreatedInitializePopup();
protected abstract void OnOpenedEventsPopup(OpenPopupUiEvent evt);
protected abstract void OnClosedEventsPopup(ClosePopupUiEvent evt);
protected abstract void OnInputStartedPopup(TInputEnum actionEnum, InputAction.CallbackContext context);
protected abstract void OnInputPerformedPopup(TInputEnum actionEnum, InputAction.CallbackContext context);
protected abstract void OnInputCanceledPopup(TInputEnum actionEnum, InputAction.CallbackContext context);
protected override void Awake()
protected override void OnCreatedInitializeBasePopup()
{
base.Awake();
_viewModel = GetComponent<TViewModel>();
OnCreatedInitializePopup();
}
protected override void OnOpenedEvents()
protected override void OnOpenedEventsBasePopup(OpenPopupUiEvent evt)
{
base.OnOpenedEvents();
_viewModel?.Initialize();
if (_viewModel && _bindingContext != null)
{
_bindingContext.SetDataContext(_viewModel);
_viewModel.PropertyChanged += OnViewModelPropertyChanged;
}
// PopupUi의 입력 바인딩 등록
foreach (var actionEnum in _uiActionsInputBinding.BindingActions.GetFlags())
{
if (actionEnum.Equals(default(TInputEnum))) continue;
@ -65,18 +70,17 @@ protected override void OnOpenedEvents()
}
InputActionMaps = _uiActionsInputBinding.InputActionMaps;
OnOpenedEventsPopup(evt);
if (IsTopPopup)
{
InputManager.Instance.SwitchCurrentActionMap(_uiActionsInputBinding.InputActionMaps);
}
}
protected override void OnClosedEvents()
protected override void OnClosedEventsBasePopup(ClosePopupUiEvent evt)
{
base.OnClosedEvents();
if (_viewModel != null)
{
_viewModel.PropertyChanged -= OnViewModelPropertyChanged;
}
// 입력 핸들러 해제
foreach (var (action, handler) in _registeredHandlers)
{
if (action != null)
@ -86,32 +90,30 @@ protected override void OnClosedEvents()
action.canceled -= handler;
}
}
_registeredHandlers.Clear();
}
public override void Open(OpenPopupUiEvent evt)
{
base.Open(evt);
_viewModel?.Initialize();
if (IsTopPopup)
{
InputManager.Instance.SwitchCurrentActionMap(_uiActionsInputBinding.InputActionMaps);
}
}
public override void Close()
{
base.Close();
OnClosedEventsPopup(evt);
_viewModel?.Cleanup();
}
private void OnInputStarted(TInputEnum actionEnum, InputAction.CallbackContext context)
{
if (IsTopPopup == false) return;
OnInputStartedPopup(actionEnum, context);
}
// 입력 처리 메서드들
protected virtual bool OnInputStarted(TInputEnum actionEnum, InputAction.CallbackContext context) => IsTopPopup;
protected virtual bool OnInputPerformed(TInputEnum actionEnum, InputAction.CallbackContext context) => IsTopPopup;
protected virtual bool OnInputCanceled(TInputEnum actionEnum, InputAction.CallbackContext context) => IsTopPopup;
private void OnInputPerformed(TInputEnum actionEnum, InputAction.CallbackContext context)
{
if (IsTopPopup == false) return;
OnInputPerformedPopup(actionEnum, context);
}
private void OnInputCanceled(TInputEnum actionEnum, InputAction.CallbackContext context)
{
if (IsTopPopup == false) return;
OnInputCanceledPopup(actionEnum, context);
}
}
}

View File

@ -69,7 +69,7 @@ public void HandleEvent(OpenPopupUiEvent evt)
if (!popup.IsOpen)
{
PushPopup(popup);
popup.Open(evt);
popup.OpenPopup(evt);
if (popup.IsBlockingTime)
{
@ -83,21 +83,17 @@ public void HandleEvent(OpenPopupUiEvent evt)
}
public void HandleEvent(ClosePopupUiEvent evt)
{
{
if (_popupUis.TryGetValue(evt.UiType, out var popup))
{
if (popup.IsOpen)
{
popup.ClosePanel();
PopPopup(popup);
PopPopup(popup);
if (popup.IsBlockingTime)
{
var timeScaleChangeEvent = GameEvents.RequestTimeScaleChangeEvent;
timeScaleChangeEvent.Requester = popup;
timeScaleChangeEvent.NewTimeScale = 1f;
EventBus.Broadcast(timeScaleChangeEvent);
}
if (popup.IsBlockingTime)
{
var timeScaleChangeEvent = GameEvents.RequestTimeScaleChangeEvent;
timeScaleChangeEvent.Requester = popup;
timeScaleChangeEvent.NewTimeScale = 1f;
EventBus.Broadcast(timeScaleChangeEvent);
}
}
}

View File

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
@ -26,65 +25,6 @@ public class CookUi : PopupUi<RestaurantUiActions, CookViewModel>
[SerializeField] private HorizontalLayoutGroup _tasteHashTagContentLayoutGroup;
[SerializeField] private RectTransform _tasteHashTagContent2;
protected override void OnCreatedInitialize()
{
base.OnCreatedInitialize();
_addedCookTabGroup.Initialize(OnAddedCookTabSelected);
foreach (var selectedIngredient in _selectedIngredients)
{
selectedIngredient.Initialize();
}
}
public override void Open(OpenPopupUiEvent evt)
{
base.Open(evt);
if (evt.Payload is CookwareType cookwareType)
{
_viewModel.SetCookwareType(cookwareType);
}
_viewModel.CreateAddedCookItemSlot(_addedCookContent);
_viewModel.CreateIngredientInventoryItemSlot(_cookIngredientContent);
_addedCookTabGroup.SelectFirstTab();
IsInitialized = true;
}
protected override void OnOpenedEvents()
{
base.OnOpenedEvents();
_viewModel.OnAddedIngredients += OnAddedIngredients;
}
protected override void OnClosedEvents()
{
base.OnClosedEvents();
if (_viewModel)
{
_viewModel.OnAddedIngredients -= OnAddedIngredients;
}
}
protected override void SetupBindings()
{
base.SetupBindings();
BindingHelper.BindImage(_bindingContext, _cookwareImage, nameof(_viewModel.CookwareIcon));
BindingHelper.BindLocalizedStringEvent(_bindingContext, _cookwareName, nameof(_viewModel.CookwareName));
BindingHelper.BindLocalizedStringEvent<CookViewModel>(_bindingContext, _cookName, viewModel => viewModel.SelectedCookSnapshot.Name);
BindingHelper.BindLocalizedStringEvent<CookViewModel>(_bindingContext, _cookDescriptionName, viewModel => viewModel.SelectedCookSnapshot.Description);
BindingHelper.BindText<CookViewModel>(_bindingContext, _cookPrice, viewModel => viewModel.SelectedCookSnapshot.CookPrice);
BindingHelper.BindImage<CookViewModel>(_bindingContext, _cookImage, viewModel => viewModel.SelectedCookSnapshot.CookIcon);
}
protected override GameObject GetInitialSelected()
{
if (IsInitialized == false) return null;
@ -97,11 +37,49 @@ protected override GameObject GetInitialSelected()
return null;
}
protected override bool OnInputPerformed(RestaurantUiActions actionEnum, InputAction.CallbackContext context)
protected override void OnCreatedInitializePopup()
{
if (base.OnInputPerformed(actionEnum, context) == false) return false;
_addedCookTabGroup.Initialize(OnAddedCookTabSelected);
foreach (var selectedIngredient in _selectedIngredients)
{
selectedIngredient.Initialize();
}
SetupBindings();
}
protected override void OnOpenedEventsPopup(OpenPopupUiEvent evt)
{
if (evt.Payload is CookwareType cookwareType)
{
_viewModel.SetCookwareType(cookwareType);
}
_viewModel.CreateAddedCookItemSlot(_addedCookContent);
_viewModel.CreateIngredientInventoryItemSlot(_cookIngredientContent);
_addedCookTabGroup.SelectFirstTab();
_viewModel.OnAddedIngredients += OnAddedIngredients;
}
protected override void OnClosedEventsPopup(ClosePopupUiEvent evt)
{
if (_viewModel)
{
_viewModel.OnAddedIngredients -= OnAddedIngredients;
}
}
protected override void OnInputStartedPopup(RestaurantUiActions actionEnum, InputAction.CallbackContext context)
{
}
protected override void OnInputPerformedPopup(RestaurantUiActions actionEnum, InputAction.CallbackContext context)
{
switch (actionEnum)
{
case RestaurantUiActions.Cancel:
@ -110,9 +88,26 @@ protected override bool OnInputPerformed(RestaurantUiActions actionEnum, InputAc
case RestaurantUiActions.Interact1:
HandleInteract1();
break;
case RestaurantUiActions.Interact2:
HandleInteract2();
break;
}
}
return true;
protected override void OnInputCanceledPopup(RestaurantUiActions actionEnum, InputAction.CallbackContext context)
{
}
private void SetupBindings()
{
BindingHelper.BindImage(_bindingContext, _cookwareImage, nameof(_viewModel.CookwareIcon));
BindingHelper.BindLocalizedStringEvent(_bindingContext, _cookwareName, nameof(_viewModel.CookwareName));
BindingHelper.BindLocalizedStringEvent<CookViewModel>(_bindingContext, _cookName, viewModel => viewModel.SelectedCookSnapshot.Name);
BindingHelper.BindLocalizedStringEvent<CookViewModel>(_bindingContext, _cookDescriptionName, viewModel => viewModel.SelectedCookSnapshot.Description);
BindingHelper.BindText<CookViewModel>(_bindingContext, _cookPrice, viewModel => viewModel.SelectedCookSnapshot.CookPrice);
BindingHelper.BindImage<CookViewModel>(_bindingContext, _cookImage, viewModel => viewModel.SelectedCookSnapshot.CookIcon);
}
private void HandleInteract1()
@ -122,6 +117,11 @@ private void HandleInteract1()
interactable?.OnInteract();
}
private void HandleInteract2()
{
// TODO : 요리 선택 (미니게임 더미 연출)
}
private void OnAddedCookTabSelected(int index)
{
_viewModel.SetAddedCook(index);

View File

@ -35,65 +35,7 @@ protected override void Update()
_viewModel.UpdateHoldProgress();
}
}
protected override void OnCreatedInitialize()
{
base.OnCreatedInitialize();
InitializeViews();
InitializeTabGroups();
SetupCategoryTabs();
}
protected override void OnOpenedEvents()
{
base.OnOpenedEvents();
_sectionTabs.SelectFirstTab();
_menuCategoryTabs.SelectFirstTab();
if (_viewModel)
{
_viewModel.OnBatchCompleted += HandleBatchCompleted;
_viewModel.OnChecklistFailed += HandleChecklistFailed;
_viewModel.OnMenuSectionSelected += HandleMenuSectionSelected;
_viewModel.OnCookwareSectionSelected += HandleCookwareSectionSelected;
_viewModel.OnTabMoved += HandleTabMoved;
_viewModel.OnInteractRequested += HandleInteractRequested;
_viewModel.OnCloseRequested += HandleCloseRequested;
_viewModel.OnMenuCategorySelected += HandleMenuCategorySelected;
}
foreach (var view in _subViews)
{
view.OnOpenedEvents();
}
IsInitialized = true;
}
protected override void OnClosedEvents()
{
base.OnClosedEvents();
if (_viewModel)
{
_viewModel.OnBatchCompleted -= HandleBatchCompleted;
_viewModel.OnChecklistFailed -= HandleChecklistFailed;
_viewModel.OnMenuSectionSelected -= HandleMenuSectionSelected;
_viewModel.OnCookwareSectionSelected -= HandleCookwareSectionSelected;
_viewModel.OnTabMoved -= HandleTabMoved;
_viewModel.OnInteractRequested -= HandleInteractRequested;
_viewModel.OnCloseRequested -= HandleCloseRequested;
_viewModel.OnMenuCategorySelected -= HandleMenuCategorySelected;
}
foreach (var view in _subViews)
{
view.OnClosedEvents();
}
}
protected override GameObject GetInitialSelected()
{
if (IsInitialized == false) return null;
@ -118,11 +60,97 @@ protected override GameObject GetInitialSelected()
return null;
}
protected override void SetupBindings()
protected override void OnCreatedInitializePopup()
{
base.SetupBindings();
InitializeViews();
InitializeTabGroups();
SetupCategoryTabs();
SetupBindings();
}
protected override void OnOpenedEventsPopup(OpenPopupUiEvent evt)
{
_sectionTabs.SelectFirstTab();
_menuCategoryTabs.SelectFirstTab();
if (_viewModel)
{
_viewModel.OnBatchCompleted += HandleBatchCompleted;
_viewModel.OnChecklistFailed += HandleChecklistFailed;
_viewModel.OnMenuSectionSelected += HandleMenuSectionSelected;
_viewModel.OnCookwareSectionSelected += HandleCookwareSectionSelected;
_viewModel.OnTabMoved += HandleTabMoved;
_viewModel.OnInteractRequested += HandleInteractRequested;
_viewModel.OnCloseRequested += HandleCloseRequested;
_viewModel.OnMenuCategorySelected += HandleMenuCategorySelected;
}
foreach (var view in _subViews)
{
view.OnOpenedEvents();
}
}
protected override void OnClosedEventsPopup(ClosePopupUiEvent evt)
{
if (_viewModel)
{
_viewModel.OnBatchCompleted -= HandleBatchCompleted;
_viewModel.OnChecklistFailed -= HandleChecklistFailed;
_viewModel.OnMenuSectionSelected -= HandleMenuSectionSelected;
_viewModel.OnCookwareSectionSelected -= HandleCookwareSectionSelected;
_viewModel.OnTabMoved -= HandleTabMoved;
_viewModel.OnInteractRequested -= HandleInteractRequested;
_viewModel.OnCloseRequested -= HandleCloseRequested;
_viewModel.OnMenuCategorySelected -= HandleMenuCategorySelected;
}
foreach (var view in _subViews)
{
view.OnClosedEvents();
}
}
protected override void OnInputStartedPopup(RestaurantUiActions actionEnum, InputAction.CallbackContext context)
{
}
protected override void OnInputPerformedPopup(RestaurantUiActions actionEnum, InputAction.CallbackContext context)
{
switch (actionEnum)
{
case RestaurantUiActions.Cancel:
_viewModel.CloseUi();
break;
case RestaurantUiActions.PreviousTab:
_viewModel.MoveTab(-1);
break;
case RestaurantUiActions.NextTab:
_viewModel.MoveTab(1);
break;
case RestaurantUiActions.Interact1:
_viewModel.InteractWithSelected();
break;
case RestaurantUiActions.Interact2:
_viewModel.StartHold();
break;
}
}
protected override void OnInputCanceledPopup(RestaurantUiActions actionEnum, InputAction.CallbackContext context)
{
switch (actionEnum)
{
case RestaurantUiActions.Interact2:
_viewModel.CancelHold();
break;
}
}
private void SetupBindings()
{
BindingHelper.BindImageFilled(_bindingContext, _completeBatchFilledImage, nameof(RestaurantManagementViewModel.NormalizedHoldProgress));
_itemDetailView.SetupBindings(_bindingContext);
@ -191,8 +219,7 @@ protected override void HandleCustomPropertyChanged(string propertyName)
break;
}
}
// ViewModel 이벤트 핸들러들
private void HandleBatchCompleted()
{
Close();
@ -239,8 +266,7 @@ private void HandleMenuCategorySelected(InventoryCategoryType category)
{
_menuCategoryTabs.SelectTab((int)category);
}
// UI 이벤트 핸들러들 (TabGroupUi 콜백)
private void OnSectionTabSelected(int sectionValue)
{
_viewModel?.SetSection((SectionButtonType)sectionValue);
@ -250,46 +276,5 @@ private void OnCategoryTabSelected(int categoryValue)
{
_viewModel?.SetCategory((InventoryCategoryType)categoryValue);
}
// 입력 처리 - ViewModel로 위임
protected override bool OnInputPerformed(RestaurantUiActions actionEnum, InputAction.CallbackContext context)
{
if (base.OnInputPerformed(actionEnum, context) == false) return false;
switch (actionEnum)
{
case RestaurantUiActions.Cancel:
_viewModel.CloseUi();
break;
case RestaurantUiActions.PreviousTab:
_viewModel.MoveTab(-1);
break;
case RestaurantUiActions.NextTab:
_viewModel.MoveTab(1);
break;
case RestaurantUiActions.Interact1:
_viewModel.InteractWithSelected();
break;
case RestaurantUiActions.Interact2:
_viewModel.StartHold();
break;
}
return true;
}
protected override bool OnInputCanceled(RestaurantUiActions actionEnum, InputAction.CallbackContext context)
{
if (base.OnInputPerformed(actionEnum, context) == false) return false;
switch (actionEnum)
{
case RestaurantUiActions.Interact2:
_viewModel.CancelHold();
break;
}
return true;
}
}
}