| | 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 | | public event Action<bool> OnCloseExploreV2; |
| | 16 | |
|
| | 17 | | internal IPlacesAndEventsSectionComponentView view; |
| | 18 | | internal IHighlightsSubSectionComponentController highlightsSubSectionComponentController; |
| | 19 | | internal IPlacesSubSectionComponentController placesSubSectionComponentController; |
| | 20 | | internal IEventsSubSectionComponentController eventsSubSectionComponentController; |
| | 21 | |
|
| 18 | 22 | | internal BaseVariable<bool> placesAndEventsVisible => DataStore.i.exploreV2.placesAndEventsVisible; |
| | 23 | |
|
| 6 | 24 | | public PlacesAndEventsSectionComponentController(IPlacesAndEventsSectionComponentView view, IExploreV2Analytics expl |
| | 25 | | { |
| 6 | 26 | | this.view = view; |
| | 27 | |
|
| 6 | 28 | | PlacesAPIController placesAPI = new PlacesAPIController(); |
| 6 | 29 | | EventsAPIController eventsAPI = new EventsAPIController(); |
| | 30 | |
|
| 6 | 31 | | highlightsSubSectionComponentController = new HighlightsSubSectionComponentController( |
| | 32 | | view.currentHighlightsSubSectionComponentView, |
| | 33 | | placesAPI, |
| | 34 | | eventsAPI, |
| | 35 | | FriendsController.i, |
| | 36 | | exploreV2Analytics); |
| | 37 | |
|
| 6 | 38 | | highlightsSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing; |
| 6 | 39 | | highlightsSubSectionComponentController.OnGoToEventsSubSection += GoToEventsSubSection; |
| | 40 | |
|
| 6 | 41 | | placesSubSectionComponentController = new PlacesSubSectionComponentController( |
| | 42 | | view.currentPlacesSubSectionComponentView, |
| | 43 | | placesAPI, |
| | 44 | | FriendsController.i, |
| | 45 | | exploreV2Analytics); |
| | 46 | |
|
| 6 | 47 | | placesSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing; |
| | 48 | |
|
| 6 | 49 | | eventsSubSectionComponentController = new EventsSubSectionComponentController( |
| | 50 | | view.currentEventsSubSectionComponentView, |
| | 51 | | eventsAPI, |
| | 52 | | exploreV2Analytics); |
| | 53 | |
|
| 6 | 54 | | eventsSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing; |
| | 55 | |
|
| 6 | 56 | | placesAndEventsVisible.OnChange += PlacesAndEventsVisibleChanged; |
| 6 | 57 | | PlacesAndEventsVisibleChanged(placesAndEventsVisible.Get(), false); |
| 6 | 58 | | } |
| | 59 | |
|
| 2 | 60 | | internal void RequestExploreV2Closing() { OnCloseExploreV2?.Invoke(false); } |
| | 61 | |
|
| 2 | 62 | | internal void GoToEventsSubSection() { view.GoToSubsection(PlacesAndEventsSectionComponentView.EVENTS_SUB_SECTION_IN |
| | 63 | |
|
| | 64 | | public void Dispose() |
| | 65 | | { |
| 6 | 66 | | highlightsSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing; |
| 6 | 67 | | highlightsSubSectionComponentController.OnGoToEventsSubSection -= GoToEventsSubSection; |
| 6 | 68 | | highlightsSubSectionComponentController.Dispose(); |
| | 69 | |
|
| 6 | 70 | | placesSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing; |
| 6 | 71 | | placesSubSectionComponentController.Dispose(); |
| | 72 | |
|
| 6 | 73 | | eventsSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing; |
| 6 | 74 | | eventsSubSectionComponentController.Dispose(); |
| | 75 | |
|
| 6 | 76 | | placesAndEventsVisible.OnChange -= PlacesAndEventsVisibleChanged; |
| 6 | 77 | | } |
| | 78 | |
|
| 16 | 79 | | internal void PlacesAndEventsVisibleChanged(bool current, bool previous) { view.SetActive(current); } |
| | 80 | | } |