private void prepareViews() { if (TraitCollection.HorizontalSizeClass == UIUserInterfaceSizeClass.Regular) { PreferredContentSize = new CGSize(0, desiredIpadHeight); } //This is needed for the ImageView.TintColor bindings to work foreach (var button in getButtons()) { button.SetImage( button.ImageForState(UIControlState.Normal) .ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal ); button.TintColor = Colors.StartTimeEntry.InactiveButton.ToNativeColor(); } TimeInput.TintColor = Colors.StartTimeEntry.Cursor.ToNativeColor(); DescriptionTextView.TintColor = Colors.StartTimeEntry.Cursor.ToNativeColor(); DescriptionTextView.BecomeFirstResponder(); Placeholder.ConfigureWith(DescriptionTextView); Placeholder.Text = Resources.StartTimeEntryPlaceholder; prepareTimeViews(); }
public override void TouchesBegan(NSSet touches, UIEvent evt) { base.TouchesBegan(touches, evt); if (TimeInput.IsEditing) { TimeInput.EndEditing(true); DescriptionTextView.BecomeFirstResponder(); } }
private void prepareViews() { //This is needed for the ImageView.TintColor bindings to work foreach (var button in getButtons()) { button.SetImage( button.ImageForState(UIControlState.Normal) .ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal ); button.TintColor = Color.StartTimeEntry.InactiveButton.ToNativeColor(); } TimeInput.TintColor = Color.StartTimeEntry.Cursor.ToNativeColor(); DescriptionTextView.TintColor = Color.StartTimeEntry.Cursor.ToNativeColor(); DescriptionTextView.BecomeFirstResponder(); Placeholder.TextView = DescriptionTextView; Placeholder.Text = Resources.StartTimeEntryPlaceholder; }
private void prepareViews() { //This is needed for the ImageView.TintColor bindings to work foreach (var button in getButtons()) { button.SetImage( button.ImageForState(UIControlState.Normal) .ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal ); } TimeLabel.Font = TimeLabel.Font.GetMonospacedDigitFont(); var stringAttributes = new CTStringAttributes( new UIStringAttributes { ForegroundColor = Color.StartTimeEntry.Placeholder.ToNativeColor() }.Dictionary ); DescriptionTextView.TintColor = Color.StartTimeEntry.Cursor.ToNativeColor(); DescriptionTextView.BecomeFirstResponder(); }
public override void ViewDidLoad() { base.ViewDidLoad(); prepareViews(); prepareSiriButton(); localizeLabels(); BillableSwitch.Rx().Changed() .Select(_ => BillableSwitch.On) .Subscribe(ViewModel.IsBillable.Accept) .DisposedBy(DisposeBag); TagsTextView.Rx() .BindAction(ViewModel.SelectTags) .DisposedBy(DisposeBag); ViewModel.HasTags .Invert() .Subscribe(AddTagsView.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.HasTags .Subscribe(TagsTextView.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.TagNames .Select(tagsListToAttributedString.Convert) .Subscribe(TagsTextView.Rx().AttributedTextObserver()) .DisposedBy(DisposeBag); SelectTagsView.Rx() .BindAction(ViewModel.SelectTags) .DisposedBy(DisposeBag); SelectProjectView.Rx() .BindAction(ViewModel.SelectProject) .DisposedBy(DisposeBag); ViewModel.ProjectClientTask .Select(info => projectTaskClientToAttributedString.Convert( info.Project, info.Task, info.Client, new Color(info.ProjectColor).ToNativeColor())) .Subscribe(ProjectTaskClientLabel.Rx().AttributedText()) .DisposedBy(DisposeBag); ViewModel.ProjectClientTask .Select(info => info.HasProject) .Subscribe(ProjectTaskClientLabel.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.ProjectClientTask .Select(info => !info.HasProject) .Subscribe(AddProjectAndTaskView.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.IsBillable .Subscribe(BillableSwitch.Rx().CheckedObserver()) .DisposedBy(DisposeBag); ViewModel.IsBillableAvailable .Subscribe(BillableView.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.PasteFromClipboard .Invert() .Subscribe(DescriptionTextView.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.PasteFromClipboard .Subscribe(DescriptionUsingClipboardWrapperView.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.PasteFromClipboard .Subscribe(PasteFromClipboardHintView.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.PasteFromClipboard .Select(enabled => enabled ? pasteFromClipboardButtonImageEnabled : pasteFromClipboardButtonImage) .Subscribe(image => { PasteFromClipboardButton.SetImage(image, UIControlState.Normal); }) .DisposedBy(DisposeBag); ViewModel.PasteFromClipboard .Subscribe(enabled => { if (enabled) { DescriptionTextView.ResignFirstResponder(); } else { DescriptionTextView.BecomeFirstResponder(); } }) .DisposedBy(DisposeBag); DescriptionTextView.TextObservable .Subscribe(ViewModel.Description.Accept) .DisposedBy(DisposeBag); PasteFromClipboardButton.Rx() .BindAction(ViewModel.SelectClipboard) .DisposedBy(DisposeBag); }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); DescriptionTextView.BecomeFirstResponder(); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Set view title. Title = ViewModel.Title; // Set navigation bar style. this.SetNavigationBarStyle(); // Add left navigation bar item. var leftNavigationButton = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (sender, e) => ViewModel.GoBackCommand.Execute(null)); NavigationItem.LeftBarButtonItem = leftNavigationButton; // Add right navigation bar item. var rightNavigationButton = new UIBarButtonItem(UIBarButtonSystemItem.Save, (sender, e) => ViewModel.SaveDetailsCommand.Execute(null)); NavigationItem.RightBarButtonItem = rightNavigationButton; // Adjust description text field border. DescriptionTextField.BorderStyle = UITextBorderStyle.RoundedRect; // Feed the text from text view into the text field which serves // as the visual frame. DescriptionTextView.Changed += (sender, e) => { DescriptionTextField.Text = DescriptionTextView.Text; ViewModel.Validate(); }; // Register event handlers to trigger validation. NSNotificationCenter.DefaultCenter.AddObserver(UITextField.TextFieldTextDidChangeNotification, obj => { ViewModel.Validate(); }); NSNotificationCenter.DefaultCenter.AddObserver(UITextView.TextDidChangeNotification, obj => { ViewModel.Validate(); }); // Move the labels and fields up if needed. if (ViewModel.IsExisting) { DescriptionLabelTopConstraint.Constant = -50; } // Register event handlers to trigger focus flow. StreetNameTextField.ShouldReturn += textField => DescriptionTextView.BecomeFirstResponder(); RoomsTextField.ShouldReturn += textField => LivingAreaTextField.BecomeFirstResponder(); LivingAreaTextField.ShouldReturn += textField => LotSizeTextField.BecomeFirstResponder(); LotSizeTextField.ShouldReturn += textField => OperatingCostsTextField.BecomeFirstResponder(); OperatingCostsTextField.ShouldReturn += textField => OperatingCostsTextField.ResignFirstResponder(); // Create and apply the binding set. var set = this.CreateBindingSet <DetailsView, DetailsViewModel>(); set.Bind(StreetNameTextField).To(vm => vm.StreetName); set.Bind(StreetNameLabel).For("Visibility").To(vm => vm.IsExisting).WithConversion("InvertedVisibility"); set.Bind(StreetNameTextField).For("Visibility").To(vm => vm.IsExisting).WithConversion("InvertedVisibility"); set.Bind(DescriptionTextView).To(vm => vm.Details.Description); set.Bind(RoomsTextField).To(vm => vm.Details.Rooms); set.Bind(LivingAreaTextField).To(vm => vm.Details.LivingArea); set.Bind(LotSizeTextField).To(vm => vm.Details.LotSize); set.Bind(OperatingCostsTextField).To(vm => vm.Details.OperatingCosts); set.Bind(rightNavigationButton).For(b => b.Enabled).To(vm => vm.IsValid); set.Apply(); }