public static void HandleActionItem(Dictionary <string, string> Attributes) { if (!Attributes.ContainsKey("ActionType") || Attributes["ActionType"] == "0") { return; } var resource = ""; if (Attributes.ContainsKey("Resource")) { resource = Attributes["Resource"]; } var parameter = ""; if (Attributes.ContainsKey("Parameter")) { parameter = Attributes["Parameter"]; } if (Attributes["ActionType"] == "1" && !string.IsNullOrWhiteSpace(resource)) //push new page { AvalancheNavigation.GetPage(Attributes["Resource"], parameter); } else if (Attributes["ActionType"] == "2" && !string.IsNullOrWhiteSpace(resource)) //replace { AvalancheNavigation.ReplacePage(Attributes["Resource"], parameter); } else if (Attributes["ActionType"] == "3") //pop page { AvalancheNavigation.RemovePage(); } else if (Attributes["ActionType"] == "4" && !string.IsNullOrWhiteSpace(resource)) { if (!string.IsNullOrWhiteSpace(parameter) && parameter == "1") { if (resource.Contains("?")) { resource += "&rckipid=" + GetRckipid(); } else { resource += "?rckipid=" + GetRckipid(); } } else if (resource.Contains("{{rckipid}}")) { resource.Replace("{{rckipid}}", GetRckipid()); } Device.OpenUri(new Uri(resource)); } }
private void HandleResponse() { var page = observableResource.Resource as MobilePage; this.Title = page.Title; var layoutType = Type.GetType("Avalanche.Layouts." + page.LayoutType.Replace(" ", "")); if (layoutType == null) { AvalancheNavigation.RemovePage(); return; } var layout = ( ContentView )Activator.CreateInstance(layoutType); if (page.ShowTitle) { AddTitleBar(layout, page); } //Modify the page with attributes AttributeHelper.ApplyTranslation(this, page.Attributes); //Put blocks into the layout foreach (var block in page.Blocks) { var blockType = Type.GetType(block.BlockType); if (blockType != null) { IRenderable mobileBlock = ( IRenderable )Activator.CreateInstance(blockType); mobileBlock.Attributes = block.Attributes; //Setup postback handler if required if (mobileBlock is IHasBlockMessenger) { var hasPostbackBlock = mobileBlock as IHasBlockMessenger; hasPostbackBlock.MessageHandler = new BlockMessenger(block.BlockId); } var zone = layout.FindByName <Layout <View> >(block.Zone); if (zone != null) { try { var renderedBlock = mobileBlock.Render(); AttributeHelper.ApplyTranslation(renderedBlock, mobileBlock.Attributes); zone.Children.Add(renderedBlock); } catch (Exception e) { // } } } } if (ActivityIndicator.IsRunning == false) { layout.Opacity = 0; MainGrid.Children.Clear(); AddBackgroundImage(); MainGrid.Children.Add(layout); layout.FadeTo(1, 500, Easing.CubicInOut); } else { MainGrid.Children.Add(layout); ActivityIndicator.IsRunning = false; } btnBack.IsVisible = false; lTimeout.IsVisible = false; }
private void AddTitleBar(ContentView layout, MobilePage page) { var nav = layout.FindByName <StackLayout>("NavBar"); if (nav != null) { nav.IsVisible = true; if (page.Attributes.ContainsKey("AccentColor") && !string.IsNullOrEmpty(page.Attributes["AccentColor"])) { nav.BackgroundColor = (Color) new ColorTypeConverter().ConvertFromInvariantString(page.Attributes["AccentColor"]); } StackLayout stackLayout = new StackLayout { HeightRequest = 44, Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.Center }; nav.Children.Add(stackLayout); if (App.Current.MainPage.Navigation.NavigationStack.Count > 1) { IconLabel icon = new IconLabel { Text = "fa fa-chevron-left", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, FontSize = 30, Margin = new Thickness(10, 7, 0, 0), TextColor = Color.Black }; TapGestureRecognizer tgr = new TapGestureRecognizer() { NumberOfTapsRequired = 1 }; tgr.Tapped += (s, ee) => { AvalancheNavigation.RemovePage(); }; nav.GestureRecognizers.Add(tgr); stackLayout.Children.Add(icon); } Label label = new Label { Text = page.Title, HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.Center, FontSize = 20, Margin = new Thickness(0, 6, 0, 0), TextColor = Color.Black }; stackLayout.Children.Add(label); BoxView boxview = new BoxView { HeightRequest = 0.5, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Black }; nav.Children.Add(boxview); } }