public HomeItemCell(Item.Item unItem, User u, bool readOnly, List <User> someUsers) { user = u; users = someUsers; this.item = unItem; this.Orientation = StackOrientation.Horizontal; this.HorizontalOptions = LayoutOptions.FillAndExpand; this.VerticalOptions = LayoutOptions.Start; titleLabel = new Label(); titleLabel.Text = item.title; titleLabel.FontSize = 20; stateLabel = new Label(); stateLabel.BindingContext = item; stateLabel.SetBinding(Label.TextProperty, "state"); stateLabel.FontSize = 12; stateLabel.Text += " to " + item.GetExpDate(); head = new StackLayout(); head.Orientation = StackOrientation.Vertical; head.HorizontalOptions = LayoutOptions.FillAndExpand; head.VerticalOptions = LayoutOptions.Start; prev = new Image() { Source = ImageSource.FromUri(new Uri("https://upload.wikimedia.org/wikipedia/commons/8/8e/1leftarrow.png")), WidthRequest = 40, HeightRequest = 40, Aspect = Aspect.AspectFit, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.End }; next = new Image() { Source = ImageSource.FromUri(new Uri("https://upload.wikimedia.org/wikipedia/commons/3/3c/1rightarrow.png")), WidthRequest = 40, HeightRequest = 40, Aspect = Aspect.AspectFit, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.End }; head.Children.Add(titleLabel); head.Children.Add(stateLabel); this.Children.Add(head); if (item.GetExpDateTime() < DateTime.Today) { Image warning = new Image() { Source = ImageSource.FromUri(new Uri("http://www.freeiconspng.com/uploads/warning-icon-png-26.png")), WidthRequest = 40, HeightRequest = 40, Aspect = Aspect.AspectFit, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.End }; this.Children.Add(warning); } if (!readOnly) { this.Children.Add(prev); this.Children.Add(next); TapGestureRecognizer nextTapGestureRecognizer = new TapGestureRecognizer(); nextTapGestureRecognizer.Tapped += NextTapGestureRecognizer_Tapped;; next.GestureRecognizers.Add(nextTapGestureRecognizer); TapGestureRecognizer prevTapGestureRecognizer = new TapGestureRecognizer(); prevTapGestureRecognizer.Tapped += PrevTapGestureRecognizer_Tapped;; prev.GestureRecognizers.Add(prevTapGestureRecognizer); TapGestureRecognizer headTapGestureRecognizer = new TapGestureRecognizer(); headTapGestureRecognizer.Tapped += HeadTapGestureRecognizer_Tapped;; head.GestureRecognizers.Add(headTapGestureRecognizer); } }
public UpdateTask(Item.Item task, User u, List <User> someUsers) { user = u; users = someUsers; updatingItem = task; var stack = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { new Label { HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, Text = "Updating: " + task.title, FontSize = 20 } } }; Label nameLabel = new Label() { HorizontalTextAlignment = TextAlignment.Start, VerticalTextAlignment = TextAlignment.Center, Text = "Name: ", FontSize = 20 }; Label descLabel = new Label() { HorizontalTextAlignment = TextAlignment.Start, VerticalTextAlignment = TextAlignment.Center, Text = "Description: ", FontSize = 20 }; Label expLabel = new Label() { HorizontalTextAlignment = TextAlignment.Start, VerticalTextAlignment = TextAlignment.Center, Text = "Expiration date: ", FontSize = 20 }; expDatePicker = new DatePicker(); expDatePicker.Date = updatingItem.GetExpDateTime(); nameEntry.Placeholder = task.title; descEntry.Placeholder = task.desc; armarLog(); if (updatingItem.desc == "") { descEntry.Placeholder = "No description"; } armarLog(); delete.Text = "Delete Task"; delete.Clicked += Delete_Clicked; stack.Children.Add(nameLabel); stack.Children.Add(nameEntry); stack.Children.Add(descLabel); stack.Children.Add(descEntry); stack.Children.Add(expLabel); stack.Children.Add(expDatePicker); stack.Children.Add(delete); stack.Children.Add(logItem); Content = stack; this.Disappearing += UpdateTask_Disappearing; }
private void load() { VerticalOptions = LayoutOptions.FillAndExpand; HorizontalOptions = LayoutOptions.FillAndExpand; BackgroundColor = Color.White; stack = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, WidthRequest = this.WidthRequest - 30, Padding = new Thickness(15, 0, 15, 0), Spacing = 15 }; nameEntry.Placeholder = task.title; nameEntry.FontSize = 21; nameEntry.TranslationY = 20; nameEntry.Focused += NameEntry_Focused; nameEntry.Unfocused += NameEntry_Unfocused; descEntry.Text = task.desc; descEntry.FontSize = 21; descEntry.TranslationY = 20; descEntry.Focused += DescEntry_Focused; descEntry.Unfocused += DescEntry_Unfocused; expDatePicker = new ColorDatePicker() { TranslationX = -5, HorizontalOptions = LayoutOptions.StartAndExpand, Date = task.GetExpDateTime().Date }; expTimePicker = new ColorTimePicker() { TranslationX = -5, HorizontalOptions = LayoutOptions.StartAndExpand, Time = task.GetExpDateTime().TimeOfDay }; //expTimePicker.Time.Hours = task.GetExpDateTime().Hour; labelState = new Label() { HorizontalOptions = LayoutOptions.StartAndExpand, TranslationY = -5, Text = task.state }; StackLayout otroStack = new StackLayout() { Orientation = StackOrientation.Horizontal, TranslationY = 10 }; error = new Label() { Text = "No se puede crear una tarea sin nombre", HorizontalOptions = LayoutOptions.Center, TextColor = Color.Red, IsVisible = false }; //nameEntry.TextChanged += NameEntry_TextChanged; sep = new StackLayout() { BackgroundColor = Color.Gray, HeightRequest = 1 }; se = new StackLayout() { HeightRequest = 1, BackgroundColor = Color.Gray }; Children.Add(stack); stack.Children.Add(nameEntry); stack.Children.Add(se); stack.Children.Add(descEntry); stack.Children.Add(sep); StackLayout sDate = new StackLayout() { HorizontalOptions = LayoutOptions.StartAndExpand }; StackLayout sTime = new StackLayout() { HorizontalOptions = LayoutOptions.EndAndExpand }; StackLayout SDate = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand }; StackLayout STime = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand }; StackLayout SSDate = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, TranslationY = 12, Orientation = StackOrientation.Horizontal }; StackLayout SSTime = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, TranslationY = 12, Orientation = StackOrientation.Horizontal }; StackLayout SSState = new StackLayout() { TranslationY = 40, Orientation = StackOrientation.Horizontal }; sDate.Children.Add(SDate); SDate.Children.Add(SSDate); sTime.Children.Add(STime); STime.Children.Add(SSTime); TapGestureRecognizer t1 = new TapGestureRecognizer(); t1.Tapped += T1_Tapped;; SDate.GestureRecognizers.Add(t1); TapGestureRecognizer t2 = new TapGestureRecognizer(); t2.Tapped += T2_Tapped;; STime.GestureRecognizers.Add(t2); TapGestureRecognizer t3 = new TapGestureRecognizer(); t3.Tapped += T3_Tapped; SSState.GestureRecognizers.Add(t3); SSDate.Children.Add(expDatePicker); SSDate.Children.Add(new Label() { Text = " " }); SSTime.Children.Add(expTimePicker); SSTime.Children.Add(new Label() { Text = " " }); SSState.Children.Add(labelState); SSDate.Children.Add(new Image() { Source = "detailIcon.png", Scale = 1.5, HorizontalOptions = LayoutOptions.EndAndExpand }); SSTime.Children.Add(new Image() { Source = "detailIcon.png", Scale = 1.5, HorizontalOptions = LayoutOptions.EndAndExpand }); SSState.Children.Add(new Image() { Source = "detailIcon.png", Scale = 1.5, TranslationY = -5, HorizontalOptions = LayoutOptions.EndAndExpand }); s1 = new StackLayout() { BackgroundColor = Color.Gray, HeightRequest = 1 }; s2 = new StackLayout() { HeightRequest = 1, BackgroundColor = Color.Gray }; StackLayout s3 = new StackLayout() { TranslationY = 25, HeightRequest = 1, BackgroundColor = Color.Gray }; sDate.Children.Add(s1); sTime.Children.Add(s2); otroStack.Children.Add(sDate); otroStack.Children.Add(sTime); stack.Children.Add(otroStack); stack.Children.Add(SSState); stack.Children.Add(s3); stack.Children.Add(error); }