Beispiel #1
0
        /// <summary>
        /// Method that adds an activity to the ActivityList via Pop-ups, called by the equivalent command.
        /// </summary>
        /// <param name="Index">Index where the activity will be inserted</param>
        private async Task AddActivity(int Index)
        {
            string newActivity = await _popUpService.ActionSheet(AppResources.SelectAnActivity,
                                                                 AppResources.Cancel, null, AppResources.Push_ups, AppResources.Sit_ups, AppResources.Pause);

            if (newActivity != null && !newActivity.Equals("") && !newActivity.Equals(AppResources.Cancel))
            {
                string newAmount = await _popUpService.DisplayPrompt(newActivity,
                                                                     AppResources.EnterRepetitions, AppResources.Okay, AppResources.Cancel, "10", 3, Keyboard.Numeric);

                if (newAmount != null && Regex.IsMatch(newAmount, @"^[1-9]{1}\d{0,2}$"))
                {
                    if (newActivity.Equals(AppResources.Push_ups))
                    {
                        ActivityList.Insert(Index, new ActivityWrapper(AppResources.Push_ups, _pushUpActivity, int.Parse(newAmount)));
                    }
                    if (newActivity.Equals(AppResources.Sit_ups))
                    {
                        ActivityList.Insert(Index, new ActivityWrapper(AppResources.Sit_ups, _sitUpActivity, int.Parse(newAmount)));
                    }
                    if (newActivity.Equals(AppResources.Pause))
                    {
                        ActivityList.Insert(Index, new ActivityWrapper(AppResources.Pause, null, int.Parse(newAmount)));
                    }
                    _inserted = true;
                }
            }
        }