public RepositoriesTrendingView() { var titleButton = new TrendingTitleButton { Frame = new CGRect(0, 0, 200f, 32f), TintColor = Theme.PrimaryNavigationBarTextColor }; NavigationItem.TitleView = titleButton; titleButton.TouchUpInside += (sender, e) => ViewModel.GoToLanguages.ExecuteIfCan(); this.WhenAnyValue(x => x.ViewModel.SelectedLanguage).IsNotNull() .Subscribe(x => titleButton.Text = x.Name); EmptyView = new Lazy <UIView>(() => new EmptyListView(Octicon.Pulse.ToEmptyListImage(), "There are no trending repositories.")); Appearing .Where(_ => NavigationController != null) .Subscribe(_ => NavigationController.NavigationBar.ShadowImage = new UIImage()); Disappearing .Where(_ => NavigationController != null) .Subscribe(_ => NavigationController.NavigationBar.ShadowImage = null); }
public NotificationsView() { _segmentBarButton = new UIBarButtonItem(_viewSegment); EmptyView = new Lazy <UIView>(() => new EmptyListView(Octicon.Inbox.ToImage(64f), "No new notifications.")); _markButton = new UIBarButtonItem(string.Empty, UIBarButtonItemStyle.Plain, (s, e) => ViewModel.ReadSelectedCommand.ExecuteIfCan()); _segmentToolbar = new [] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _segmentBarButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace) }; _markToolbar = new [] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _markButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace) }; ToolbarItems = _segmentToolbar; _editButton = new UIBarButtonItem(UIBarButtonSystemItem.Edit, (s, e) => StartEditing()); _cancelButton = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (s, e) => StopEditing()); this.WhenActivated(d => { d(this.WhenAnyValue(x => x.ViewModel.GroupedNotifications) .SelectMany(x => x) .SelectMany(x => x.Notifications) .Select(x => x.WhenAnyValue(y => y.IsSelected)) .Merge() .Select(_ => ViewModel.GroupedNotifications.SelectMany(x => x.Notifications).Any(x => x.IsSelected)) .Where(x => TableView.Editing) .Subscribe(x => { _markButton.Title = x ? "Mark Selected as Read" : "Read All as Read"; })); d(this.WhenAnyValue(x => x.ViewModel.GroupedNotifications) .Where(x => x.Count == 0 && TableView.Editing) .Subscribe(_ => StopEditing())); d(this.WhenAnyValue(x => x.ViewModel.GroupedNotifications) .Subscribe(x => _editButton.Enabled = x.Count > 0)); d(this.WhenAnyValue(x => x.ViewModel.ActiveFilter) .Subscribe(x => { _viewSegment.SelectedSegment = x; NavigationItem.SetRightBarButtonItem((_viewSegment.SelectedSegment != 2) ? _editButton : null, true); })); }); Appearing .Where(_ => NavigationController != null) .Subscribe(x => NavigationController.SetToolbarHidden(false, x)); Disappearing .Where(_ => NavigationController != null) .Subscribe(x => NavigationController.SetToolbarHidden(true, x)); }
public override void ViewDidLoad() { base.ViewDidLoad(); SelectedTheme = _applicationService.Account.CodeEditTheme ?? "idea"; var themes = Directory .GetFiles(Path.Combine("WebResources", "styles")) .Where(x => x.EndsWith(".css", StringComparison.Ordinal)) .Select(x => Path.GetFileNameWithoutExtension(x)) .ToArray(); var model = new PickerModel(themes); _pickerView.Model = model; var selectedIndex = Array.IndexOf(themes, SelectedTheme); if (selectedIndex >= 0 && selectedIndex < themes.Length) { _pickerView.Select(selectedIndex, 0, false); } Add(_pickerView); var loadCommand = ReactiveCommand.CreateFromTask <string>(LoadTheme); loadCommand .ThrownExceptions .Select(error => new UserError(LoadErrorMessage, error)) .SelectMany(Interactions.Errors.Handle) .Subscribe(); this.WhenAnyValue(x => x.SelectedTheme) .InvokeReactiveCommand(loadCommand); this.WhenAnyValue(x => x.SelectedTheme) .Skip(1) .Take(1) .Subscribe(_ => _isModified = true); OnActivation(d => { d(model.SelectedObservable .Subscribe(x => SelectedTheme = x)); }); Disappearing .Where(_ => _isModified) .Select(_ => SelectedTheme) .SelectMany(theme => SetSelectedTheme(theme).ToObservable()) .Subscribe(_ => {}, err => this.Log().ErrorException("Unable to save theme", err)); }
protected BaseDialogViewController() : base(UITableViewStyle.Grouped) { SlideUpTitle = new SlideUpTitleView(44f) { Offset = 100f }; NavigationItem.TitleView = SlideUpTitle; HeaderView = new ImageAndTitleHeaderView(); _backgroundHeaderView = new UIView(); Appearing .Where(x => ToolbarItems != null && NavigationController != null) .Subscribe(x => NavigationController.SetToolbarHidden(false, x)); Disappearing .Where(x => ToolbarItems != null && NavigationController != null) .Subscribe(x => NavigationController.SetToolbarHidden(true, x)); Disappearing .Where(_ => NavigationController != null) .Subscribe(_ => NavigationController.NavigationBar.ShadowImage = null); }