public void TogglePrayed(bool prayed) { // if the prayer state is changing if (prayed != Prayed) { Prayed = prayed; uint currColor = 0; uint targetColor = 0; // if we are ACTIVATING prayed if (prayed == true) { // update the circle color and send an analytic RockApi.Put_PrayerRequests_Prayed(PrayerRequest.Id, null); currColor = 0; targetColor = PrayerConfig.PrayedForColor; PrayerActionCircle.Layer.BorderWidth = 0; PrayerActionButton.SetTitleColor(Rock.Mobile.UI.Util.GetUIColor(0xFFFFFFFF), UIControlState.Normal); PrayerActionButton.SetTitle(PrayerStrings.Prayer_After, UIControlState.Normal); PrayerActionButton.SizeToFit( ); } else { // otherwise just update the color currColor = PrayerConfig.PrayedForColor; targetColor = 0; PrayerActionCircle.Layer.BorderWidth = 1; PrayerActionButton.SetTitleColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor), UIControlState.Normal); PrayerActionButton.SetTitle(PrayerStrings.Prayer_Before, UIControlState.Normal); PrayerActionButton.SizeToFit( ); } PrayerActionButton.SizeToFit( ); PositionPrayedLabel( ); // animate the circle color to its new target SimpleAnimator_Color colorAnim = new SimpleAnimator_Color(currColor, targetColor, .35f, delegate(float percent, object value) { PrayerActionCircle.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor((uint)value); }, null); colorAnim.Start( ); } }
public PrayerCard(Rock.Client.PrayerRequest prayer, CGRect bounds) { //setup the actual "card" outline View = PlatformView.Create( ); View.Bounds = new System.Drawing.RectangleF((float)bounds.X, (float)bounds.Y, (float)bounds.Width, (float)bounds.Height); View.BackgroundColor = ControlStylingConfig.BG_Layer_Color; View.BorderColor = ControlStylingConfig.BG_Layer_BorderColor; View.CornerRadius = ControlStylingConfig.Button_CornerRadius; View.BorderWidth = ControlStylingConfig.BG_Layer_BorderWidth; // ensure we clip children ((UIView)View.PlatformNativeObject).ClipsToBounds = true; // setup the prayer request text field PrayerText = new PrayerTextView( ); PrayerText.Editable = false; PrayerText.BackgroundColor = UIColor.Clear; PrayerText.Layer.AnchorPoint = new CGPoint(0, 0); PrayerText.DelaysContentTouches = false; // don't allow delaying touch, we need to forward it PrayerText.TextColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor); PrayerText.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); PrayerText.TextContainerInset = UIEdgeInsets.Zero; PrayerText.TextContainer.LineFragmentPadding = 0; // setup the bottom prayer button, and its fill-in circle PrayerActionButton = UIButton.FromType(UIButtonType.Custom); PrayerActionButton.Layer.AnchorPoint = new CGPoint(0, 0); PrayerActionButton.SetTitle(PrayerStrings.Prayer_Before, UIControlState.Normal); PrayerActionButton.SetTitleColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor), UIControlState.Normal); PrayerActionButton.SetTitleColor(Rock.Mobile.UI.Util.GetUIColor(Rock.Mobile.Graphics.Util.ScaleRGBAColor(ControlStylingConfig.TextField_PlaceholderTextColor, 2, false)), UIControlState.Highlighted); PrayerActionButton.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize); PrayerActionButton.SizeToFit( ); PrayerActionCircle = new UIView( ); PrayerActionCircle.Bounds = new CGRect(0, 0, 100, 100); PrayerActionCircle.Layer.CornerRadius = PrayerActionCircle.Bounds.Width / 2; PrayerActionCircle.Layer.BorderWidth = 1; PrayerActionCircle.Layer.BorderColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor).CGColor; PrayerActionCircle.Layer.AnchorPoint = new CGPoint(0, 0); PrayerActionButton.TouchUpInside += (object sender, EventArgs e) => { TogglePrayed(true); }; // setup the name field NameLayer = new UIView( ); NameLayer.Layer.AnchorPoint = new CGPoint(0, 0); NameLayer.Layer.BorderColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_Color).CGColor; NameLayer.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor); Name = new UILabel( ); Name.Layer.AnchorPoint = new CGPoint(0, 0); Name.TextColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_ActiveTextColor); Name.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(ControlStylingConfig.Font_Bold, ControlStylingConfig.Medium_FontSize); Name.BackgroundColor = UIColor.Clear; Name.LineBreakMode = UILineBreakMode.TailTruncation; // setup the date field DateLayer = new UIView( ); DateLayer.Layer.AnchorPoint = new CGPoint(0, 0); DateLayer.Layer.BorderWidth = 1; DateLayer.Layer.BorderColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_Color).CGColor; DateLayer.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor); Date = new UILabel( ); Date.Layer.AnchorPoint = new CGPoint(0, 0); Date.TextColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_ActiveTextColor); Date.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(ControlStylingConfig.Font_Light, ControlStylingConfig.Small_FontSize); Date.BackgroundColor = UIColor.Clear; // setup the category field CategoryLayer = new UIView( ); CategoryLayer.Layer.AnchorPoint = new CGPoint(0, 0); CategoryLayer.Layer.BorderWidth = 1; CategoryLayer.Layer.BorderColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_Color).CGColor; CategoryLayer.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor); Category = new UILabel( ); Category.Layer.AnchorPoint = new CGPoint(0, 0); Category.TextColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_ActiveTextColor); Category.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(ControlStylingConfig.Font_Light, ControlStylingConfig.Small_FontSize); Category.BackgroundColor = UIColor.Clear; Category.LineBreakMode = UILineBreakMode.TailTruncation; Category.AdjustsFontSizeToFitWidth = false; // add the controls UIView nativeView = View.PlatformNativeObject as UIView; nativeView.AddSubview(NameLayer); nativeView.AddSubview(Name); nativeView.AddSubview(CategoryLayer); nativeView.AddSubview(Category); nativeView.AddSubview(DateLayer); nativeView.AddSubview(Date); nativeView.AddSubview(PrayerText); nativeView.AddSubview(PrayerActionCircle); nativeView.AddSubview(PrayerActionButton); PrayerText.Parent = nativeView; SetPrayer(prayer); }