| | 1 | | using System; |
| | 2 | | using DCL.NotificationModel; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | public class NotificationHUDView : MonoBehaviour, IDisposable |
| | 6 | | { |
| | 7 | | public NotificationFactory notificationFactory; |
| | 8 | |
|
| | 9 | | [SerializeField] |
| | 10 | | private RectTransform notificationPanel; |
| | 11 | |
|
| | 12 | | public event Action<INotification> OnNotificationDismissedEvent; |
| | 13 | |
|
| | 14 | | public void ShowNotification(INotification notification, Model model = null) |
| | 15 | | { |
| 4 | 16 | | if (notification == null) |
| 0 | 17 | | return; |
| | 18 | |
|
| 4 | 19 | | notification.OnNotificationDismissed += OnNotificationDismissed; |
| | 20 | |
|
| 4 | 21 | | if (model != null) |
| 4 | 22 | | notification.Show(model); |
| 4 | 23 | | } |
| | 24 | |
|
| | 25 | | public Notification ShowNotification(Model notificationModel) |
| | 26 | | { |
| 4 | 27 | | if (notificationModel == null) |
| 0 | 28 | | return null; |
| | 29 | |
|
| 4 | 30 | | Notification notification = notificationFactory.CreateNotificationFromType(notificationModel.type, notificationP |
| 4 | 31 | | notificationModel.destroyOnFinish = true; |
| 4 | 32 | | ShowNotification(notification, notificationModel); |
| 4 | 33 | | return notification; |
| | 34 | | } |
| | 35 | |
|
| 2 | 36 | | private void OnNotificationDismissed(INotification notification) { OnNotificationDismissedEvent?.Invoke(notification |
| | 37 | |
|
| 2 | 38 | | public void SetActive(bool active) { gameObject.SetActive(active); } |
| | 39 | |
|
| | 40 | | public void Dispose() |
| | 41 | | { |
| 0 | 42 | | } |
| | 43 | | } |