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 CustomViewCellTwoTextTwoButton () { var titleLabel = new Label { VerticalOptions = LayoutOptions.Center, TextColor = Color.Black, FontSize = 20 }; var secondaryLabel = new Label { VerticalOptions = LayoutOptions.Center, FontSize = 14, TextColor = Color.Black, FontAttributes = FontAttributes.None }; var buttonOne = new CustomImageButton () { Style = (Style)Application.Current.Resources ["assignButtonStyleSmall"], VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.End }; buttonOne.Clicked += (sender, args) => { TemplateViewModel template = SimpleTemplate; if (template.SelectedUser == null) { Insights.Track ("Clicked to go to page to assign a member to a template from 'TemplateListPage'", new Dictionary<string, string> () { { "template name", template.TemplateName }, { "template id", template.LocalUserExerciseGroupID.ToString () } }); this.ParentView.Navigation.PushAsync (new ModalAssignMemberWorkoutPage (template), true); } else { buttonOne.IsEnabled = false; buttonOne.Opacity = .5; template.ParentTemplateViewModel.IsBusy = true; template.AssignTemplateCommand.Execute (template); } }; var buttonTwo = new CustomImageButton () { Style = (Style)Application.Current.Resources ["greenReviewButtonStyleSmall"], VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.End }; buttonTwo.Clicked += (sender, args) => { var template = SimpleTemplate; //Uses session tracking //LocalUserExerciseGroupID Insights.Track ("Reviewed template button click", new Dictionary<string, string> () { { "template name", template.TemplateName }, { "template id", template.LocalUserExerciseGroupID.ToString () } }); this.ParentView.Navigation.PushAsync (new ReviewPage (new ReviewPageViewModel (), template)); }; #region listview item actions //------ Creating Contact Action 1 Start --------// var deleteAction = new MenuItem { Text = "Delete", IsDestructive = true }; // red background deleteAction.SetBinding (MenuItem.CommandParameterProperty, new Binding (".")); deleteAction.Clicked += (sender, e) => { var mi = ((MenuItem)sender); if (mi.CommandParameter is TemplateViewModel) { Action action = async () => { TemplateViewModel templateViewModel = mi.CommandParameter as TemplateViewModel; //retrieve workout template from the db var template = await WorkoutTemplateDAL.GetWorkoutTemplateByID (App.WorkoutCreatorContext.StaffMember.GymID, templateViewModel.Id); template.IsSoftDeleted = true; await WorkoutTemplateDAL.AddModifyTemplate (template); var group = templateViewModel.ParentTemplateViewModel.SimpleTemplateGroups.Where (row => row.Key == templateViewModel.TemplateName.Substring (0, 1)).FirstOrDefault (); group.Remove (templateViewModel); //Uses session tracking Insights.Track ("Deleted workout template on 'TemplatelistPage'", new Dictionary<string, string> () { { "template name", templateViewModel.TemplateName }, { "group id", templateViewModel.Id.ToString () } }); }; DependencyService.Get<ICustomDialog> ().Display ("Are you sure you want to delete this template?", "No", "Yes", action); } }; ContextActions.Add (deleteAction); #endregion titleLabel.SetBinding (Label.TextProperty, "TemplateName"); secondaryLabel.SetBinding (Label.TextProperty, "TemplateDescription"); buttonOne.SetBinding (Button.IsVisibleProperty, "IsAssignVisible"); Grid grid = new Grid { VerticalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength (6, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength (Device.OnPlatform<double> (1, 2.2, 1), GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength (Device.OnPlatform<double> (1, 2.2, 1), GridUnitType.Star) } } }; grid.Children.Add (titleLabel, 0, 0); grid.Children.Add (secondaryLabel, 0, 1); grid.Children.Add (buttonOne, 1, 2, 0, 2); grid.Children.Add (buttonTwo, 2, 3, 0, 2); grid.Padding = new Thickness (10, 10, 20, 10); this.View = grid; }
public ExerciseContainerPage(bool createWorkoutOnly = false, User logFeedbackOnlyUser = null) { InitializeComponent(); if (createWorkoutOnly) { this.Title = "Create Workout"; } if (logFeedbackOnlyUser != null) { this.Title = "Log Feedback for " + logFeedbackOnlyUser.FullMemberName; } _createWorkoutOnly = createWorkoutOnly; _viewModel = new WorkoutContainerViewModel(App.WorkoutCreatorContext, CrossConnectivity.Current, createWorkoutOnly, logFeedbackOnlyUser); 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 { 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.Start, 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 workout creation in progress from 'ExerciseContainerPage'", new Dictionary<string, string>() { }); Action cancelAction = async () => { _viewModel.RemoveTemplateAndExercises(); summaryLabel.Text = ExerciseViewModel.WorkoutSummary(); await Navigation.PopToRootAsync(true); }; DependencyService.Get<ICustomDialog>().Display("Cancel workout creation in progress?", "No", "Yes", cancelAction); }; createWorkoutButton.Clicked += async (sender, args) => { //Uses session tracking Insights.Track("Clicked create workout button in exercise container", new Dictionary<string, string>() { }); await Navigation.PushAsync(new ModalWorkoutCreationPage(createWorkoutOnly, logFeedbackOnlyUser), true); }; reviewButton.Clicked += reviewButton_Clicked; summaryLabel.Text = ExerciseViewModel.WorkoutSummary(); if (_viewModel.WorkoutCreatorContext.Exercises.Count() == 0) { createWorkoutButton.IsEnabled = false; } else { createWorkoutButton.IsEnabled = true; } }