public static double GetOpacity(this View view, ControlState state = ControlState.Default) { var opacity = view?.GetEnvironment <double?>(EnvironmentKeys.View.Opacity, state); //Fall back to the default state before using the default color opacity ??= view?.GetEnvironment <double?>(EnvironmentKeys.View.Opacity); return(opacity ?? 1); }
public static FontAttributes GetFont(this View view, FontAttributes defaultFont) { var size = view.GetEnvironment <float?>(EnvironmentKeys.Fonts.Size) ?? defaultFont.Size; var name = view.GetEnvironment <string>(EnvironmentKeys.Fonts.Family) ?? defaultFont.Family; var weight = view.GetEnvironment <Weight?>(EnvironmentKeys.Fonts.Weight) ?? defaultFont.Weight; var italic = view.GetEnvironment <bool?>(EnvironmentKeys.Fonts.Italic) ?? defaultFont.Italic; return(new FontAttributes { Size = size, Family = name, Italic = italic, Weight = weight, }); }
public static LayoutAlignment GetVerticalLayoutAlignment(this View view, ContainerView container, LayoutAlignment defaultSizing = LayoutAlignment.Start) { var sizing = view.GetEnvironment <LayoutAlignment?>(view, EnvironmentKeys.Layout.VerticalLayoutAlignment); if (sizing != null) { return((LayoutAlignment)sizing); } if (container != null) { sizing = view.GetEnvironment <LayoutAlignment?>(view, $"{container.GetType().Name}.{EnvironmentKeys.Layout.VerticalLayoutAlignment}"); } return(sizing ?? defaultSizing); }
public static Sizing GetVerticalSizing(this View view, ContainerView container, Sizing defaultSizing = Sizing.Fit) { var sizing = view.GetEnvironment <Sizing?>(view, EnvironmentKeys.Layout.VerticalSizing); if (sizing != null) { return((Sizing)sizing); } if (container != null) { sizing = view.GetEnvironment <Sizing?>(view, $"{container.GetType().Name}.{EnvironmentKeys.Layout.VerticalSizing}"); } return(sizing ?? defaultSizing); }
public static string GetTitle(this View view) { var title = view?.GetEnvironment <string>(EnvironmentKeys.View.Title); title ??= view?.BuiltView?.GetEnvironment <string>(EnvironmentKeys.View.Title, true) ?? ""; return(title); }
public static Font GetFont(this View view, Font?defaultFont) { Font font = Font.Default; var size = view.GetEnvironment <double?>(EnvironmentKeys.Fonts.Size) ?? defaultFont?.Size ?? font.Size; var name = view.GetEnvironment <string>(EnvironmentKeys.Fonts.Family) ?? defaultFont?.Family ?? font.Family; var weight = view.GetEnvironment <FontWeight?>(EnvironmentKeys.Fonts.Weight) ?? defaultFont?.Weight ?? Microsoft.Maui.FontWeight.Regular; var slant = view.GetEnvironment <FontSlant?>(EnvironmentKeys.Fonts.Slant) ?? Microsoft.Maui.FontSlant.Default; if (!string.IsNullOrWhiteSpace(name)) { return(Font.OfSize(name, size, weight, slant)); } //else if (size > 0) return(Font.SystemFontOfSize(size, weight, slant)); //return font; }
public static Paint GetBackground(this View view, Paint defaultColor = null, ControlState state = ControlState.Default) { var color = view?.GetEnvironment <object>(EnvironmentKeys.Colors.Background, state); return(color.ConvertToPaint() ?? defaultColor); }
public static View GetOverlay(this View view) { return(view.GetEnvironment <View>(EnvironmentKeys.View.Overlay)); }
public static TextAlignment?GetVerticalTextAlignment(this View view, TextAlignment?defaultValue = null) { var value = view.GetEnvironment <TextAlignment?>(view, EnvironmentKeys.Text.VerticalAlignment); return(value ?? defaultValue); }
public static Color GetBackgroundColor(this View view, Color defaultColor = null, ControlState state = ControlState.Default) { var color = view?.GetEnvironment <Color>(EnvironmentKeys.Colors.BackgroundColor, state); return(color ?? defaultColor); }
public static Shape GetClipShape(this View view, Shape defaultShape = null, Type type = null) { var shape = view.GetEnvironment <Shape>(type, EnvironmentKeys.View.ClipShape); return(shape ?? defaultShape); }
public static Shape GetOverlay(this View view) { return(view.GetEnvironment <Shape>(EnvironmentKeys.View.Overlay)); }
public static bool GetIgnoreSafeArea(this View view, bool defaultValue) => (bool?)view.GetEnvironment(view, EnvironmentKeys.Layout.IgnoreSafeArea, false) ?? defaultValue;
public static Thickness GetPadding(this View view, Thickness?defaultValue = null) { var margin = view.GetEnvironment <Thickness?>(view, EnvironmentKeys.Layout.Padding); return(margin ?? defaultValue ?? Thickness.Zero); }
public static Thickness GetMargin(this View view, Thickness?defaultValue = null) { var margin = view.GetEnvironment <Thickness?>(view, EnvironmentKeys.Layout.Margin); return(margin ?? defaultValue ?? Thickness.Empty); }
public static Sizing GetVerticalSizing(this View view, Sizing defaultSizing = Sizing.Fit) { var sizing = view.GetEnvironment <Sizing?>(view, EnvironmentKeys.Layout.VerticalSizing); return(sizing ?? defaultSizing); }
public static Shadow GetShadow(this View view, Shadow defaultShadow = null, Type type = null) { var shadow = view.GetEnvironment <Shadow>(type, EnvironmentKeys.View.Shadow); return(shadow ?? defaultShadow); }
public static FrameConstraints GetFrameConstraints(this View view, FrameConstraints defaultContraints = null) { var constraints = view.GetEnvironment <FrameConstraints>(view, EnvironmentKeys.Layout.FrameConstraints); return(constraints ?? defaultContraints); }
public static Color GetNavigationTextColor(this View view, Color defaultColor = null) { var color = view.GetEnvironment <Color>(EnvironmentKeys.Navigation.TextColor); return(color ?? defaultColor); }
public static Thickness GetPadding(this View view, Thickness?defaultValue = null) { var padding = view.GetEnvironment <Thickness?>(view, EnvironmentKeys.Layout.Padding); return(padding ?? defaultValue ?? Thickness.Empty); }
public static Animation GetAnimation(this View view) { var animation = view.GetEnvironment <Animation>(EnvironmentKeys.Animations.Animation); return(animation); }
public static object GetLayoutConstraints(this View view, object defaultValue = null) { var constraints = view.GetEnvironment <object>(view, EnvironmentKeys.Layout.Constraints); return(constraints ?? defaultValue); }
public static Color GetBackgroundColor(this View view, Color defaultColor = null) { var color = view.GetEnvironment <Color>(EnvironmentKeys.Colors.BackgroundColor); return(color ?? defaultColor); }
public static string GetAutomationId(this View view) => view.GetEnvironment <string>(view, EnvironmentKeys.View.AutomationId, cascades: false);