public AddPhotoPage() { _photoTitleEntry = new CustomReturnEntry { Placeholder = "Title", BackgroundColor = Color.White, TextColor = ColorConstants.TextColor, HorizontalOptions = LayoutOptions.FillAndExpand, ReturnType = ReturnType.Go }; _photoTitleEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.PhotoTitle)); _photoTitleEntry.SetBinding(CustomReturnEntry.ReturnCommandProperty, nameof(ViewModel.TakePhotoCommand)); _takePhotoButton = new Button { Text = "Take Photo", BackgroundColor = ColorConstants.NavigationBarBackgroundColor, TextColor = ColorConstants.TextColor }; _takePhotoButton.SetBinding(Button.CommandProperty, nameof(ViewModel.TakePhotoCommand)); _takePhotoButton.SetBinding(IsEnabledProperty, new Binding(nameof(ViewModel.IsPhotoSaving), BindingMode.Default, new InverseBooleanConverter(), ViewModel.IsPhotoSaving)); _photoImage = new CachedImage(); _photoImage.SetBinding(CachedImage.SourceProperty, nameof(ViewModel.PhotoImageSource)); _saveToobarItem = new ToolbarItem { Text = "Save", Priority = 0, AutomationId = AutomationIdConstants.AddPhotoPage_SaveButton, }; _saveToobarItem.SetBinding(MenuItem.CommandProperty, nameof(ViewModel.SavePhotoCommand)); ToolbarItems.Add(_saveToobarItem); _cancelToolbarItem = new ToolbarItem { Text = "Cancel", Priority = 1, AutomationId = AutomationIdConstants.CancelButton }; ToolbarItems.Add(_cancelToolbarItem); var activityIndicator = new ActivityIndicator(); activityIndicator.SetBinding(IsVisibleProperty, nameof(ViewModel.IsPhotoSaving)); activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(ViewModel.IsPhotoSaving)); this.SetBinding(TitleProperty, nameof(ViewModel.PhotoTitle)); Padding = new Thickness(20); var stackLayout = new StackLayout { Spacing = 20, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { _photoImage, _photoTitleEntry, _takePhotoButton, activityIndicator } }; Content = new ScrollView { Content = stackLayout }; }
public AddOpportunityPage() { #region Create Topic Controls var topicLabel = new Label { Text = "Topic" }; _topicEntry = new CustomReturnEntry { ReturnType = ReturnType.Next, AutomationId = AutomationIdConstants.TopicEntry, ReturnCommand = new Command(() => _companyEntry.Focus()) }; _topicEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.Topic)); #endregion #region Create Company Controls var companyLabel = new Label { Text = "Company" }; _companyEntry = new CustomReturnEntry { ReturnType = ReturnType.Next, AutomationId = AutomationIdConstants.CompanyEntry, ReturnCommand = new Command(() => _leaseAmountEntry.Focus()) }; _companyEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.Company)); #endregion #region Create DBA Controls var dbaLabel = new Label { Text = "DBA" }; _dbaEntry = new CustomReturnEntry { AutomationId = AutomationIdConstants.DBAEntry, ReturnType = ReturnType.Go }; _dbaEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.DBA)); _dbaEntry.SetBinding(CustomReturnEntry.ReturnCommandProperty, nameof(ViewModel.SaveButtonTapped)); #endregion #region Create LeaseAmount Controls var leaseAmountLabel = new Label { Text = "Lease Amount" }; _leaseAmountEntry = new CustomReturnEntry { ReturnType = ReturnType.Next, AutomationId = AutomationIdConstants.LeaseAmountEntry, Keyboard = Keyboard.Numeric, Placeholder = "0", ReturnCommand = new Command(() => _ownerEntry.Focus()) }; _leaseAmountEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.LeaseAmount)); #endregion #region Create Owner Controls var ownerLabel = new Label { Text = "Owner" }; _ownerEntry = new CustomReturnEntry { ReturnType = ReturnType.Next, AutomationId = AutomationIdConstants.OwnerEntry, ReturnCommand = new Command(() => _dbaEntry.Focus()) }; _ownerEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.Owner)); #endregion #region create the Relative Layout var mainLayout = new RelativeLayout(); mainLayout.Children.Add(topicLabel, Constraint.Constant(0), Constraint.Constant(0) ); mainLayout.Children.Add(_topicEntry, Constraint.Constant(0), Constraint.RelativeToView(topicLabel, (parent, view) => view.Y + view.Height), Constraint.RelativeToParent((parent) => parent.Width) ); mainLayout.Children.Add(companyLabel, Constraint.Constant(0), Constraint.RelativeToView(_topicEntry, (parent, view) => view.Y + view.Height + _relativeLayoutSpacing) ); mainLayout.Children.Add(_companyEntry, Constraint.Constant(0), Constraint.RelativeToView(companyLabel, (parent, view) => view.Y + view.Height), Constraint.RelativeToParent((parent) => parent.Width) ); mainLayout.Children.Add(leaseAmountLabel, Constraint.Constant(0), Constraint.RelativeToView(_companyEntry, (parent, view) => view.Y + view.Height + _relativeLayoutSpacing) ); mainLayout.Children.Add(_leaseAmountEntry, Constraint.Constant(0), Constraint.RelativeToView(leaseAmountLabel, (parent, view) => view.Y + view.Height), Constraint.RelativeToParent((parent) => parent.Width) ); mainLayout.Children.Add(ownerLabel, Constraint.Constant(0), Constraint.RelativeToView(_leaseAmountEntry, (parent, view) => view.Y + view.Height + _relativeLayoutSpacing) ); mainLayout.Children.Add(_ownerEntry, Constraint.Constant(0), Constraint.RelativeToView(ownerLabel, (parent, view) => view.Y + view.Height), Constraint.RelativeToParent((parent) => parent.Width) ); mainLayout.Children.Add(dbaLabel, Constraint.Constant(0), Constraint.RelativeToView(_ownerEntry, (parent, view) => view.Y + view.Height + _relativeLayoutSpacing) ); mainLayout.Children.Add(_dbaEntry, Constraint.Constant(0), Constraint.RelativeToView(dbaLabel, (parent, view) => view.Y + view.Height), Constraint.RelativeToParent((parent) => parent.Width) ); #endregion #region Create Save Button var saveButtonToolBar = new ToolbarItem { Text = _saveToolBarItemText, Priority = 0, AutomationId = AutomationIdConstants.SaveButton }; saveButtonToolBar.SetBinding(ToolbarItem.CommandProperty, nameof(ViewModel.SaveButtonTapped)); ToolbarItems.Add(saveButtonToolBar); #endregion #region Create Cancel Button _cancelButtonToolBarItem = new ToolbarItem { Text = _cancelToolBarItemText, Priority = 1, AutomationId = AutomationIdConstants.CancelButton }; ToolbarItems.Add(_cancelButtonToolBarItem); #endregion Title = PageTitleConstants.AddOpportunityPageTitle; Padding = new Thickness(20, 10, 20, 0); Content = mainLayout; }
public LoadImagePage() { _viewModel = new LoadImageViewModel(); BindingContext = _viewModel; var imageUrlLabel = new Label { Text = "Image Url" }; var imageUrlEntry = new CustomReturnEntry { AutomationId = AutomationIdConstants.ImageUrlEntry, ReturnType = ReturnType.Go }; imageUrlEntry.SetBinding(Entry.TextProperty, nameof(_viewModel.ImageUrlEntryText)); imageUrlEntry.SetBinding(CustomReturnEntry.ReturnCommandProperty, nameof(_viewModel.LoadImageButtonCommand)); var loadImageButton = new Button { Margin = new Thickness(0, 20, 0, 0), AutomationId = AutomationIdConstants.LoadImageButton }; loadImageButton.SetBinding(IsEnabledProperty, nameof(_viewModel.IsLoadImageButtonEnabled)); loadImageButton.SetBinding(Button.CommandProperty, nameof(_viewModel.LoadImageButtonCommand)); loadImageButton.SetBinding(Button.TextProperty, nameof(_viewModel.DownloadImageButtonText)); var downloadedImage = new Image { AutomationId = AutomationIdConstants.DownloadedImage }; downloadedImage.SetBinding(IsVisibleProperty, nameof(_viewModel.AreImageAndClearButtonVisible)); downloadedImage.SetBinding(Image.SourceProperty, nameof(_viewModel.DownloadedImageSource)); var clearImageButton = new Button { AutomationId = AutomationIdConstants.ClearImageButton, Text = "Clear Image From Screen" }; clearImageButton.SetBinding(IsVisibleProperty, nameof(_viewModel.AreImageAndClearButtonVisible)); clearImageButton.SetBinding(Button.CommandProperty, nameof(_viewModel.ClearImageButtonTapped)); var isDownloadingActivityIndicator = new ActivityIndicator { AutomationId = AutomationIdConstants.IsDownloadingActivityIndicator }; isDownloadingActivityIndicator.SetBinding(IsVisibleProperty, nameof(_viewModel.IsImageDownloading)); isDownloadingActivityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(_viewModel.IsImageDownloading)); Padding = new Thickness(20); Title = "Load Images"; Content = new ScrollView { Content = new StackLayout { Children = { imageUrlLabel, imageUrlEntry, loadImageButton, downloadedImage, clearImageButton, isDownloadingActivityIndicator } } }; }