Use builder pattern for FontStyles
authorLukasz Stanislawski <lukasz.stanislawski@gmail.com>
Fri, 3 Apr 2020 12:51:32 +0000 (14:51 +0200)
committerLukasz Stanislawski <lukasz.stanislawski@gmail.com>
Fri, 3 Apr 2020 13:12:30 +0000 (15:12 +0200)
This allow to mix styles if required.

Oobe/Oobe.Terms/Views/TermsView.cs
Oobe/Oobe.Welcome/WelcomeStep.cs
Oobe/OobeCommon/Styles/FontStyles.cs
Oobe/OobeLanguage/LanguageStep.cs
Oobe/OobeRegion/RegionStep.cs

index d10154924069ed039794624b3e8ce696c18842f6..730f836294a1eb537bbd19975cfcee354717aa2d 100644 (file)
@@ -34,7 +34,7 @@ namespace Oobe.Terms.Views
             title.TextColor = new Color(0, 20.0f / 255.0f, 71.0f / 255.0f, 1.0f);
             title.PixelSize = 48.0f;
             title.FontFamily = "BreezeSans";
-            title.FontStyle = FontsStyles.Light();
+            title.FontStyle = new PropertyMap().AddLightFontStyle();
 
             View bounding = new View();
             bounding.BackgroundImage = NUIApplication.Current.DirectoryInfo.Resource + "Rectangle 861.svg";
index 8acf083b5ad45b2b7a6666c47f74aa0e246f7c31..521792f3b1cab0649a2108c450f273ed40d72659 100644 (file)
@@ -20,7 +20,7 @@ namespace Oobe.Welcome
             title.PointSize = 48.0f;\r
             title.HorizontalAlignment = HorizontalAlignment.Center;\r
             title.FontFamily = "BreezeSans";\r
-            title.FontStyle = FontsStyles.Light();\r
+            title.FontStyle = new PropertyMap().AddLightFontStyle();\r
 \r
             TextLabel content = new TextLabel();\r
             content.Position2D = new Position2D(81, 247);\r
index 38febd49df905f26a765a3a6c483c99200e84b3c..2dfd32039b9188a3953a61d9b1462141a8a1717a 100644 (file)
@@ -4,26 +4,19 @@ namespace Oobe.Common.Styles
 {
     public static class FontsStyles
     {
-        private static PropertyMap light;
+        public static PropertyMap AddLightFontStyle(this PropertyMap propertyMap)
+        {
+            return propertyMap.Add("weight", new PropertyValue("light"));
+        }
 
-        public static PropertyMap Light()
+        public static PropertyMap AddRegularFontStyle(this PropertyMap propertyMap)
         {
-            if (light == null)
-            {
-                light = new PropertyMap();
-                light.Add("weight", new PropertyValue("light"));
-            }
-            return light;
+            return propertyMap.Add("weight", new PropertyValue("regular"));
         }
 
-        public static PropertyMap Regular()
+        public static PropertyMap AddBoldFontStyle(this PropertyMap propertyMap)
         {
-            if (light == null)
-            {
-                light = new PropertyMap();
-                light.Add("weight", new PropertyValue("regular"));
-            }
-            return light;
+            return propertyMap.Add("weight", new PropertyValue("bold"));
         }
     }
-}
\ No newline at end of file
+}
index 982514e9669231250da4e8e4b1aecc04d17414c4..9964ae615d8d91a3594834b2949c434ec13293b2 100644 (file)
@@ -39,7 +39,7 @@ namespace Oobe.Language
             title.Ellipsis = false;\r
             title.PixelSize = 48.0f;\r
             title.FontFamily = "BreezeSans";\r
-            title.FontStyle = FontsStyles.Light();\r
+            title.FontStyle = new PropertyMap().AddLightFontStyle();\r
 \r
             var carousel = new CarouselPicker(CarouselPickerStyles.Default);\r
             carousel.Position2D = new Position2D(412, 242);\r
index e7ac232c31e73e403a2e45bb1a5e56af1af0ad5e..127052df3d5f33dcc73a315d818c62531312e849 100644 (file)
@@ -34,7 +34,7 @@ namespace Oobe.Region
             title.Ellipsis = false;\r
             title.PixelSize = 48.0f;\r
             title.FontFamily = "BreezeSans";\r
-            title.FontStyle = FontsStyles.Light();\r
+            title.FontStyle = new PropertyMap().AddLightFontStyle();\r
 \r
             var carousel = new CarouselPicker(CarouselPickerStyles.Default);\r
             carousel.Position2D = new Position2D(412, 242);\r