void UpdateDateVisibility() { DatePicker.Superview.Hidden = !(QuestionnaireViewModel.Selection == QuestionaireSelection.YesSince); if (QuestionnaireViewModel.Selection == QuestionaireSelection.YesSince) { DateTime valueToShow = QuestionnaireViewModel.DateHasBeenSet ? QuestionnaireViewModel.GetLocalSelectedDate() : DateTime.Now.Date; _viewModel.SetSelectedDateUTC(valueToShow); // Set the default date value when user enter pick date mode UpdateDateLbl(QuestionnaireViewModel.DateLabel); UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, DatePicker); } }
partial void NextBtn_TouchUpInside(UIButton sender) { SetWarningViewVisibility(); if (_consentViewModel.ConsentIsGiven) { OnboardingStatusHelper.Status = ConsentsHelper.GetStatusDependingOnRelease(); GoToResultPage(); } else { UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, WarningLbl); } }
partial void AcceptSwitched(UISwitch sender) { _consentViewModel.ConsentIsGiven = sender.On; if (sender.On) { SetWarningViewVisibility(); } UIAccessibility.PostNotification( UIAccessibilityPostNotification.ScreenChanged, new NSString(sender.On ? ConsentViewModel.SWITCH_ACCESSIBILITY_ANNOUNCEMENT_CONSENT_GIVEN : ConsentViewModel.SWITCH_ACCESSIBILITY_ANNOUNCEMENT_CONSENT_NOT_GIVEN)); UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, sender); }
/// <summary> /// Some view controllers that inherit from BaseViewController have UI elements, e.g., close button, /// on the top in View stack that leads to it being read first by VO eventhough a UIAccessibility.PostNotification /// is being called to indicate another element that should be in focus. This can be addressed by removing the UIView /// that is read first to focus on the element that should be targeted by UIAccessibility.PostNotification call, and /// put it back into accessibility elements after a short delay (1 sec). /// </summary> /// <param name="uiViewToDisable">UIView to be removed from VoiceOver reading hierarchy</param> protected void PostAccessibilityNotificationAndReenableElement(UIView uiViewToDisable, UIView uiViewPostNotification) { if (UIAccessibility.IsVoiceOverRunning) { UIAccessibility.PostNotification(UIAccessibilityPostNotification.LayoutChanged, uiViewPostNotification); uiViewToDisable.IsAccessibilityElement = false; DispatchTime when = new DispatchTime(DispatchTime.Now, TimeSpan.FromSeconds(1)); DispatchQueue.MainQueue.DispatchAfter(when, () => { uiViewToDisable.IsAccessibilityElement = true; }); } }
public void RemoveZombie() { WalkingDead zombie = zombies.Last(); if (zombie != null) { zombies.Remove(zombie); zombie.Disassemble(); } UIAccessibility.PostNotification(LayoutChangedNotification, null); removeZombieSound.Play(); }
public static void SetSemanticFocus(this IView element) { if (element?.Handler?.PlatformView is not PlatformView platformView) { throw new NullReferenceException("Can't access view from a null handler"); } #if __ANDROID__ platformView.SendAccessibilityEvent(EventTypes.ViewHoverEnter); #elif __IOS__ || MACCATALYST UIAccessibility.PostNotification(UIAccessibilityPostNotification.LayoutChanged, platformView); #endif }
public void RequestGuidedAccessSession() { if (!TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.Inconclusive("Requires iOS7 or later"); } // should not affect execution since it needs to be a "supervised" device (and allowed in MDM) // UIAccessibility.RequestGuidedAccessSession (true, delegate (bool didSuccess) { // Assert.Fail ("should not be reached"); //}); UIAccessibility.RequestGuidedAccessSession(false, null); }
public static void SetSemanticFocus(this IView element) { if (element?.Handler?.NativeView == null) { throw new NullReferenceException("Can't access view from a null handler"); } if (element.Handler.NativeView is not NSObject nativeView) { return; } UIAccessibility.PostNotification(UIAccessibilityPostNotification.LayoutChanged, nativeView); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. // Set navigation bar attributes NavigationControllerUtil.SetNavigationBarAttributes(this.NavigationController.NavigationBar); NavigationControllerUtil.SetNavigationTitle(this.NavigationItem, Constants.ApplicationName); this.NavigationItem.HidesBackButton = true; this.resultsStoryboard = UIStoryboard.FromName("Results", null); //set the initial focus element UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, AnalyzingLabel); }
public override void ViewDidLoad() { base.ViewDidLoad(); Button.AccessibilityIdentifier = "myButton"; Button.IsAccessibilityElement = true; Button.TouchUpInside += delegate { var title = string.Format("{0} clicks!", count++); Button.SetTitle(title, UIControlState.Normal); Button.AccessibilityTraits |= UIAccessibilityTrait.Selected; Button.AccessibilityTraits |= UIAccessibilityTrait.Button; UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, MyLabel); }; MyLabel.AccessibilityLabel = "This is a label"; }
protected void AddDoneButton(Entry element) { UIToolbar toolbar = new UIToolbar(new RectangleF(0.0f, 0.0f, 50.0f, 44.0f)); var doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate { this.Control.ResignFirstResponder(); UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, Control); }); toolbar.Items = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), doneButton }; Control.InputAccessoryView = toolbar; }
public void AddZombie() { float chrome = 50; var frame = new CGRect(chrome, Frame.Size.Height - 160 - chrome, 80, 200); var dead = new WalkingDead(frame); dead.WalkingDeadDidDisassemble += WalkingDeadDidDisassemble; zombies.Add(dead); AddSubview(dead); dead.Animate(); UIAccessibility.PostNotification(LayoutChangedNotification, null); newZombieSound.Play(); }
static void PlatformSetSemanticFocus(this VisualElement element) { var iosView = Platform.GetRenderer(element); if (iosView == null) { throw new NullReferenceException("Can't access view"); } if (iosView is not NSObject nativeView) { return; } UIAccessibility.PostNotification(UIAccessibilityPostNotification.LayoutChanged, nativeView); }
public override void ViewDidLoad() { base.ViewDidLoad(); NavigationItem.LargeTitleDisplayMode = UINavigationItemLargeTitleDisplayMode.Never; SaveButton.TouchUpInside += (sender, e) => { current.Name = NameText.Text; current.Notes = NotesText.Text; current.Done = DoneSwitch.On; current.For = ForText.Text; // includes CoreSpotlight indexing! Delegate.SaveTodo(current); UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, new NSString(@"Item was saved")); NavigationController.PopViewController(true); }; CancelButton.TouchUpInside += (sender, e) => { if (Delegate != null) { Delegate.DeleteTodo(current); // also CoreSpotlight UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, new NSString(@"Item was deleted")); } else // HACK: TODO: { Console.WriteLine("Delegate not set - HACK"); } NavigationController.PopViewController(true); }; #region iOS 9 Contacts contacts = new ContactHelper(current); UITapGestureRecognizer forTextTap = new UITapGestureRecognizer(() => { PresentViewController(contacts.GetPicker(), true, null); }); ForText.AddGestureRecognizer(forTextTap); ForText.UserInteractionEnabled = true; #endregion NameText.TextAlignment = UITextAlignment.Natural; NotesText.TextAlignment = UITextAlignment.Natural; UserActivity = UserActivityHelper.CreateNSUserActivity(current ?? new TodoItem()); }
/// <summary> /// Update UI for viewmodel property changes /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName != nameof(_viewModel.CurrentRoute)) { return; } Route firstRoute = _viewModel.CurrentRoute?.Routes?.FirstOrDefault(); if (firstRoute == null) { _stopsTable.Source = null; return; } // Build up the walk time label StringBuilder walkTimeStringBuilder = new StringBuilder(); // Add walk time and distance label if (firstRoute.TotalTime.Hours > 0) { walkTimeStringBuilder.Append($"{firstRoute.TotalTime.Hours}:{firstRoute.TotalTime.Minutes}"); } else { walkTimeStringBuilder.Append($"{firstRoute.TotalTime.Minutes + 1} " + "RouteTimeMinutesLabel".Localize()); } _routeDurationLabel.Text = walkTimeStringBuilder.ToString(); // Create the list of stop features (origin and destination) var tableSource = new List <Feature> { _viewModel.FromLocationFeature, _viewModel.ToLocationFeature }; // Update the stops table with new data _stopsTable.Source = new RouteTableSource(tableSource); // necessary so that table is reloaded before layout is requested _stopsTable.ReloadData(); RelayoutRequested?.Invoke(this, EventArgs.Empty); UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, (NSString)"RouteFoundAccessibilityAnnouncement".Localize()); }
/// <summary> /// Execute an accessiblity announcement /// </summary> /// <typeparam name="TView"></typeparam> /// <param name="view"></param> /// <param name="text"></param> /// <param name="attributtedEnums">Is for iOS UIAccessibilityPostNotification</param> public static void AccessibilityAnnounce <TView>(this TView view, string text, AccessbillityNotificationType notificationTypeEnum = AccessbillityNotificationType.Announcement) where TView : View { #if __ANDROID__ var nView = view.GetOrCreateRenderer(); if (nView != null) { nView.View.AnnounceForAccessibility(text); } #else var nView = view.GetOrCreateRenderer(); if (nView != null) { var notificationType = notificationTypeEnum.ToString(); var typeEnum = ParseEnum <UIAccessibilityPostNotification>(notificationType); UIAccessibility.PostNotification(typeEnum, new NSString(text)); } #endif }
/// <summary> /// Update the UI when the viewmodel state changes /// </summary> private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName != nameof(_viewModel.CurrentState)) { return; } if (_viewModel.CurrentState == UiState.RouteNotFound) { _headerLabel.Text = "RouteNotFoundCardTitle".Localize(); UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, (NSString)"RouteNotFoundCardTitle".Localize()); } else if (_viewModel.CurrentState == UiState.LocationNotFound) { _headerLabel.Text = "LocationNotFoundCardTitle".Localize(); UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, (NSString)"LocationNotFoundCardTitle".Localize()); } }
/// <summary> /// Initialization of the view <see cref="ImageInputViewController"/> /// </summary> public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib; this.GetStartedButton.Layer.CornerRadius = CornerRadius; this.GetStartedButton.ClipsToBounds = true; SetUpStringAttributes(); // Add gesture recognizer for the string tappableStringChestXRayAIModel this.Description.UserInteractionEnabled = true; // UserInteractionEnabled must be true for gesture recognizers to be activated this.Description.AddGestureRecognizer(new UITapGestureRecognizer((UITapGestureRecognizer gestureRecognizer) => { // Launch link if tap lands within description bounds LaunchUrlInSafari(SharedConstants.MLModelRepository); // To implement tappable portions of an attributed string, uncomment the lines of code below. // Issues with the function: VoiceOver taps don't land within the bounds of the tappable string range. //UILabel label = gestureRecognizer.View as UILabel; //if (GestureRecognizerUtil.DidTapAttributedTextInLabel(label, rangeOfStringChestXRayAIModel, gestureRecognizer, label.TextAlignment)) //{ // LaunchUrlInSafari(SharedConstants.MLModelRepository); //} })); NavigationControllerUtil.SetNavigationBarAttributes(this.NavigationController.NavigationBar); NavigationControllerUtil.SetNavigationTitle(this.NavigationItem, Constants.ApplicationName); UIButton rightButton = new UIButton(UIButtonType.InfoLight); rightButton.TouchUpInside += NavBarButtonInfo_TouchUpInside; UIBarButtonItem rightBarButton = new UIBarButtonItem(customView: rightButton); this.NavigationItem.SetRightBarButtonItem(rightBarButton, true); // Set up touch events this.GetStartedButton.TouchUpInside += GetStartedButton_TouchUpInside; //set the initial focus element UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, Title); }
private void AnimateCardsForHello(bool forHello) { AnimateCardOffScreenToTop(forHello, () => { _currentMatchIndex++; Person nextMatch = CurrentMatch; if (nextMatch != null) { // Show the next match's profile in the card _cardView.Update(nextMatch); // Ensure that the view's layout is up to date before we animate it View.LayoutIfNeeded(); if (UIAccessibility.IsReduceMotionEnabled) { // Fade the card into view FadeCardIntoView(); } else { // Zoom the new card from a tiny point into full view ZoomCardIntoView(); } } else { // Hide the card _cardView.Hidden = true; // Fade in the "Stay tuned for more matches" blurb UIView.Animate(FadeAnimationDuration, () => { _swipeInstructionsView.Alpha = 0f; _allMatchesViewedExplanatoryView.Alpha = 1f; }); } UIAccessibility.PostNotification(UIAccessibilityPostNotification.LayoutChanged, null); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); SaveButton.TouchUpInside += (sender, e) => { currentTask.Name = TitleText.Text; currentTask.Notes = NotesText.Text; currentTask.Done = DoneSwitch.On; Delegate.SaveTask(currentTask); // TODO: review use of UIAccessibility.PostNotification UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, new NSString(@"Item was saved")); }; DeleteButton.TouchUpInside += (sender, e) => { Delegate.DeleteTask(currentTask); // TODO: review use of UIAccessibility.PostNotification UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, new NSString(@"Item was deleted")); }; TitleText.TextAlignment = UITextAlignment.Natural; NotesText.TextAlignment = UITextAlignment.Natural; }
public void ButtonDragged(ButtonView button, UITouch location) { CGPoint point = location.LocationInView(miniPadView); if (miniPadView.PointInside(point, null)) { if (!buttonDraggedToPad) { CATransaction.Begin(); CATransaction.AnimationDuration = 1; miniPadView.Layer.BorderColor = UIColor.Yellow.CGColor; miniPadView.Layer.BorderWidth = 2; CATransaction.Commit(); buttonDraggedToPad = true; if (!isVoiceOverSpeaking) { isVoiceOverSpeaking = true; UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, (NSString)"Memory object near the zombies, Lift to deploy"); } } } else { if (buttonDraggedToPad) { if (!isVoiceOverSpeaking) { isVoiceOverSpeaking = true; UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, (NSString)"Memory object outside iPad. Lift to Cancel"); } } buttonDraggedToPad = false; miniPadView.Layer.BorderWidth = 0; } }
CardView AddCardViewToView(UIView containerView) { CardView cv = new CardView(); cv.Update(CurrentMatch); cv.TranslatesAutoresizingMaskIntoConstraints = false; this.cardView = cv; containerView.AddSubview(cv); UISwipeGestureRecognizer swipeUpRecognizer = new UISwipeGestureRecognizer(HandleSwipeUp); swipeUpRecognizer.Direction = UISwipeGestureRecognizerDirection.Up; cv.AddGestureRecognizer(swipeUpRecognizer); UISwipeGestureRecognizer swipeDownRecognizer = new UISwipeGestureRecognizer(HandleSwipeDown); swipeDownRecognizer.Direction = UISwipeGestureRecognizerDirection.Down; cv.AddGestureRecognizer(swipeDownRecognizer); string sayHelloName = "Say hello".LocalizedString(@"Accessibility action to say hello"); helloAction = new UIAccessibilityCustomAction(sayHelloName, SayHello); string sayGoodbyeName = "Say goodbye".LocalizedString("Accessibility action to say goodbye"); goodbyeAction = new UIAccessibilityCustomAction(sayGoodbyeName, SayGoodbye); UIView[] elements = NSArray.FromArray <UIView> ((NSArray)cv.GetAccessibilityElements()); foreach (UIView element in elements) { element.AccessibilityCustomActions = new UIAccessibilityCustomAction[] { helloAction, goodbyeAction } } ; return(cv); } void HandleSwipeUp(UISwipeGestureRecognizer gestureRecognizer) { if (gestureRecognizer.State == UIGestureRecognizerState.Recognized) { SayHello(helloAction); } } void HandleSwipeDown(UISwipeGestureRecognizer gestureRecognizer) { if (gestureRecognizer.State == UIGestureRecognizerState.Recognized) { SayGoodbye(goodbyeAction); } } UIView AddAllMatchesViewExplanatoryViewToContainerView(UIView containerView, List <NSLayoutConstraint> constraints) { UIView overlayView = AddOverlayViewToContainerView(containerView); // Start out hidden // This view will become visible once all matches have been viewed overlayView.Alpha = 0f; UILabel label = StyleUtilities.CreateStandardLabel(); label.Font = StyleUtilities.LargeFont; label.Text = "Stay tuned for more matches!".LocalizedString("Shown when all matches have been viewed"); overlayView.AddSubview(label); // Center the overlay view constraints.Add(NSLayoutConstraint.Create(overlayView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, containerView, NSLayoutAttribute.CenterX, 1f, 0f)); constraints.Add(NSLayoutConstraint.Create(overlayView, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, containerView, NSLayoutAttribute.CenterY, 1f, 0f)); // Position the label in the overlay view constraints.Add(NSLayoutConstraint.Create(label, NSLayoutAttribute.Top, NSLayoutRelation.Equal, overlayView, NSLayoutAttribute.Top, 1f, StyleUtilities.ContentVerticalMargin)); constraints.Add(NSLayoutConstraint.Create(label, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, overlayView, NSLayoutAttribute.Bottom, 1f, -1 * StyleUtilities.ContentVerticalMargin)); constraints.Add(NSLayoutConstraint.Create(label, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, overlayView, NSLayoutAttribute.Leading, 1f, StyleUtilities.ContentHorizontalMargin)); constraints.Add(NSLayoutConstraint.Create(label, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, overlayView, NSLayoutAttribute.Trailing, 1f, -1 * StyleUtilities.ContentHorizontalMargin)); return(overlayView); } bool SayHello(UIAccessibilityCustomAction customAction) { AnimateCardsForHello(true); return(true); } bool SayGoodbye(UIAccessibilityCustomAction customAction) { AnimateCardsForHello(false); return(true); } void AnimateCardsForHello(bool forHello) { AnimateCardOffScreenToTop(forHello, () => { currentMatchIndex++; Person nextMatch = CurrentMatch; if (nextMatch != null) { // Show the next match's profile in the card cardView.Update(nextMatch); // Ensure that the view's layout is up to date before we animate it View.LayoutIfNeeded(); if (UIAccessibility.IsReduceMotionEnabled) { // Fade the card into view FadeCardIntoView(); } else { // Zoom the new card from a tiny point into full view ZoomCardIntoView(); } } else { // Hide the card cardView.Hidden = true; // Fade in the "Stay tuned for more matches" blurb UIView.Animate(FadeAnimationDuration, () => { swipeInstructionsView.Alpha = 0f; allMatchesViewedExplanatoryView.Alpha = 1f; }); } UIAccessibility.PostNotification(UIAccessibilityPostNotification.LayoutChanged, null); }); } void FadeCardIntoView() { cardView.Alpha = 0f; UIView.Animate(FadeAnimationDuration, () => { cardView.Alpha = 1f; }); } void ZoomCardIntoView() { cardView.Transform = CGAffineTransform.MakeScale(0f, 0f); UIView.Animate(ZoomAnimationDuration, () => { cardView.Transform = CGAffineTransform.MakeIdentity(); }); } void AnimateCardOffScreenToTop(bool toTop, Action completion) { NSLayoutConstraint offScreenConstraint = null; if (toTop) { offScreenConstraint = NSLayoutConstraint.Create(cardView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, View, NSLayoutAttribute.Top, 1f, 0f); } else { offScreenConstraint = NSLayoutConstraint.Create(cardView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, View, NSLayoutAttribute.Bottom, 1f, 0f); } View.LayoutIfNeeded(); UIView.Animate(SwipeAnimationDuration, () => { // Slide the card off screen View.RemoveConstraints(cardViewVerticalConstraints); View.AddConstraint(offScreenConstraint); View.LayoutIfNeeded(); }, () => { // Bring the card back into view View.RemoveConstraint(offScreenConstraint); View.AddConstraints(cardViewVerticalConstraints); if (completion != null) { completion(); } }); } UIView AddSwipeInstructionsToContainerView(UIView containerView, List <NSLayoutConstraint> constraints) { UIView overlayView = AddOverlayViewToContainerView(containerView); UILabel swipeInstructionsLabel = StyleUtilities.CreateStandardLabel(); swipeInstructionsLabel.Font = StyleUtilities.LargeFont; overlayView.AddSubview(swipeInstructionsLabel); swipeInstructionsLabel.Text = "Swipe ↑ to say \"Hello!\"\nSwipe ↓ to say \"Goodbye...\"".LocalizedString("Instructions for the Matches page"); swipeInstructionsLabel.AccessibilityLabel = "Swipe up to say \"Hello!\"\nSwipe down to say \"Goodbye\"".LocalizedString("Accessibility instructions for the Matches page"); float overlayMargin = StyleUtilities.OverlayMargin; NSLayoutConstraint topMarginConstraint = NSLayoutConstraint.Create(overlayView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, TopLayoutGuide, NSLayoutAttribute.Bottom, 1f, overlayMargin); float priority = (int)UILayoutPriority.Required - 1; topMarginConstraint.Priority = priority; constraints.Add(topMarginConstraint); // Position the label inside the overlay view constraints.Add(NSLayoutConstraint.Create(swipeInstructionsLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, overlayView, NSLayoutAttribute.Top, 1f, HelloGoodbyeVerticalMargin)); constraints.Add(NSLayoutConstraint.Create(swipeInstructionsLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, overlayView, NSLayoutAttribute.CenterX, 1f, 0f)); constraints.Add(NSLayoutConstraint.Create(overlayView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, swipeInstructionsLabel, NSLayoutAttribute.Bottom, 1f, HelloGoodbyeVerticalMargin)); // Center the overlay view horizontally constraints.Add(NSLayoutConstraint.Create(overlayView, NSLayoutAttribute.Left, NSLayoutRelation.Equal, containerView, NSLayoutAttribute.Left, 1f, overlayMargin)); constraints.Add(NSLayoutConstraint.Create(overlayView, NSLayoutAttribute.Right, NSLayoutRelation.Equal, containerView, NSLayoutAttribute.Right, 1f, -overlayMargin)); return(overlayView); } UIView AddOverlayViewToContainerView(UIView containerView) { UIView overlayView = new UIView { BackgroundColor = StyleUtilities.OverlayColor, TranslatesAutoresizingMaskIntoConstraints = false, }; overlayView.Layer.CornerRadius = StyleUtilities.OverlayCornerRadius; containerView.AddSubview(overlayView); return(overlayView); } }
void Close() { Superview.WillRemoveSubview(this); RemoveFromSuperview(); UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, _initiaterView); }
public void speakText(View v, string s) { UIAccessibility.PostNotification(notification: UIAccessibilityPostNotification.ScreenChanged, argument: new NSString(s)); }
public void SetFocus(VisualElement element) { var nativeView = Platform.GetRenderer(element).NativeView; UIAccessibility.PostNotification(UIAccessibilityPostNotification.LayoutChanged, nativeView); }
void Pause() { paused = true; miniPadView.PauseZombies(); UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, (NSString)"Apocalypse On Pause"); }
private void ConfigureAnalyzeStartedVoiceOverAccessibilityAttributes() { UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, new NSString(AccessibilityConstants.AnalyzeStartedNotificationAccessibilityString)); }
public override void ViewDidLoad() { base.ViewDidLoad(); // DEMO: the second item in the stack disables large titles NavigationItem.LargeTitleDisplayMode = UINavigationItemLargeTitleDisplayMode.Never; SaveButton.TouchUpInside += (sender, e) => { Current.Name = NameText.Text; Current.Notes = NotesText.Text; Current.Done = DoneSwitch.On; // includes CoreSpotlight indexing! Delegate.SaveTodo(Current); UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, new NSString(@"Item was saved")); NavigationController.PopViewController(true); }; CancelButton.TouchUpInside += (sender, e) => { if (Delegate != null) { Delegate.DeleteTodo(Current); // also CoreSpotlight UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, new NSString(@"Item was deleted")); } else { Console.WriteLine("Delegate not set - this shouldn't happen"); } NavigationController.PopViewController(true); }; NameText.TextAlignment = UITextAlignment.Natural; NotesText.TextAlignment = UITextAlignment.Natural; UserActivity = UserActivityHelper.CreateNSUserActivity(Current ?? new TodoItem()); // Map button PhotoButton = UIButton.FromType(UIButtonType.Custom); PhotoButton.SetTitle("Photo", UIControlState.Normal); PhotoButton.BackgroundColor = UIColor.Green; PhotoButton.SizeToFit(); PhotoButton.TouchUpInside += (sender, e) => { Console.WriteLine("take photo"); var popover = Storyboard.InstantiateViewController("photo"); Console.WriteLine("pass todo item"); (popover as PhotoViewController).Todo = (NavigationController.VisibleViewController as DetailViewController).Current; PresentViewController(popover, true, null); // Configure the popover for the iPad, the popover displays as a modal view on the iPhone UIPopoverPresentationController presentationPopover = popover.PopoverPresentationController; if (presentationPopover != null) { presentationPopover.SourceView = View; presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up; presentationPopover.SourceRect = View.Frame; } }; View.AddSubview(PhotoButton); }
/// <summary> /// Toggle see more /// </summary> /// <param name="button">UIButton</param> partial void SeeMore(UIButton button) { nfloat imageViewHeight = ImageViewWrapper.Frame.Height; nfloat imageViewWidth = ImageViewWrapper.Frame.Width; nfloat deviceWidth = View.Frame.Width; nfloat secondaryViewHeight = secondaryTableView.Frame.Height; const int scaleFactor = 2; seeMoreToggled = !seeMoreToggled; //toggle button state ButtonSeeMore.SetTitle(seeMoreToggled ? "Hide" : "See More", UIControlState.Normal); ButtonSeeMore.Enabled = false; ButtonSeeMore.AccessibilityLabel = seeMoreToggled ? Constants.AccessibilityLabel_SeeMoreHideButton : Constants.AccessibilityLabel_SeeMoreShowButton; View.LayoutIfNeeded(); primaryTableView.ScrollEnabled = seeMoreToggled; //force the primary tableview to scroll to the top primaryTableView.ScrollToRow(NSIndexPath.Create(new int[] { 0, 0 }), UITableViewScrollPosition.Top, true); //animate secondary conditions ConstraintSecondaryTableViewTop.Constant = seeMoreToggled ? secondaryViewHeight : 0; ConstraintSecondaryTableViewBottom.Constant = seeMoreToggled ? -secondaryViewHeight : 0; //animate tableview into frame ConstraintPrimaryTableViewTop.Constant = seeMoreToggled ? -imageViewHeight : 0; AnalyzedImageFileNameHeaderLabel.Text = seeMoreToggled ? "Analyzed Image" : "X-Ray Image"; ConditionsTableViewSource primarySource = primaryTableView.Source as ConditionsTableViewSource; ConditionsTableViewSource secondarySource = secondaryTableView.Source as ConditionsTableViewSource; // Set see-more visibility for tableviews primarySource.SeeMoreVisible = seeMoreToggled; secondarySource.SeeMoreVisible = seeMoreToggled; // Reload each tableview primaryTableView.ReloadData(); secondaryTableView.ReloadData(); // Set the original label voice over status dependent on see-more visibility EnableVoiceOverForViews(originalLabels.ToArray(), seeMoreToggled); // Focus to top back-button on see-more toggle if (seeMoreToggled) { UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, this.NavigationItem.LeftBarButtonItem); } UIView.Animate( 0.33, 0, UIViewAnimationOptions.CurveEaseIn, () => { View.LayoutIfNeeded(); //animate image to top right (this needs to be in the animation closure) ImageViewWrapper.Layer.AnchorPoint = seeMoreToggled ? new CGPoint(0, 1) : new CGPoint(0.5, 0.5); ImageViewWrapper.Transform = seeMoreToggled ? CGAffineTransform.MakeScale(0.5F, 0.5F) : CGAffineTransform.MakeScale(1F, 1F); OriginalImageWrapper.Layer.AnchorPoint = seeMoreToggled ? new CGPoint(0, 0) : new CGPoint(0.5, 0.5); //scale & transformation to move original image to to bottom right var originalImageTransformation = CGAffineTransform.MakeScale(0.5F, 0.5F); originalImageTransformation.Translate(0.0F, secondaryViewHeight / 2); OriginalImageWrapper.Transform = seeMoreToggled ? originalImageTransformation : CGAffineTransform.MakeScale(1F, 1F); if (seeMoreToggled) { //get the distance from the bottom of the Analyzed Image View Wrapper to the top of the original image view wrapper var distance = OriginalImageWrapper.Frame.Top - ImageViewWrapper.Frame.Bottom; //set the height of the info views to distance AnalyzedImageInfoViewHeightConstraint.Constant = distance; OriginalImageInfoViewHeightConstraint.Constant = distance; //force autolayout to recalculate View.LayoutIfNeeded(); //move the info views down AnalyzedImageInfoViewBottomConstraint.Constant = AnalyzedImageInfoView.Frame.Size.Height; OriginalImageInfoViewBottomConstraint.Constant = OriginalImageInfoView.Frame.Size.Height; //scale the font size by a factor of 2 //because the imagewrapper is scaled by a factor of 0.5 AnalyzedImageFileNameHeaderLabel.Font = UIFont.PreferredHeadline.WithSize(UIFont.PreferredHeadline.PointSize * scaleFactor); AnalyzedImageFileNameLabel.Font = UIFont.PreferredSubheadline.WithSize(UIFont.PreferredSubheadline.PointSize * scaleFactor); AnalyzedImageDateHeaderLabel.Font = UIFont.PreferredHeadline.WithSize(UIFont.PreferredHeadline.PointSize * scaleFactor); AnalyzedImageDateLabel.Font = UIFont.PreferredSubheadline.WithSize(UIFont.PreferredSubheadline.PointSize * scaleFactor); OriginalImageFileNameHeaderLabel.Font = UIFont.PreferredHeadline.WithSize(UIFont.PreferredHeadline.PointSize * scaleFactor); OriginalImageFileNameLabel.Font = UIFont.PreferredSubheadline.WithSize(UIFont.PreferredSubheadline.PointSize * scaleFactor); OriginalImageDateHeaderLabel.Font = UIFont.PreferredHeadline.WithSize(UIFont.PreferredHeadline.PointSize * scaleFactor); OriginalImageDateLabel.Font = UIFont.PreferredSubheadline.WithSize(UIFont.PreferredSubheadline.PointSize * scaleFactor); } else { //remove the constants applied from above //this will revert the height and position to before see more is tapped AnalyzedImageInfoViewBottomConstraint.Constant = 0; AnalyzedImageInfoViewHeightConstraint.Constant = 0; OriginalImageInfoViewBottomConstraint.Constant = 0; OriginalImageInfoViewHeightConstraint.Constant = 0; AnalyzedImageFileNameHeaderLabel.Font = UIFont.PreferredHeadline; AnalyzedImageFileNameLabel.Font = UIFont.PreferredSubheadline; AnalyzedImageDateHeaderLabel.Font = UIFont.PreferredHeadline; AnalyzedImageDateLabel.Font = UIFont.PreferredSubheadline; OriginalImageFileNameHeaderLabel.Font = UIFont.PreferredHeadline; OriginalImageFileNameLabel.Font = UIFont.PreferredSubheadline; OriginalImageDateHeaderLabel.Font = UIFont.PreferredHeadline; OriginalImageDateLabel.Font = UIFont.PreferredSubheadline; } }, () => { ButtonSeeMore.Enabled = true; } ); }
protected override void OnElementChanged(ElementChangedEventArgs <RoundedComboBox> e) { base.OnElementChanged(e); if (e.OldElement != null || Element == null) { return; } var element = Element as RoundedComboBox; var textField = new CustomTextField { ShowCursor = false //EdgeInsets = new UIEdgeInsets(5, 10, 5, 10) }; textField.BackgroundColor = element.BackgroundColor.ToUIColor(); textField.ShouldBeginEditing += (sender) => { if (UIAccessibility.IsVoiceOverRunning && picker != null) { UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, picker); } return(true); }; textField.EditingDidBegin += (sender, args) => { var rootViewController = UIApplication.SharedApplication.KeyWindow.RootViewController; while (rootViewController.PresentedViewController != null) { rootViewController = rootViewController.PresentedViewController; } var rootView = rootViewController.View; if (overlayView == null) { overlayView = new UIView(rootView.Bounds); overlayView.UserInteractionEnabled = true; overlayView.AddGestureRecognizer(new UITapGestureRecognizer(() => Control.ResignFirstResponder())); } Element.IsDialogVisible = true; rootView.Add(overlayView); }; textField.EditingDidEnd += (sender, args) => { if (overlayView != null) { overlayView.RemoveFromSuperview(); } Element.IsDialogVisible = false; }; SetNativeControl(textField); Control.ShouldChangeCharacters += (field, range, replacementString) => false; //Control.ShouldBeginEditing = t => { return false; }; Control.SetCornerRadius((nfloat)element.CornerRadius, UIRectCorner.AllCorners); picker = new UIPickerView(); Control.InputView = picker; SetModel(element); SetItemsSource(); SetAccesibilityLabel(element); SetSelectedIndex(element); //SetText(element); SetTextColor(element); SetTextAlignment(element); SetBorder(element); SetFont(element); SetImages((double)this.Control.Frame.Height); AddDoneButton(); }