Example #1
0
		private void RenderView()
		{

			var padding = 10.0f;

			var y = padding;

			foreach (var item in ViewModel.Stories)
			{
				var itemCtrl = new TitleAndSummaryItem();
				itemCtrl.View.Frame = new RectangleF(padding, y, container.Frame.Width - (2*padding), 50.0f);

				itemCtrl.Clicked += (sender, e) => UIApplication.SharedApplication.OpenUrl(new NSUrl(item.Uri.OriginalString));

				itemCtrl.TitleLabelText = item.NewsTitle;

				itemCtrl.SummaryLabelText = item.Published.ToString("dddd d. MMMM", new CultureInfo("nb-no")).ToUpperInvariant();

				if(!String.IsNullOrEmpty(item.Ingress)) itemCtrl.SummaryLabelText += Environment.NewLine + Environment.NewLine + item.Ingress.Replace(" ", " ");

				container.Add(itemCtrl.View);

				y += itemCtrl.Frame.Height + padding;
			}

			container.ContentSize = new SizeF(320, y);
			container.ScrollEnabled = true;
		}
Example #2
0
		protected override void ViewModelReady()
		{
			base.ViewModelReady();

			var padding = 10.0f;

			DescriptionLabel.Text = ViewModel.Description;

			var labelSize = DescriptionLabel.SizeThatFits(new SizeF(View.Frame.Width-2*padding, 0f));

			DescriptionLabel.Frame = new RectangleF(new PointF(padding,padding), labelSize);
			DescriptionContainer.BackgroundColor = Application.ThemeColors.Hero;
			DescriptionContainer.Frame = new RectangleF(0, 0, View.Frame.Width, labelSize.Height + padding+padding);

			var y = padding;


			foreach (var s in ItemsContainer.Subviews)
				s.RemoveFromSuperview();

			foreach (var item in ViewModel.Posts)
			{
				var itemCtrl = new TitleAndSummaryItem();
				itemCtrl.Frame = new RectangleF(padding, y, View.Frame.Width - 2 * padding, 10);

				itemCtrl.Clicked += (sender, e) =>
				{
					UIApplication.SharedApplication.OpenUrl(new NSUrl(item.Url));

				};

				itemCtrl.TitleLabelText = item.Title;

				itemCtrl.SummaryLabelText = item.Published.ToString("dddd d. MMMM", new CultureInfo("nb-no")).ToUpperInvariant();

				item.Content = Regex.Replace(item.Content.Replace(@"…", "...").Replace(@" ", " "), 
										@"&#\d*?;", String.Empty);

				if(!String.IsNullOrEmpty(item.Content)) itemCtrl.SummaryLabelText += Environment.NewLine + Environment.NewLine 
					                                                                 + item.Content;


				ItemsContainer.Add(itemCtrl.View);

				y += itemCtrl.Frame.Height + padding;
			}

			ItemsContainer.Frame = new RectangleF(0, DescriptionLabel.Frame.Bottom + padding, View.Frame.Width, y);
			ScrollContainer.ContentSize = new SizeF(ScrollContainer.Bounds.Width, y);
		}