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