예제 #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.WhenAnyValue(x => x.ViewModel.Patch).Subscribe(x =>
            {
                if (x == null)
                {
                    LoadContent(string.Empty);
                }
                else
                {
                    var razorView = new CommitDiffRazorView
                    {
                        Model = new CommitDiffModel(x.Split('\n'), (int)UIFont.PreferredBody.PointSize)
                    };

                    LoadContent(razorView.GenerateString(), NSBundle.MainBundle.BundlePath);
                }
            });
//
//
//			ViewModel.Bind(x => x.FilePath, x =>
//			{
//				var data = System.IO.File.ReadAllText(x, System.Text.Encoding.UTF8);
//				var patch = JavaScriptStringEncode(data);
//				ExecuteJavascript("var a = \"" + patch + "\"; patch(a);");
//			});
//
//			ViewModel.BindCollection(x => x.Comments, e =>
//			{
//				//Convert it to something light weight
//				var slimComments = ViewModel.Comments.Items.Where(x => string.Equals(x.Path, ViewModel.Filename)).Select(x => new {
//					Id = x.Id, User = x.User.Login, Avatar = x.User.AvatarUrl, LineTo = x.Position, LineFrom = x.Position,
//					Content = x.Body, Date = x.UpdatedAt
//				}).ToList();
//
//				var c = _serializationService.Serialize(slimComments);
//				ExecuteJavascript("var a = " + c + "; setComments(a);");
//			});
        }
예제 #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.WhenActivated(d => {
                d(this.WhenAnyValue(x => x.ViewModel.Patch, y => y.ViewModel.Comments, (x, y) => Tuple.Create(x, y)).Subscribe(x => {
                    if (x.Item1 == null)
                    {
                        LoadContent(string.Empty);
                    }
                    else
                    {
                        var comments = (x.Item2 ?? Enumerable.Empty <FileDiffCommentViewModel>())
                                       .Select(y => new CommitCommentModel(y.Name, y.AvatarUrl, y.Body, y.Line));
                        var model     = new CommitDiffModel(x.Item1.Split('\n'), comments, (int)UIFont.PreferredBody.PointSize);
                        var razorView = new CommitDiffRazorView {
                            Model = model
                        };
                        LoadContent(razorView.GenerateString(), NSBundle.MainBundle.BundlePath);
                    }
                }));
            });
        }