| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using TMPro; |
| | 5 | | using UnityEngine; |
| | 6 | |
|
| | 7 | | namespace DCL.Builder |
| | 8 | | { |
| | 9 | | public class NewProjectFirstStepView : BaseComponentView |
| | 10 | | { |
| | 11 | | public event Action OnBackPressed; |
| | 12 | | public event Action<string, string> OnNextPressed; |
| | 13 | |
|
| | 14 | | [SerializeField] internal LimitInputField titleInputField; |
| | 15 | | [SerializeField] private LimitInputField descriptionInputField; |
| | 16 | |
|
| | 17 | | [SerializeField] internal ButtonComponentView nextButton; |
| | 18 | | [SerializeField] private ButtonComponentView backButton; |
| | 19 | |
|
| | 20 | | // Start is called before the first frame update |
| | 21 | | public override void Awake() |
| | 22 | | { |
| 8 | 23 | | base.Awake(); |
| | 24 | |
|
| 8 | 25 | | titleInputField.OnLimitReached += DisableNextButton; |
| 8 | 26 | | titleInputField.OnEmptyValue += DisableNextButton; |
| 8 | 27 | | titleInputField.OnInputAvailable += EnableNextButton; |
| | 28 | |
|
| 8 | 29 | | descriptionInputField.OnLimitReached += DisableNextButton; |
| 8 | 30 | | descriptionInputField.OnInputAvailable += EnableNextButton; |
| | 31 | |
|
| 8 | 32 | | backButton.onClick.AddListener(BackPressed); |
| 8 | 33 | | nextButton.onClick.AddListener(NextPressed); |
| | 34 | |
|
| 8 | 35 | | DisableNextButton(); |
| 8 | 36 | | } |
| | 37 | |
|
| 0 | 38 | | public override void RefreshControl() { } |
| | 39 | |
|
| | 40 | | public override void Dispose() |
| | 41 | | { |
| 8 | 42 | | base.Dispose(); |
| 8 | 43 | | titleInputField.OnLimitReached -= DisableNextButton; |
| 8 | 44 | | titleInputField.OnEmptyValue -= DisableNextButton; |
| 8 | 45 | | titleInputField.OnInputAvailable -= EnableNextButton; |
| | 46 | |
|
| 8 | 47 | | descriptionInputField.OnLimitReached -= DisableNextButton; |
| 8 | 48 | | descriptionInputField.OnInputAvailable -= EnableNextButton; |
| | 49 | |
|
| 8 | 50 | | backButton.onClick.RemoveListener(BackPressed); |
| 8 | 51 | | nextButton.onClick.RemoveListener(NextPressed); |
| 8 | 52 | | } |
| | 53 | |
|
| | 54 | | internal void NextPressed() |
| | 55 | | { |
| 1 | 56 | | if (!nextButton.IsInteractable()) |
| 0 | 57 | | return; |
| | 58 | |
|
| 1 | 59 | | string title = titleInputField.GetValue(); |
| 1 | 60 | | string description = descriptionInputField.GetValue(); |
| | 61 | |
|
| 1 | 62 | | OnNextPressed?.Invoke(title, description); |
| 1 | 63 | | } |
| | 64 | |
|
| 2 | 65 | | internal void BackPressed() { OnBackPressed?.Invoke(); } |
| | 66 | |
|
| 6 | 67 | | internal void EnableNextButton() { nextButton.SetInteractable(true); } |
| | 68 | |
|
| 22 | 69 | | internal void DisableNextButton() { nextButton.SetInteractable(false); } |
| | 70 | |
|
| | 71 | | } |
| | 72 | | } |