예제 #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));
 }