示例#1
0
 protected virtual void ApplyTextStyle(ContextualObject view, TextStyle textStyle)
 {
     SetEnvironment(view, textStyle.StyleId, EnvironmentKeys.Colors.Color, textStyle.Color);
     SetEnvironment(view, textStyle.StyleId, EnvironmentKeys.Fonts.Size, textStyle?.Font, (f) => (f is Font font) ? font.Size : null);
     SetEnvironment(view, textStyle.StyleId, EnvironmentKeys.Fonts.Family, textStyle?.Font, (f) => (f is Font font) ? font.Family : null);
     SetEnvironment(view, textStyle.StyleId, EnvironmentKeys.Fonts.Weight, textStyle?.Font, (f) => (f is Font font) ? font.Weight : null);
 }
示例#2
0
 protected virtual void ApplySliderStyle(ContextualObject view)
 {
     SetEnvironment(view, "", EnvironmentKeys.Slider.TrackColor, Slider?.TrackColor);
     SetEnvironment(view, "", EnvironmentKeys.Slider.ProgressColor, Slider?.ProgressColor);
     SetEnvironment(view, "", EnvironmentKeys.Slider.ThumbColor, Slider?.ThumbColor);
     ApplyViewStyles(view, Slider, typeof(Slider));
 }
示例#3
0
 protected override void ApplyButton(ContextualObject view)
 {
     base.ApplyButton(view);
     ApplyButton(view, OutlinedButtonStyleId, OutlinedButton);
     ApplyButton(view, ContainedButtonStyleId, ContainedButton);
     ApplyButton(view, TextButtonStyleId, TextButton);
 }
示例#4
0
 protected virtual void ApplyViewStyles(ContextualObject view, ViewStyle style, Type viewType)
 {
     SetEnvironment(view, viewType, EnvironmentKeys.View.ClipShape, style?.ClipShape);
     SetEnvironment(view, viewType, EnvironmentKeys.View.Overlay, style?.Overlay);
     SetEnvironment(view, viewType, EnvironmentKeys.View.Border, style?.Border);
     SetEnvironment(view, viewType, EnvironmentKeys.Colors.Background, style?.BackgroundColor);
     SetEnvironment(view, viewType, EnvironmentKeys.View.Shadow, style?.Shadow);
 }
示例#5
0
 protected virtual void ApplyTextStyle(ContextualObject view, TextStyle textStyle)
 {
     SetEnvironment(view, textStyle.StyleId, EnvironmentKeys.Colors.Color, textStyle.Color);
     SetEnvironment(view, textStyle.StyleId, EnvironmentKeys.Fonts.Size, textStyle?.Font, (f) => (f as FontAttributes)?.Size);
     SetEnvironment(view, textStyle.StyleId, EnvironmentKeys.Fonts.Family, textStyle?.Font, (f) => (f as FontAttributes)?.Family);
     SetEnvironment(view, textStyle.StyleId, EnvironmentKeys.Fonts.Italic, textStyle?.Font, (f) => (f as FontAttributes)?.Italic);
     SetEnvironment(view, textStyle.StyleId, EnvironmentKeys.Fonts.Weight, textStyle?.Font, (f) => (f as FontAttributes)?.Weight);
 }
示例#6
0
        protected virtual void ApplyButton(ContextualObject view)
        {
            SetEnvironment(view, typeof(Button), EnvironmentKeys.Colors.Color, Button?.TextColor);
            //Set the BorderStyle
            SetEnvironment(view, typeof(Button), EnvironmentKeys.View.ClipShape, Button?.Border);
            SetEnvironment(view, typeof(Button), EnvironmentKeys.View.Overlay, Button?.Border);
            SetEnvironment(view, typeof(Button), EnvironmentKeys.Colors.Background, Button?.BackgroundColor);

            SetEnvironment(view, typeof(Button), EnvironmentKeys.View.Shadow, Button?.Shadow);
        }
示例#7
0
 void SetEnvironmentValue(ContextualObject view, string styleId, string key, object value)
 {
     if (view != null)
     {
         view.SetEnvironment(styleId, key, value);
     }
     else
     {
         View.SetGlobalEnvironment(styleId, key, value);
     }
 }
示例#8
0
        protected virtual void ApplyButton(ContextualObject view, string styleId, ButtonStyle style)
        {
            SetEnvironment(view, styleId, EnvironmentKeys.Colors.Color, style?.TextColor);

            //Set the BorderStyle

            SetEnvironment(view, styleId, EnvironmentKeys.View.Border, style?.Border);
            SetEnvironment(view, styleId, EnvironmentKeys.View.Overlay, style?.Border);
            SetEnvironment(view, styleId, EnvironmentKeys.Colors.Background, style?.BackgroundColor);

            SetEnvironment(view, styleId, EnvironmentKeys.View.Shadow, style?.Shadow);
        }
示例#9
0
 protected void SetEnvironment(ContextualObject view, string styleId, string key, StyleAwareValue value, Func <object, object> getProperty)
 {
     if (value == null)
     {
         SetEnvironmentValue(view, styleId, key, null);
         return;
     }
     foreach (var pair in value.ToEnvironmentValues())
     {
         var newKey = pair.key == null ? key : $"{pair.key}.{key}";
         SetEnvironmentValue(view, styleId, newKey, getProperty(pair.value));
     }
 }
示例#10
0
        public static T SetEnvironment <T>(this T contextualObject, Type type, string key, object value, bool cascades = true, ControlState state = ControlState.Default)
            where T : ContextualObject
        {
            key = ContextualObject.GetControlStateKey(state, key);
            var typedKey = ContextualObject.GetTypedKey(type, key);

            contextualObject.SetValue(typedKey, value, cascades);
            //TODO: Verify this is needed
            ThreadHelper.RunOnMainThread(() => {
                contextualObject.ContextPropertyChanged(typedKey, value, cascades);
            });
            return(contextualObject);
        }
示例#11
0
 public static T SetEnvironment <T>(this T contextualObject, string key, object value, bool cascades = true, ControlState state = ControlState.Default)
     where T : ContextualObject
 {
     key = ContextualObject.GetControlStateKey(state, key);
     if (!contextualObject.SetValue(key, value, cascades))
     {
         return(contextualObject);
     }
     ThreadHelper.RunOnMainThread(() => {
         contextualObject.ContextPropertyChanged(key, value, cascades);
     });
     return(contextualObject);
 }
示例#12
0
        public static T SetEnvironment <T, TValue>(this T view, Type type, string key, Binding <TValue> binding, bool cascades = true, ControlState state = ControlState.Default)
            where T : View
        {
            binding.BindToProperty(view, key);
            key = ContextualObject.GetControlStateKey(state, key);
            var typedKey = ContextualObject.GetTypedKey(type, key);

            view.SetValue(typedKey, binding, cascades);
            //TODO: Verify this is needed
            ThreadHelper.RunOnMainThread(() => {
                view.ContextPropertyChanged(typedKey, binding, cascades);
            });
            return(view);
        }
示例#13
0
        protected void SetEnvironment(ContextualObject view, Type type, string key, StyleAwareValue value)
        {
            if (value == null)
            {
                SetEnvironmentValue(view, type, key, null);
                return;
            }

            foreach (var pair in value.ToEnvironmentValues())
            {
                var newKey = pair.key == null ? key : $"{key}.{pair.key}";
                SetEnvironmentValue(view, type, newKey, pair.value);
            }
        }
示例#14
0
 public static T SetEnvironment <T, TValue>(this T view, string key, Binding <TValue> binding, bool cascades = true, ControlState state = ControlState.Default)
     where T : View
 {
     binding.BindToProperty(view, key);
     key = ContextualObject.GetControlStateKey(state, key);
     if (!view.SetValue(key, binding, cascades))
     {
         return(view);
     }
     ThreadHelper.RunOnMainThread(() => {
         view.ContextPropertyChanged(key, binding, cascades);
     });
     return(view);
 }
示例#15
0
 public virtual void Apply(ContextualObject view = null)
 {
     if (view == null)
     {
         SetDefaultControlSizingForLayouts();
     }
     ApplyButton(view);
     ApplyNavbarStyles(view);
     ApplyTextStyle(view, Label);
     ApplyTextStyle(view, H1);
     ApplyTextStyle(view, H2);
     ApplyTextStyle(view, H3);
     ApplyTextStyle(view, H4);
     ApplyTextStyle(view, H5);
     ApplyTextStyle(view, H6);
     ApplyTextStyle(view, Subtitle1);
     ApplyTextStyle(view, Subtitle2);
     ApplyTextStyle(view, Body1);
     ApplyTextStyle(view, Body2);
     ApplyTextStyle(view, Caption);
     ApplyTextStyle(view, Overline);
     ApplySliderStyle(view);
     ApplyProgresBarStyle(view);
 }
示例#16
0
 public override void Apply(ContextualObject view = null)
 {
     SetDefaultControlSizingForLayouts();
 }
示例#17
0
 protected virtual void ApplyProgresBarStyle(ContextualObject view)
 {
     SetEnvironment(view, "", EnvironmentKeys.ProgressBar.TrackColor, ProgressBar?.TrackColor);
     SetEnvironment(view, "", EnvironmentKeys.ProgressBar.ProgressColor, ProgressBar?.ProgressColor);
     ApplyViewStyles(view, ProgressBar, typeof(ProgressBar));
 }
示例#18
0
 protected virtual void ApplyNavbarStyles(ContextualObject view)
 {
     SetEnvironment(view, "", EnvironmentKeys.Navigation.BackgroundColor, Navbar?.BackgroundColor);
     SetEnvironment(view, "", EnvironmentKeys.Navigation.TextColor, Navbar?.TextColor);
 }
示例#19
0
        //public static T SetEnvironment<T>(this T contextualObject, IDictionary<string, object> data, bool cascades = true) where T : ContextualObject
        //{
        //    foreach (var pair in data)
        //        contextualObject.SetValue(pair.Key, pair.Value,cascades);

        //    return contextualObject;
        //}

        public static T GetEnvironment <T>(this ContextualObject contextualObject, View view, string key, bool cascades             = true) => contextualObject.GetEnvironment <T>(view, contextualObject.GetType(), key, cascades);
示例#20
0
 public static object GetEnvironment(this ContextualObject contextualObject, View view, Type type, string key, bool cascades = true) => contextualObject.GetValue(key, contextualObject, view, ContextualObject.GetTypedStyleId(contextualObject, key), ContextualObject.GetTypedKey(type ?? contextualObject.GetType(), key), cascades);
示例#21
0
 public static object GetEnvironment(this View view, Type type, string key, bool cascades = true) => view.GetValue(key, view, view.Parent, ContextualObject.GetTypedStyleId(view, key), ContextualObject.GetTypedKey(type ?? view.GetType(), key), cascades);
示例#22
0
 public static T GetEnvironment <T>(this View view, Type type, string key, ControlState state, bool cascades = true)
 {
     key = ContextualObject.GetControlStateKey(state, key);
     return(view.GetEnvironment <T>(type, key, cascades));
 }