public void PushNNM(NativeNavigationModel nnm)
        {
            string story    = nnm.storyboard;
            string viewCtrl = nnm.viewController;
            var    window   = UIApplication.SharedApplication.KeyWindow;
            var    vc       = window.RootViewController;

            while (vc.PresentedViewController != null)
            {
                vc = vc.PresentedViewController;
            }
            var              navController = vc as UINavigationController;
            UIStoryboard     board         = UIStoryboard.FromName(story, null);
            UIViewController ctrl          = (UIViewController)board.InstantiateViewController(viewCtrl);

            navController.PushViewController(ctrl, true);
        }
 public NavigateByString(NativeNavigationModel nm)
 {
     nnm = nm;
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            fm = SupportFragmentManager;

            Forms.Init(this, null);

            MobileCenter.Start("d19450d5-6882-4bea-9b6e-0b3f2e4afe02",
                               typeof(Analytics), typeof(Crashes));

            MessagingCenter.Subscribe <NativeNavigation, string>(this, "NativeNav", (sender, arg) =>
            {
                System.Console.WriteLine("Got the message from Xamarin Forms to load Global Search");
                NativeNavigationModel nnm = JsonConvert.DeserializeObject <NativeNavigationModel>(arg);
                NavigateByString nav      = new NavigateByString(nnm);
                nav.NavigateXF();
            }
                                                                 );

            SetContentView(Resource.Layout.Main);

            MainToolBar = FindViewById <V7Toolbar>(Resource.Id.mainToolBar);

            //UpwardFontTextView upwardLogo = ViewUtil.GetUpwardFontTextView(this, "U", 60, Resource.Color.white);
            //MainToolBar.FindViewById<RelativeLayout>(Resource.Id.upwardLogo_container).AddView(upwardLogo);

            ViewUtil.AddUpwardLogoToView(this, MainToolBar.FindViewById <Android.Widget.RelativeLayout>(Resource.Id.upwardLogo_container),
                                         Resources.GetInteger(Resource.Integer.upward_toolbar_logo_size));

            SetSupportActionBar(MainToolBar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeAsUpIndicator(new IconDrawable(this, "md-menu").SizeDp(28).Color(Android.Graphics.Color.White));

            MainTabLayout = FindViewById <TabLayout>(Resource.Id.mainTabLayout);
            MainViewPager = FindViewById <ViewPager>(Resource.Id.mainViewPager);

            //NOTE: The following group of lines restores the old tab layout. These were removed in favor of the singular home page fragment approach for Upward
            SetUpFragments();
            MainFragAdapter       = new MainAdapter(this, fm, Fragments);
            MainViewPager.Adapter = MainFragAdapter;
            MainTabLayout.SetupWithViewPager(MainViewPager);
            MainViewPager.OffscreenPageLimit = Fragments.Count - 1;
            MainViewPager.AddOnPageChangeListener(this);

            //HomeFeedFragment fragment = new HomeFeedFragment();
            //FragmentUtil.LoadFragment(SupportFragmentManager, Resource.Id.staticFragmentContainer, fragment, Constants.VALUE_TYPE_HOME_FEED);

            NavView = FindViewById <NavigationView>(Resource.Id.nav_view);
            //NavView.NavigationItemSelected += DrawerItemSelected;
            DrawerLayout = FindViewById <FRDrawerLayout>(Resource.Id.drawer_layout);


            //Fab = FindViewById<FloatingActionButton>(Resource.Id.fab);
            ////var icon = new IconDrawable(this, "md-create").Color(Android.Graphics.Color.White).SizeDp(20);
            //Fab.Click += (sender, e) =>
            //{
            //    IntentUtil.GoToCreatePost(this);
            //    //add layout and tint to layout

            //};
            //Fab.SetImageDrawable(icon);
            SetUpFab();

            SetTabIcons();
            SetConnectivityMessage();

            //The following 6 lines of code will set up the drawer for a non-logged in state to start, and change it later as required
            Fab.Visibility = ViewStates.Gone;
            NavView.FindViewById(Resource.Id.drawerLogout).Visibility = ViewStates.Gone;
            NavView.FindViewById(Resource.Id.drawerNonAuthenticatedHeader).Visibility = ViewStates.Visible;
            NavView.FindViewById(Resource.Id.drawerAuthenticatedHeader).Visibility    = ViewStates.Gone;
            NavView.FindViewById <ImageView>(Resource.Id.drawerNonAuthenticatedHeader_Avatar)
            .SetImageDrawable(ViewUtil.GetSVGDrawable(this, "profile_empty", 200, Resource.Color.Upward_dark_grey));
            MainTabLayout.Visibility = ViewStates.Gone;
            FindViewById(Resource.Id.flDrawerNonAuthenticatedHeader_AvatarContainer).SetOnClickListener(this);

            //Setup MainView
            var linear = new LinearLayout(this);

            linear.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, Android.Views.ViewGroup.LayoutParams.MatchParent);
            linear.Orientation      = Orientation.Vertical;

            var frame = new FrameLayout(this);

            frame.LayoutParameters = linear.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, Android.Views.ViewGroup.LayoutParams.MatchParent);

            frame.Id = 100;

            //linear.AddView(frame);

            //SetContentView(linear);

            //Setup navigation
            if (!Forms.IsInitialized)
            {
                Forms.Init(this, savedInstanceState);
            }

            DependencyService.Register <IAppNavigation, AppNavigation>();

            //AppNavigation.Manager = FragmentManager;
            //AppNavigation.ResourceId = 100;

            var appNavigation = DependencyService.Get <IAppNavigation>();

            //appNavigation.Push(App.StartPage);
        }
Example #4
0
        public void PushNNM(NativeNavigationModel nnm)
        {
            NavigateByString nbs = new NavigateByString(nnm);

            nbs.NavigateDROID(nnm.fragmentType, nnm.fragmentValue);
        }