| | 1 | | using TMPro; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.UI; |
| | 4 | |
|
| | 5 | | public interface IBIWSearchBarView |
| | 6 | | { |
| | 7 | | TMP_InputField searchInput { get; } |
| | 8 | | Button smartItemBtn { get; } |
| | 9 | | void SetSmartItemPressStatus(bool isPressed); |
| | 10 | | void SetEmptyFilter(); |
| | 11 | | } |
| | 12 | |
|
| | 13 | | public class BIWSearchBarView : MonoBehaviour , IBIWSearchBarView |
| | 14 | | { |
| 2 | 15 | | public TMP_InputField searchInput => searchInputField; |
| 2 | 16 | | public Button smartItemBtn => smartItemButton; |
| | 17 | |
|
| | 18 | | public Color smartItemPressedBtnColor; |
| | 19 | | public Color smartItemNormalBtnColor; |
| | 20 | |
|
| | 21 | | [Header("Prefab References")] |
| | 22 | | [SerializeField] internal TMP_InputField searchInputField; |
| | 23 | | [SerializeField] internal Button smartItemButton; |
| | 24 | | [SerializeField] internal Button clearSearchButton; |
| | 25 | |
|
| | 26 | | private void Awake() |
| | 27 | | { |
| 15 | 28 | | if (searchInputField.placeholder != null) |
| | 29 | | { |
| 15 | 30 | | searchInput.onSelect.AddListener((x) => searchInputField.placeholder.gameObject.SetActive(false)); |
| 15 | 31 | | searchInput.onDeselect.AddListener((x) => searchInputField.placeholder.gameObject.SetActive(true)); |
| | 32 | | } |
| | 33 | |
|
| 15 | 34 | | clearSearchButton.onClick.AddListener(() => searchInputField.text = string.Empty); |
| 15 | 35 | | } |
| | 36 | |
|
| | 37 | | private void OnDestroy() |
| | 38 | | { |
| 15 | 39 | | searchInput.onSelect.RemoveAllListeners(); |
| 15 | 40 | | searchInput.onDeselect.RemoveAllListeners(); |
| 15 | 41 | | clearSearchButton.onClick.RemoveAllListeners(); |
| 15 | 42 | | } |
| | 43 | |
|
| 0 | 44 | | public void SetSmartItemPressStatus(bool isPressed) { smartItemBtn.image.color = isPressed ? smartItemPressedBtnColo |
| | 45 | |
|
| 0 | 46 | | public void SetEmptyFilter() { searchInputField.text = ""; } |
| | 47 | | } |