protected override void OnElementChanged(ElementChangedEventArgs <BottomBarPage> e) { base.OnElementChanged(e); if (e.NewElement != null) { BottomBarPage bottomBarPage = e.NewElement; if (_bottomBar == null) { _pageController = PageController.Create(bottomBarPage); // create a view which will act as container for Page's _frameLayout = new FrameLayout(Forms.Context); _frameLayout.LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent, GravityFlags.Fill); AddView(_frameLayout, 0); // create bottomBar control _bottomBar = BottomNavigationBar.BottomBar.Attach(_frameLayout, null); _bottomBar.NoTabletGoodness(); _bottomBar.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); _bottomBar.SetOnTabClickListener(this); UpdateTabs(); UpdateBarBackgroundColor(); UpdateBarTextColor(); } if (bottomBarPage.CurrentPage != null) { SwitchContent(bottomBarPage.CurrentPage); } } }
public void CreatePostShould_ReturnViewIfPageServiceThrows() { // Arrange var fakeHttpContext = new Mock <HttpContextBase>(); var fakeIdentity = new GenericIdentity("User"); var principal = new GenericPrincipal(fakeIdentity, null); fakeHttpContext.Setup(t => t.User).Returns(principal); var controllerContext = new Mock <ControllerContext>(); controllerContext.Setup(t => t.HttpContext).Returns(fakeHttpContext.Object); PageController controller = new PageController( booksServiceMock.Object, pagesServiceMock.Object, pageConnectionsServiceMock.Object, usersServiceMock.Object ); controller.ControllerContext = controllerContext.Object; // Act usersServiceMock.Setup(x => x.FindSingle("User")).Returns(new User()); booksServiceMock.Setup(x => x.FindSingle(1)).Returns(new Book()); pagesServiceMock.Setup(x => x.Add(new Page())).Throws(new Exception()); ActionResult result = controller.Create(new PageCreateViewModel() { BookCatNum = 1 }); // Assert Assert.IsNotNull(result); }
protected override void OnElementChanged(ElementChangedEventArgs <BottomTabbed> e) { base.OnElementChanged(e); if (e.NewElement != null) { BottomTabbed bottomBarPage = e.NewElement; if (_bottomBar == null) { _pageController = PageController.Create(bottomBarPage); // create a view which will act as container for Page's _frameLayout = new FrameLayout(Forms.Context); _frameLayout.LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent, GravityFlags.Fill); AddView(_frameLayout, 0); // create bottomBar control _bottomBar = BottomNavigationBar.BottomBar.Attach(_frameLayout, null); _bottomBar.NoTabletGoodness(); if (bottomBarPage.FixedMode) { _bottomBar.UseFixedMode(); } switch (bottomBarPage.BarTheme) { case BottomTabbed.BarThemeTypes.Light: break; case BottomTabbed.BarThemeTypes.DarkWithAlpha: _bottomBar.UseDarkThemeWithAlpha(true); break; case BottomTabbed.BarThemeTypes.DarkWithoutAlpha: _bottomBar.UseDarkThemeWithAlpha(false); break; default: throw new ArgumentOutOfRangeException(); } _bottomBar.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); _bottomBar.SetOnTabClickListener(this); UpdateTabs(); UpdateBarBackgroundColor(); UpdateBarTextColor(); _bottomBar.SetTextAppearance(Resource.Style.TabTextStyle); _bottomBar.IgnoreScalingResize = true; } if (bottomBarPage.CurrentPage != null) { SwitchContent(bottomBarPage.CurrentPage); } } }
private Page CreateNestedPage() { PageController pc = new PageController(); var page = pc.Create("page", testContext.users[0]); var pageSub1 = pc.AddSubPage("sub page 1", page.Id, testContext.users[0]); var pageSub2 = pc.AddSubPage("sub page 2", page.Id, testContext.users[0]); var p = pc.AddSubPage("sub 1 sub page 1", pageSub1.Id, testContext.users[0]); pc.ChangeOwner(p.Id, testContext.users[17].Id, testContext.users[0]); pc.AddSubPage("sub 2 sub page 1", pageSub2.Id, testContext.users[0]); var t = pc.AddAttachment("sub 1 attachment 1", pageSub1.Id, testContext.users[0]); AttachmentController ac = new AttachmentController(); ac.ChangeOwner(t.Id, testContext.users[25].Id, testContext.users[0]); pc.AddAttachment("page attachment", page.Id, testContext.users[0]); var teams = CreateTeams(); pc.AddAdmin(page.Id, teams[0].Id, testContext.users[0]); pc.AddReader(page.Id, teams[1].Id, testContext.users[0]); pc.AddAdmin(page.Id, testContext.users[10].Id, testContext.users[0]); pc.AddReader(page.Id, testContext.users[11].Id, testContext.users[0]); return(page); }
protected override void OnElementChanged(ElementChangedEventArgs <BottomBarPage> e) { base.OnElementChanged(e); if (e.NewElement != null) { BottomBarPage bottomBarPage = e.NewElement; if (_bottomBar == null) { _pageController = PageController.Create(bottomBarPage); // create a view which will act as container for Page's #pragma warning disable CS0618 // Type or member is obsolete #pragma warning disable IDE0017 // Simplify object initialization _frameLayout = new FrameLayout(Forms.Context); #pragma warning restore IDE0017 // Simplify object initialization #pragma warning restore CS0618 // Type or member is obsolete _frameLayout.LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent, GravityFlags.Fill); AddView(_frameLayout, 0); // create bottomBar control _bottomBar = BottomNavigationBar.BottomBar.Attach(_frameLayout, null); _bottomBar.NoTabletGoodness(); if (bottomBarPage.FixedMode) { _bottomBar.UseFixedMode(); } switch (bottomBarPage.BarTheme) { case BottomBarPage.BarThemeTypes.Light: break; case BottomBarPage.BarThemeTypes.DarkWithAlpha: _bottomBar.UseDarkThemeWithAlpha(true); break; case BottomBarPage.BarThemeTypes.DarkWithoutAlpha: _bottomBar.UseDarkThemeWithAlpha(false); break; default: throw new ArgumentOutOfRangeException(); } _bottomBar.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); _bottomBar.SetOnTabClickListener(this); UpdateTabs(); UpdateBarBackgroundColor(); UpdateBarTextColor(); } if (bottomBarPage.CurrentPage != null) { SwitchContent(bottomBarPage.CurrentPage); } } }
protected override void OnElementChanged(ElementChangedEventArgs <BottomBarPage> e) { base.OnElementChanged(e); if (e.NewElement != null) { var bottomBarPage = e.NewElement; if (bottomBar == null) { pageController = PageController.Create(bottomBarPage); // create a view which will act as container for Page's frameLayout = new FrameLayout(Forms.Context) { LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent, GravityFlags.Fill) }; AddView(frameLayout, 0); // create bottomBar control bottomBar = BottomBar.Attach(frameLayout, null); bottomBar.NoTabletGoodness(); bottomBar.MaxFixedTabCount = Element.Children.Count - 1; if (bottomBarPage.FixedMode) { bottomBar.UseFixedMode(); } switch (bottomBarPage.BarTheme) { case BottomBarPage.BarThemeTypes.Light: break; case BottomBarPage.BarThemeTypes.DarkWithAlpha: bottomBar.UseDarkThemeWithAlpha(); break; case BottomBarPage.BarThemeTypes.DarkWithoutAlpha: bottomBar.UseDarkThemeWithAlpha(false); break; default: throw new ArgumentOutOfRangeException(); } bottomBar.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); bottomBar.SetOnTabClickListener(this); UpdateTabs(); UpdateBarBackgroundColor(); UpdateBarTextColor(); } if (bottomBarPage.CurrentPage != null) { SwitchContent(bottomBarPage.CurrentPage); } } }
protected override void OnElementChanged(ElementChangedEventArgs <HomePage> e) { base.OnElementChanged(e); if (e.NewElement != null) { HomePage bottomBarPage = e.NewElement; if (_bottomBar == null) { _pageController = PageController.Create(bottomBarPage); _frameLayout = new FrameLayout(MainActivity.ApplicationContext) { LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent, GravityFlags.Fill) }; AddView(_frameLayout, 0); _bottomBar = BottomNavigationBar.BottomBar.Attach(_frameLayout, null); _bottomBar.NoTopOffset(); _bottomBar.NoTabletGoodness(); if (bottomBarPage.FixedMode) { _bottomBar.UseFixedMode(); } switch (bottomBarPage.BarTheme) { case BarThemeTypes.Light: break; case BarThemeTypes.DarkWithAlpha: _bottomBar.UseDarkThemeWithAlpha(true); break; case BarThemeTypes.DarkWithoutAlpha: _bottomBar.UseDarkThemeWithAlpha(false); break; default: throw new ArgumentOutOfRangeException(); } _bottomBar.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); _bottomBar.SetOnTabClickListener(this); UpdateTabs(); UpdateBarBackgroundColor(); UpdateBarTextColor(); } if (bottomBarPage.CurrentPage != null) { SwitchContent(bottomBarPage.CurrentPage); } } }
private Page CreateNestedPage() { var page = controller.Create("page", testContext.users[0]); var pageSub1 = controller.AddSubPage("sub page 1", page.Id, testContext.users[0]); var pageSub2 = controller.AddSubPage("sub page 2", page.Id, testContext.users[0]); var p = controller.AddSubPage("sub 1 sub page 1", pageSub1.Id, testContext.users[0]); controller.ChangeOwner(p.Id, testContext.users[17].Id, testContext.users[0]); controller.AddSubPage("sub 2 sub page 1", pageSub2.Id, testContext.users[0]); controller.AddAttachment("sub 1 attachment 1", pageSub1.Id, testContext.users[0]); controller.AddAttachment("page attachment", page.Id, testContext.users[0]); var teams = CreateTeams(); controller.AddAdmin(page.Id, teams[0].Id, testContext.users[0]); controller.AddReader(page.Id, teams[1].Id, testContext.users[0]); controller.AddAdmin(page.Id, testContext.users[10].Id, testContext.users[0]); controller.AddReader(page.Id, testContext.users[11].Id, testContext.users[0]); return(page); }
public void CreateGet() { // Arrange PageController controller = new PageController( booksServiceMock.Object, pagesServiceMock.Object, pageConnectionsServiceMock.Object, usersServiceMock.Object ); // Act ViewResult result = controller.Create() as ViewResult; // Assert Assert.IsNotNull(result); }
protected override void OnElementChanged(ElementChangedEventArgs <RootView> e) { base.OnElementChanged(e); if (e.NewElement != null) { RootView bottomBarPage = e.NewElement; if (_bottomBar == null) { _pageController = PageController.Create(bottomBarPage); // create a view which will act as container for Page's _frameLayout = new FrameLayout(Forms.Context); _frameLayout.LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent, GravityFlags.Fill); AddView(_frameLayout, 0); // create bottomBar control _bottomBar = BottomNavigationBar.BottomBar.Attach(_frameLayout, null); _bottomBar.MaxFixedTabCount = bottomBarPage.Children.Count - 1; _bottomBar.UseFixedMode(); _bottomBar.SetFixedInactiveIconColor(Color.Silver.ToAndroid()); _bottomBar.NoTabletGoodness(); _bottomBar.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); _bottomBar.SetOnTabClickListener(this); _bottomBar.SetShiftingIconColor(Element.ActiveIconColor.ToAndroid()); UpdateTabs(); UpdateBarTextColor(); UpdateBarBackgroundColor(); } if (bottomBarPage.CurrentPage != null) { SwitchContent(bottomBarPage.CurrentPage); } } }
protected override void OnElementChanged(ElementChangedEventArgs <TabbedPageBottom> e) { base.OnElementChanged(e); if (e.NewElement != null) { TabbedPageBottom bottomBarPage = e.NewElement; if (_bottomBar == null) { _pageController = PageController.Create(bottomBarPage); // create a view which will act as container for Page's _frameLayout = new FrameLayout(Context); _frameLayout.LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent, GravityFlags.Fill); AddView(_frameLayout, 0); // create bottomBar control _bottomBar = BottomBar.Attach(_frameLayout, null); _bottomBar.NoTabletGoodness(); _bottomBar.UseFixedMode(); _bottomBar.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); _bottomBar.SetOnTabClickListener(this); // create tab items SetTabItems(); } if (bottomBarPage.CurrentPage != null) { SwitchContent(bottomBarPage.CurrentPage); UpdateSelectedTabIndex(Element.CurrentPage); } } }
protected override void OnElementChanged(ElementChangedEventArgs <BottomTabbedPage> e) { base.OnElementChanged(e); if (e.NewElement != null) { BottomTabbedPage bottomBarPage = e.NewElement; if (_bottomBar == null) { _pageController = PageController.Create(bottomBarPage); _rootLayout = new LinearLayout(Context) { LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent) }; AddView(_rootLayout); // create a view which will act as container for Page's _frameLayout = new FrameLayout(Context) { LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent) }; _rootLayout.AddView(_frameLayout); _bottomBar = new BottomNavigationViewEx(Context) { LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent) }; _rootLayout.AddView(_bottomBar); _bottomBar.SetOnNavigationItemSelectedListener(this); if (BackgroundColor.HasValue) { _bottomBar.SetBackgroundColor(BackgroundColor.Value); } if (ItemIconTintList != null) { _bottomBar.ItemIconTintList = ItemIconTintList; } if (ItemTextColor != null) { _bottomBar.ItemTextColor = ItemTextColor; } if (ItemBackgroundResource.HasValue) { _bottomBar.ItemBackgroundResource = ItemBackgroundResource.Value; } // Resource.Drawable.bnv_selector _menu = (BottomNavigationMenu)_bottomBar.Menu; UpdateTabs(); } if (bottomBarPage.CurrentPage != null) { SwitchContent(bottomBarPage.CurrentPage); } } }