using System;
using System.Collections.Generic;
using Cute;
using UnityEngine;

namespace Wizard;

[AddComponentMenu("NGUI/Interaction/Drag Multi Scroll View (wizard)")]
public class UIDragMultiScrollView : MonoBehaviour
{
	[SerializeField]
	private List<UIScrollView> _scrollViewList;

	public Action<bool> OnPressCallback { private get; set; }

	public Action<float> OnScrollCallback { private get; set; }

	public void AddScrollView(UIScrollView scrollView)
	{
		if (!_scrollViewList.Contains(scrollView))
		{
			_scrollViewList.Add(scrollView);
		}
	}

	public void RemoveScrollView(UIScrollView scrollView)
	{
		if (_scrollViewList.Contains(scrollView))
		{
			_scrollViewList.Remove(scrollView);
		}
	}

	public void OnPress(bool pressed)
	{
		if (!NGUITools.GetActive(this) || _scrollViewList.Count == 0)
		{
			return;
		}
		foreach (UIScrollView scrollView in _scrollViewList)
		{
			scrollView.Press(pressed);
		}
		OnPressCallback.Call(pressed);
	}

	public void OnDrag(Vector2 delta)
	{
		if (!NGUITools.GetActive(this) || _scrollViewList.Count == 0)
		{
			return;
		}
		foreach (UIScrollView scrollView in _scrollViewList)
		{
			scrollView.Drag();
		}
	}

	public void OnScroll(float delta)
	{
		if (!NGUITools.GetActive(this) || _scrollViewList.Count == 0)
		{
			return;
		}
		foreach (UIScrollView scrollView in _scrollViewList)
		{
			scrollView.Scroll(delta);
		}
		OnScrollCallback.Call(delta);
	}

	public void OnPan(Vector2 delta)
	{
		if (!NGUITools.GetActive(this) || _scrollViewList.Count == 0)
		{
			return;
		}
		foreach (UIScrollView scrollView in _scrollViewList)
		{
			scrollView.OnPan(delta);
		}
	}
}
