public AddExerciseContainerPage() { InitializeComponent(); _viewModel = new AddExerciseWorkoutContainerViewModel(App.WorkoutCreatorContext); this.BindingContext = _viewModel; _unselectedPadding = new Thickness(36, 20, 36, 0); _selectedPadding = new Thickness(36, 20, 36, 0); _mfBlue = (Color)Application.Current.Resources["blueColor"]; var exerciseListTask = _viewModel.GetAllExercises(); Action<Task> action = (actionResult) => Device.BeginInvokeOnMainThread(() => { _viewModel.IsBusy = true; List<String> categories = _viewModel.GetExerciseCategories(); foreach (String bodypart in categories) { CustomImageButton circleButton = new CustomImageButton { IsVisible = false, Style = (Style)Application.Current.Resources["circleButtonStyle"] }; CustomImageButton emptyCircleButton = new CustomImageButton { //Image = "expandexercise.png", Style = (Style)Application.Current.Resources["emptyCircleButtonStyle"] }; Label bodyPartLabel = new Label { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Start, FontAttributes = FontAttributes.None, FontSize = _closedFrameBodyPartLabelFontSize, TextColor = Color.Gray, }; Label bodyPartSubLabel = new Label { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Start, FontAttributes = FontAttributes.None, TextColor = Color.Gray }; StackLayout bodyPartLabelStack = new StackLayout { Children = { bodyPartLabel, bodyPartSubLabel }, Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.Center, Spacing = 15, HorizontalOptions = LayoutOptions.Start }; var boxView = new BoxView() { Color = _mfBlue, HeightRequest = 1, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand, IsVisible = false }; Grid bodyPartGrid = new Grid { VerticalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, }, ColumnDefinitions = { new ColumnDefinition { Width = GridLength.Auto }, new ColumnDefinition { Width = GridLength.Auto }, new ColumnDefinition { Width = new GridLength (.8, GridUnitType.Star) }, new ColumnDefinition { Width = GridLength.Auto }, }, Padding = _unselectedPadding, StyleId = "closed" }; bodyPartGrid.Children.Add(circleButton, 0, 0); bodyPartGrid.Children.Add(bodyPartLabelStack, 1, 0); bodyPartGrid.Children.Add(boxView, 0, 1); Grid.SetColumnSpan(boxView, 4); bodyPartGrid.Children.Add(emptyCircleButton, 0, 0); emptyCircleButton.Clicked += async (button, e) => { emptyCircleButton.IsEnabled = false; await ShowHideExercisesInBodypart(bodyPartLabel, bodypart, boxView, circleButton, emptyCircleButton); emptyCircleButton.IsEnabled = true; }; circleButton.Clicked += async (button, e) => { circleButton.IsEnabled = false; await ShowHideExercisesInBodypart(bodyPartLabel, bodypart, boxView, circleButton, emptyCircleButton); circleButton.IsEnabled = true; }; String bodyPartStringForProcessing = bodypart; String[] bodyPartComponents = bodyPartStringForProcessing.Split('-'); if (bodyPartComponents.Count() > 1) { bodyPartLabel.Text = bodyPartComponents[0].Trim(); bodyPartSubLabel.Text = bodyPartComponents[1].Trim(); } else { bodyPartLabel.Text = bodyPartStringForProcessing; bodyPartSubLabel.Text = "General"; } primaryStackLayout.Children.Add(bodyPartGrid); } _viewModel.IsBusy = false; }); exerciseListTask.ContinueWith(action); cancelButton.Clicked += (sender, args) => { //Uses session tracking Insights.Track("Canceled adding an exercise to an existing member program from 'AddExerciseContainerPage'", new Dictionary<string, string>() { }); Action cancelAction = async () => { await Navigation.PopAsync(true); }; DependencyService.Get<ICustomDialog>().Display("Cancel add member exercise?", "No", "Yes", cancelAction); }; }
public void Setup(){ mockStaffMemberDataRepository = new Mock<IStaffMember> (); mockExercise = new Mock<IExercise> (); //Create 2 simple exercise objects MemberExerciseViewModel exercise1 = new MemberExerciseViewModel (); exercise1.SetsIndex= 1; exercise1.RepsIndex = 2; exercise1.WeightIndex = 2; exercise1.SeatPosition1Label = 1; exercise1.SeatPosition1Value = 1; MemberExerciseViewModel exercise2 = new MemberExerciseViewModel (); exercise1.SetsIndex = 2; exercise1.RepsIndex = 1; exercise1.WeightIndex = 2; exercise1.SeatPosition1Label = 2; exercise1.SeatPosition1Value = 1; //Add exercises to observable collection _memberExerciseViewModelCollection = new ObservableCollection<MemberExerciseViewModel>(); _memberExerciseViewModelCollection.Add(exercise1); _memberExerciseViewModelCollection.Add(exercise2); StaffMember staffMember = new StaffMember (); staffMember.FirstName = "Clay"; staffMember.LastName = "Martin"; staffMember.GymID = 8; staffMember.PhoneNumber = "5024171595"; staffMember.StaffID = 132; _templateFolder = new TemplateFolder(); _templateFolder.StaffMember = staffMember; exercise = new Exercise (); exercise.ExerciseName = "Barbell Bench Press"; exercise.Bodypart = "Chest"; exerciseList = new List<Exercise> (); exerciseList.Add (exercise); exercise = new Exercise (); exercise.ExerciseName = "Barbell Inclie Bench Press"; exercise.Bodypart = "Chest"; exerciseList = new List<Exercise> (); exerciseList.Add (exercise); exercise = new Exercise (); exercise.ExerciseName = "Barbell Row"; exercise.Bodypart = "Back"; exerciseList = new List<Exercise> (); exerciseList.Add (exercise); exercise = new Exercise (); exercise.ExerciseName = "DB Row"; exercise.Bodypart = "Back"; exerciseList = new List<Exercise> (); exerciseList.Add (exercise); exercise = new Exercise (); exercise.ExerciseName = "DB Shoulder Press"; exercise.Bodypart = "Shoulders"; exerciseList = new List<Exercise> (); exerciseList.Add (exercise); workoutCreatorViewModel = new AddExerciseWorkoutContainerViewModel(_templateFolder, mockExercise.Object); }