Files
XRLib/Assets/Scripts/Factory/UIToolkit/Modal/UTKFactorySettingModalContentDisplay.cs

115 lines
3.5 KiB
C#

#nullable enable
using Cysharp.Threading.Tasks;
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
using UVC.UIToolkit;
namespace Factory.UIToolkit.Modal
{
/// <summary>
/// 설정 모달 - Display 탭 콘텐츠
/// </summary>
[UxmlElement]
public partial class UTKFactorySettingModalContentDisplay : VisualElement, IDisposable, IUTKTabContent
{
#region Constants
private const string UXML_PATH = "Factory/UIToolkit/Modal/UTKFactorySettingModalContentDisplayUXML";
#endregion
#region Fields
private bool _disposed;
#endregion
#region Properties
private UTKReordableTabList? _reordableTabList;
#endregion
#region Constructor
public UTKFactorySettingModalContentDisplay()
{
var asset = Resources.Load<VisualTreeAsset>(UXML_PATH);
if (asset != null)
{
var root = asset.Instantiate();
root.style.flexGrow = 1;
_reordableTabList = root.Q<UTKReordableTabList>("tab-list");
if(_reordableTabList != null)
{
_reordableTabList.OnDataChanged += OnDataChanged;
_reordableTabList.OnOrderChanged += OnOrderChanged;
SetTabListSampleData();
}
Add(root);
}
}
private void OnDataChanged(string tabName, int tabIndex)
{
Debug.Log($"Tab '{tabName}' at index {tabIndex} has changed.");
}
private void OnOrderChanged(string tabName, int tabIndex)
{
Debug.Log($"Tab '{tabName}' moved index {tabIndex}.");
}
private void SetTabListSampleData()
{
var data = new Dictionary<string, List<Dictionary<string, string>>>
{
["센서"] = new()
{
new() { ["order"] = "0", ["active"] = "True", ["text"] = "온도 센서" },
new() { ["order"] = "1", ["active"] = "True", ["text"] = "습도 센서" },
new() { ["order"] = "2", ["active"] = "False", ["text"] = "압력 센서" },
},
["장비"] = new()
{
new() { ["order"] = "0", ["active"] = "True", ["text"] = "컨베이어" },
new() { ["order"] = "1", ["active"] = "False", ["text"] = "로봇암" },
new() { ["order"] = "2", ["active"] = "True", ["text"] = "CNC" },
new() { ["order"] = "3", ["active"] = "True", ["text"] = "AGV" },
},
["알림"] = new()
{
new() { ["order"] = "0", ["active"] = "True", ["text"] = "경고" },
new() { ["order"] = "1", ["active"] = "True", ["text"] = "에러" },
}
};
_reordableTabList?.SetData(data);
}
#endregion
#region Public Methods
public void Show(object? data)
{
}
public async UniTask Hide()
{
}
#endregion
#region IDisposable
public void Dispose()
{
if (_disposed) return;
_disposed = true;
if (_reordableTabList != null)
{
_reordableTabList.OnDataChanged -= OnDataChanged;
_reordableTabList.OnOrderChanged -= OnOrderChanged;
}
}
#endregion
}
}