Пример #1
0
                    static float PrayerActionDimension = 100;//Rock.Mobile.Graphics.Util.UnitToPx( 50 );

                    public PrayerCard(Rock.Client.PrayerRequest prayer, RectangleF bounds)
                    {
                        PrayerRequest = prayer;

                        View                 = PlatformView.Create( );
                        View.Bounds          = bounds;
                        View.BackgroundColor = ControlStylingConfig.BG_Layer_Color;
                        View.BorderColor     = ControlStylingConfig.BG_Layer_BorderColor;
                        View.CornerRadius    = ControlStylingConfig.Button_CornerRadius;
                        View.BorderWidth     = ControlStylingConfig.BG_Layer_BorderWidth;

                        // create a vertically oriented linearLayout that will act as our root
                        RelativeLayout root = new RelativeLayout(Rock.Mobile.PlatformSpecific.Android.Core.Context);

                        //root.SetBackgroundColor( Android.Graphics.Color.GreenYellow );
                        root.LayoutParameters = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);


                        // create the bottom prayer layout
                        PrayerActionSize = new System.Drawing.SizeF(Rock.Mobile.Graphics.Util.UnitToPx(PrayerActionDimension),
                                                                    Rock.Mobile.Graphics.Util.UnitToPx(PrayerActionDimension));


                        // create the layout that will contain the circle, button and label
                        PrayerActionLayout = new RelativeLayout(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                        //frameLayout.SetBackgroundColor( Android.Graphics.Color.Aqua );
                        PrayerActionLayout.LayoutParameters = new LinearLayout.LayoutParams((int)PrayerActionSize.Width, (int)PrayerActionSize.Height);
                        ((LinearLayout.LayoutParams)PrayerActionLayout.LayoutParameters).Weight = 1;
                        root.AddView(PrayerActionLayout);


                        // Pray Button
                        PrayerActionButton                  = new Button(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                        PrayerActionButton.Enabled          = false;
                        PrayerActionButton.Background       = null;
                        PrayerActionButton.LayoutParameters = new RelativeLayout.LayoutParams((int)PrayerActionSize.Width, (int)PrayerActionSize.Height);
                        //Pray.SetBackgroundColor( Android.Graphics.Color.Green );
                        PrayerActionLayout.AddView(PrayerActionButton);


                        // Layout for the text and circle
                        PrayerActionCircle             = new Rock.Mobile.PlatformSpecific.Android.Graphics.CircleView(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                        PrayerActionCircle.Color       = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor);
                        PrayerActionCircle.StrokeWidth = 1;
                        //PrayerActionCircle.SetBackgroundColor( Android.Graphics.Color.Blue );
                        PrayerActionCircle.LayoutParameters = new RelativeLayout.LayoutParams((int)PrayerActionSize.Width, (int)PrayerActionSize.Height);
                        PrayerActionLayout.AddView(PrayerActionCircle);

                        // Setup the "I Prayed" label
                        PrayerActionLabel = new TextView(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                        PrayerActionLabel.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                        PrayerActionLabel.Text             = PrayerStrings.Prayer_Before;
                        PrayerActionLabel.Gravity          = GravityFlags.Center;
                        //PrayerActionLabel.SetBackgroundColor( Android.Graphics.Color.Orange );
                        PrayerActionLabel.SetTypeface(Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont(ControlStylingConfig.Font_Regular), TypefaceStyle.Normal);
                        PrayerActionLabel.SetTextSize(ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize);
                        PrayerActionLabel.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor));
                        PrayerActionLayout.AddView(PrayerActionLabel);

                        PositionPrayedLabel( );

                        PrayerActionButton.Click += (object sender, EventArgs e) =>
                        {
                            TogglePrayed(true);
                        };
                        //

                        // add the controls
                        ViewGroup nativeView = View.PlatformNativeObject as ViewGroup;

                        nativeView.AddView(root);


                        // add it to this view
                        PrayerLayout = new PrayerLayoutRender(new RectangleF(bounds.Left, bounds.Top, bounds.Width, bounds.Height - PrayerActionSize.Height),
                                                              PrayerActionSize.Height * .75f,
                                                              prayer);
                        nativeView.AddView(PrayerLayout.LinearLayout);

                        PrayerActionButton.Enabled = true;
                    }
                    static float PrayerActionDimension = 100;//Rock.Mobile.Graphics.Util.UnitToPx( 50 );

                    public PrayerCard( Rock.Client.PrayerRequest prayer, RectangleF bounds )
                    {
                        PrayerRequest = prayer;

                        View = PlatformView.Create( );
                        View.Bounds = bounds;
                        View.BackgroundColor = ControlStylingConfig.BG_Layer_Color;
                        View.BorderColor = ControlStylingConfig.BG_Layer_BorderColor;
                        View.CornerRadius = ControlStylingConfig.Button_CornerRadius;
                        View.BorderWidth = ControlStylingConfig.BG_Layer_BorderWidth;

                        // create a vertically oriented linearLayout that will act as our root
                        RelativeLayout root = new RelativeLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                        //root.SetBackgroundColor( Android.Graphics.Color.GreenYellow );
                        root.LayoutParameters = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent );


                        // create the bottom prayer layout
                        PrayerActionSize = new System.Drawing.SizeF( Rock.Mobile.Graphics.Util.UnitToPx( PrayerActionDimension ), 
                                                                     Rock.Mobile.Graphics.Util.UnitToPx( PrayerActionDimension ) );


                        // create the layout that will contain the circle, button and label
                        PrayerActionLayout = new RelativeLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                        //frameLayout.SetBackgroundColor( Android.Graphics.Color.Aqua );
                        PrayerActionLayout.LayoutParameters = new LinearLayout.LayoutParams( (int)PrayerActionSize.Width, (int)PrayerActionSize.Height );
                        ((LinearLayout.LayoutParams)PrayerActionLayout.LayoutParameters).Weight = 1;
                        root.AddView( PrayerActionLayout );


                        // Pray Button
                        PrayerActionButton = new Button( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                        PrayerActionButton.Enabled = false;
                        PrayerActionButton.Background = null;
                        PrayerActionButton.LayoutParameters = new RelativeLayout.LayoutParams( (int)PrayerActionSize.Width, (int)PrayerActionSize.Height );
                        //Pray.SetBackgroundColor( Android.Graphics.Color.Green );
                        PrayerActionLayout.AddView( PrayerActionButton );
                            

                        // Layout for the text and circle
                        PrayerActionCircle = new Rock.Mobile.PlatformSpecific.Android.Graphics.CircleView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                        PrayerActionCircle.Color = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor );
                        PrayerActionCircle.StrokeWidth = 1;
                        //PrayerActionCircle.SetBackgroundColor( Android.Graphics.Color.Blue );
                        PrayerActionCircle.LayoutParameters = new RelativeLayout.LayoutParams( (int)PrayerActionSize.Width, (int)PrayerActionSize.Height );
                        PrayerActionLayout.AddView( PrayerActionCircle );

                        // Setup the "I Prayed" label
                        PrayerActionLabel = new TextView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                        PrayerActionLabel.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
                        PrayerActionLabel.Text = PrayerStrings.Prayer_Before;
                        PrayerActionLabel.Gravity = GravityFlags.Center;
                        //PrayerActionLabel.SetBackgroundColor( Android.Graphics.Color.Orange );
                        PrayerActionLabel.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Regular ), TypefaceStyle.Normal );
                        PrayerActionLabel.SetTextSize( ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize );
                        PrayerActionLabel.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor ) );
                        PrayerActionLayout.AddView( PrayerActionLabel );

                        PositionPrayedLabel( );

                        PrayerActionButton.Click += (object sender, EventArgs e) => 
                            {
                                TogglePrayed( true );
                            };
                        //

                        // add the controls
                        ViewGroup nativeView = View.PlatformNativeObject as ViewGroup;
                        nativeView.AddView( root );


                        // add it to this view
                        PrayerLayout = new PrayerLayoutRender( new RectangleF( bounds.Left, bounds.Top, bounds.Width, bounds.Height - PrayerActionSize.Height ), 
                                                               PrayerActionSize.Height * .75f, 
                                                               prayer );
                        nativeView.AddView( PrayerLayout.LinearLayout );

                        PrayerActionButton.Enabled = true;
                    }