| | 1 | | using DCL; |
| | 2 | | using ExploreV2Analytics; |
| | 3 | | using System; |
| | 4 | |
|
| | 5 | | public interface IPlacesAndEventsSectionComponentController : IDisposable |
| | 6 | | { |
| | 7 | | /// <summary> |
| | 8 | | /// It will be triggered when the section want to request to close the ExploreV2 main menu. |
| | 9 | | /// </summary> |
| | 10 | | event Action<bool> OnCloseExploreV2; |
| | 11 | | } |
| | 12 | |
|
| | 13 | | public class PlacesAndEventsSectionComponentController : IPlacesAndEventsSectionComponentController |
| | 14 | | { |
| | 15 | | internal const float MIN_TIME_TO_CHECK_API = 60f; |
| | 16 | |
|
| | 17 | | public event Action<bool> OnCloseExploreV2; |
| | 18 | |
|
| | 19 | | internal IPlacesAndEventsSectionComponentView view; |
| | 20 | | internal IHighlightsSubSectionComponentController highlightsSubSectionComponentController; |
| | 21 | | internal IPlacesSubSectionComponentController placesSubSectionComponentController; |
| | 22 | | internal IEventsSubSectionComponentController eventsSubSectionComponentController; |
| | 23 | |
|
| 18 | 24 | | internal BaseVariable<bool> placesAndEventsVisible => DataStore.i.exploreV2.placesAndEventsVisible; |
| | 25 | |
|
| 6 | 26 | | public PlacesAndEventsSectionComponentController(IPlacesAndEventsSectionComponentView view, IExploreV2Analytics expl |
| | 27 | | { |
| 6 | 28 | | this.view = view; |
| | 29 | |
|
| 6 | 30 | | PlacesAPIController placesAPI = new PlacesAPIController(); |
| 6 | 31 | | EventsAPIController eventsAPI = new EventsAPIController(); |
| | 32 | |
|
| 6 | 33 | | highlightsSubSectionComponentController = new HighlightsSubSectionComponentController( |
| | 34 | | view.currentHighlightsSubSectionComponentView, |
| | 35 | | placesAPI, |
| | 36 | | eventsAPI, |
| | 37 | | FriendsController.i, |
| | 38 | | exploreV2Analytics); |
| | 39 | |
|
| 6 | 40 | | highlightsSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing; |
| 6 | 41 | | highlightsSubSectionComponentController.OnGoToEventsSubSection += GoToEventsSubSection; |
| | 42 | |
|
| 6 | 43 | | placesSubSectionComponentController = new PlacesSubSectionComponentController( |
| | 44 | | view.currentPlacesSubSectionComponentView, |
| | 45 | | placesAPI, |
| | 46 | | FriendsController.i, |
| | 47 | | exploreV2Analytics); |
| | 48 | |
|
| 6 | 49 | | placesSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing; |
| | 50 | |
|
| 6 | 51 | | eventsSubSectionComponentController = new EventsSubSectionComponentController( |
| | 52 | | view.currentEventsSubSectionComponentView, |
| | 53 | | eventsAPI, |
| | 54 | | exploreV2Analytics); |
| | 55 | |
|
| 6 | 56 | | eventsSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing; |
| | 57 | |
|
| 6 | 58 | | placesAndEventsVisible.OnChange += PlacesAndEventsVisibleChanged; |
| 6 | 59 | | PlacesAndEventsVisibleChanged(placesAndEventsVisible.Get(), false); |
| 6 | 60 | | } |
| | 61 | |
|
| 2 | 62 | | internal void RequestExploreV2Closing() { OnCloseExploreV2?.Invoke(false); } |
| | 63 | |
|
| 2 | 64 | | internal void GoToEventsSubSection() { view.GoToSubsection(PlacesAndEventsSectionComponentView.EVENTS_SUB_SECTION_IN |
| | 65 | |
|
| | 66 | | public void Dispose() |
| | 67 | | { |
| 6 | 68 | | highlightsSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing; |
| 6 | 69 | | highlightsSubSectionComponentController.OnGoToEventsSubSection -= GoToEventsSubSection; |
| 6 | 70 | | highlightsSubSectionComponentController.Dispose(); |
| | 71 | |
|
| 6 | 72 | | placesSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing; |
| 6 | 73 | | placesSubSectionComponentController.Dispose(); |
| | 74 | |
|
| 6 | 75 | | eventsSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing; |
| 6 | 76 | | eventsSubSectionComponentController.Dispose(); |
| | 77 | |
|
| 6 | 78 | | placesAndEventsVisible.OnChange -= PlacesAndEventsVisibleChanged; |
| 6 | 79 | | } |
| | 80 | |
|
| 16 | 81 | | internal void PlacesAndEventsVisibleChanged(bool current, bool previous) { view.SetActive(current); } |
| | 82 | | } |