Exemple #1
0
        /// <summary>
        /// Creates a date picker dialog that can be modified or stored before showing.
        /// <para></para>
        /// Before calling <see cref="DialogDatePicker.Show"/>, call <see cref="DialogDatePicker.Initialize(int,int,int,Action{DateTime},Action,Color)"/>.
        /// <para></para>
        /// For a simpler solution with less customizability, use <see cref="ShowDatePicker(int,int,int,Action{DateTime},Color)"/>.
        /// </summary>
        /// <returns>The instance of the created dialog.</returns>
        public static DialogDatePicker CreateDatePicker()
        {
            DialogDatePicker dialog = PrefabManager.InstantiateGameObject(PrefabManager.ResourcePrefabs.dialogDatePicker, instance.transform).GetComponent <DialogDatePicker>();

            dialog.Initialize();
            return(dialog);
        }
Exemple #2
0
        public static void ShowDatePicker(int year, int month, int day, Action <DateTime> onAffirmativeClicked, Color accentColor)
        {
            DialogDatePicker dialog = PrefabManager.InstantiateGameObject(PrefabManager.ResourcePrefabs.dialogDatePicker, instance.transform).GetComponent <DialogDatePicker>();

            dialog.Initialize(year, month, day, onAffirmativeClicked, accentColor);
            dialog.Show();
        }
Exemple #3
0
        /// <summary>
        /// Creates a date picker dialog that can be modified or stored before showing.
        /// <para></para>
        /// Before calling <see cref="DialogDatePicker.Show"/>, call <see cref="DialogDatePicker.Initialize(int,int,int,Action{DateTime},Action,Color)"/>.
        /// <para></para>
        /// For a simpler solution with less customizability, use <see cref="ShowDatePicker(int,int,int,Action{DateTime},Color)"/>.
        /// </summary>
        /// <returns>The instance of the created dialog.</returns>
        public DialogDatePicker CreateDatePicker()
        {
            DialogDatePicker dialog = PrefabManager.InstantiateGameObject(PrefabManager.ResourcePrefabs.dialogDatePicker, GetContentTransform()).GetComponent <DialogDatePicker>();

            DialogManager.CreateActivity(dialog, dialog.transform.parent);
            //dialog.Initialize();
            return(dialog);
        }
Exemple #4
0
        /// <summary>
        /// Shows a date picker dialog with a required date picker, and a required button.
        /// </summary>
        /// <param name="year">The year selected when the dialog is shown.</param>
        /// <param name="month">The month selected when the dialog is shown.</param>
        /// <param name="day">The day selected when the dialog is shown.</param>
        /// <param name="onAffirmativeClicked">Called when the affirmative button is clicked.</param>
        /// <param name="onDismissiveClicked">Called when the negative button is clicked.</param>
        /// <param name="accentColor">Color of the accent of the picker.</param>
        public DialogDatePicker ShowDatePicker(int year, int month, int day, Action <DateTime> onAffirmativeClicked, Action onDismissiveClicked, Color accentColor)
        {
            DialogDatePicker dialog = PrefabManager.InstantiateGameObject(PrefabManager.ResourcePrefabs.dialogDatePicker, GetContentTransform()).GetComponent <DialogDatePicker>();

            DialogManager.CreateActivity(dialog, dialog.transform.parent);
            dialog.Initialize(year, month, day, onAffirmativeClicked, onDismissiveClicked, accentColor);
            dialog.Show();
            return(dialog);
        }
Exemple #5
0
        public override void Show()
        {
            System.DateTime date = GetCurrentDate();

            var isTimePicker  = m_PickerMode == DateTimeMode.Time || m_PickerMode == DateTimeMode.DateTime;
            var isDatePicker  = m_PickerMode == DateTimeMode.Date || m_PickerMode == DateTimeMode.DateTime;
            var isMonthPicker = m_PickerMode == DateTimeMode.Month;

            if (isDatePicker || isMonthPicker)
            {
                //We must call changeTime after change date (if supported)
                System.Action <System.DateTime> onChangeDate = (pickedDate) =>
                {
                    HandleOnChangeDateKeepingLastTime(pickedDate);

                    pickedDate = GetCurrentDate();
                    if (isTimePicker)
                    {
                        ShowFrameActivity <DialogTimePicker>(s_TimePicker, PrefabManager.ResourcePrefabs.dialogTimePicker,
                                                             (dialog, isDialog) =>
                        {
                            s_TimePicker = dialog;
                            dialog.Initialize(pickedDate, HandleOnChangeTimeKeepingLastDate, m_DialogColor);
                        });
                    }
                };

                //Show DatePicker
                if (isMonthPicker)
                {
                    ShowFrameActivity <DialogDatePicker>(s_MonthPicker, PrefabManager.ResourcePrefabs.dialogMonthPicker,
                                                         (dialog, isDialog) =>
                    {
                        s_MonthPicker = dialog;
                        dialog.Initialize(date.Year, date.Month, date.Day, onChangeDate, HandleOnHide, m_DialogColor);
                        dialog.SetCultureInfo(GetCultureInfo());
                    });
                }
                else
                {
                    ShowFrameActivity <DialogDatePicker>(s_DatePicker, PrefabManager.ResourcePrefabs.dialogDatePicker,
                                                         (dialog, isDialog) =>
                    {
                        s_DatePicker = dialog;
                        dialog.Initialize(date.Year, date.Month, date.Day, onChangeDate, HandleOnHide, m_DialogColor);
                        dialog.SetCultureInfo(GetCultureInfo());
                    });
                }
            }

            //Show Time Picker Only
            if (isTimePicker && m_PickerMode != DateTimeMode.DateTime)
            {
                ShowFrameActivity <DialogTimePicker>(s_TimePicker, PrefabManager.ResourcePrefabs.dialogTimePicker,
                                                     (dialog, isDialog) =>
                {
                    s_TimePicker = dialog;
                    dialog.Initialize(date, HandleOnChangeDateTime, m_DialogColor);
                });
            }
        }