using System.Collections.Generic;
using DG.Tweening;
using Kill.Managers;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Kill.UI.Pages
{
///
/// 首页设备列表项 - 显示单个设备信息
/// 支持左滑手势:左滑时内容元素向左滑出,露出右侧菜单,
/// 滑动超过菜单宽度1/3松手则完整展开,否则缩回
///
public class HomePageDeviceItem : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
public Text deviceNameText;
///
/// 置顶标识
///
public GameObject topIcon;
public GameObject selectedIndicator;
/// 菜单(子物体,锚点位于item最右侧),内容左移后露出
public RectTransform menuRect;
// 当前设备信息
public DeviceInfo deviceInfo;
///
/// 菜单按钮数组 0:重命名 1:分享 2:删除 3:置顶 4:取消置顶
/// 最多显示3个按钮 拥有的设备显示分享 被分享的设备显示删除
/// 根据置顶状态显示置顶/取消置顶按钮
///
public Button[] menuButtons;
/// 当前展开菜单的item(全局仅允许一个菜单展开)
private static HomePageDeviceItem openItem;
private float menuWidth;
private float currentOffset;
private float dragStartOffset;
private bool isMenuOpen;
private bool isDragging;
private Vector3 menuInitPos;
private Tweener tweener;
private Button button;
private bool menuListenersBound;
/// 除菜单外的内容子物体
private readonly List contentRects = new List();
/// 各内容子物体的初始位置
private readonly List contentInitPositions = new List();
void Awake()
{
button = GetComponent