private async void GetDrawerInfo() { var profile = await _profileDrawerControllerService.GetUserProfile(); RunOnUiThread(() => { if (profile != null) { //set up profile picture, logout button and favorites if the user is logged in LoggedIn = true; NavView.FindViewById(Resource.Id.drawerNonAuthenticatedHeader).Visibility = ViewStates.Gone; NavView.FindViewById(Resource.Id.drawerLogout).Visibility = ViewStates.Visible; var authHeader = NavView.FindViewById(Resource.Id.drawerAuthenticatedHeader); authHeader.Visibility = ViewStates.Visible; Picasso.With(this).Load(profile.ProfileImageUrl) .Into(authHeader.FindViewById <ImageView>(Resource.Id.drawerAuthenticatedHeader_Avatar)); authHeader.Tag = profile.ProfileId; authHeader.SetOnClickListener(this); authHeader.FindViewById <TextView>(Resource.Id.drawerUser_Fullname).Text = profile.ProfileFirstName + " " + profile.ProfileLastName; authHeader.FindViewById <TextView>(Resource.Id.drawerUser_Handle).Text = profile.ProfileHandle; //Setting up auth tab layout //MainTabLayout.Visibility = ViewStates.Visible; Fab.Visibility = ViewStates.Visible; //TODO: Change these to real fragments later if (Fragments.Count == 1) { Fragments.Add(NotificationFragment.NewInstance()); Fragments.Add(NotificationFragment.NewInstance()); } MainFragAdapter.NotifyDataSetChanged(); SetTabIcons(); } else { //set up icon and hide tab layout when user is not logged in LoggedIn = false; 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; } PreferenceManager.GetDefaultSharedPreferences(ApplicationContext).Edit() .PutBoolean(Constants.PREF_SIGNED_IN_KEY, LoggedIn).Commit(); }); }
private void SetTabIcons() { var tabIconSize = 42; var navIconSize = 14; var tabColor = ContextCompat.GetColor(this, Resource.Color.white); var navColor = ContextCompat.GetColor(this, Resource.Color.primary); var homeIcon = "fa-home"; MainTabLayout.GetTabAt(0).SetIcon(ViewUtil.GetSVGDrawable(this, "home_tab_bar", tabIconSize, tabColor, "#FFFFFF")); //NavView.Menu.FindItem(Resource.Id.navHome).SetIcon(new IconDrawable(this, homeIcon).Color(navColor).SizeDp(navIconSize)); //var trendingIcon = "md-trending-up"; //MainTabLayout.GetTabAt(1).SetIcon(new IconDrawable(this, trendingIcon).Color(tabColor).SizeDp(tabIconSize)); //NavView.Menu.FindItem(Resource.Id.navTrending).SetIcon(new IconDrawable(this, trendingIcon).Color(navColor).SizeDp(navIconSize)); //var boardIcon = "fa-users"; //MainTabLayout.GetTabAt(2).SetIcon(new IconDrawable(this, boardIcon).Color(tabColor).SizeDp(tabIconSize)); //NavView.Menu.FindItem(Resource.Id.navBoards).SetIcon(new IconDrawable(this, boardIcon).Color(navColor).SizeDp(navIconSize)); if (Fragments.Count > 1) { var bellIcon = "fa-bell"; MainTabLayout.GetTabAt(1).SetIcon(ViewUtil.GetSVGDrawable(this, "notifications_white", tabIconSize, tabColor)); MainTabLayout.GetTabAt(2).SetIcon(ViewUtil.GetSVGDrawable(this, "messaging_white", tabIconSize, tabColor)); //UpwardFontTextView v = ViewUtil.GetUpwardFontTextView(this, "O", navIconSize, Resource.Color.white); //v.DrawingCacheEnabled = true; //v.Measure(MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified), MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified)); //v.Layout(0, 0, v.MeasuredWidth, v.MeasuredHeight); //v.BuildDrawingCache(true); //Bitmap b = Bitmap.CreateBitmap(v.DrawingCache); //v.DrawingCacheEnabled = false; //MainTabLayout.GetTabAt(1).SetIcon(new BitmapDrawable(b)); } //NavView.Menu.FindItem(Resource.Id.navNotificaitons).SetIcon(new IconDrawable(this, bellIcon).Color(navColor).SizeDp(navIconSize)); //NavView.Menu.FindItem(Resource.Id.navMyProfile).SetIcon(new IconDrawable(this, "md-person").Color(navColor).SizeDp(navIconSize)); //NavView.Menu.FindItem(Resource.Id.navLogout).SetIcon(new IconDrawable(this, "fa-sign-out").Color(navColor).SizeDp(navIconSize)); //NavView.Menu.FindItem(Resource.Id.navSearch).SetIcon(new IconDrawable(this, "md-search").Color(navColor).SizeDp(navIconSize)); //NavView.Menu.FindItem(Resource.Id.navAppInfo).SetIcon(new IconDrawable(this, "md-info-outline").Color(navColor).SizeDp(navIconSize)); }
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); }