Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add default coloring of RowBadgeElement via Constructor. Also provide…

… the user with standard badge colors based off of Twitter's Bootstrap. Updated example showing off the new functionality.
  • Loading branch information...
commit 2ca7be9d2652424850f39078631d81e1008989ce 1 parent ad9d2c1
@mps mps authored
Showing with 44 additions and 1 deletion.
  1. +41 −0 ElementPack/RowBadgeElement.cs
  2. +3 −1 Sample/AppDelegate.cs
View
41 ElementPack/RowBadgeElement.cs
@@ -60,12 +60,43 @@ public RowBadgeElement (string caption, NSAction tapped) : this(caption)
{
Tapped += tapped;
}
+
+ public RowBadgeElement (string caption, string badgeValue, string hexColor) : this(caption, badgeValue)
+ {
+ int red = 0, green = 0, blue = 0;
+
+ if (hexColor.Length == 6) {
+ red = int.Parse (hexColor.Substring (0, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
+ green = int.Parse (hexColor.Substring (2, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
+ blue = int.Parse (hexColor.Substring (4, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
+ } else if (hexColor.Length == 3) {
+ red = int.Parse (
+ hexColor.Substring (0, 1) + hexColor.Substring (0, 1),
+ System.Globalization.NumberStyles.AllowHexSpecifier
+ );
+ green = int.Parse (
+ hexColor.Substring (1, 1) + hexColor.Substring (1, 1),
+ System.Globalization.NumberStyles.AllowHexSpecifier
+ );
+ blue = int.Parse (
+ hexColor.Substring (2, 1) + hexColor.Substring (2, 1),
+ System.Globalization.NumberStyles.AllowHexSpecifier
+ );
+ }
+
+ this.Color = UIColor.FromRGB (red, green, blue);
+ }
public RowBadgeElement (string caption, string badgeValue, NSAction tapped) : this(caption, badgeValue)
{
Tapped += tapped;
}
+ public RowBadgeElement (string caption, string badgeValue, NSAction tapped, string hexColor) : this(caption, badgeValue, hexColor)
+ {
+ Tapped += tapped;
+ }
+
public event NSAction Tapped;
public override UITableViewCell GetCell (UITableView tv)
@@ -248,5 +279,15 @@ public override void SetHighlighted (bool highlighted, bool animated)
}
}
}
+
+ public static class BadgeColors
+ {
+ public const string DEFAULT = "999";
+ public const string SUCCESS = "468847";
+ public const string WARNING = "F89406";
+ public const string IMPORTANT = "B94A48";
+ public const string INFO = "3A87AD";
+ public const string INVERSE = "333";
+ }
}
View
4 Sample/AppDelegate.cs
@@ -29,6 +29,8 @@ public override bool FinishedLaunching (UIApplication app, NSDictionary options)
new RowBadgeElement ("Colored", "color", () => {}) {
Color = UIColor.FromRGBA (0.792f, 0.197f, 0.219f, 1f)
},
+ new RowBadgeElement ("Colored with default coloring", "5", BadgeColors.WARNING) {
+ },
new RowBadgeElement ("With radius", "9f", () => {}) {
Radius = 9f,
Color = UIColor.FromRGBA (0.197f, 0.592f, 0.219f, 1f)
@@ -41,7 +43,7 @@ public override bool FinishedLaunching (UIApplication app, NSDictionary options)
BackgroundColor = UIColor.Red,
Radius = 9f,
Color = UIColor.FromRGBA (0.197f, 0.592f, 0.219f, 1f)
- },
+ }
};
var counterSection = new Section("Counter Elements") {

1 comment on commit 2ca7be9

@ziva006

Can you add icon in front of the rowbadgeelement as well?

Please sign in to comment.
Something went wrong with that request. Please try again.