Esempio n. 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = Resources.Siri_Shortcuts;

            DescriptionLabel.Text = Resources.Siri_Shortcuts_Description;
            HeaderView.RemoveFromSuperview();
            HeaderView.BackgroundColor = Colors.Siri.HeaderBackground.ToNativeColor();
            TableView.TableHeaderView  = HeaderView;
            HeaderView.TranslatesAutoresizingMaskIntoConstraints = false;
            HeaderView.WidthAnchor.ConstraintEqualTo(TableView.WidthAnchor).Active = true;

            TableView.BackgroundColor = Colors.Siri.HeaderBackground.ToNativeColor();
            TableView.TableFooterView = new UIView();

            var tableViewSource = new SiriShortcutsTableViewSource(TableView);

            TableView.Source = tableViewSource;

            refreshSubject
            .SelectMany(getAllShortcuts())
            .SelectMany(toViewModels)
            .Select(toSections)
            .ObserveOn(new NSRunloopScheduler())
            .Subscribe(TableView.Rx().ReloadSections(tableViewSource))
            .DisposedBy(DisposeBag);

            tableViewSource.Rx().ModelSelected()
            .Subscribe(handleShortcutTap)
            .DisposedBy(DisposeBag);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = Resources.SiriWorkflows;

            HeaderLabel.Text = Resources.SiriWorkflowsDescription;
            HeaderView.RemoveFromSuperview();
            HeaderView.BackgroundColor = Colors.Siri.HeaderBackground.ToNativeColor();
            TableView.TableHeaderView  = HeaderView;
            HeaderView.TranslatesAutoresizingMaskIntoConstraints = false;
            HeaderView.WidthAnchor.ConstraintEqualTo(TableView.WidthAnchor).Active = true;

            TableView.SeparatorStyle  = UITableViewCellSeparatorStyle.None;
            TableView.BackgroundColor = Colors.Siri.HeaderBackground.ToNativeColor();
            TableView.TableFooterView = new UIView();
            TableView.ContentInset    = new UIEdgeInsets(0, 0, 20, 0);

            TableView.RegisterNibForCellReuse(SiriWorkflowCell.Nib, SiriWorkflowCell.Identifier);
            TableView.RowHeight = UITableView.AutomaticDimension;

            var source = new CustomTableViewSource <SectionModel <Unit, SiriWorkflow>, Unit, SiriWorkflow>(
                SiriWorkflowCell.CellConfiguration(SiriWorkflowCell.Identifier)
                );

            downloadJson()
            .Select(JsonConvert.DeserializeObject <List <SiriWorkflow> >)
            .Select(list => list.ToImmutableList())
            .ObserveOn(IosDependencyContainer.Instance.SchedulerProvider.MainScheduler)
            .Subscribe(TableView.Rx().ReloadItems(source))
            .DisposedBy(DisposeBag);

            source.Rx().ModelSelected()
            .Subscribe(workflowSelected)
            .DisposedBy(DisposeBag);

            TableView.Source = source;
        }