/// <summary> /// Initializes a new instance of the <see cref="App"/> class. /// </summary> public App() { InitializeComponent(); var viewLocator = DependencyContainer.Instance.GetInstance <IViewLocator>(); IBindablePage firstScreenView; if (PlatformService.IsFoldingScreen) { firstScreenView = viewLocator.GetViewFor <TwoPanePageViewModel>(); } else { #if INFINITE_LIST MaterialFrame.ChangeGlobalTheme(MaterialFrame.Theme.Dark); firstScreenView = viewLocator.GetViewFor <SillyBottomTabsPageViewModel>(); #else firstScreenView = viewLocator.GetViewFor <SillyPeopleVm>(); #endif } MainPage = new NavigationPage((Page)firstScreenView); NavigationPage.SetHasNavigationBar(MainPage, false); var firstScreenVm = (ANavigableViewModel)firstScreenView.BindingContext; firstScreenVm.Load(null); }
protected override void OnElementChanged(ElementChangedEventArgs <Frame> e) { base.OnElementChanged(e); MaterialFrame frame = (MaterialFrame)Element; if (frame != null) { // Update shadow to match better material design standards of elevation Layer.ShadowRadius = 2.0f; Layer.ShadowColor = UIColor.Gray.CGColor; Layer.ShadowOffset = new CGSize(2, 2); Layer.ShadowOpacity = 0.80f; if (!App.AppSettings.DarkTheme) { Layer.ShadowColor = UIColor.Gray.CGColor; } else { Layer.ShadowColor = UIColor.Gray.CGColor; Layer.ShadowPath = UIBezierPath.FromRect(Layer.Bounds).CGPath; } Layer.MasksToBounds = false; } }
/// <summary> /// Initializes a new matboard with a size of 0 and a blank, white material. /// </summary> public MatBoard() { matFrame = new MaterialFrame(); minBoard = QuadBoard.Default; color = Color.White; updateMatFit = true; }
public WorkflowInstanceViewCell() { contractTitle = new Label { Text = " ", FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.CenterAndExpand }; dynamicContent = new Label { Text = " ", HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; if (Device.RuntimePlatform == Device.Android) { contractTitle.FontSize = 16; dynamicContent.FontSize = 14; } var grid = new Grid { BackgroundColor = Color.Transparent, ColumnSpacing = 10, VerticalOptions = LayoutOptions.Fill, RowDefinitions = { new RowDefinition { Height = 20 }, new RowDefinition { Height = GridLength.Auto }, } }; grid.Children.Add(contractTitle, 0, 0); grid.Children.Add(dynamicContent, 0, 1); var frame = new MaterialFrame { Content = grid, Padding = 10, BackgroundColor = Color.White }; View = new ContentView { Content = frame, Padding = 10, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("E3E3E3") }; }
private async Task Animate() { await MaterialFrame.ScaleTo(0.5); await MaterialFrame.ScaleTo(1); _currentRotation = (_currentRotation + 90) % 360; await MaterialFrame.RotateTo(_currentRotation); }
private void PanGestureRecognizer_PanUpdated(object sender, PanUpdatedEventArgs e) { if (animationStarted) { return; } if (LogoImage.TranslationY > -50 && LogoImage.TranslationY <= 0) { LogoImage.TranslationY += e.TotalY; if (LogoImage.TranslationY > 0) { LogoImage.TranslationY = 0; } return; } animationStarted = true; Animating?.Invoke(); MaterialFrame.FadeTo(0.99, 160u * (uint)InputSL.Children.Count, Easing.CubicInOut); // Opacity 1.0 causes text above to become blurred? LogoImage.TranslateTo(0, Height * -0.35d, 400, Easing.CubicOut); TitleSL.FadeTo(1, 600, Easing.CubicInOut); TitleSL.TranslateTo(0, 0, 600, Easing.CubicInOut); ChevronSL.FadeTo(0, 100, Easing.CubicOut); EmailEntry.IsEnabled = PasswordEntry.IsEnabled = PasswordConfirmationEntry.IsEnabled = true; int t = 0; foreach (VisualElement v in InputSL.Children) { t += 160; v.TranslationX = -v.Width; Device.StartTimer(TimeSpan.FromMilliseconds(t), () => { if (!_signUp) { if (v == Button) { v.TranslateTo(0, -(PasswordConfirmationSL.Height + 4), 400, Easing.SinOut); v.FadeTo(1, 400, Easing.SinOut); return(false); } else if (v == PasswordConfirmationSL) { v.TranslateTo(0, 0, 400, Easing.SinOut); return(false); } } v.TranslateTo(0, 0, 400, Easing.SinOut); v.FadeTo(1, 400, Easing.SinOut); return(false); }); } ThemeEngine.RefreshTheme(); // Set nav colours to what they should be on android }
public PolyBoard() { triangles = new List <int>(); vertices = new List <Vector2>(); drawVertices = new List <Vector2>(); matFrame = new MaterialFrame(); polyMat = PolyMaterial.Default; polyMat.texCoords = new List <Vector2>(); _sides = 16; updateVertices = true; }
public Glyph(Material atlas, Vector2 size, Vector2 origin, float aw, float lsb) { advanceWidth = aw; leftSideBearing = lsb; matFrame = new MaterialFrame() { Material = new Material(atlas.TextureID, atlas.size, origin, size), Alignment = MaterialAlignment.FitHorizontal, }; Vector2 bbSize = matFrame.Material.size; texCoords = matFrame.GetMaterialAlignment(bbSize.X / bbSize.Y); MatFrame = matFrame; }
public static void SetLightMode() { MaterialFrame.ChangeGlobalTheme(MaterialFrame.Theme.Light); SetDynamicResource(DynamicNavigationBarColor, "Accent"); SetDynamicResource(DynamicBarTextColor, "TextPrimaryDarkColor"); SetDynamicResource(DynamicTopShadow, ShadowType.Top); SetDynamicResource(DynamicBottomShadow, ShadowType.Bottom); SetDynamicResource(DynamicHasShadow, true); SetDynamicResource(DynamicPrimaryTextColor, "TextPrimaryLightColor"); SetDynamicResource(DynamicSecondaryTextColor, "TextSecondaryLightColor"); SetDynamicResource(DynamicBackgroundColor, "LightSurface"); SetDynamicResource(Elevation4dpColor, "OnSurfaceColor"); }
public static void SetDarkMode() { MaterialFrame.ChangeGlobalTheme(MaterialFrame.Theme.Dark); SetDynamicResource(DynamicNavigationBarColor, "DarkElevation2dp"); SetDynamicResource(DynamicBarTextColor, "TextPrimaryDarkColor"); SetDynamicResource(DynamicTopShadow, ShadowType.None); SetDynamicResource(DynamicBottomShadow, ShadowType.None); SetDynamicResource(DynamicHasShadow, false); SetDynamicResource(DynamicPrimaryTextColor, "TextPrimaryDarkColor"); SetDynamicResource(DynamicSecondaryTextColor, "TextSecondaryDarkColor"); SetDynamicResource(DynamicBackgroundColor, "DarkSurface"); SetDynamicResource(Elevation4dpColor, "DarkElevation4dp"); }
private void ToastButton_Click(object sender, RoutedEventArgs e) { //MaterialToast newToast = new MaterialToast(); //ToastListView.Items.Add(newToast); //MaterialToast newToast = new MaterialToast(ToastItemsControl); //AllToasts.Add(newToast); MaterialFrame newToast = new MaterialFrame(); AllToasts.Add(newToast); ////newToast.DisplayTime = new TimeSpan(0, 0, 1); //newToast.HideCompleted += NewToast_HideCompleted; //newToast.IsCloseButtonVisible = true; //newToast.HideOnClick = true; newToast.ToolTip = DateTime.Now.ToString(); //newToast.Content = Resources["ToastContent"]; // [System.Windows.ControlTemplate] //newToast.Template = (ControlTemplate)Resources["ToastContent"]; // Replaced style, lost close button //newToast.Content = "This is my content."; // Embeds string inside xceed toast //newToast.Content = new Rectangle() { Width = 20, Height = 20, Fill = Brushes.Aqua }; // Embeds aqua rect inside xceed toast ////////// WORKS VIA XAML //////////////////// newToast.ContentTemplate = (DataTemplate)Resources["ToastContent"]; ////////////////////////////////////////////////////////// ////////// WORKS VIA FULL CODE BEHIND //////////////////// //StackPanel toastStack = new StackPanel(); //toastStack.Orientation = Orientation.Vertical; //toastStack.Children.Add(new TextBlock() { Text = "This is my Title" }); //toastStack.Children.Add(new TextBlock() { Text = "This is my Content" }); //toastStack.Children.Add(new TextBlock() { Text = DateTime.Now.TimeOfDay.ToString(@"mm\:ss\.ff") }); //newToast.Content = toastStack; ////////////////////////////////////////////////////////// if (NotificationLayoutAnchor.IsHidden) { NotificationLayoutAnchor.Show(); } if (ToastItemsControl.IsVisible) { //newToast.ShowToast(); } }
public static void SetLightMode(bool isAcrylic) { MaterialFrame.ChangeGlobalTheme(isAcrylic ? MaterialFrame.Theme.Acrylic : MaterialFrame.Theme.Light); SetDynamicResource(DynamicNavigationBarColor, "Accent"); SetDynamicResource(DynamicBarTextColor, "TextPrimaryDarkColor"); SetDynamicResource(DynamicTopShadow, isAcrylic ? ShadowType.AcrylicTop : ShadowType.Top); SetDynamicResource(DynamicBottomShadow, ShadowType.Bottom); SetDynamicResource(DynamicHasShadow, true); SetDynamicResource(DynamicPrimaryTextColor, "TextPrimaryLightColor"); SetDynamicResource(DynamicSecondaryTextColor, "TextSecondaryLightColor"); SetDynamicResource(DynamicBackgroundColor, isAcrylic ? "AcrylicSurface" : "LightSurface"); SetDynamicResource(Elevation4dpColor, isAcrylic ? "AcrylicFrameBackgroundColor" : "OnSurfaceColor"); SetDynamicResource(DynamicLightThemeColor, isAcrylic ? "AcrylicFrameBackgroundColor" : "OnSurfaceColor"); SetDynamicResource(DynamicCornerRadius, isAcrylic ? 10 : 5); }
private void PanGestureRecognizer_PanUpdated(object sender, PanUpdatedEventArgs e) { if (animationStarted) { return; } if (LogoImage.TranslationY > -50 && LogoImage.TranslationY <= 0) { LogoImage.TranslationY += e.TotalY; if (LogoImage.TranslationY > 0) { LogoImage.TranslationY = 0; } return; } animationStarted = true; Animating?.Invoke(); MaterialFrame.FadeTo(0.99, 160u * (uint)ButtonSL.Children.Count, Easing.CubicInOut); // Opacity 1.0 causes text above to become blurred? LogoImage.TranslateTo(0, Height * -0.35d, 400, Easing.CubicOut); TitleSL.FadeTo(1, 600, Easing.CubicInOut); TitleSL.TranslateTo(0, 0, 600, Easing.CubicInOut); ChevronSL.FadeTo(0, 100, Easing.CubicOut); int t = 0; foreach (Frame f in ButtonSL.Children) { t += 160; f.TranslationX = -f.Width; Device.StartTimer(TimeSpan.FromMilliseconds(t), () => { f.TranslateTo(0, 0, 400, Easing.SinOut); f.FadeTo(1, 400, Easing.SinOut); return(false); }); } ThemeEngine.RefreshTheme(); // Set nav colours to what they should be on android }
public async void buildTranscripts() { Courses.Children.Clear(); Courses c = new Courses(); List <Models.Record> courses = await c.CheckForCourses(); if (courses.Count() > 0) { foreach (Models.Record course in courses) { Frame card; Models.Record courseRecord = await App.Database.GetCourseByID(course.CourseID); card = new MaterialFrame { ClassId = "course_" + course.CourseID }; Label title = new Label { Text = course.CourseName, Style = (Style)Application.Current.Resources["headerStyle"] }; string htmlText = @"<html> <head> <meta name='viewport' content='width=device-width; height=device-height; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;'/> <style type='text/css'> body{font-family:Segoe UI, Helvetica Neue,'Lucida Sans Unicode', Skia, sans-serif; border:0px;padding:0px;margin:0px; background-color:transparent; overflow:hidden; } </style> </head> <body>" + HttpUtility.HtmlDecode(course.CourseDescription) + "</body></html>"; var description = new CustomWebview { HeightRequest = 300, Source = new HtmlWebViewSource { Html = htmlText }, Style = (Style)Application.Current.Resources["descriptionWebView"] }; Grid chartGrid = new Grid() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Padding = 0, Margin = 0 }; chartGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(100) }); chartGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); chartGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); string completion = (course.CompletionStatus == "") ? (course.CompletionStatus == "unknown") ? "In Progress" : "Not Attempted" : course.CompletionStatus; string success = (course.SuccessStatus == "" || course.SuccessStatus == "unknown") ? "" : "/" + course.SuccessStatus; string score; float score_a = 0; float score_b = 0; float perc_complete; float perc_incomplete; if (String.IsNullOrEmpty(course.ProgressMeasure)) { perc_complete = (course.CompletionStatus == "") ? 0 : (course.CompletionStatus == "Completed") ? 100 : 50; perc_incomplete = 100 - perc_complete; } else { perc_complete = (float.Parse(courseRecord.ProgressMeasure) < 0) ? float.Parse(courseRecord.ProgressMeasure) * 100 : float.Parse(courseRecord.ProgressMeasure); perc_incomplete = 100 - perc_complete; } bool hasScore = false; if (!String.IsNullOrEmpty(course.ScoreRaw) && String.IsNullOrEmpty(course.Score)) { int raw = Convert.ToInt32(course.ScoreRaw); int max = Convert.ToInt32(course.ScoreMax); int min = Convert.ToInt32(course.ScoreMin); int scaled = ((raw - min) / (max - min)) * 100; score = scaled.ToString(); score_a = scaled; score_b = (scaled < 100) ? 100 - score_a : 0; hasScore = true; } else { if (!String.IsNullOrEmpty(course.Score)) { score = (course.Score == "") ? "" : " " + Math.Round(double.Parse(course.Score)).ToString() + "%"; score_a = (double.Parse(course.Score) < 1) ? (float)Math.Round(double.Parse(course.Score) * 100, 0, MidpointRounding.AwayFromZero) : (float)double.Parse(course.Score); score_b = ((Math.Round(score_a)) < 100) ? 100 - score_a : 0; hasScore = true; } } Doughnut doughnut = new Doughnut(); Grid doughnutContainer = (hasScore == false) ? null : doughnut.CompletionChart("Score", (float)Math.Round(score_a, 0, MidpointRounding.AwayFromZero), score_b); Label status = new Label { Text = completion + success, Style = (Style)Application.Current.Resources["headerStyle"] }; Doughnut completeDoughnut = new Doughnut(); Grid completeDoughnutContainer = completeDoughnut.CompletionChart("Complete", (float)Math.Round(perc_complete, 0, MidpointRounding.AwayFromZero), perc_incomplete); if (doughnutContainer != null) { doughnutContainer.VerticalOptions = LayoutOptions.CenterAndExpand; doughnutContainer.HorizontalOptions = LayoutOptions.CenterAndExpand; chartGrid.Children.Add(doughnutContainer, 0, 0); } StackLayout layout = new StackLayout(); card.Content = layout; layout.Children.Add(title); completeDoughnutContainer.VerticalOptions = LayoutOptions.CenterAndExpand; completeDoughnutContainer.HorizontalOptions = LayoutOptions.CenterAndExpand; chartGrid.Children.Add(completeDoughnutContainer, 1, 0); layout.Children.Add(chartGrid); Courses.Children.Add(card); } } else { Label message = new Label { Text = "You have not started any courses on this device.", Style = (Style)Application.Current.Resources["headerStyle"] }; Courses.Children.Add(message); } }
public PaysCell() { MaterialFrame frame = new MaterialFrame(); frame.SetAppThemeColor(Frame.BorderColorProperty, (Color)Application.Current.Resources["MainColor"], Color.White); frame.HorizontalOptions = LayoutOptions.FillAndExpand; frame.SetOnAppTheme(Frame.HasShadowProperty, false, true); frame.SetOnAppTheme(MaterialFrame.ElevationProperty, 0, 20); frame.VerticalOptions = LayoutOptions.Start; frame.BackgroundColor = Color.White; frame.Margin = new Thickness(10, 0, 10, 10); frame.Padding = new Thickness(15, 15, 15, 15); frame.CornerRadius = 30; StackLayout container = new StackLayout(); container.Orientation = StackOrientation.Vertical; StackLayout dateIdent = new StackLayout(); dateIdent.Orientation = StackOrientation.Horizontal; StackLayout identAdress = new StackLayout(); identAdress.HorizontalOptions = LayoutOptions.StartAndExpand; identAdress.Spacing = 0; ident.FontSize = 15; ident.TextColor = Color.Black; adress.FontSize = 12; adress.TextColor = Color.Gray; adress.FontFamily = "Roboto"; identAdress.Children.Add(ident); identAdress.Children.Add(adress); IconView x = new IconView(); x.Source = "ic_close"; x.Foreground = (Color)Application.Current.Resources["MainColor"]; x.HeightRequest = 10; x.WidthRequest = 10; Label close = new Label(); close.Text = AppResources.Delete; close.TextColor = (Color)Application.Current.Resources["MainColor"]; close.FontSize = 15; close.TextDecorations = TextDecorations.Underline; dell.Orientation = StackOrientation.Horizontal; dell.HorizontalOptions = LayoutOptions.EndAndExpand; dell.VerticalOptions = LayoutOptions.Center; dell.MinimumWidthRequest = 80; dell.Children.Add(x); dell.Children.Add(close); dateIdent.Children.Add(identAdress); dateIdent.Children.Add(dell); Label separator = new Label(); separator.HeightRequest = 1; separator.BackgroundColor = Color.Gray; separator.Margin = new Thickness(0, 5, 0, 5); container.Children.Add(dateIdent); container.Children.Add(separator); StackLayout sums = new StackLayout(); sums.Orientation = StackOrientation.Horizontal; sums.Margin = new Thickness(30, 0, 30, 5); sumPayDate.Text = string.Format("Сумма к оплате{0} на 31.05.2020", Environment.NewLine); sumPayDate.FontSize = 15; sumPayDate.TextColor = Color.Gray; sumPayDate.HorizontalTextAlignment = TextAlignment.End; sumPayDate.Margin = new Thickness(0, 0, 15, 0); sumPay.Text = "4593.01 руб"; sumPay.TextColor = (Color)Application.Current.Resources["MainColor"]; sumPay.FontSize = 25; sumPay.VerticalOptions = LayoutOptions.Center; sums.Children.Add(sumPayDate); sums.Children.Add(sumPay); container.Children.Add(sums); Frame frameBtn = new Frame(); frameBtn.HorizontalOptions = LayoutOptions.FillAndExpand; frameBtn.VerticalOptions = LayoutOptions.Start; frameBtn.Padding = 0; frameBtn.BackgroundColor = (Color)Application.Current.Resources["MainColor"]; frameBtn.CornerRadius = 10; StackLayout containerBtn = new StackLayout(); containerBtn.Orientation = StackOrientation.Horizontal; containerBtn.Spacing = 0; containerBtn.HorizontalOptions = LayoutOptions.CenterAndExpand; IconView image = new IconView(); image.Source = "ic_pays"; image.Foreground = Color.White; // image.Margin = new Thickness(-45, 0, 0, 0); image.HeightRequest = 30; image.WidthRequest = 30; Label btn = new Label(); // btn.Margin = new Thickness(-30, 0, 0, 0); btn.TextColor = Color.White; btn.BackgroundColor = Color.Transparent; btn.HorizontalOptions = LayoutOptions.Center; btn.Margin = new Thickness(13,13,0,13); btn.FontAttributes = FontAttributes.Bold; btn.FontSize = 16; btn.Text = AppResources.Pay; containerBtn.Children.Add(image); containerBtn.Children.Add(btn); frameBtn.Content = containerBtn; container.Children.Add(frameBtn); Label payPeriod = new Label(); FormattedString formatted = new FormattedString(); formatted.Spans.Add(new Span { Text = AppResources.PayProcessing, FontSize = 12 }); formatted.Spans.Add(new Span { Text = " 2-3 ", FontSize = 12, FontAttributes = FontAttributes.Bold }); formatted.Spans.Add(new Span { Text = AppResources.WorkDays, FontSize = 12 }); payPeriod.FormattedText = formatted; payPeriod.TextColor = (Color)Application.Current.Resources["MainColor"]; payPeriod.FontSize = 12; payPeriod.HorizontalOptions = LayoutOptions.CenterAndExpand; container.Children.Add(payPeriod); frame.Content = container; View = frame; }
public async Task <bool> buildCourseCard(string courseid, string coursetitle, string coursedescription, StackLayout container, EventHandler downloadClicked, EventHandler launchCourse, string duedate) { MaterialFrame frame; StackLayout layout; // let's try to sync all the courses var current = Connectivity.NetworkAccess; if (current == NetworkAccess.Internet) { API api = new API(); Device.BeginInvokeOnMainThread(async() => await api.SyncCourse(courseid)); } // DownloadButton launchBtn; ActivityIndicator spinner; // Image marquee; StackLayout marqueeContainer; // See if there is a course record so we can display the proper navigation (download, launch etc...) Models.Record courseRecord = await App.Database.GetCourseByID(courseid); CachedImage marquee = BuildMarquee(courseid, true); // wrap the course Marquee in a stack layout so we have more control with the layout marqueeContainer = new StackLayout { }; Image marqueePlaceholder = new Image { Source = ImageSource.FromResource("TCMobile.Images.placeholder.png") }; marqueeContainer.Children.Add(marquee); // marqueeContainer.Children.Add(marqueePlaceholder); marqueePlaceholder.SetBinding(Image.IsVisibleProperty, "IsLoading"); marqueePlaceholder.BindingContext = marquee; frame = new MaterialFrame { HasShadow = true, Padding = new Thickness(0, 0, 0, 0), Margin = new Thickness(0, 8, 0, 24), CornerRadius = 0 }; layout = new StackLayout { ClassId = "course_" + courseid }; StackLayout cardBody = new StackLayout { Padding = new Thickness(16, 0, 16, 0), ClassId = "course_" + courseid, VerticalOptions = LayoutOptions.FillAndExpand }; Label title = new Label { Text = coursetitle, Style = (Style)Application.Current.Resources["headerStyle"] }; Grid titleGrid = new Grid() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Padding = 0, Margin = 15 }; if (courseRecord != null && courseRecord.Downloaded != false) { titleGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(40) }); titleGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); titleGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(80) }); } else { titleGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(40) }); titleGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); } string duedateText = ""; //ChartView chartView = null; if (!String.IsNullOrEmpty(duedate)) { DateTime dt = Convert.ToDateTime(duedate); duedateText = "Due: " + String.Format("{0:ddd, MMM d, yyyy}", dt); } float perc_complete = 0; float perc_incomplete = 0; if (courseRecord != null && courseRecord.Downloaded == true) { if (courseRecord.ProgressMeasure != null && courseRecord.ProgressMeasure != "") { perc_complete = (float)Math.Round(float.Parse(courseRecord.ProgressMeasure), 0, MidpointRounding.AwayFromZero); perc_incomplete = 100 - perc_complete; } else { perc_complete = (courseRecord != null && courseRecord.CompletionStatus.ToLower() == "completed") ? 100 :(courseRecord != null) ? 50 : 0; perc_incomplete = (courseRecord != null && courseRecord.CompletionStatus.ToLower() != "completed") ? (courseRecord != null) ? 50 : 0 : 100; } } Label dueDate = new Label { Text = duedateText }; string htmlText = @"<html> <head> <meta name='viewport' content='width=device-width; height=device-height; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;'/> <style type='text/css'> body{font-family:Segoe UI, Helvetica Neue,'Lucida Sans Unicode', Skia, sans-serif; border:0px;padding:0px;margin:0px; background-color:transparent; overflow:hidden; } </style> </head> <body>" + HttpUtility.HtmlDecode(coursedescription) + "</body></html>"; var description = new CustomWebview { HeightRequest = 250, VerticalOptions = LayoutOptions.FillAndExpand, Source = new HtmlWebViewSource { Html = htmlText }, Style = (Style)Application.Current.Resources["descriptionWebView"] }; // ViewCell webViewViewCell = new ViewCell(); Grid webViewGrid = new Grid(); webViewGrid.Children.Add(description); spinner = new ActivityIndicator { IsVisible = false, Style = (Style)Application.Current.Resources["spinnerStyle"], HeightRequest = 20 }; Grid btnGrid = new Grid() { HorizontalOptions = LayoutOptions.Center }; btnGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(50) }); btnGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(20) }); btnGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(80) }); Label lbl = new Label() { Text = (courseRecord == null || courseRecord.Downloaded == false) ? "download" : (courseRecord.CompletionStatus.ToLower() == "completed") ? "review" : (courseRecord.CMI == "") ? "open" : "resume", HorizontalOptions = LayoutOptions.Center }; DownloadImageButton downloadBtn = BuildImageDownload(courseid, courseRecord, spinner, lbl); downloadBtn.CourseID = courseid; StackLayout cardFooter = new StackLayout { Padding = new Thickness(16, 0, 16, 8), ClassId = "course_" + courseid }; DownloadImageButton launchBtn = BuildImageLaunch(courseid, courseRecord, spinner, lbl); downloadBtn.LaunchButton = launchBtn; launchBtn.Clicked += launchCourse; downloadBtn.Clicked += downloadClicked; btnGrid.Children.Add(downloadBtn, 0, 0); btnGrid.Children.Add(launchBtn, 0, 0); btnGrid.Children.Add(spinner, 0, 0); btnGrid.Children.Add(lbl, 0, 1); //titleGrid.Children.Add(title, 0, 0); if (courseRecord != null && courseRecord.Downloaded != false) { Doughnut doughnut = new Doughnut(); Grid doughnutContainer = doughnut.CompletionChart("Completed", perc_complete, perc_incomplete); titleGrid.Children.Add(doughnutContainer, 1, 0); } cardBody.Children.Add(titleGrid); cardBody.Children.Add(dueDate); //string x = (courseRecord == null || courseRecord.Deleted == "true") ? "download" : // (courseRecord.CompletionStatus.ToLower() == "completed") ? "review" : // (courseRecord.CMI == "") ? "open" : "resume"; cardBody.Children.Add(webViewGrid); layout.Children.Add(title); layout.Children.Add(marqueeContainer); layout.Children.Add(cardBody); layout.Children.Add(cardFooter); //cardFooter.Children.Add(launchBtn); // cardFooter.Children.Add(downloadBtn); //cardFooter.Children.Add(lbl); cardFooter.Children.Add(btnGrid); //cardFooter.Children.Add(spinner); frame.Content = layout; container.Children.Add(frame); return(true); }
public async void buildLPCard(string id, string lptitle, string lpdescription, FlexLayout LP, EventHandler detailsClicked) { StudentActivityMap map = null; MaterialFrame frame; StackLayout layout; Label status = new Label(); LearningPath lpObj = new LearningPath(); int completionPercent = await lpObj.GetCompletion(id); Models.LPDBRecord lp = await getMap(id); if (lp.LPMap != "") { map = JsonConvert.DeserializeObject <StudentActivityMap>(lp.LPMap); if (map != null) { LP learningPath = new LP(); Models.statusObject completionStatus = learningPath.lpStatus(map.Objective); status.Text = completionStatus.completion; } else { status.Text = "not started"; } } else { status.Text = "not started"; } frame = new MaterialFrame { HasShadow = true, Padding = new Thickness(0, 0, 0, 0), Margin = new Thickness(0, 8, 0, 24), CornerRadius = 0 }; // need to add doughnut Doughnut doughnut = new Doughnut(); int percentIncomplete = 100 - completionPercent; Grid doughnutContainer = doughnut.CompletionChart("Completed", completionPercent, percentIncomplete); Label lbl = new Label() { Text = "more info", HorizontalOptions = LayoutOptions.Center }; DownloadImageButton moreBtn = new DownloadImageButton { //Text = "more", Source = "outline_info_black_48.png", //Style = (Style)Application.Current.Resources["buttonStyle"], ClassId = id, CourseID = id, BackgroundColor = Color.Transparent, BorderColor = Color.Transparent, }; moreBtn.Clicked += detailsClicked; layout = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand }; StackLayout cardBody = new StackLayout { Padding = new Thickness(16, 0, 16, 0), ClassId = "course_" + id, VerticalOptions = LayoutOptions.FillAndExpand }; Label title = new Label { Text = lptitle, Style = (Style)Application.Current.Resources["headerStyle"] }; // html description StackLayout cardFooter = new StackLayout { Padding = new Thickness(16, 0, 16, 8), ClassId = "course_" + id }; string htmlText = @"<html> <head> <meta name='viewport' content='width=device-width; height=device-height; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;'/> <style type='text/css'> body{font-family:Segoe UI, Helvetica Neue,'Lucida Sans Unicode', Skia, sans-serif; border:0px;padding:0px;margin:0px; background-color:transparent; overflow:hidden; } </style> </head> <body>" + HttpUtility.HtmlDecode(lpdescription) + "</body></html>"; CustomWebview description = new CustomWebview { HeightRequest = 300, Source = new HtmlWebViewSource { Html = htmlText }, Style = (Style)Application.Current.Resources["descriptionWebView"] }; Grid btnGrid = new Grid() { HorizontalOptions = LayoutOptions.Center }; btnGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(50) }); btnGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(20) }); btnGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(80) }); btnGrid.Children.Add(moreBtn, 0, 0); btnGrid.Children.Add(lbl, 0, 1); cardFooter.Children.Add(doughnutContainer); cardFooter.Children.Add(btnGrid); cardBody.Children.Add(title); cardBody.Children.Add(status); cardBody.Children.Add(description); layout.Children.Add(cardBody); layout.Children.Add(cardFooter); frame.Content = layout; LP.Children.Add(frame); }
public AppConstCell() { MaterialFrame frame = new MaterialFrame(); frame.SetAppThemeColor(Frame.BorderColorProperty, (Color)Application.Current.Resources["MainColor"], Color.White); frame.Elevation = 20; frame.SetOnAppTheme(Frame.HasShadowProperty, false, true); frame.SetOnAppTheme(MaterialFrame.ElevationProperty, 0, 20); frame.HorizontalOptions = LayoutOptions.FillAndExpand; frame.VerticalOptions = LayoutOptions.Start; frame.BackgroundColor = Color.White; frame.Margin = new Thickness(10, 0, 10, 14); frame.Padding = new Thickness(20, 15, 20, 20); frame.CornerRadius = 40; StackLayout container = new StackLayout(); container.Orientation = StackOrientation.Horizontal; StackLayout containerData = new StackLayout(); containerData.Orientation = StackOrientation.Vertical; containerData.HorizontalOptions = LayoutOptions.FillAndExpand; SvgCachedImage arrow = new SvgCachedImage(); arrow.Source = "resource://xamarinJKH.Resources.ic_arrow_forward.svg"; Color hex = (Color)Application.Current.Resources["MainColor"]; arrow.ReplaceStringMap = new System.Collections.Generic.Dictionary <string, string> { { "#000000", $"#{Settings.MobileSettings.color}" } }; arrow.HeightRequest = 25; arrow.WidthRequest = 25; arrow.Margin = new Thickness(0, 0, -5, 0); arrow.VerticalOptions = LayoutOptions.CenterAndExpand; arrow.HorizontalOptions = LayoutOptions.End; //LabelDate.TextColor = Color.Black; //LabelDate.FontSize = 15; //LabelDate.Margin = new Thickness(0, -5, 0, 0); numberAndDate.TextColor = Color.Black; numberAndDate.FontSize = 12; numberAndDate.VerticalOptions = LayoutOptions.CenterAndExpand; numberAndDate.HorizontalOptions = LayoutOptions.Fill; ImageStatus.ReplaceStringMap = new System.Collections.Generic.Dictionary <string, string> { { "#000000", $"#{Settings.MobileSettings.color}" } }; ImageStatus.Source = "resource://xamarinJKH.Resources.ic_status_new.svg"; ImageStatus.HeightRequest = 15; ImageStatus.VerticalOptions = LayoutOptions.Center; ImageStatus.WidthRequest = 15; ImageStatus.Margin = new Thickness(0, 0, 0, 0); ImageStatus.HorizontalOptions = LayoutOptions.End; LabelStatus.TextColor = Color.Black; LabelStatus.FontSize = 13; LabelStatus.VerticalTextAlignment = TextAlignment.Center; LabelStatus.VerticalOptions = LayoutOptions.Center; //LabelStatus.LineBreakMode = LineBreakMode.WordWrap; LabelStatus.HorizontalOptions = LayoutOptions.End; // status.Children.Add(ImageStatus); // status.Children.Add(LabelStatus); LabelText.TextColor = Color.Black; LabelText.HorizontalOptions = LayoutOptions.Start; LabelText.FontSize = 15; LabelText.HorizontalTextAlignment = TextAlignment.Start; LabelText.VerticalOptions = LayoutOptions.Start; LabelText.MaxLines = 1; LabelAddressApp.TextColor = Color.Black; LabelAddressApp.HorizontalOptions = LayoutOptions.Start; LabelAddressApp.FontSize = 10; LabelAddressApp.HorizontalTextAlignment = TextAlignment.Start; LabelAddressApp.VerticalOptions = LayoutOptions.Start; // LabelAddressApp.MaxLines = 1; Grid grid = new Grid { RowDefinitions = { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, } }; // status.Children.Add(numberAndDate); // status.Children.Add(LabelText); //grid.Children.Add(numberAndDate, 0, 0); StackLayout stackLayoutStatus = new StackLayout(); stackLayoutStatus.Orientation = StackOrientation.Horizontal; stackLayoutStatus.HorizontalOptions = LayoutOptions.Fill; // stackLayoutStatus.Spacing = 0; stackLayoutStatus.Children.Add(numberAndDate); stackLayoutStatus.Children.Add(ImageStatus); stackLayoutStatus.Children.Add(LabelStatus); StackLayout stackLayoutText = new StackLayout(); stackLayoutText.Orientation = StackOrientation.Horizontal; stackLayoutText.HorizontalOptions = LayoutOptions.FillAndExpand; stackLayoutText.Children.Add(LabelText); //containerData.Children.Add(grid); containerData.Children.Add(stackLayoutStatus); containerData.Children.Add(LabelAddressApp); containerData.Children.Add(stackLayoutText); container.Children.Add(containerData); // <CheckBox // HorizontalOptions="Center" // x:Name="CheckBoxBonus" // VerticalOptions="Center" // Color="{x:DynamicResource MainColor}" /> checkBox = new CheckBox() { HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, Margin = new Thickness(0, 0, -5, 0), Color = hex }; #if DEBUG container.Children.Add(checkBox); #endif container.Children.Add(arrow); frame.Content = container; View = frame; }
public AppCell() { MaterialFrame frame = new MaterialFrame(); frame.SetAppThemeColor(Frame.BorderColorProperty, (Color)Application.Current.Resources["MainColor"], Color.White); frame.SetOnAppTheme(Frame.HasShadowProperty, false, true); frame.SetOnAppTheme(MaterialFrame.ElevationProperty, 0, 20); frame.HorizontalOptions = LayoutOptions.FillAndExpand; frame.VerticalOptions = LayoutOptions.Start; frame.BackgroundColor = Color.White; frame.Margin = new Thickness(10, 0, 10, 14); frame.Padding = new Thickness(25, 15, 25, 20); frame.CornerRadius = 40; StackLayout container = new StackLayout(); container.Orientation = StackOrientation.Horizontal; StackLayout containerData = new StackLayout(); containerData.HorizontalOptions = LayoutOptions.FillAndExpand; var arrow = new SvgCachedImage(); arrow.Source = "resource://xamarinJKH.Resources.ic_arrow_forward.svg"; Color hex = (Color)Application.Current.Resources["MainColor"]; arrow.ReplaceStringMap = new System.Collections.Generic.Dictionary <string, string> { { "#000000", $"#{Settings.MobileSettings.color}" } }; arrow.HeightRequest = 25; arrow.WidthRequest = 25; arrow.VerticalOptions = LayoutOptions.CenterAndExpand; arrow.HorizontalOptions = LayoutOptions.End; numberAndDate.TextColor = Color.Black; numberAndDate.FontSize = 12; numberAndDate.VerticalOptions = LayoutOptions.StartAndExpand; numberAndDate.HorizontalOptions = LayoutOptions.StartAndExpand; LabelDate.TextColor = Color.Black; LabelDate.FontSize = 15; LabelDate.Margin = new Thickness(0, -5, 0, 0); StackLayout status = new StackLayout(); status.Orientation = StackOrientation.Horizontal; status.HorizontalOptions = LayoutOptions.FillAndExpand; arrow.ReplaceStringMap = new System.Collections.Generic.Dictionary <string, string> { { "#000000", $"#{Settings.MobileSettings.color}" } }; ImageStatus.Source = "resource://xamarinJKH.Resources.ic_status_new.svg"; ImageStatus.HeightRequest = 15; ImageStatus.VerticalOptions = LayoutOptions.End; ImageStatus.WidthRequest = 15; ImageStatus.Margin = new Thickness(0, 0, 0, 0); LabelStatus.TextColor = Color.Black; LabelStatus.FontSize = 15; LabelStatus.VerticalTextAlignment = TextAlignment.Center; LabelStatus.VerticalOptions = LayoutOptions.Center; // status.Children.Add(ImageStatus); // status.Children.Add(LabelStatus); LabelText.TextColor = Color.Black; LabelText.HorizontalOptions = LayoutOptions.Start; LabelText.FontSize = 15; LabelText.HorizontalTextAlignment = TextAlignment.Start; LabelText.VerticalOptions = LayoutOptions.Start; LabelText.FontAttributes = FontAttributes.Bold; Grid grid = new Grid { RowDefinitions = { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, } }; // status.Children.Add(numberAndDate); // status.Children.Add(LabelText); grid.Children.Add(numberAndDate, 0, 0); StackLayout stackLayoutStatus = new StackLayout(); stackLayoutStatus.Orientation = StackOrientation.Horizontal; // stackLayoutStatus.Spacing = 0; stackLayoutStatus.Children.Add(ImageStatus); stackLayoutStatus.Children.Add(LabelStatus); containerData.Children.Add(grid); containerData.Children.Add(LabelDate); containerData.Children.Add(stackLayoutStatus); Frame readindicator = new Frame { BackgroundColor = Color.Red, CornerRadius = 5 }; Grid containerMain = new Grid(); containerMain.Padding = 0; containerMain.ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = GridLength.Star }, new ColumnDefinition { Width = new GridLength(5) } }; containerMain.RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(5) }, new RowDefinition { Height = GridLength.Star } }; container.Children.Add(containerData); container.Children.Add(arrow); containerMain.Children.Add(container); Grid.SetRowSpan(container, 2); Grid.SetColumnSpan(container, 2); ReadIndicator = new Frame { CornerRadius = 5, BackgroundColor = Color.Red, IsVisible = false }; ReadIndicator.SetBinding(View.IsVisibleProperty, "Read", BindingMode.TwoWay); containerMain.Children.Add(ReadIndicator, 1, 0); frame.Content = containerMain; var stackLMain = new StackLayout() { Margin = new Thickness(0, 2) }; stackLMain.Children.Add(frame); View = stackLMain; //View = frame; MessagingCenter.Subscribe <Object, int>(this, "SetAppRead", (sender, args) => { if (this.ID == args) { ReadIndicator.IsVisible = false; } }); }
public ApplicationViewCell() { VerticalOptions = LayoutOptions.Fill; var MainRelativeLayout = new RelativeLayout { Margin = 5, BackgroundColor = Color.Transparent, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, MinimumWidthRequest = 0 }; applicationShortName = new Label { TextColor = Color.White, FontSize = 30, FontAttributes = FontAttributes.Bold, Text = "AT", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center }; Func <RelativeLayout, double> applicationShortNameWidth = (parent) => applicationShortName.Measure(MainRelativeLayout.Width, MainRelativeLayout.Height).Request.Width; Func <RelativeLayout, double> applicationShortNameHeight = (parent) => applicationShortName.Measure(MainRelativeLayout.Width, MainRelativeLayout.Height).Request.Height; applicationBox = new BoxView { HorizontalOptions = LayoutOptions.FillAndExpand, MinimumWidthRequest = App.ScreenWidth / 2 }; Func <RelativeLayout, double> applicationBoxWidth = (parent) => applicationBox.Measure(MainRelativeLayout.Width, MainRelativeLayout.Height).Request.Width; Func <RelativeLayout, double> applicationBoxHeight = (parent) => applicationBox.Measure(MainRelativeLayout.Width, MainRelativeLayout.Height).Request.Height; applicationBox.BindingContext = applicationBox; applicationBox.SetBinding(HeightRequestProperty, "Width"); applicationName = new Label { Text = "Asset Transfer", TextColor = Color.Black, FontSize = 14, AutomationId = "ApplicationViewCell", VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, LineBreakMode = LineBreakMode.WordWrap, FontAttributes = FontAttributes.Bold, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, }; Func <RelativeLayout, double> applicationNameWidth = (parent) => applicationName.Measure(MainRelativeLayout.Width, MainRelativeLayout.Height).Request.Width; Func <RelativeLayout, double> applicationNameHeight = (parent) => applicationName.Measure(MainRelativeLayout.Width, MainRelativeLayout.Height).Request.Height; applicationDeployedDate = new Label { Text = "Deployed 07/11/18", TextColor = Color.Black, FontSize = 11, AutomationId = "ApplicationDeployedDate", VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, LineBreakMode = LineBreakMode.WordWrap, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, Margin = new Thickness(0, 0, 0, 5) }; Func <RelativeLayout, double> applicationDeployedDateWidth = (parent) => applicationDeployedDate.Measure(MainRelativeLayout.Width, MainRelativeLayout.Height).Request.Width; Func <RelativeLayout, double> applicationDeployedDateHeight = (parent) => applicationDeployedDate.Measure(MainRelativeLayout.Width, MainRelativeLayout.Height).Request.Height; applicationEnabledState = new Label { Text = "Enabled", TextColor = Color.Black, FontSize = 11, AutomationId = "ApplicationEnabledState", VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, LineBreakMode = LineBreakMode.WordWrap, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, Margin = new Thickness(0, 0, 0, 5) }; Func <RelativeLayout, double> applicationEnabledStateWidth = (parent) => applicationEnabledState.Measure(MainRelativeLayout.Width, MainRelativeLayout.Height).Request.Width; Func <RelativeLayout, double> applicationEnabledStateHeight = (parent) => applicationEnabledState.Measure(MainRelativeLayout.Width, MainRelativeLayout.Height).Request.Height; //ADD CHILDREN TO RELATIVELAYOUT MainRelativeLayout.Children.Add(applicationBox, Constraint.RelativeToParent((parent) => { return(parent.X); }), Constraint.RelativeToParent((parent) => { return(parent.Y); }), Constraint.RelativeToParent((parent) => { return(parent.Width - 20); }), Constraint.RelativeToParent((parent) => { return(parent.Width - 20); })); MainRelativeLayout.Children.Add(applicationShortName, Constraint.RelativeToView(applicationBox, (parent, sibling) => { return(sibling.Bounds.Center.X - applicationShortNameWidth(parent) / 2); }), Constraint.RelativeToView(applicationBox, (parent, sibling) => { return(sibling.Bounds.Center.Y - applicationShortNameHeight(parent) / 2); })); MainRelativeLayout.Children.Add(applicationName, Constraint.RelativeToView(applicationBox, (parent, sibling) => { return(sibling.Bounds.Center.X - applicationNameWidth(parent) / 2); }), Constraint.RelativeToView(applicationBox, (parent, sibling) => { return(sibling.Bounds.Bottom + 10); })); MainRelativeLayout.Children.Add(applicationDeployedDate, Constraint.RelativeToView(applicationBox, (parent, sibling) => { return(sibling.Bounds.Center.X - applicationDeployedDateWidth(parent) / 2); }), Constraint.RelativeToView(applicationName, (parent, sibling) => { return(sibling.Bounds.Bottom + 5); })); MainRelativeLayout.Children.Add(applicationEnabledState, Constraint.RelativeToView(applicationBox, (parent, sibling) => { return(sibling.Bounds.Center.X - applicationEnabledStateWidth(parent) / 2); }), Constraint.RelativeToView(applicationDeployedDate, (parent, sibling) => { return(sibling.Bounds.Bottom + 7); })); var frame = new MaterialFrame { Content = MainRelativeLayout, Padding = 5, BackgroundColor = Color.White, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; Content = new ContentView { Content = frame, Padding = 10, BackgroundColor = Color.Transparent }; }
public WorkflowViewCell() { var MainRelativeLayout = new RelativeLayout { Margin = 5, BackgroundColor = Color.Transparent, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, MinimumWidthRequest = 0 }; workflowShortName = new Label { TextColor = Color.White, FontSize = 30, FontAttributes = FontAttributes.Bold, Text = "AT", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center }; Func <RelativeLayout, double> workflowShortNameWidth = (parent) => workflowShortName.Measure(MainRelativeLayout.Width, MainRelativeLayout.Height).Request.Width; Func <RelativeLayout, double> workflowShortNameHeight = (parent) => workflowShortName.Measure(MainRelativeLayout.Width, MainRelativeLayout.Height).Request.Height; workflowBox = new BoxView { HorizontalOptions = LayoutOptions.FillAndExpand, MinimumWidthRequest = App.ScreenWidth / 2 }; Func <RelativeLayout, double> workflowBoxWidth = (parent) => workflowBox.Measure(MainRelativeLayout.Width, MainRelativeLayout.Height).Request.Width; Func <RelativeLayout, double> workflowBoxHeight = (parent) => workflowBox.Measure(MainRelativeLayout.Width, MainRelativeLayout.Height).Request.Height; workflowBox.BindingContext = workflowBox; workflowBox.SetBinding(HeightRequestProperty, "Width"); workflowName = new Label { Text = "Asset Transfer", TextColor = Color.Black, FontSize = 14, AutomationId = "ApplicationViewCell", VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, LineBreakMode = LineBreakMode.WordWrap, FontAttributes = FontAttributes.Bold, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, Margin = new Thickness(0, 0, 0, 10) }; Func <RelativeLayout, double> workflowNameWidth = (parent) => workflowName.Measure(MainRelativeLayout.Width, MainRelativeLayout.Height).Request.Width; Func <RelativeLayout, double> workflowNameHeight = (parent) => workflowName.Measure(MainRelativeLayout.Width, MainRelativeLayout.Height).Request.Height; MainRelativeLayout.Children.Add(workflowBox, Constraint.RelativeToParent((parent) => { return(parent.X); }), Constraint.RelativeToParent((parent) => { return(parent.Y); }), Constraint.RelativeToParent((parent) => { return(parent.Width - 20); }), Constraint.RelativeToParent((parent) => { return(parent.Width - 20); })); MainRelativeLayout.Children.Add(workflowShortName, Constraint.RelativeToView(workflowBox, (parent, sibling) => { return(sibling.Bounds.Center.X - workflowShortNameWidth(parent) / 2); }), Constraint.RelativeToView(workflowBox, (parent, sibling) => { return(sibling.Bounds.Center.Y - workflowShortNameHeight(parent) / 2); })); MainRelativeLayout.Children.Add(workflowName, Constraint.RelativeToView(workflowBox, (parent, sibling) => { return(sibling.Bounds.Center.X - workflowNameWidth(parent) / 2); }), Constraint.RelativeToView(workflowBox, (parent, sibling) => { return(sibling.Bounds.Bottom + 10); })); //Add extra label to fix weird padding bug if (Device.RuntimePlatform.Equals(Device.Android)) { var blankLabel = new Label { Text = "" }; MainRelativeLayout.Children.Add(blankLabel, Constraint.RelativeToView(workflowBox, (parent, sibling) => { return(sibling.Bounds.Center.X - workflowNameWidth(parent) / 2); }), Constraint.RelativeToView(workflowName, (parent, sibling) => { return(sibling.Bounds.Bottom + 25); })); } var frame = new MaterialFrame { Content = MainRelativeLayout, Padding = 5, BackgroundColor = Color.White, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; Content = new ContentView { Content = frame, Padding = 10, BackgroundColor = Color.Transparent, }; }
public QuestionsCell() { MaterialFrame frame = new MaterialFrame(); frame.SetAppThemeColor(Frame.BorderColorProperty, (Color)Application.Current.Resources["MainColor"], Color.White); frame.HorizontalOptions = LayoutOptions.FillAndExpand; frame.VerticalOptions = LayoutOptions.Start; frame.BackgroundColor = Color.White; frame.Margin = new Thickness(10, 0, 10, 10); frame.Padding = new Thickness(18, 18, 18, 18); frame.CornerRadius = 35; frame.SetOnAppTheme(Frame.HasShadowProperty, false, true); frame.SetOnAppTheme(MaterialFrame.ElevationProperty, 0, 20); StackLayout container = new StackLayout(); container.Orientation = StackOrientation.Vertical; title.TextColor = Color.Black; title.FontAttributes = FontAttributes.Bold; title.FontSize = 18; container.Children.Add(title); date.HorizontalOptions = LayoutOptions.Start; date.TextColor = Color.Black; date.FontSize = 12; date.IsVisible = false; date.Margin = new Thickness(0, -5, 0, 0); StackLayout containerCount = new StackLayout(); containerCount.Orientation = StackOrientation.Horizontal; StackLayout containerOne = new StackLayout(); containerOne.Orientation = StackOrientation.Horizontal; StackLayout containerTwo = new StackLayout(); containerTwo.Orientation = StackOrientation.Horizontal; countQuestTitle.Text = $"{AppResources.QuestionsAmount}:"; countQuestTitle.HorizontalOptions = LayoutOptions.Start; countQuestTitle.FontSize = 12; countAnsweredTitle.VerticalOptions = LayoutOptions.Center; countQuestTitle.TextColor = Color.Black; countQuest.TextColor = (Color)Application.Current.Resources["MainColor"]; countQuest.HorizontalOptions = LayoutOptions.Start; countQuest.FontSize = 12; countQuest.FontAttributes = FontAttributes.Bold; containerOne.Children.Add(countQuestTitle); containerOne.Children.Add(countQuest); countAnsweredTitle.Text = $"{AppResources.AnsweredAmount}:"; countAnsweredTitle.TextColor = Color.Black; countAnsweredTitle.HorizontalOptions = LayoutOptions.Start; countAnsweredTitle.VerticalOptions = LayoutOptions.Center; countAnsweredTitle.FontSize = 12; countAnswered.TextColor = (Color)Application.Current.Resources["MainColor"]; countAnswered.HorizontalOptions = LayoutOptions.Start; countAnswered.FontAttributes = FontAttributes.Bold; countAnswered.FontSize = 12; containerTwo.Children.Add(countAnsweredTitle); containerTwo.Children.Add(countAnswered); containerTwo.HorizontalOptions = LayoutOptions.End; Grid grid = new Grid { RowDefinitions = { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, } }; // containerCount.Children.Add(containerOne); // containerCount.Children.Add(containerTwo); grid.Children.Add(containerOne, 0, 0); grid.Children.Add(containerTwo, 1, 0); container.Children.Add(date); container.Children.Add(grid); Frame frameBtn = new Frame(); frameBtn.HorizontalOptions = LayoutOptions.FillAndExpand; frameBtn.VerticalOptions = LayoutOptions.Start; frameBtn.BackgroundColor = (Color)Application.Current.Resources["MainColor"]; frameBtn.Margin = new Thickness(0, 10, 0, 10); frameBtn.Padding = 0; frameBtn.CornerRadius = 10; frameBtn.SetOnAppTheme(Frame.HasShadowProperty, false, true); frameBtn.SetOnAppTheme(MaterialFrame.ElevationProperty, 0, 20); StackLayout containerBtn = new StackLayout(); containerBtn.Spacing = 0; containerBtn.Orientation = StackOrientation.Horizontal; containerBtn.HorizontalOptions = LayoutOptions.CenterAndExpand; SvgCachedImage image = new SvgCachedImage(); image.Source = "resource://xamarinJKH.Resources.ic_questions2.svg"; image.ReplaceStringMap = new Dictionary <string, string> { { "#000000", "#FFFFFF" } }; // image.Margin = new Thickness(-40, 0, 0, 0); image.HeightRequest = 25; image.WidthRequest = 25; // Label btn = new Label(); // btn.Margin = new Thickness(-15, 0, 0, 0); // btn.TextColor = Color.White; // btn.FontAttributes = FontAttributes.Bold; // btn.Text = "Пройти опрос"; // btn.Margin = new Thickness(-30, 0, 0, 0); btn.TextColor = Color.White; btn.BackgroundColor = Color.Transparent; btn.HorizontalOptions = LayoutOptions.Center; btn.Margin = new Thickness(9, 13, 0, 13); btn.FontAttributes = FontAttributes.Bold; btn.VerticalOptions = LayoutOptions.Center; btn.FontSize = 15; btn.Text = "Пройти опрос"; containerBtn.Children.Add(image); containerBtn.Children.Add(btn); frameBtn.Content = containerBtn; container.Children.Add(frameBtn); Grid containerMain = new Grid(); containerMain.Padding = 0; containerMain.ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = GridLength.Star }, new ColumnDefinition { Width = new GridLength(5) } }; containerMain.RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(5) }, new RowDefinition { Height = GridLength.Star } }; containerMain.Children.Add(container); Grid.SetRowSpan(container, 2); Grid.SetColumnSpan(container, 2); ReadIndicator = new Frame { CornerRadius = 5, BackgroundColor = Color.Red, IsVisible = false }; ReadIndicator.SetBinding(View.IsVisibleProperty, "Read", BindingMode.TwoWay); containerMain.Children.Add(ReadIndicator, 1, 0); frame.Content = containerMain; View = frame; }
private MaterialFrame CreateFrame(Product product) { MaterialFrame frame = new MaterialFrame(); frame.HasShadow = true; frame.CornerRadius = 2; frame.Padding = 0; frame.HeightRequest = 280; frame.Elevation = 6; frame.IsVisible = product.InStock; Grid grid2 = new Grid { RowDefinitions = { new RowDefinition(), new RowDefinition(), new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto } } }; Image image = new Image { Source = product.ProductImage.ImageSource, Aspect = Aspect.AspectFill, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; grid2.Children.Add(image, 0, 0); grid2.ColumnSpacing = 5; grid2.Children.Add(new Image { Source = "tilbud.png", IsVisible = true, Aspect = Aspect.AspectFill, VerticalOptions = LayoutOptions.Center }, 0, 0); Grid.SetRowSpan(image, 2); grid2.Children.Add(new Label { Margin = new Thickness(10, 0, 0, 0), Text = product.Name, TextColor = Color.Black, FontSize = 15, FontFamily = "sans-serif-condensed", FontAttributes = FontAttributes.Bold }, 0, 2); grid2.Children.Add(new Label { Margin = new Thickness(10, 0, 0, 0), Text = "Pris " + product.Price.ToString() + ".kr", TextColor = Color.Black, FontSize = 13, FontFamily = "sans-serif-condensed", FontAttributes = FontAttributes.Bold }, 0, 3); StackLayout stackLayout = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand }; if (product.AmountOffer != null) { stackLayout.Children.Add(new Label { FontSize = 10, FontAttributes = FontAttributes.Bold, TextColor = Color.Red, FontFamily = "sans-serif-condensed", Text = "Ta" + product.AmountOffer.Amount + "for" }); stackLayout.Children.Add(new Label { FontSize = 10, FontAttributes = FontAttributes.Bold, TextColor = Color.Red, FontFamily = "sans-serif-condensed", Text = product.AmountOffer.Price + ".kr" }); } Button button = new Button { FontSize = 15, FontAttributes = FontAttributes.Bold, FontFamily = "sans-serif-condensed", Text = "Tilføj til kurv", BackgroundColor = Color.Transparent, Command = viewModel.AddToBasketCommand, CommandParameter = product, }; button.Behaviors.Add(new ButtonAnimationBehavior()); grid2.Children.Add(stackLayout, 0, 4); grid2.Children.Add(button, 0, 5); frame.Content = grid2; return(frame); }