Esempio n. 1
0
        public override void SetContentView(int layoutResId)
        {
            base.SetContentView(layoutResId);

            LegacyBar = FindViewById <LegacyBar.Library.Bar.LegacyBar>(Resource.Id.ActionBar);

            if (LegacyBar != null)
            {
                LegacyBar.Title = Title;
                LegacyBar.Theme = LegacyBarTheme.HoloBlack;

                LegacyBar.SetHomeAction(new ActionLegacyBarAction(this,
                                                                  () => _slidingMenu.Toggle(true),
                                                                  Resource.Drawable.Menu));

                if (RefreshCommand != null)
                {
                    LegacyBar.AddAction(new ActionLegacyBarAction(this, () => RefreshCommand.Execute(null), Resource.Drawable.Refresh));
                }

                _slidingMenu = new SlidingMenu(this)
                {
                    Mode                       = MenuMode.Left,
                    TouchModeAbove             = DisableMenuSwipe ? TouchMode.None : TouchMode.Fullscreen,
                    BehindOffset               = 50,
                    BehindWidth                = 400,
                    ShadowWidth                = 20,
                    ShadowDrawableRes          = Resource.Drawable.SlidingMenuShadow,
                    SecondaryShadowDrawableRes = Resource.Drawable.SlidingMenuShadowRight
                };

                _slidingMenu.SetBackgroundColor(Color.Black);
                _slidingMenu.AttachToActivity(this, SlideStyle.Content);
                _slidingMenu.SetMenu(Resource.Layout.MenuFrame);

                var menuFragment = new MenuFragment();
                menuFragment.ViewModel = new MenuViewModel(((ViewModelBase)ViewModel).Messenger);

                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.MenuFrame, menuFragment).Commit();
            }
        }
 public void Toggle()
 {
     _slidingMenu.Toggle();
 }
 /// <summary>
 /// Toggle the SlidingMenu. If it is open, it will be closed, and vice versa.
 /// </summary>
 public void Toggle()
 {
     mSlidingMenu.Toggle();
 }
Esempio n. 4
0
        protected override void OnViewModelSet()
        {
            //this.Parent.RequestWindowFeature (WindowFeatures.NoTitle);

            //RequestWindowFeature (WindowFeatures.NoTitle);

            homeViewModel = (HomeViewModel)ViewModel;

            SetContentView(Resource.Layout.Content_Frame);

            MenuId = Resource.Menu.HomeMenu;


            LegacyBar = FindViewById <LegacyBar.Library.Bar.LegacyBar>(Resource.Id.actionbar);

            //LegacyBar.SetHomeLogo(Resource.Drawable.jabbr_home_icon);
            AddHomeAction(() => {
                slidingMenu.Toggle();
            }, Resource.Drawable.jabbr_home_icon);

            LegacyBar.Click += (sender, e) => {
                slidingMenu.Toggle();
            };
            LegacyBar.Title = "JabbR";



            slidingMenu = new SlidingMenu(this)
            {
                Mode                       = MenuMode.LeftRight,
                TouchModeAbove             = TouchMode.Fullscreen,
                BehindOffset               = 80,
                ShadowWidth                = 20,
                ShadowDrawableRes          = Resource.Drawable.SlidingMenuShadow,
                SecondaryShadowDrawableRes = Resource.Drawable.SlidingMenuShadowRight
            };

            slidingMenu.AttachToActivity(this, SlideStyle.Content);
            slidingMenu.SetMenu(Resource.Layout.Menu_Frame);
            //slidingMenu.ShadowDrawableRes = Resource.Drawable.SlidingMenuShadow;

            menuFragment           = new MenuFragment();
            menuFragment.ViewModel = ViewModel;

            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.menu_frame, menuFragment).Commit();

            slidingMenu.SetSecondaryMenu(Resource.Layout.UserList_Frame);
            //slidingMenu.SecondaryShadowDrawableRes = Resource.Drawable.SlidingMenuShadowRight;

            emptyFragment           = new EmptyFragment();
            emptyFragment.ViewModel = this.ViewModel;

            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.content_frame, emptyFragment).Commit();


            //TODO: Put some kind of default view in the chat fragment space

            homeViewModel.PropertyChanged += (sender, e) => {
                Console.WriteLine("PropertyChanged: " + e.PropertyName);

                if (e.PropertyName == "CurrentRoom")
                {
                    if (homeViewModel.CurrentRoom == null)
                    {
                        if (emptyFragment == null)
                        {
                            emptyFragment = new EmptyFragment();
                        }

                        chatFragment = null;

                        SupportFragmentManager.BeginTransaction()
                        .Replace(Resource.Id.content_frame, emptyFragment).Commit();

                        LegacyBar.Title = "JabbR";

                        showActions = false;
                        ToggleActions();

                        userListFragment.ViewModel = null;

                        SupportFragmentManager.BeginTransaction()
                        .Replace(Resource.Id.userlist_frame, userListFragment).Commit();
                        return;
                    }

                    showActions = true;


                    if (chatFragment == null)
                    {
                        chatFragment           = new ChatFragment();
                        chatFragment.ViewModel = homeViewModel.CurrentRoom;

                        SupportFragmentManager.BeginTransaction()
                        .Replace(Resource.Id.content_frame, chatFragment).Commit();
                    }
                    else
                    {
                        chatFragment.ViewModel = homeViewModel.CurrentRoom;
                    }

                    if (userListFragment == null)
                    {
                        userListFragment           = new UserListFragment();
                        userListFragment.ViewModel = homeViewModel.CurrentRoom;

                        SupportFragmentManager.BeginTransaction()
                        .Replace(Resource.Id.userlist_frame, userListFragment).Commit();
                    }
                    else
                    {
                        userListFragment.ViewModel = homeViewModel.CurrentRoom;
                    }


                    ToggleActions();

                    slidingMenu.Toggle();

                    this.RunOnUiThread(() => LegacyBar.Title = homeViewModel.CurrentRoom.Room.Name);
                }
            };

            messenger = Mvx.Resolve <IMvxMessenger> ();
            _mvxMsgTokUserSelected = messenger.SubscribeOnMainThread <UserSelectedMessage> (msg => {
                chatFragment.AppendText("@" + msg.User.Name);

                slidingMenu.ShowContent(true);
            });
        }