Пример #1
0
 protected MenuBaseViewController()
     : base(style: UITableViewStyle.Plain)
 {
     _profileButton = new MenuProfileView(new RectangleF(0, 0, 320f, 44f));
     _profileButton.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
     _profileButton.TouchUpInside   += ProfileButtonClicked;
     NavigationItem.TitleView        = _profileButton;
 }
Пример #2
0
        public MenuView()
        {
            _profileButton = new MenuProfileView(new CGRect(0, 0, 320f, 44f));
            _profileButton.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
            _profileButton.TouchUpInside   += (sender, e) => ViewModel.GoToAccountsCommand.ExecuteIfCan();
            NavigationItem.TitleView        = _profileButton;

            _topSection = new Section
            {
                new MenuElement("Profile", () => ViewModel.GoToProfileCommand.ExecuteIfCan(), Images.Person),
                (_notifications = new MenuElement("Notifications", () => ViewModel.GoToNotificationsCommand.ExecuteIfCan(), Images.Inbox)),
                new MenuElement("News", () => ViewModel.GoToNewsCommand.ExecuteIfCan(), Images.RadioTower),
                new MenuElement("Issues", () => ViewModel.GoToMyIssuesCommand.ExecuteIfCan(), Images.IssueOpened)
            };

            _repoSection = new Section {
                HeaderView = new MenuSectionView("Repositories")
            };
            _repoSection.Add(new MenuElement("Owned", () => ViewModel.GoToOwnedRepositoriesCommand.ExecuteIfCan(), Images.Repo));
            _repoSection.Add(new MenuElement("Starred", () => ViewModel.GoToStarredRepositoriesCommand.ExecuteIfCan(), Images.Star));
            _repoSection.Add(new MenuElement("Watching", () => ViewModel.GoToWatchedRepositoriesCommand.ExecuteIfCan(), Images.Eye));
            _repoSection.Add(new MenuElement("Trending", () => ViewModel.GoToTrendingRepositoriesCommand.ExecuteIfCan(), Images.Pulse));
            _repoSection.Add(new MenuElement("Explore", () => ViewModel.GoToExploreRepositoriesCommand.ExecuteIfCan(), Images.Telescope));

            _gistsSection = new Section {
                HeaderView = new MenuSectionView("Gists")
            };
            _gistsSection.Add(new MenuElement("My Gists", () => ViewModel.GoToMyGistsCommand.ExecuteIfCan(), Images.Gist));
            _gistsSection.Add(new MenuElement("Starred", () => ViewModel.GoToStarredGistsCommand.ExecuteIfCan(), Images.Star));
            _gistsSection.Add(new MenuElement("Public", () => ViewModel.GoToPublicGistsCommand.ExecuteIfCan(), Images.Globe));

            _infoSection = new Section {
                HeaderView = new MenuSectionView("Info & Preferences")
            };
            _infoSection.Add(new MenuElement("Settings", () => ViewModel.GoToSettingsCommand.ExecuteIfCan(), Images.Gear));
            _infoSection.Add(new MenuElement("Upgrades", () => ViewModel.GoToUpgradesCommand.ExecuteIfCan(), Images.Lock));
            _infoSection.Add(new MenuElement("Feedback & Support", () => ViewModel.GoToFeedbackCommand.ExecuteIfCan(), Images.Question));
            _infoSection.Add(new MenuElement("Accounts", () => ViewModel.GoToAccountsCommand.ExecuteIfCan(), Images.Person));

            this.WhenAnyValue(x => x.ViewModel)
            .IsNotNull()
            .Subscribe(x => x.LoadCommand.ExecuteIfCan());

            this.WhenAnyValue(x => x.ViewModel.Account)
            .IsNotNull()
            .Subscribe(x =>
            {
                _profileButton.Name     = string.IsNullOrEmpty(x.Name) ? x.Username : x.Name;
                _profileButton.Username = x.Email;
                _profileButton.ImageUri = x.AvatarUrl;
            });

            this.WhenAnyValue(x => x.ViewModel.Notifications).DistinctUntilChanged().Subscribe(x =>
            {
                _notifications.NotificationNumber = x;
                if (_dialogSource != null)
                {
                    _dialogSource.Root.Reload(_notifications);
                }
            });

            Appearing.Subscribe(_ => CreateMenuRoot());
            Appearing.Subscribe(_ =>
            {
                var frame            = NavigationController.NavigationBar.Frame;
                _profileButton.Frame = new CGRect(0, 0, frame.Width, frame.Height);
            });
        }
Пример #3
0
        public MenuViewController()
        {
            _profileButton = new MenuProfileView(new CGRect(0, 0, 320f, 44f));
            _profileButton.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
            _profileButton.TouchUpInside   += (sender, e) => ViewModel.GoToAccountsCommand.ExecuteIfCan();
            NavigationItem.TitleView        = _profileButton;

            _topSection = new Section
            {
                new MenuElement("Profile", () => ViewModel.GoToProfileCommand.ExecuteIfCan(), Octicon.Person.ToImage()),
                (_notifications = new MenuElement("Notifications", () => ViewModel.GoToNotificationsCommand.ExecuteIfCan(), Octicon.Inbox.ToImage())),
                new MenuElement("News", () => ViewModel.GoToNewsCommand.ExecuteIfCan(), Octicon.RadioTower.ToImage()),
                new MenuElement("Issues", () => ViewModel.GoToMyIssuesCommand.ExecuteIfCan(), Octicon.IssueOpened.ToImage())
            };

            _trendingElement = new MenuElement("Trending", () => ViewModel.GoToTrendingRepositoriesCommand.ExecuteIfCan(), Octicon.Pulse.ToImage());
            this.WhenAnyValue(x => x.ViewModel.Account)
            .Select(x => x != null && x.IsEnterprise)
            .StartWith(true)
            .Subscribe(x => _trendingElement.Hidden = x);

            _repoSection = new Section {
                HeaderView = new MenuSectionView("Repositories")
            };
            _repoSection.Add(new MenuElement("Owned", () => ViewModel.GoToOwnedRepositoriesCommand.ExecuteIfCan(), Octicon.Repo.ToImage()));
            _repoSection.Add(new MenuElement("Starred", () => ViewModel.GoToStarredRepositoriesCommand.ExecuteIfCan(), Octicon.Star.ToImage()));
            _repoSection.Add(new MenuElement("Watching", () => ViewModel.GoToWatchedRepositoriesCommand.ExecuteIfCan(), Octicon.Eye.ToImage()));
            _repoSection.Add(_trendingElement);
            _repoSection.Add(new MenuElement("Explore", () => ViewModel.GoToExploreRepositoriesCommand.ExecuteIfCan(), Octicon.Telescope.ToImage()));

            _gistsSection = new Section {
                HeaderView = new MenuSectionView("Gists")
            };
            _gistsSection.Add(new MenuElement("My Gists", () => ViewModel.GoToMyGistsCommand.ExecuteIfCan(), Octicon.Gist.ToImage()));
            _gistsSection.Add(new MenuElement("Starred", () => ViewModel.GoToStarredGistsCommand.ExecuteIfCan(), Octicon.Star.ToImage()));
            _gistsSection.Add(new MenuElement("Public", () => ViewModel.GoToPublicGistsCommand.ExecuteIfCan(), Octicon.Globe.ToImage()));

            _infoSection = new Section {
                HeaderView = new MenuSectionView("Info & Preferences")
            };
            _infoSection.Add(new MenuElement("Settings", () => ViewModel.GoToSettingsCommand.ExecuteIfCan(), Octicon.Gear.ToImage()));
            //RegisterForNotifications_infoSection.Add(new MenuElement("Go Pro", () => ViewModel.GoToUpgradesCommand.ExecuteIfCan(), Octicon.Lock.ToImage()));
            _infoSection.Add(new MenuElement("Feedback & Support", () => ViewModel.GoToFeedbackCommand.ExecuteIfCan(), Octicon.Question.ToImage()));
            _infoSection.Add(new MenuElement("Accounts", () => ViewModel.GoToAccountsCommand.ExecuteIfCan(), Octicon.Person.ToImage()));

            this.WhenAnyValue(x => x.ViewModel)
            .IsNotNull()
            .Subscribe(x => x.LoadCommand.ExecuteIfCan());

            this.WhenAnyValue(x => x.ViewModel.Account)
            .IsNotNull()
            .Subscribe(x =>
            {
                _profileButton.Text     = string.IsNullOrEmpty(x.Name) ? x.Username : x.Name;
                _profileButton.Subtitle = x.Email;
            });

            this.WhenAnyValue(x => x.ViewModel.Avatar)
            .Subscribe(x => _profileButton.SetImage(x.ToUri(64), Images.UnknownUser));

            this.WhenAnyValue(x => x.ViewModel.Notifications)
            .Subscribe(x => _notifications.NotificationNumber = x);

            Appearing.Subscribe(_ => CreateMenuRoot());
            Appearing.Subscribe(_ =>
            {
                var frame            = NavigationController.NavigationBar.Frame;
                _profileButton.Frame = new CGRect(0, 0, frame.Width, frame.Height);
            });

            Appeared
            .Take(1)
            .Delay(TimeSpan.FromMilliseconds(250), RxApp.MainThreadScheduler)
            .Subscribe(_ => ViewModel.ActivateCommand.ExecuteIfCan());
        }