| | 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 | | private DataStore dataStore; |
| | 24 | |
|
| 18 | 25 | | internal BaseVariable<bool> placesAndEventsVisible => dataStore.exploreV2.placesAndEventsVisible; |
| | 26 | |
|
| 6 | 27 | | public PlacesAndEventsSectionComponentController( |
| | 28 | | IPlacesAndEventsSectionComponentView view, |
| | 29 | | IExploreV2Analytics exploreV2Analytics, |
| | 30 | | DataStore dataStore) |
| | 31 | | { |
| 6 | 32 | | this.view = view; |
| 6 | 33 | | this.dataStore = dataStore; |
| | 34 | |
|
| 6 | 35 | | PlacesAPIController placesAPI = new PlacesAPIController(); |
| 6 | 36 | | EventsAPIController eventsAPI = new EventsAPIController(); |
| | 37 | |
|
| 6 | 38 | | highlightsSubSectionComponentController = new HighlightsSubSectionComponentController( |
| | 39 | | view.HighlightsSubSectionView, |
| | 40 | | placesAPI, |
| | 41 | | eventsAPI, |
| | 42 | | FriendsController.i, |
| | 43 | | exploreV2Analytics, |
| | 44 | | dataStore); |
| | 45 | |
|
| 6 | 46 | | highlightsSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing; |
| 6 | 47 | | highlightsSubSectionComponentController.OnGoToEventsSubSection += GoToEventsSubSection; |
| | 48 | |
|
| 6 | 49 | | placesSubSectionComponentController = new PlacesSubSectionComponentController( |
| | 50 | | view.PlacesSubSectionView, |
| | 51 | | placesAPI, |
| | 52 | | FriendsController.i, |
| | 53 | | exploreV2Analytics, |
| | 54 | | dataStore); |
| | 55 | |
|
| 6 | 56 | | placesSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing; |
| | 57 | |
|
| 6 | 58 | | eventsSubSectionComponentController = new EventsSubSectionComponentController( |
| | 59 | | view.EventsSubSectionView, |
| | 60 | | eventsAPI, |
| | 61 | | exploreV2Analytics, |
| | 62 | | dataStore); |
| | 63 | |
|
| 6 | 64 | | eventsSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing; |
| | 65 | |
|
| 6 | 66 | | placesAndEventsVisible.OnChange += PlacesAndEventsVisibleChanged; |
| 6 | 67 | | PlacesAndEventsVisibleChanged(placesAndEventsVisible.Get(), false); |
| 6 | 68 | | } |
| | 69 | |
|
| 2 | 70 | | internal void RequestExploreV2Closing() { OnCloseExploreV2?.Invoke(false); } |
| | 71 | |
|
| 2 | 72 | | internal void GoToEventsSubSection() { view.GoToSubsection(PlacesAndEventsSectionComponentView.EVENTS_SUB_SECTION_IN |
| | 73 | |
|
| | 74 | | public void Dispose() |
| | 75 | | { |
| 6 | 76 | | highlightsSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing; |
| 6 | 77 | | highlightsSubSectionComponentController.OnGoToEventsSubSection -= GoToEventsSubSection; |
| 6 | 78 | | highlightsSubSectionComponentController.Dispose(); |
| | 79 | |
|
| 6 | 80 | | placesSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing; |
| 6 | 81 | | placesSubSectionComponentController.Dispose(); |
| | 82 | |
|
| 6 | 83 | | eventsSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing; |
| 6 | 84 | | eventsSubSectionComponentController.Dispose(); |
| | 85 | |
|
| 6 | 86 | | placesAndEventsVisible.OnChange -= PlacesAndEventsVisibleChanged; |
| 6 | 87 | | } |
| | 88 | |
|
| 8 | 89 | | internal void PlacesAndEventsVisibleChanged(bool current, bool _) => view.SetActive(current); |
| | 90 | | } |