80 lines
2.8 KiB
C#
80 lines
2.8 KiB
C#
#nullable enable
|
|
using Cysharp.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UVC.Data;
|
|
using UVC.Data.Core;
|
|
using UVC.UI.Tab;
|
|
|
|
namespace UVC.Factory.Modal.Settings
|
|
{
|
|
public class DisplaySettingTabContent: MonoBehaviour, ITabContent
|
|
{
|
|
[SerializeField]
|
|
public TabController tabController; // 탭 컨트롤러
|
|
|
|
/// <summary>
|
|
/// 탭 콘텐츠에 데이터를 전달합니다.
|
|
/// </summary>
|
|
/// <param name="data">전달할 데이터 객체</param>
|
|
public void SetContentData(object? data)
|
|
{
|
|
Debug.Log($"SetContentData: {data}");
|
|
if (tabController != null)
|
|
{
|
|
//mask 설정을 않한 경우 데이터를 보여줄 수 없음 -> DataRepository에서 가져와서 처리
|
|
|
|
var keys = DataRepository.Instance.GetAllKeys();// DataMask.DataMasks;
|
|
foreach (var item in keys)
|
|
{
|
|
Debug.Log($"Key: {item}, Value: {item}");
|
|
// 1. TabConfig 설정
|
|
tabController.AddTabConfig(item, item, "Factory/Prefabs/Modal/Setting/DisplayDataOrderTabContent", "", item, true);
|
|
}
|
|
|
|
// 2. 컨트롤러 초기화
|
|
tabController.Initialize();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 탭 전환 시 데이터가 있는 경우 전달 되는 데이터. SetContentData 이후 호출 됨
|
|
/// </summary>
|
|
/// <param name="data">전달할 데이터 객체</param>
|
|
public void UpdateContentData(object? data)
|
|
{
|
|
if (data != null && data is string content)
|
|
{
|
|
Debug.Log($"UpdateContentData: {content}");
|
|
|
|
if (content.StartsWith("shortcut:"))
|
|
{
|
|
// 특정 탭으로 이동
|
|
string[] parts = content.Substring("shortcut:".Length - 1).Split('>');
|
|
if (parts.Length > 1)
|
|
{
|
|
// 시간차를 계산해 0.5초 후에 탭을 활성화
|
|
UniTask.Delay(500).ContinueWith(() => {
|
|
string tabKey = parts[1];
|
|
Debug.Log($"ActivateTab2: {tabKey}");
|
|
tabController?.ActivateTab(tabKey);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 닫힐 때 실행되는 로직을 처리합니다.
|
|
/// </summary>
|
|
/// <returns>비동기 닫기 작업을 나타내는 <see cref="UniTask"/>입니다.</returns>
|
|
public async UniTask OnCloseAsync()
|
|
{
|
|
await UserSetting.SaveToAppData(); // 데이터 마스크를 앱 데이터에 저장합니다.
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|