Пример #1
0
        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));

            _photoImage = new CachedImage();
            _photoImage.SetBinding(CachedImage.SourceProperty, nameof(ViewModel.PhotoImageSource));

            _saveToobarItem = new ToolbarItem
            {
                Text         = "Save",
                Priority     = 0,
                AutomationId = AutomationIdConstants.SaveButton,
            };
            _saveToobarItem.SetBinding(MenuItem.CommandProperty, nameof(ViewModel.SavePhotoCommand));
            ToolbarItems.Add(_saveToobarItem);

            _cancelToolbarItem = new ToolbarItem
            {
                Text         = "Cancel",
                Priority     = 1,
                AutomationId = AutomationIdConstants.CancelButton
            };
            ToolbarItems.Add(_cancelToolbarItem);

            this.SetBinding(TitleProperty, nameof(ViewModel.PhotoTitle));

            Padding = new Thickness(20);

            Content = new StackLayout
            {
                Spacing = 20,

                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.FillAndExpand,

                Children =
                {
                    _photoImage,
                    _photoTitleEntry,
                    _takePhotoButton,
                }
            };
        }
Пример #2
0
        static Entry CreateEntry(bool shouldUseEffects, ReturnType returnType, string placeholder, string automationId, string bindingSource)
        {
            Entry entry;

            switch (shouldUseEffects)
            {
            case true:
                entry = new Entry();
                CustomReturnEffect.SetReturnType(entry, returnType);
                break;

            case false:
                entry = new CustomReturnEntry
                {
                    ReturnType = returnType,
                };
                break;

            default:
                throw new Exception("Invalid Type");
            }
            entry.Placeholder  = placeholder;
            entry.AutomationId = automationId;
            entry.SetBinding(Entry.TextProperty, bindingSource);

            return(entry);
        }
        static Entry CreateEntry <T>(bool shouldUseEffects, ReturnType returnType, string placeholder, string automationId, Expression <Func <T, object> > textPropertyBindingSource) where T : BaseViewModel
        {
            Entry entry;

            switch (shouldUseEffects)
            {
            case true:
                entry = new Entry();
                ReturnTypeEffect.SetReturnType(entry, returnType);
                break;

            case false:
                entry = new CustomReturnEntry
                {
                    ReturnType = returnType,
                };
                break;

            default:
                throw new Exception("Invalid Type");
            }
            entry.Placeholder  = placeholder;
            entry.AutomationId = automationId;
            entry.SetBinding <T>(Entry.TextProperty, textPropertyBindingSource);

            return(entry);
        }
Пример #4
0
        public static View CreatePickEntryReturnTypePageLayout(bool shouldUseEffects)
        {
            Entry customizableEntry;

            if (shouldUseEffects)
            {
                customizableEntry = new Entry();
                customizableEntry.SetBinding(CustomReturnEffect.ReturnTypeProperty, nameof(PickEntryReturnTypeViewModel.EntryReturnType));
            }
            else
            {
                customizableEntry = new CustomReturnEntry();
                customizableEntry.SetBinding(CustomReturnEntry.ReturnTypeProperty, nameof(PickEntryReturnTypeViewModel.EntryReturnType));
            }

            customizableEntry.AutomationId = AutomationIdConstants.CustomizableEntryAutomationId;
            customizableEntry.SetBinding(Entry.PlaceholderProperty, nameof(PickEntryReturnTypeViewModel.EntryPlaceHolderText));

            var entryReturnTypePicker = new Picker
            {
                AutomationId = AutomationIdConstants.EntryReturnTypePickerAutomationId
            };

            entryReturnTypePicker.SetBinding(Picker.ItemsSourceProperty, nameof(PickEntryReturnTypeViewModel.EntryReturnTypePickerSource));
            entryReturnTypePicker.SetBinding(Picker.SelectedItemProperty, nameof(PickEntryReturnTypeViewModel.PickerSelection));

            return(new StackLayout
            {
                Children =
                {
                    customizableEntry,
                    entryReturnTypePicker
                }
            });
        }
Пример #5
0
        public static View CreatePickEntryReturnTypePageLayout(bool shouldUseEffects, PickEntryReturnTypeViewModel pickEntryReturnTypeViewModel)
        {
            Entry customizableEntry;

            switch (shouldUseEffects)
            {
            case true:
                customizableEntry = new Entry();
                CustomReturnEffect.SetReturnType(customizableEntry, ReturnType.Go);
                customizableEntry.SetBinding(CustomReturnEffect.ReturnTypeProperty, nameof(pickEntryReturnTypeViewModel.EntryReturnType));
                break;

            case false:
                customizableEntry = new CustomReturnEntry();
                customizableEntry.SetBinding(CustomReturnEntry.ReturnTypeProperty, nameof(pickEntryReturnTypeViewModel.EntryReturnType));
                break;

            default:
                throw new Exception("Invalid Type");
            }

            customizableEntry.AutomationId = AutomationIdConstants.CustomizableEntryAutomationId;
            customizableEntry.SetBinding(Entry.PlaceholderProperty, nameof(pickEntryReturnTypeViewModel.EntryPlaceHolderText));

            var entryReturnTypePicker = new Picker
            {
                AutomationId = AutomationIdConstants.EntryReturnTypePickerAutomationId
            };

            entryReturnTypePicker.SetBinding(Picker.ItemsSourceProperty, nameof(pickEntryReturnTypeViewModel.EntryReturnTypePickerSource));
            entryReturnTypePicker.SetBinding(Picker.SelectedItemProperty, nameof(pickEntryReturnTypeViewModel.PickerSelection));

            return(new StackLayout
            {
                Children =
                {
                    customizableEntry,
                    entryReturnTypePicker
                }
            });
        }
Пример #6
0
        public MainPage()
        {
            Title           = "Main Page";
            BackgroundColor = Color.FromHex("4FCAE6");

            var goEntry = new CustomReturnEntry
            {
                Placeholder      = "Enter Text Here",
                PlaceholderColor = Color.FromHex("749FA8"),
                AutomationId     = AutomationIdConstants.EntryAutomationID,
                TextColor        = Color.FromHex("2C7797"),
                BackgroundColor  = Color.FromHex("91E2F4"),
                ReturnType       = ReturnType.Done,
                ReturnCommand    = new Command(Unfocus)
            };

            goEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.EmailKeyboardEntryText));

            var textLabel = new Label
            {
                TextColor               = Color.White,
                AutomationId            = AutomationIdConstants.LabelAutomationID,
                HorizontalTextAlignment = TextAlignment.Center
            };

            textLabel.SetBinding(Label.TextProperty, nameof(ViewModel.TextLabelText));

            Padding = GetPagePadding();

            var stackLayout = new StackLayout
            {
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Children          =
                {
                    goEntry,
                    textLabel
                }
            };

            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 Entry
            {
                AutomationId = AutomationIdConstants.DBAEntry,
            };
            _dbaEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.DBA));
            #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;
        }
Пример #8
0
        public AddPersonPage()
        {
            var saveButtonToolBar = new ToolbarItem
            {
                Text     = _saveToolBarItemText,
                Priority = 0,
            };

            saveButtonToolBar.SetBinding(ToolbarItem.CommandProperty, nameof(ViewModel.SaveButtonCommand));
            ToolbarItems.Add(saveButtonToolBar);

            _cancelButtonToolbarItem = new ToolbarItem
            {
                Text     = _cancelToolBarItemText,
                Priority = 1
            };
            ToolbarItems.Add(_cancelButtonToolbarItem);

            var ageLabel = new Label {
                Text = "Age"
            };

            var ageEntry = new CustomReturnEntry
            {
                Placeholder   = "Age",
                Keyboard      = Keyboard.Numeric,
                ReturnType    = ReturnType.Default,
                ReturnCommand = new Command(Unfocus)
            };

            ageEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.AgeEntryText));

            var nameLabel = new Label {
                Text = "Name"
            };

            var nameEntry = new CustomReturnEntry
            {
                Placeholder   = "Name",
                ReturnType    = ReturnType.Next,
                ReturnCommand = new Command(() => ageEntry.Focus())
            };

            nameEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.NameEntryText));

            Padding = GetPageThickness();

            var stackLayout = new StackLayout
            {
                Children =
                {
                    nameLabel,
                    nameEntry,
                    ageLabel,
                    ageEntry
                }
            };

            Title = "Add Person";

            Content = new ScrollView {
                Content = stackLayout
            };
        }
Пример #9
0
        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
                    }
                }
            };
        }
        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
            };
        }