Esempio n. 1
0
        public ContactDetailPage(ContactModel selectedContact, bool isNewContact)
        {
            ViewModel.SaveContactCompleted += HandleSaveContactCompleted;

            _isNewContact     = isNewContact;
            ViewModel.Contact = selectedContact;

            var phoneNumberDataEntry = new ContactDetailEntry
            {
                ReturnType    = ReturnType.Go,
                AutomationId  = AutomationIdConstants.PhoneNumberEntry,
                ReturnCommand = new Command(Unfocus)
            };

            phoneNumberDataEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.PhoneNumberText));

            var lastNameDataEntry = new ContactDetailEntry
            {
                ReturnType    = ReturnType.Next,
                ReturnCommand = new Command(() => phoneNumberDataEntry.Focus()),
                AutomationId  = AutomationIdConstants.LastNameEntry
            };

            lastNameDataEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.LastNameText));

            var firstNameDataEntry = new ContactDetailEntry
            {
                ReturnType    = ReturnType.Next,
                ReturnCommand = new Command(() => lastNameDataEntry.Focus()),
                AutomationId  = AutomationIdConstants.FirstNameEntry
            };

            firstNameDataEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.FirstNameText));

            var phoneNumberTextLabel = new ContactDetailLabel {
                Text = "Phone Number"
            };
            var lastNameTextLabel = new ContactDetailLabel {
                Text = "Last Name"
            };
            var firstNameTextLabel = new ContactDetailLabel {
                Text = "First Name"
            };

            var isSavingIndicator = new ActivityIndicator();

            isSavingIndicator.SetBinding(IsVisibleProperty, nameof(ViewModel.IsSaving));
            isSavingIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(ViewModel.IsSaving));

            var saveToobarItem = new ToolbarItem
            {
                Text             = "Save",
                Priority         = 0,
                AutomationId     = AutomationIdConstants.SaveContactButton,
                CommandParameter = _isNewContact
            };

            saveToobarItem.SetBinding(MenuItem.CommandProperty, nameof(ViewModel.SaveButtonTappedCommand));

            var cancelToolbarItem = new ToolbarItem
            {
                Text         = "Cancel",
                Priority     = 1,
                AutomationId = AutomationIdConstants.CancelContactButton
            };

            cancelToolbarItem.Clicked += HandleCancelToolBarItemClicked;

            ToolbarItems.Add(saveToobarItem);

            if (isNewContact)
            {
                ToolbarItems.Add(cancelToolbarItem);
            }


            Title = PageTitleConstants.ContactDetailsPage;

            Padding = new Thickness(20, 0, 20, 0);

            Content = new StackLayout
            {
                Margin   = new Thickness(0, 10, 0, 0),
                Children =
                {
                    firstNameTextLabel,
                    firstNameDataEntry,
                    lastNameTextLabel,
                    lastNameDataEntry,
                    phoneNumberTextLabel,
                    phoneNumberDataEntry,
                    isSavingIndicator
                }
            };
        }
Esempio n. 2
0
        public ContactDetailPage(ContactModel selectedContact, bool canEdit)
        {
            _contactModel  = selectedContact;
            BindingContext = _contactModel;

            var phoneNumberDataEntry = new ContactDetailEntry(canEdit)
            {
                ReturnType    = ReturnType.Go,
                ReturnCommand = new Command(async() => await SaveContactAndPopPage()),
                AutomationId  = AutomationIdConstants.PhoneNumberEntry
            };

            phoneNumberDataEntry.SetBinding(Entry.TextProperty, nameof(_contactModel.PhoneNumber));

            var lastNameDataEntry = new ContactDetailEntry(canEdit)
            {
                ReturnType    = ReturnType.Next,
                ReturnCommand = new Command(() => phoneNumberDataEntry.Focus()),
                AutomationId  = AutomationIdConstants.LastNameEntry
            };

            lastNameDataEntry.SetBinding(Entry.TextProperty, nameof(_contactModel.LastName));

            var firstNameDataEntry = new ContactDetailEntry(canEdit)
            {
                ReturnType    = ReturnType.Next,
                ReturnCommand = new Command(() => lastNameDataEntry.Focus()),
                AutomationId  = AutomationIdConstants.FirstNameEntry
            };

            firstNameDataEntry.SetBinding(Entry.TextProperty, nameof(_contactModel.FirstName));

            var phoneNumberTextLabel = new ContactDetailLabel {
                Text = "Phone Number"
            };
            var lastNameTextLabel = new ContactDetailLabel {
                Text = "Last Name"
            };
            var firstNameTextLabel = new ContactDetailLabel {
                Text = "First Name"
            };

            _saveToobarItem = new ToolbarItem
            {
                Text         = "Save",
                Priority     = 0,
                AutomationId = AutomationIdConstants.SaveContactButton
            };

            _cancelToolbarItem = new ToolbarItem
            {
                Text         = "Cancel",
                Priority     = 1,
                AutomationId = AutomationIdConstants.CancelContactButton
            };

            switch (canEdit)
            {
            case true:
                ToolbarItems.Add(_saveToobarItem);
                ToolbarItems.Add(_cancelToolbarItem);
                break;
            }

            Title = PageTitles.ContactDetailsPage;

            Padding = new Thickness(20, 0, 20, 0);

            Content = new StackLayout
            {
                Margin   = new Thickness(0, 10, 0, 0),
                Children =
                {
                    firstNameTextLabel,
                    firstNameDataEntry,
                    lastNameTextLabel,
                    lastNameDataEntry,
                    phoneNumberTextLabel,
                    phoneNumberDataEntry
                }
            };
        }
Esempio n. 3
0
        public ContactDetailPage(ContactModel selectedContact, bool isNewContact)
        {
            _isNewContact     = isNewContact;
            ViewModel.Contact = selectedContact;

            var phoneNumberDataEntry = new ContactDetailEntry
            {
                ReturnType    = ReturnType.Go,
                AutomationId  = AutomationIdConstants.PhoneNumberEntry,
                ReturnCommand = new Command(Unfocus)
            };

            phoneNumberDataEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.PhoneNumberText));

            var lastNameDataEntry = new ContactDetailEntry
            {
                ReturnType    = ReturnType.Next,
                ReturnCommand = new Command(() => phoneNumberDataEntry.Focus()),
                AutomationId  = AutomationIdConstants.LastNameEntry
            };

            lastNameDataEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.LastNameText));

            var firstNameDataEntry = new ContactDetailEntry
            {
                ReturnType    = ReturnType.Next,
                ReturnCommand = new Command(() => lastNameDataEntry.Focus()),
                AutomationId  = AutomationIdConstants.FirstNameEntry
            };

            firstNameDataEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.FirstNameText));

            var phoneNumberTextLabel = new ContactDetailLabel {
                Text = "Phone Number"
            };
            var lastNameTextLabel = new ContactDetailLabel {
                Text = "Last Name"
            };
            var firstNameTextLabel = new ContactDetailLabel {
                Text = "First Name"
            };

            _saveToobarItem = new ToolbarItem
            {
                Text             = "Save",
                Priority         = 0,
                AutomationId     = AutomationIdConstants.SaveContactButton,
                CommandParameter = _isNewContact
            };
            _saveToobarItem.SetBinding(MenuItem.CommandProperty, nameof(ViewModel.SaveButtonTappedCommand));

            _cancelToolbarItem = new ToolbarItem
            {
                Text         = "Cancel",
                Priority     = 1,
                AutomationId = AutomationIdConstants.CancelContactButton
            };

            ToolbarItems.Add(_saveToobarItem);

            switch (isNewContact)
            {
            case true:
                ToolbarItems.Add(_cancelToolbarItem);
                break;
            }

            Title = PageTitleConstants.ContactDetailsPage;

            Padding = new Thickness(20, 0, 20, 0);

            Content = new StackLayout
            {
                Margin   = new Thickness(0, 10, 0, 0),
                Children =
                {
                    firstNameTextLabel,
                    firstNameDataEntry,
                    lastNameTextLabel,
                    lastNameDataEntry,
                    phoneNumberTextLabel,
                    phoneNumberDataEntry
                }
            };
        }