bool LoadFile(string url) { try { var file = Path.GetFileNameWithoutExtension(url); var ext = Path.GetExtension(url); var nsUrl = NSBundle.MainBundle.GetUrlForResource(file, ext); if (nsUrl == null) { return(false); } PlatformView?.LoadFileUrl(nsUrl, nsUrl); return(true); } catch (Exception) { Console.WriteLine($"Could not load {url} as local file"); } return(false); }
internal async Task FirstLoadUrlAsync(string url) { try { var uri = new Uri(url); var safeHostUri = new Uri($"{uri.Scheme}://{uri.Authority}", UriKind.Absolute); var safeRelativeUri = new Uri($"{uri.PathAndQuery}{uri.Fragment}", UriKind.Relative); NSUrlRequest request = new NSUrlRequest(new Uri(safeHostUri, safeRelativeUri)); if (HasCookiesToLoad(url) && !PlatformVersion.IsAtLeast(11)) { return; } await SyncPlatformCookiesAsync(url); PlatformView?.LoadRequest(request); } catch (UriFormatException) { // If we got a format exception trying to parse the URI, it might be because // someone is passing in a local bundled file page. If we can find a better way // to detect that scenario, we should use it; until then, we'll fall back to // local file loading here and see if that works: if (!LoadFile(url)) { MauiContext?.CreateLogger <WebViewHandler>()?.LogWarning($"Unable to Load Url {url}"); } } catch (Exception) { MauiContext?.CreateLogger <WebViewHandler>()?.LogWarning($"Unable to Load Url {url}"); } }
void OnFocusChange(object?sender, global::Android.Views.View.FocusChangeEventArgs e) { if (PlatformView == null) { return; } if (e.HasFocus) { if (PlatformView.Clickable) { PlatformView.CallOnClick(); } else { OnClick(PlatformView, EventArgs.Empty); } } else if (_dialog != null) { _dialog.Hide(); PlatformView.ClearFocus(); _dialog = null; } }
public void Create( object masterView, string backgroundImageName, string logoImageName, RectangleF frame, OnCompletion onCompletion ) { View = PlatformView.Create( ); View.BackgroundColor = 0; View.AddAsSubview( masterView ); ImageBG = PlatformImageView.Create( true ); ImageBG.BackgroundColor = ControlStylingConfig.OOBE_Splash_BG_Color; ImageBG.AddAsSubview( masterView ); // if a background image was provided, use that. if ( string.IsNullOrEmpty( backgroundImageName ) == false ) { MemoryStream stream = Rock.Mobile.IO.AssetConvert.AssetToStream( backgroundImageName ); stream.Position = 0; ImageBG.Image = stream; ImageBG.SizeToFit( ); ImageBG.ImageScaleType = PlatformImageView.ScaleType.ScaleAspectFit; stream.Dispose( ); } MemoryStream logoStream = Rock.Mobile.IO.AssetConvert.AssetToStream( logoImageName ); logoStream.Position = 0; ImageLogo = PlatformImageView.Create( true ); ImageLogo.AddAsSubview( masterView ); ImageLogo.Image = logoStream; ImageLogo.SizeToFit( ); ImageLogo.ImageScaleType = PlatformImageView.ScaleType.ScaleAspectFit; logoStream.Dispose( ); OnCompletionCallback = onCompletion; }
private void InitializeViews() { BasesViewModel = new BasesViewModel(db); BasesView = new BasesView { DataContext = BasesViewModel }; PlatformViewModel = new PlatformViewModel(db); PlatformView = new PlatformView { DataContext = PlatformViewModel }; ActionsViewModel = new ActionsViewModel(db); ActionsView = new ActionsView { DataContext = ActionsViewModel }; DistributionViewModel = new DistributionViewModel(db); DistributionView = new DistributionView { DataContext = DistributionViewModel }; HomeViewModel = new HomeViewModel(db); HomeView = new HomeView { DataContext = HomeViewModel }; TelegramViewModel = new TelegramViewModel(db); TelegramView = new TelegramView { DataContext = TelegramViewModel }; }
public void Create(object masterView, bool scaleImage, string imageName, RectangleF frame, OnCompletion onCompletion) { View = PlatformView.Create( ); View.BackgroundColor = ControlStylingConfig.BackgroundColor; View.Frame = frame; View.AddAsSubview(masterView); MemoryStream logoStream = Rock.Mobile.IO.AssetConvert.AssetToStream(imageName); logoStream.Position = 0; PonyImage = PlatformImageView.Create( ); PonyImage.AddAsSubview(View.PlatformNativeObject); PonyImage.Image = logoStream; PonyImage.ImageScaleType = PlatformImageView.ScaleType.ScaleAspectFit; logoStream.Dispose( ); CloseButton = PlatformButton.Create( ); CloseButton.AddAsSubview(View.PlatformNativeObject); CloseButton.Text = "Prance! Dance! It's Magic Pony Time!"; CloseButton.BackgroundColor = PrayerConfig.PrayedForColor; CloseButton.TextColor = ControlStylingConfig.Button_TextColor; CloseButton.CornerRadius = ControlStylingConfig.Button_CornerRadius; CloseButton.SizeToFit( ); CloseButton.ClickEvent = delegate(PlatformButton button) { OnCompletionCallback( ); }; OnCompletionCallback = onCompletion; }
void OnSetImageSource(UIImage?image) { if (image == null) { PlatformView.SetImage(null, UIControlState.Normal); } else { var maxWidth = PlatformView.Frame.Width * 0.5f; var maxHeight = PlatformView.Frame.Height * 0.5f; var resizedImage = MaxResizeSwipeItemIconImage(image, maxWidth, maxHeight); try { PlatformView.SetImage(resizedImage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal); var tintColor = VirtualView.GetTextColor(); if (tintColor != null) { PlatformView.TintColor = tintColor.ToPlatform(); } } catch (Exception) { // UIImage ctor throws on file not found if MonoTouch.ObjCRuntime.Class.ThrowOnInitFailure is true; MauiContext?.CreateLogger <SwipeItemMenuItemHandler>()?.LogWarning("Can not load SwipeItem Icon"); } } }
public void Create(object masterView, string backgroundImageName, string logoImageName, bool scaleImage, RectangleF frame, OnCompletion onCompletion) { View = PlatformView.Create( ); View.BackgroundColor = 0; View.AddAsSubview(masterView); ImageBG = PlatformImageView.Create( ); ImageBG.BackgroundColor = ControlStylingConfig.OOBE_Splash_BG_Color; ImageBG.AddAsSubview(masterView); // if a background image was provided, use that. if (string.IsNullOrEmpty(backgroundImageName) == false) { MemoryStream stream = Rock.Mobile.IO.AssetConvert.AssetToStream(backgroundImageName); stream.Position = 0; ImageBG.Image = stream; ImageBG.ImageScaleType = PlatformImageView.ScaleType.ScaleAspectFit; stream.Dispose( ); } MemoryStream logoStream = Rock.Mobile.IO.AssetConvert.AssetToStream(logoImageName); logoStream.Position = 0; ImageLogo = PlatformImageView.Create( ); ImageLogo.AddAsSubview(masterView); ImageLogo.Image = logoStream; ImageLogo.ImageScaleType = PlatformImageView.ScaleType.ScaleAspectFit; logoStream.Dispose( ); OnCompletionCallback = onCompletion; }
void SetupToolbar() { if (_stackNavigationManager == null || _navController == null) { return; } var appbarConfigBuilder = new AppBarConfiguration .Builder(_stackNavigationManager.NavGraph); if (_drawerLayout != null) { appbarConfigBuilder = appbarConfigBuilder.SetOpenableLayout(_drawerLayout); } var appbarConfig = appbarConfigBuilder.Build(); NavigationUI .SetupWithNavController(PlatformView, _navController, appbarConfig); // the call to SetupWithNavController resets the Navigation Icon UpdateValue(nameof(IToolbar.BackButtonVisible)); PlatformView.SetNavigationOnClickListener(BackNavigationClick); }
void UpdateSize() { var textSize = 0; var contentHeight = 0; var mauiSwipeView = PlatformView.Parent.GetParentOfType <MauiSwipeView>(); if (mauiSwipeView == null) { return; } contentHeight = mauiSwipeView.Height; if (PlatformView is TextView textView) { textSize = !string.IsNullOrEmpty(textView.Text) ? (int)textView.TextSize : 0; var icons = textView.GetCompoundDrawables(); if (icons.Length > 1 && icons[1] != null) { OnSetImageSource(icons[1]); } } var iconSize = GetIconSize(); var buttonPadding = (contentHeight - (iconSize + textSize + 6)) / 2; PlatformView.SetPadding(0, buttonPadding, 0, buttonPadding); }
public virtual void OnViewSet(IView view) { if (view == View) { return; } if (View != null && PlatformView.IsAlive()) { PlatformView.RemoveFromParent(); View.Handler?.DisconnectHandler(); } _view = view; if (view != null) { Context context; if (!(_context.TryGetTarget(out context))) { return; } PlatformView = view.ToPlatform(_mauiContext); Handler = view.Handler; } else { PlatformView = null; } }
void UpdateMinimumHeight() { var minHeight = 0; if (View?.MinimumHeightRequest > 0) { minHeight = (int)Context.ToPixels(View.MinimumHeightRequest); } else if (_flyoutHeaderBehavior == FlyoutHeaderBehavior.CollapseOnScroll) { minHeight = Context.GetActionBarHeight(); } else { minHeight = 0; } if (MinimumHeight != minHeight) { this.SetMinimumHeight(minHeight); } if (Parent is AView frameLayoutView && minHeight > frameLayoutView.MinimumHeight) { frameLayoutView.SetMinimumHeight(minHeight); } if (PlatformView.MinimumHeight != minHeight) { PlatformView.SetMinimumHeight(minHeight); } }
public void Create(object masterView, bool scaleImage, RectangleF frame, OnCompletion onCompletion) { View = PlatformView.Create( ); View.BackgroundColor = ControlStylingConfig.BackgroundColor; View.Frame = frame; View.AddAsSubview(masterView); Credits = new List <Credit>(); Credits.Add(new Credit("Hey you found me! I'm Jered, the mobile app developer here at CCV. Making this app was a ton of work, and couldn't have happened without the support of a ton of people!\n\nThanks so much to:\n" + "Jenni, my beautiful wife and very patient app tester!\n\n" + "Jon & David, for developing this app's backbone, Rock.\n\n" + "Mason & Mike for testing, end points, and endless puns! (See what I did there?)\n\n" + "Nick & Kyle for all the great artwork and design you see in this app.\n\n" + "Dan & Kris Simpson for HUGE feedback, testing, and movie nights!!\n\n" + "The IT boyz: Jim, `Stopher and Chris, for being extremely willing Android guinea pigs.\n\n" + "Matt, Emily, Robin, Jill and Bree, for their testing and feedback.\n\n\n" + "And thanks of course to all of you out there using the app and making CCV the awesome church that it is!", "me.png", scaleImage, frame, View)); CloseButton = PlatformButton.Create( ); CloseButton.AddAsSubview(View.PlatformNativeObject); CloseButton.Text = "Got It!"; CloseButton.BackgroundColor = PrayerConfig.PrayedForColor; CloseButton.TextColor = ControlStylingConfig.Button_TextColor; CloseButton.CornerRadius = ControlStylingConfig.Button_CornerRadius; CloseButton.SizeToFit( ); CloseButton.ClickEvent = delegate(PlatformButton button) { OnCompletionCallback( ); }; OnCompletionCallback = onCompletion; }
void OnPlatformViewReady(object?sender, EventArgs e) { if (VirtualView != null) { PlatformView?.UpdateThumbColor(VirtualView, DefaultThumbColor); } }
public void LayoutView(int l, int t, int r, int b) { PlatformView.Layout(l, t, r, b); //if (width == -1) // width = double.PositiveInfinity; //if (height == -1) // height = double.PositiveInfinity; //Width = width; //Height = height; //MaxWidth = maxWidth; //MaxHeight = maxHeight; //X = x; //Y = y; //Context context; //if (Handler == null || !(_context.TryGetTarget(out context)) || !PlatformView.IsAlive()) // return; //if (View == null) //{ // MauiView.Measure(0, 0); // MauiView.Arrange(Rectangle.Zero); // return; //} //var request = MauiView.Measure(width, height); //var layoutParams = PlatformView.LayoutParameters; //if (double.IsInfinity(height)) // height = request.Height; //if (double.IsInfinity(width)) // width = request.Width; //if (height > maxHeight) // height = maxHeight.Value; //if (width > maxWidth) // width = maxWidth.Value; //if (layoutParams.Width != LP.MatchParent) // layoutParams.Width = (int)context.ToPixels(width); //if (layoutParams.Height != LP.MatchParent) // layoutParams.Height = (int)context.ToPixels(height); //PlatformView.LayoutParameters = layoutParams; //var c = PlatformView.Context; //var l = (int)c.ToPixels(x); //var t = (int)c.ToPixels(y); //var r = (int)c.ToPixels(width) + l; //var b = (int)c.ToPixels(height) + t; //PlatformView.Layout(l, t, r, b); }
void OnPaneOpening(UI.Xaml.Controls.NavigationView sender, object args) { UpdateValue(nameof(Shell.FlyoutBackground)); UpdateValue(nameof(Shell.FlyoutVerticalScrollMode)); PlatformView.UpdateFlyoutBackdrop(); PlatformView.UpdateFlyoutPosition(); VirtualView.FlyoutIsPresented = true; }
public LinearLayoutBuilderTest() { builder = new LayoutBuilder(new RectangleF(0, 0, 100, 100)); view1 = new PlatformView(0, 0, 20, 30); view2 = new PlatformView(0, 0, 20, 20); view3 = new PlatformView(0, 0, 100, 100); }
public PlatformInitialize(IPlatformFactory factory, IPlatformModel model) { _factory = factory; var platform = _factory.CreatePlatform(); _platformView = platform.GetComponent <PlatformView>(); _platformViewModel = new PlatformViewModel(model); }
protected override void Initialize( ) { base.Initialize( ); ChildControls = new List <IUIControl>( ); BorderView = PlatformView.Create( ); }
protected override MauiTimePicker CreatePlatformView() { return(new MauiTimePicker(() => { SetVirtualViewTime(); PlatformView?.ResignFirstResponder(); })); }
public void PaddingsAppliedToViewFrame() { Layout.Padding = new EdgeInsets(10, 10, 10, 10); var view1 = new PlatformView(); var view1Frame = Layout.View(view1).Left(10).Top(10).Width(20).Height(20).Frame; Assert.Equal(new RectangleF(20, 20, 20, 20), view1Frame); }
public void SameBoxAllTheTime() { var view = new PlatformView(); var vv1 = Layout.View(view); var vv2 = Layout.View(view); Assert.Same(vv1, vv2); }
void Reload() { if (VirtualView == null || PlatformView == null) { return; } PlatformView.UpdatePicker(VirtualView); }
void OnPlatformViewAttachedToWindow(object?sender, ViewAttachedToWindowEventArgs e) { if (PlatformView.IsAlive() && PlatformView.Enabled) { // https://issuetracker.google.com/issues/37095917 PlatformView.Enabled = false; PlatformView.Enabled = true; } }
void OnCompleted(object?sender, EventArgs e) { if (PlatformView == null) { return; } PlatformView.SetFocus(false); }
void OnCancelClicked(object?sender, EventArgs args) { if (VirtualView != null) { VirtualView.Text = string.Empty; } PlatformView?.ResignFirstResponder(); }
protected override void Initialize( ) { base.Initialize( ); ChildControls = new List <IUIControl>( ); ChildHorzAlignment = Alignment.Inherit; BorderView = PlatformView.Create( ); }
void OnActivated(object?sender, EventArgs e) { if (PlatformView == null) { return; } PlatformView.HideInputPanel(); }
public override void SetVirtualView(IView view) { base.SetVirtualView(view); if (PlatformView.Element != view) { PlatformView.SetElement((Shell)view); } }
public UIResultView(object parentView, RectangleF frame, DoneClickDelegate onClick) { View = PlatformView.Create( ); View.AddAsSubview(parentView); View.UserInteractionEnabled = false; StatusLabel = PlatformLabel.Create( ); //StatusBackground = PlatformView.Create( ); ResultSymbol = PlatformLabel.Create( ); ResultLabel = PlatformLabel.Create( ); //ResultBackground = PlatformView.Create( ); ResultCircle = PlatformCircleView.Create( ); ResultCircle.AddAsSubview(parentView); // setup our UI hierarchy //StatusBackground.AddAsSubview( parentView ); //StatusBackground.UserInteractionEnabled = false; //StatusBackground.BorderWidth = .5f; StatusLabel.AddAsSubview(parentView); StatusLabel.UserInteractionEnabled = false; //ResultBackground.AddAsSubview( parentView ); //ResultBackground.UserInteractionEnabled = false; //ResultBackground.BorderWidth = .5f; ResultSymbol.AddAsSubview(parentView); ResultSymbol.UserInteractionEnabled = false; ResultLabel.AddAsSubview(parentView); ResultLabel.UserInteractionEnabled = false; DoneButton = PlatformButton.Create( ); DoneButton.AddAsSubview(parentView); DoneButton.ClickEvent = ( PlatformButton button ) => { if (onClick != null) { onClick( ); } }; // default the view size and opacity SetOpacity(0.00f); SetBounds(frame); // give it a default style SetStyle( ); }
public void Insert(int index, IView child) { _ = PlatformView ?? throw new InvalidOperationException($"{nameof(PlatformView)} should have been set by base class."); _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} should have been set by base class."); _ = MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} should have been set by base class."); var targetIndex = VirtualView.GetLayoutHandlerIndex(child); PlatformView.AddView(child.ToPlatform(MauiContext), targetIndex); }
protected override void Initialize( ) { base.Initialize( ); mTitle = null; mDate = null; mSpeaker = null; BorderView = PlatformView.Create( ); }
public Credit( string message, string image, bool scaleImage, RectangleF frame, PlatformView parent ) { MemoryStream logoStream = Rock.Mobile.IO.AssetConvert.AssetToStream( image ); logoStream.Position = 0; Image = PlatformImageView.Create( scaleImage ); Image.AddAsSubview( parent.PlatformNativeObject ); Image.Image = logoStream; Image.SizeToFit( ); Image.ImageScaleType = PlatformImageView.ScaleType.ScaleAspectFit; logoStream.Dispose( ); Label = PlatformLabel.Create( ); Label.Text = message; Label.BackgroundColor = ControlStylingConfig.BG_Layer_Color; Label.BorderColor = ControlStylingConfig.BG_Layer_BorderColor; Label.BorderWidth = ControlStylingConfig.BG_Layer_BorderWidth; Label.TextColor = ControlStylingConfig.Label_TextColor; Label.Bounds = new RectangleF( 0, 0, frame.Width * .75f, 0 ); Label.SizeToFit( ); Label.AddAsSubview( parent.PlatformNativeObject ); }