public override void PushViewController(UIKit.UIViewController viewController, bool animated) { base.PushViewController(viewController, animated); var list = new List <UIBarButtonItem>(); foreach (var item in TopViewController.NavigationItem.RightBarButtonItems) { if (string.IsNullOrEmpty(item.Title)) { continue; } if (item.Title.ToLower() == "add") { var newItem = new UIBarButtonItem(UIBarButtonSystemItem.Add) { Action = item.Action, Target = item.Target }; list.Add(newItem); } TopViewController.NavigationItem.RightBarButtonItems = list.ToArray(); } }
private static void Adopt(NSViewController parent, NSViewController child) { // ensure the child view fills our entire frame child.View.Frame = parent.View.Bounds; #if UIKIT child.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; #else child.View.AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable; #endif child.View.TranslatesAutoresizingMaskIntoConstraints = true; parent.AddChildViewController(child); #if UIKIT var parentAlreadyVisible = parent.IsViewLoaded && parent.View.Window != null; if (parentAlreadyVisible) { child.BeginAppearanceTransition(true, false); } #endif parent.View.AddSubview(child.View); #if UIKIT if (parentAlreadyVisible) { child.EndAppearanceTransition(); } child.DidMoveToParentViewController(parent); #endif }
public override void WireToViewController(UIKit.UIViewController viewController, CEInteractionOperation operation) { this.operation = operation; this.viewController = viewController; PrepareGestureRecognizer(viewController.View); }
protected override UIKit.UINavigationController CreateNavigationController(UIKit.UIViewController viewController) { var toReturn = base.CreateNavigationController(viewController); toReturn.SetNavigationBarHidden(true, true); return(toReturn); }
private static void Disown(NSViewController child) { #if UIKIT child.WillMoveToParentViewController(null); #endif child.View.RemoveFromSuperview(); child.RemoveFromParentViewController(); }
public override void DidMoveToParentViewController(UIKit.UIViewController parent) { if (parent == null) { Dispose(true); } base.DidMoveToParentViewController(parent); }
public override void DidMoveToParentViewController(UIKit.UIViewController parent) { if (parent == null && !GetType().IsContainerElement()) { Dispose(true); } base.DidMoveToParentViewController(parent); }
public override void WillMoveToParentViewController(UIKit.UIViewController parent) { base.WillMoveToParentViewController(parent); if (parent != null) { parent.NavigationItem.TitleView = NavigationItem.TitleView; } }
/// <summary> /// Creates a new iOS Okta OidcClient, attached to the provided <see cref="UIKit.UIViewController"/> and based on the specified <see cref="OktaConfig"/> /// </summary> /// <param name="iOSViewController">A reference to the current iOS <see cref="UIKit.UIViewController"/>, for use in launching the browser for login</param> /// <param name="config">The <see cref="OktaConfig"/> to use for this client. The config must be valid at the time this is called.</param> public OidcClient(UIKit.UIViewController iOSViewController, IOktaConfig config) { while (iOSViewController.PresentedViewController != null) { iOSViewController = iOSViewController.PresentedViewController; } this.iOSViewController = iOSViewController; this.Config = config; validator.Validate(Config); }
public CoachMarksInstance Show(NativeRoot root) { if (_skiaCanvasView == null) { float scaleFactor = 1; #if __IOS__ //TODO use root (viewcontroller) instead of window _skiaCanvasView = new SKCanvasView(UIApplication.SharedApplication.KeyWindow.Bounds); scaleFactor = (float)_skiaCanvasView.ContentScaleFactor;; _skiaCanvasView.BackgroundColor = UIColor.Clear; _skiaCanvasView.Opaque = false; UIApplication.SharedApplication.KeyWindow.AddSubview(_skiaCanvasView); //skiaCanvasView.FillParent(); _skiaCanvasView.TranslatesAutoresizingMaskIntoConstraints = false; _skiaCanvasView.Superview.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[childView]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, "childView", _skiaCanvasView)); _skiaCanvasView.Superview.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[childView]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, "childView", _skiaCanvasView)); _skiaCanvasView.UserInteractionEnabled = true; _skiaCanvasView.AddGestureRecognizer(new UITapGestureRecognizer(_onTouch ?? _skiaCanvasView.RemoveFromSuperview)); #elif __ANDROID__ var rootView = (ViewGroup)root.Window.DecorView.RootView; _skiaCanvasView = new SKCanvasView(root); _skiaCanvasView.Touch += ((sender, args) => { if (_onTouch != null) { _onTouch?.Invoke(); } else { rootView.RemoveView(_skiaCanvasView); } }); rootView.AddView(_skiaCanvasView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent)); #endif _skiaCanvasView.PaintSurface += (sender, e) => { var canvas = e.Surface.Canvas; var size = e.Info.Size; Draw(canvas, size, scaleFactor); }; } Invalidate(); return(this); }
public override void PushViewController(NSViewController viewController, bool animated) { base.PushViewController(viewController, animated); if (!this.routerInstigated) { // code must be pushing a view directly against nav controller rather than using the router, so we need to manually sync up the router state // TODO: what should we _actually_ do here? Soft-check the view and VM type and ignore if they're not IViewFor/IRoutableViewModel? var view = (IViewFor)viewController; var viewModel = (IRoutableViewModel)view.ViewModel; this.Router.NavigationStack.Add(viewModel); } }
public override void PushViewController(UIKit.UIViewController viewController, bool animated) { base.PushViewController(viewController, animated); var list = new List <UIBarButtonItem>(); foreach (var item in TopViewController.NavigationItem.RightBarButtonItems) { if (!string.IsNullOrWhiteSpace(item.Title)) { switch (item.Title) { case "Add": var addButton = new UIBarButtonItem(UIBarButtonSystemItem.Add) { Action = item.Action, Target = item.Target }; list.Add(addButton); break; case "Done": var doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done) { Action = item.Action, Target = item.Target }; list.Add(doneButton); break; case "Trash": var trashButton = new UIBarButtonItem(UIBarButtonSystemItem.Trash) { Action = item.Action, Target = item.Target }; list.Add(trashButton); break; } } TopViewController.NavigationItem.RightBarButtonItems = list.ToArray(); } }
internal static void ActivateSubviews(this NSViewController controller, bool activate) { if (controller is null) { throw new ArgumentNullException(nameof(controller)); } if (controller.View is null) { throw new ArgumentException("The view on the controller is null.", nameof(controller)); } controller.View.ActivateSubviews(activate); }
public void Start() { Console.WriteLine("Start"); GVLProxy gvlProxy = new GVLProxy( domain, id, secret, gvlConfiguration, gvlDelegate); UIKit.UIViewController gvlViewController = gvlProxy.ViewController; gvlDelegate.gvlViewController = gvlViewController; GetTopViewController().ShowViewController(gvlViewController, null); }
private static void Adopt(NSViewController parent, NSViewController child) { parent.AddChildViewController(child); parent.View.AddSubview(child.View); // ensure the child view fills our entire frame child.View.Frame = parent.View.Bounds; #if UIKIT child.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; #else child.View.AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable; #endif child.View.TranslatesAutoresizingMaskIntoConstraints = true; #if UIKIT child.DidMoveToParentViewController(parent); #endif }
public override void WillMoveToParentViewController(UIKit.UIViewController parent) { base.WillMoveToParentViewController(parent); if (Element is ISearchControllerPage searchView) { var searchController = new UISearchController(searchResultsController: null) { HidesNavigationBarDuringPresentation = false, DimsBackgroundDuringPresentation = false, //ObscuresBackgroundDuringPresentation = true }; searchController.SearchBar.SearchBarStyle = UISearchBarStyle.Prominent; searchController.SearchBar.Placeholder = _transService.Translate("Search or add"); parent.NavigationItem.SearchController = searchController; searchController.SearchBar.ShowsSearchResultsButton = true; searchController.SearchBar.ShowsCancelButton = false; var tf = searchController.SearchBar.ValueForKey(new Foundation.NSString("_searchField")) as UITextField; if (tf != null) { tf.ClearButtonMode = UITextFieldViewMode.Never; tf.ReturnKeyType = UIReturnKeyType.Send; } searchController.SearchBar.SearchButtonClicked += (sender, e) => { searchView.SearchHandler.AddItem(); searchController.SearchBar.Text = String.Empty; }; searchController.SearchBar.TextChanged += (sender, e) => { searchView.SearchHandler.Search(e.SearchText); }; searchController.SearchBar.CancelButtonClicked += (sender, e) => { searchView.SearchHandler.Clear(); }; } }
public override void ViewDidAppear(bool animated) { if (oauth_was_shown) { // close Xamarin.Auth.XamarinForms.AuthenticatorPage this.DismissViewController ( true, async delegate { return; } ); } if (!renderer_was_shown) { renderer_was_shown = true; base.ViewDidAppear(animated); authenticator_page = (AuthenticatorPage)base.Element; Authenticator = authenticator_page.Authenticator; Authenticator.Completed += Authentication_Completed; Authenticator.Error += Authentication_Error; uiviewcontorller = Authenticator.GetUI(); PresentViewController ( uiviewcontorller, true, () => { oauth_was_shown = true; } ); } return; }
/// <summary> /// Gets or converts the view to a view controller. /// </summary> /// <returns>The view controller.</returns> /// <param name="nativeObject">Native object.</param> public static NativeViewController GetViewController(object nativeObject) { // Is it already a VC? var vc = nativeObject as NativeViewController; if (vc != null) { return(vc); } // Nope, make it one var v = nativeObject as NativeView; if (v != null) { vc = new NativeViewController(); vc.View = v; return(vc); } throw new InvalidOperationException("Cannot get " + typeof(NativeViewController) + " from " + nativeObject); }
private void Authenticate(Xamarin.Auth.Helpers.OAuth2 oauth2) { if ( string.IsNullOrEmpty(oauth2.OAuth_SecretKey_ConsumerSecret_APISecret) ) { if (oauth2.OAuth_UriAccessToken_UriRequestToken == null) { // Step 1.1 Creating and configuring an Authenticator Auth2 = new OAuth2Authenticator ( clientId: oauth2.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer, scope: oauth2.OAuth2_Scope, authorizeUrl: oauth2.OAuth_UriAuthorization, redirectUrl: oauth2.OAuth_UriCallbackAKARedirect, // Native UI API switch // true - NEW native UI support // false - OLD embedded browser API [DEFAULT] // DEFAULT will be switched to true in the near future 2017-04 isUsingNativeUI: test_native_ui ) { ShowErrors = false, AllowCancel = oauth2.AllowCancel, }; //------------------------------------------------------------- } else if (oauth2.OAuth_UriAccessToken_UriRequestToken != null) { // Step 1.1 Creating and configuring an Authenticator Auth2 = new OAuth2Authenticator ( clientId: oauth2.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer, clientSecret: oauth2.OAuth_SecretKey_ConsumerSecret_APISecret, scope: oauth2.OAuth2_Scope, authorizeUrl: oauth2.OAuth_UriAuthorization, redirectUrl: oauth2.OAuth_UriCallbackAKARedirect, accessTokenUrl: oauth2.OAuth_UriAccessToken_UriRequestToken, // Native UI API switch // true - NEW native UI support // false - OLD embedded browser API [DEFAULT] // DEFAULT will be switched to true in the near future 2017-04 isUsingNativeUI: test_native_ui ) { ShowErrors = false, AllowCancel = oauth2.AllowCancel, }; //------------------------------------------------------------- } } else { // Step 1.1 Creating and configuring an Authenticator Auth2 = new OAuth2Authenticator ( clientId: oauth2.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer, clientSecret: oauth2.OAuth_SecretKey_ConsumerSecret_APISecret, scope: oauth2.OAuth2_Scope, authorizeUrl: oauth2.OAuth_UriAuthorization, redirectUrl: oauth2.OAuth_UriCallbackAKARedirect, accessTokenUrl: oauth2.OAuth_UriAccessToken_UriRequestToken, // Native UI API switch // true - NEW native UI support // false - OLD embedded browser API [DEFAULT] // DEFAULT will be switched to true in the near future 2017-04 isUsingNativeUI: test_native_ui ) { ShowErrors = false, AllowCancel = oauth2.AllowCancel, }; } // Step 1.2 Subscribing to Authenticator events // If authorization succeeds or is canceled, .Completed will be fired. Auth2.Completed += Auth_Completed; Auth2.Error += Auth_Error; Auth2.BrowsingCompleted += Auth_BrowsingCompleted; // Step 2.1 Creating Login UI UIKit.UIViewController ui_object = Auth2.GetUI(); if (Auth2.IsUsingNativeUI == true) { // Step 2.2 Customizing the UI - Native UI [OPTIONAL] // In order to access SFSafariViewController API the cast is neccessary SafariServices.SFSafariViewController c = null; c = (SafariServices.SFSafariViewController)ui_object; // add custom schema (App Linking) handling // in AppDelegate.cs // public override bool OpenUrl // ( // UIApplication application, // NSUrl url, // string sourceApplication, // NSObject annotation // ) // // NOTE[s] // * custom scheme support only // xamarinauth://localhost // xamarin-auth://localhost // xamarin.auth://localhost // * no http[s] scheme support // 2.2 Customizing the UI - Native UI [OPTIONAL] this.UICustomization(c); ui_object = c; } // Step 3 Present/Launch the Login UI PresentViewController(ui_object, true, null); return; }
private void Authenticate(Xamarin.Auth.Helpers.OAuth1 oauth1) { // Step 1.1 Creating and configuring an Authenticator Auth1 = new OAuth1Authenticator ( consumerKey: oauth1.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer, consumerSecret: oauth1.OAuth1_SecretKey_ConsumerSecret_APISecret, requestTokenUrl: oauth1.OAuth1_UriRequestToken, authorizeUrl: oauth1.OAuth_UriAuthorization, accessTokenUrl: oauth1.OAuth_UriAccessToken_UriRequestToken, callbackUrl: oauth1.OAuth_UriCallbackAKARedirect, // Native UI API switch // true - NEW native UI support // false - OLD embedded browser API [DEFAULT] // DEFAULT will be switched to true in the near future 2017-04 isUsingNativeUI: test_native_ui ) { ShowErrors = false, AllowCancel = oauth1.AllowCancel, }; // Step 1.2 Subscribing to Authenticator events // If authorization succeeds or is canceled, .Completed will be fired. Auth1.Completed += Auth_Completed; Auth1.Error += Auth_Error; Auth1.BrowsingCompleted += Auth_BrowsingCompleted; // Step 2.1 Creating Login UI UIKit.UIViewController ui_object = Auth1.GetUI(); if (Auth1.IsUsingNativeUI == true) { // Step 2.1 Creating Login UI // In order to access SFSafariViewController API the cast is neccessary SafariServices.SFSafariViewController c = null; c = (SafariServices.SFSafariViewController)ui_object; // add custom schema (App Linking) handling // in AppDelegate.cs // public override bool OpenUrl // ( // UIApplication application, // NSUrl url, // string sourceApplication, // NSObject annotation // ) // // NOTE[s] // * custom scheme support only // xamarinauth://localhost // xamarin-auth://localhost // xamarin.auth://localhost // * no http[s] scheme support // 2.2 Customizing the UI - Native UI [OPTIONAL] if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0)) { c.PreferredBarTintColor = color_xamarin_blue; c.PreferredControlTintColor = UIColor.White; } else { c.View.TintColor = color_xamarin_blue; } Action view_controller_customization = () => { c.NavigationController.NavigationBar.TintColor = color_xamarin_blue; }; // Step 3 Present/Launch the Login UI PresentViewController(c, true, view_controller_customization); } else { // Step 3 Present/Launch the Login UI PresentViewController(ui_object, true, null); } return; }
internal static void ActivateSubviews(this NSViewController @this, bool activate) { @this.View.ActivateSubviews(activate); }
public RoutedViewHost() { this.ViewContractObservable = Observable.Return <string>(null); this.titleUpdater = new SerialDisposable(); this.WhenActivated( d => { d(this .WhenAnyValue(x => x.Router) .Where(x => x != null && x.NavigationStack.Count > 0 && this.ViewControllers.Length == 0) .Subscribe(x => { this.routerInstigated = true; NSViewController view = null; foreach (var viewModel in x.NavigationStack) { view = this.ResolveView(this.Router.GetCurrentViewModel(), null); this.PushViewController(view, false); } this.titleUpdater.Disposable = this.Router.GetCurrentViewModel() .WhenAnyValue(y => y.UrlPathSegment) .Subscribe(y => view.NavigationItem.Title = y); this.routerInstigated = false; })); var navigationStackChanged = this.WhenAnyValue(x => x.Router) .Where(x => x != null) .Select(x => x.NavigationStack.ObserveCollectionChanges()) .Switch(); d(navigationStackChanged .Where(x => x.EventArgs.Action == NotifyCollectionChangedAction.Add) .Select(contract => new { View = this.ResolveView(this.Router.GetCurrentViewModel(), /*contract*/ null), Animate = this.Router.NavigationStack.Count > 1 }) .Subscribe(x => { if (this.routerInstigated) { return; } this.titleUpdater.Disposable = this.Router.GetCurrentViewModel() .WhenAnyValue(y => y.UrlPathSegment) .Subscribe(y => x.View.NavigationItem.Title = y); this.routerInstigated = true; // super important that animate is false if it's the first view being pushed, otherwise iOS gets hella confused // and calls PushViewController twice this.PushViewController(x.View, x.Animate); this.routerInstigated = false; })); d(navigationStackChanged .Where(x => x.EventArgs.Action == NotifyCollectionChangedAction.Reset) .Subscribe(_ => { this.routerInstigated = true; this.PopToRootViewController(true); this.routerInstigated = false; })); d(this .WhenAnyObservable(x => x.Router.NavigateBack) .Subscribe(x => { this.routerInstigated = true; this.PopViewController(true); this.routerInstigated = false; })); }); }
/// <summary> /// Presents an alert that allows the user to input a single line of text. /// </summary> /// <returns>The <c>UIAlertController</c> for the alert.</returns> /// <param name="title">The alert's title.</param> /// <param name="description">The alert's description.</param> /// <param name="placeholder">The placholder text that will be displayed when the text field is empty.</param> /// <param name="text">The initial value for the text field.</param> /// <param name="controller">The View Controller that will present the alert.</param> /// <param name="action">The <c>AlertTextInputDelegate</c> that will respond to the user's action.</param> public static UIAlertController PresentTextInputAlert(string title, string description, string placeholder, string text, UIViewController controller, AlertTextInputDelegate action) { // No, inform the user that they must create a home first UIAlertController alert = UIAlertController.Create(title, description, UIAlertControllerStyle.Alert); UITextField field = null; // Add and configure text field alert.AddTextField((textField) => { // Save the field field = textField; // Initialize field field.Placeholder = placeholder; field.Text = text; field.AutocorrectionType = UITextAutocorrectionType.No; field.KeyboardType = UIKeyboardType.Default; field.ReturnKeyType = UIReturnKeyType.Done; field.ClearButtonMode = UITextFieldViewMode.WhileEditing; }); // Add cancel button alert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, (actionCancel) => { // Any action? if (action != null) { action(false, ""); } })); // Add ok button alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, (actionOK) => { // Any action? if (action != null && field != null) { action(true, field.Text); } })); // Display the alert controller.PresentViewController(alert, true, null); // Return created controller return(alert); }
/// <summary> /// Presents an alert containing only the OK button. /// </summary> /// <returns>The <c>UIAlertController</c> for the alert.</returns> /// <param name="title">The alert's title.</param> /// <param name="description">The alert's description.</param> /// <param name="controller">The View Controller that will present the alert.</param> public static UIAlertController PresentOKAlert(string title, string description, UIViewController controller) { // No, inform the user that they must create a home first UIAlertController alert = UIAlertController.Create(title, description, UIAlertControllerStyle.Alert); // Configure the alert alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, (action) => {})); // Display the alert controller.PresentViewController(alert, true, null); // Return created controller return(alert); }
protected override void WillNavigateAway(UIKit.UIViewController destination) { this._searchBoxView.DismissKeyboard(); }
/// <summary> /// Presents a destructive alert (such as delete a file). /// </summary> /// <returns>The <c>UIAlertController</c> for the alert.</returns> /// <param name="title">The alert's title.</param> /// <param name="description">The alert's description.</param> /// <param name="destructiveAction">The title for the destructive action's button (such as delete).</param> /// <param name="controller">The View Controller that will present the alert.</param> /// <param name="action">The <c>AlertOKCancelDelegate</c> use to respond to the user's action.</param> public static UIAlertController PresentDestructiveAlert(string title, string description, string destructiveAction, UIViewController controller, AlertOKCancelDelegate action) { // No, inform the user that they must create a home first UIAlertController alert = UIAlertController.Create(title, description, UIAlertControllerStyle.Alert); // Add cancel button alert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, (actionCancel) => { // Any action? if (action != null) { action(false); } })); // Add ok button alert.AddAction(UIAlertAction.Create(destructiveAction, UIAlertActionStyle.Destructive, (actionOK) => { // Any action? if (action != null) { action(true); } })); // Display the alert controller.PresentViewController(alert, true, null); // Return created controller return(alert); }
public static void PushViewController(this UIViewController This, UIViewController view) => This.NavigationController?.PushViewController(view, true);
public override void PushViewController(UIKit.UIViewController viewController, bool animated) { base.PushViewController(viewController, animated); this.AdicionarIconesNaBarradeFerramentas(); }
public override void PushViewController (NSViewController viewController, bool animated) { base.PushViewController (viewController, animated); if (!this.routerInstigated) { // code must be pushing a view directly against nav controller rather than using the router, so we need to manually sync up the router state // TODO: what should we _actually_ do here? Soft-check the view and VM type and ignore if they're not IViewFor/IRoutableViewModel? var view = (IViewFor)viewController; var viewModel = (IRoutableViewModel)view.ViewModel; this.Router.NavigationStack.Add (viewModel); } }