void UpdateStatusBarColor(ShellAppearance appearance) { var activity = AndroidContext.GetActivity(); var window = activity?.Window; var decorView = window?.DecorView; int statusBarHeight = AndroidContext.GetStatusBarHeight(); int navigationBarHeight = AndroidContext.GetNavigationBarHeight(); // we are using the split drawable here to avoid GPU overdraw. // All it really is is a drawable that only draws under the statusbar/bottom bar to make sure // we dont draw over areas we dont need to. This has very limited benefits considering its // only saving us a flat color fill BUT it helps people not freak out about overdraw. AColor color; if (appearance != null) { color = appearance.BackgroundColor.ToPlatform(Color.FromArgb("#03A9F4")); } else { color = Color.FromArgb("#03A9F4").ToPlatform(); } if (!(decorView.Background is SplitDrawable splitDrawable) || splitDrawable.Color != color || splitDrawable.TopSize != statusBarHeight || splitDrawable.BottomSize != navigationBarHeight) { var split = new SplitDrawable(color, statusBarHeight, navigationBarHeight); decorView.SetBackground(split); } }
void DrawMaterialActivityIndicator(ICanvas canvas, RectF dirtyRect) { canvas.SaveState(); float size = 40f; float strokeWidth = 4f; canvas.StrokeSize = strokeWidth; var x = dirtyRect.X; var y = dirtyRect.Y; if (View.IsRunning) { canvas.Rotate(MaterialActivityIndicatorRotate, x + strokeWidth + size / 2, y + strokeWidth + size / 2); canvas.StrokeColor = View.Color.ToGraphicsColor(Material.Color.Blue); canvas.DrawArc(x + strokeWidth, y + strokeWidth, size, size, MaterialActivityIndicatorStartAngle, MaterialActivityIndicatorStartAngle + MaterialActivityIndicatorSweepAngle, false, false); } else { canvas.Rotate(0, x + strokeWidth + size / 2, y + strokeWidth + size / 2); if (View.Color.IsDefault) { canvas.StrokeColor = GColor.FromArgb(Material.Color.LightBlue); } else { canvas.StrokeColor = View.Color.MultiplyAlpha(0.5).ToGraphicsColor(Material.Color.LightBlue); } canvas.DrawArc(x + strokeWidth, y + strokeWidth, size, size, 0, 360, false, false); } canvas.RestoreState(); }
void DrawMaterialStepperMinus(ICanvas canvas, RectF dirtyRect) { canvas.SaveState(); canvas.StrokeSize = 1; canvas.StrokeColor = GColor.FromArgb(Material.Color.Gray6); var x = dirtyRect.X + 1; var y = dirtyRect.Y; var height = MaterialStepperHeight; var width = MaterialStepperWidth / 2; canvas.DrawRoundedRectangle(x, y, width, height, 6); if (!IsEnabled) { canvas.FillColor = GColor.FromArgb(Material.Color.Gray1); canvas.FillRoundedRectangle(x, y, width, height, 6); } canvas.Translate(20, 20); var vBuilder = new PathBuilder(); var path = vBuilder.BuildPath(MaterialStepperMinusIcon); canvas.FillColor = GColor.FromArgb(Material.Color.Black); canvas.FillPath(path); canvas.RestoreState(); _minusRect = new RectF(x, y, width, height); }
void DrawMaterialEditorBorder(ICanvas canvas, RectF dirtyRect) { canvas.SaveState(); var strokeWidth = 1.0f; canvas.FillColor = GColor.FromArgb(Material.Color.Black); if (View.IsFocused) { strokeWidth = 2.0f; canvas.FillColor = GColor.FromArgb(Material.Color.Blue); } var x = dirtyRect.X; //var y = 112.91f; var y = dirtyRect.Y + dirtyRect.Height - strokeWidth * 2; var width = dirtyRect.Width; var height = strokeWidth; canvas.FillRectangle(x, y, width, height); canvas.RestoreState(); }
void DrawBackground(ICanvas canvas, RectF dirtyRect) { canvas.SaveState(); canvas.Antialias = true; canvas.FillColor = BackgroundColor; canvas.SetShadow(new SizeF(0, 0), 2, GColor.FromArgb(Material.Color.Gray6)); canvas.FillCircle(dirtyRect.Center, IconSize / 2f); canvas.RestoreState(); }
void UpdateStatusBarColor(ShellAppearance appearance) { Profile.FrameBegin("UpdtStatBarClr"); var activity = AndroidContext.GetActivity(); var window = activity?.Window; var decorView = window?.DecorView; var resources = AndroidContext.Resources; int statusBarHeight = 0; int resourceId = resources.GetIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { statusBarHeight = resources.GetDimensionPixelSize(resourceId); } int navigationBarHeight = 0; resourceId = resources.GetIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { navigationBarHeight = resources.GetDimensionPixelSize(resourceId); } // TODO Previewer Hack if (decorView != null) { // we are using the split drawable here to avoid GPU overdraw. // All it really is is a drawable that only draws under the statusbar/bottom bar to make sure // we dont draw over areas we dont need to. This has very limited benefits considering its // only saving us a flat color fill BUT it helps people not freak out about overdraw. AColor color; if (appearance != null) { color = appearance.BackgroundColor.ToAndroid(Color.FromArgb("#03A9F4")); } else { color = Color.FromArgb("#03A9F4").ToAndroid(); } if (!(decorView.Background is SplitDrawable splitDrawable) || splitDrawable.Color != color || splitDrawable.TopSize != statusBarHeight || splitDrawable.BottomSize != navigationBarHeight) { Profile.FramePartition("Create SplitDrawable"); var split = new SplitDrawable(color, statusBarHeight, navigationBarHeight); Profile.FramePartition("SetBackground"); decorView.SetBackground(split); } } Profile.FrameEnd("UpdtStatBarClr"); }
void DrawMaterialProgressTrack(ICanvas canvas, RectF dirtyRect) { canvas.SaveState(); canvas.FillColor = GColor.FromArgb(Fluent.Color.Background.NeutralLight); var x = dirtyRect.X; var y = (float)((dirtyRect.Height - MaterialTrackHeight) / 2); var width = dirtyRect.Width; canvas.FillRectangle(x, y, width, MaterialTrackHeight); canvas.RestoreState(); }
public StepperDrawable(IStepper view) { _minusRippleEffect = new RippleEffectDrawable { RippleColor = GColor.FromArgb(Material.Color.Gray6) }; _plusRippleEffect = new RippleEffectDrawable { RippleColor = GColor.FromArgb(Material.Color.Gray6) }; _minusRippleEffect.Invalidated += (s, e) => SendInvalidated(); _plusRippleEffect.Invalidated += (s, e) => SendInvalidated(); View = view; }
void DrawMaterialCheckBoxBackground(ICanvas canvas, RectF dirtyRect) { canvas.SaveState(); float size = 18f; var x = dirtyRect.X; var y = dirtyRect.Y; if (dirtyRect.Height > size) { y += (dirtyRect.Height - size) / 2; } if (IsEnabled) { if (View.IsChecked) { canvas.FillColor = View.Color.ToGraphicsColor(Material.Color.Blue); canvas.FillRoundedRectangle(x, y, size, size, 2); } else { var strokeWidth = 2; canvas.StrokeSize = strokeWidth; canvas.StrokeColor = View.Color.ToGraphicsColor(Material.Color.Gray1); canvas.DrawRoundedRectangle(x + strokeWidth / 2, y + strokeWidth / 2, size - strokeWidth, size - strokeWidth, 2); } } else { var strokeWidth = 2; canvas.FillColor = GColor.FromArgb(Material.Color.Gray2); canvas.FillRoundedRectangle(x, y, size, size, 2); canvas.StrokeSize = strokeWidth; canvas.StrokeColor = GColor.FromArgb(Material.Color.Gray1); canvas.DrawRoundedRectangle(x + strokeWidth / 2, y + strokeWidth / 2, size - strokeWidth, size - strokeWidth, 2); } canvas.RestoreState(); }
void DrawMaterialButtonBackground(ICanvas canvas, RectF dirtyRect) { canvas.SaveState(); canvas.FillColor = IsEnabled ? View.BackgroundColor.ToGraphicsColor(Material.Color.Blue) : GColor.FromArgb(Material.Color.Gray1); var x = dirtyRect.X; var y = dirtyRect.Y; var width = dirtyRect.Width - MaterialShadowOffset; var height = MaterialBackgroundHeight - MaterialShadowOffset; canvas.SetShadow(new SizeF(0, 1), 3, GColor.FromArgb(Material.Color.Gray2)); canvas.FillRoundedRectangle(x, y, width, height, (float)View.CornerRadius); canvas.RestoreState(); _backgroundRect = new RectF(x, y, width, height); }
void DrawMaterialSliderTrackBackground(ICanvas canvas, RectF dirtyRect) { canvas.SaveState(); canvas.FillColor = IsEnabled ? View.MaximumTrackColor.ToGraphicsColor(Material.Color.LightBlue) : GColor.FromArgb(Material.Color.Gray1); var x = dirtyRect.X; var width = dirtyRect.Width; var height = 2; var y = (float)((dirtyRect.Height - height) / 2); canvas.FillRoundedRectangle(x, y, width, height, 0); canvas.RestoreState(); TrackRect = new RectF(x, y, width, height); }
protected virtual void DrawMaterialSliderThumb(ICanvas canvas, RectF dirtyRect) { canvas.SaveState(); var value = ((double)ValueRate).Clamp(0, 1); var x = (float)((dirtyRect.Width * value) - (MaterialFloatThumb / 2)); if (x <= 0) { x = 0; } if (x >= dirtyRect.Width - MaterialFloatThumb) { x = dirtyRect.Width - MaterialFloatThumb; } var y = (float)((dirtyRect.Height - MaterialFloatThumb) / 2); canvas.FillColor = IsEnabled ? View.ThumbColor.ToGraphicsColor(Material.Color.Blue) : GColor.FromArgb(Material.Color.Gray1); canvas.FillEllipse(x, y, MaterialFloatThumb, MaterialFloatThumb); canvas.RestoreState(); ThumbRect = new RectF(x, y, MaterialFloatThumb, MaterialFloatThumb); }
protected virtual void DrawMaterialSliderTrackProgress(ICanvas canvas, RectF dirtyRect) { canvas.SaveState(); canvas.FillColor = IsEnabled ? View.MinimumTrackColor.ToGraphicsColor(Material.Color.Blue) : GColor.FromArgb(Material.Color.Gray1); var x = dirtyRect.X; var value = ((double)ValueRate).Clamp(0, 1); var width = (float)(dirtyRect.Width * value); var height = 2; var y = (float)((dirtyRect.Height - height) / 2); canvas.FillRoundedRectangle(x, y, width, height, 0); canvas.RestoreState(); }
void DrawMaterialSwitchThumb(ICanvas canvas, RectF dirtyRect) { canvas.SaveState(); if (View.IsToggled) { canvas.FillColor = IsEnabled ? View.ThumbColor.ToGraphicsColor(Material.Color.Blue) : GColor.FromArgb(Material.Color.Gray1); } else { canvas.FillColor = IsEnabled ? View.ThumbColor.ToGraphicsColor(Fluent.Color.Foreground.White) : GColor.FromArgb(Material.Color.Gray1); } if (!_isAnimating) { MaterialSwitchThumbPosition = (View.IsToggled ? MaterialThumbOnPosition : MaterialThumbOffPosition); } var margin = 2; var radius = 10; var y = dirtyRect.Y + margin + radius; canvas.SetShadow(new SizeF(0, 1), 2, CanvasDefaults.DefaultShadowColor); canvas.FillCircle(MaterialSwitchThumbPosition, y, radius); canvas.RestoreState(); }
void DrawMaterialSwitchBackground(ICanvas canvas, RectF dirtyRect) { canvas.SaveState(); if (View.IsToggled) { canvas.FillColor = IsEnabled ? View.OnColor.ToGraphicsColor(Material.Color.LightBlue) : GColor.FromArgb(Material.Color.Gray1); canvas.Alpha = 0.5f; } else { canvas.FillColor = IsEnabled ? View.BackgroundColor.ToGraphicsColor(Material.Color.Gray2) : GColor.FromArgb(Material.Color.Gray1); canvas.Alpha = 1.0f; } var margin = MaterialSwitchBackgroundMargin; var x = dirtyRect.X + margin; var y = dirtyRect.Y + margin; var height = 14; var width = MaterialSwitchBackgroundWidth; canvas.FillRoundedRectangle(x, y, width, height, 10); canvas.RestoreState(); }