| | 1 | | using DCL.SettingsPanelHUD.Widgets; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using UnityEngine; |
| | 4 | | using System.Linq; |
| | 5 | |
|
| | 6 | | namespace DCL.SettingsPanelHUD.Sections |
| | 7 | | { |
| | 8 | | /// <summary> |
| | 9 | | /// Interface to implement a controller for a SECTION. |
| | 10 | | /// </summary> |
| | 11 | | public interface ISettingsSectionController |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// List of all WIDGETS added to the SECTION. |
| | 15 | | /// </summary> |
| | 16 | | List<ISettingsWidgetView> widgets { get; } |
| | 17 | |
|
| | 18 | | /// <summary> |
| | 19 | | /// Adds a WIDGET into the SECTION. |
| | 20 | | /// </summary> |
| | 21 | | /// <param name="newWidget">New WIDGET that will be added.</param> |
| | 22 | | /// <param name="newWidgetController">Controller belonging to the new WIDGET.</param> |
| | 23 | | /// <param name="widgetConfig">Model that will contain the configuration of the new WIDGET.</param> |
| | 24 | | void AddWidget(ISettingsWidgetView newWidget, ISettingsWidgetController newWidgetController, SettingsWidgetModel |
| | 25 | | } |
| | 26 | |
|
| | 27 | | /// <summary> |
| | 28 | | /// This controller is in charge of manage all the logic related to a SECTION. |
| | 29 | | /// </summary> |
| | 30 | | [CreateAssetMenu(menuName = "Settings/Controllers/Section", fileName = "SettingsSectionController")] |
| | 31 | | public class SettingsSectionController : ScriptableObject, ISettingsSectionController |
| | 32 | | { |
| 6 | 33 | | public List<ISettingsWidgetView> widgets { get; } = new List<ISettingsWidgetView>(); |
| | 34 | |
|
| | 35 | | public void AddWidget( |
| | 36 | | ISettingsWidgetView newWidget, |
| | 37 | | ISettingsWidgetController newWidgetController, |
| | 38 | | SettingsWidgetModel widgetConfig) |
| | 39 | | { |
| 5 | 40 | | newWidget.Initialize(widgetConfig.title, newWidgetController, widgetConfig.controlColumns.ToList()); |
| 5 | 41 | | widgets.Add(newWidget); |
| 5 | 42 | | } |
| | 43 | | } |
| | 44 | | } |