void UpdateStyle()
        {
            var view    = Control ?? Container;
            var bgColor = (Element as VisualElement)?.BackgroundColor ?? Color.Transparent;

            PaintDrawable    paint    = new PaintDrawable(bgColor.ToAndroid());
            GradientDrawable gradient = new GradientDrawable();

            paint.SetCornerRadius(Forms.Context.ToPixels((double)Element.GetValue(ViewEffect.CornerRadiusProperty)));
            gradient.SetCornerRadius(Forms.Context.ToPixels((double)Element.GetValue(ViewEffect.CornerRadiusProperty)));
            gradient.SetColor(Color.Transparent.ToAndroid());
            gradient.SetOrientation(GradientDrawable.Orientation.LeftRight);
            gradient.SetShape(ShapeType.Rectangle);

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                view.Elevation    = Forms.Context.ToPixels((double)Element.GetValue(ViewEffect.ShadowOffsetYProperty));
                view.TranslationZ = Forms.Context.ToPixels((double)Element.GetValue(ViewEffect.ShadowOffsetYProperty));
            }

            gradient.SetStroke((int)Forms.Context.ToPixels(ViewEffect.GetBorderWidth(Element)), ((Color)Element.GetValue(ViewEffect.BorderColorProperty)).ToAndroid());
            LayerDrawable layer = new LayerDrawable(
                new Drawable[]
            {
                paint, gradient
            });

            view.SetBackground(layer);
        }
        public static void SetActionBarTheme(Activity context, FlatTheme theme, bool dark)
        {
            var color1 = theme.LightAccentColor;
            var color2 = theme.BackgroundColor;

            if (dark)
            {
                color1 = theme.BackgroundColor;
                color2 = theme.DarkAccentColor;
            }

            var front    = new PaintDrawable(color1);
            var bottom   = new PaintDrawable(color2);
            var d        = new Drawable[] { bottom, front };
            var drawable = new LayerDrawable(d);

            drawable.SetLayerInset(1, 0, 0, 0, 3);

            var actionBar = context.ActionBar;

            actionBar.SetBackgroundDrawable(drawable);

            // invalidating action bar
            actionBar.Title = actionBar.Title;
        }
Example #3
0
        protected override void OnAttached()
        {
            try
            {
                var view = Control ?? Container;

                var effect = Element.Effects.OfType <GradientEffect>()?.FirstOrDefault(e => e is GradientEffect);

                if (effect == null)
                {
                    return;
                }

                var colors = new int[]
                {
                    effect.StartColor.ToAndroid().ToArgb(),
                    effect.EndColor.ToAndroid().ToArgb()
                };

                var paint = new PaintDrawable
                {
                    Shape = new RectShape()
                };

                paint.SetShaderFactory(new GradientShaderFactory(colors, effect.Direction));

                view.SetBackground(paint);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public NotificationView(Context context) : base(context)
        {
            drawable             = new PaintDrawable();
            drawable.Paint.Color = Color.White;
            drawable.SetCornerRadius(5);

            SetBackgroundDrawable(drawable);

            var imageView = new ImageView(context);

            imageView.SetImageResource(Resource.Drawable.Icon);

            AddView(imageView);

            var textView = new TextView(context);

            textView.Text = "hello machina";
            textView.SetTextColor(Color.Black);
            //textView.Layout(150,0,50,0);
            //textView.OffsetLeftAndRight(50);

            //var prms = new RelativeLayout(context);
            //prms.off = 50;
            AddView(textView /*,prms*/);
        }
Example #5
0
        static PaintDrawable CreateBadgeBackground(Context context, XColor color)
        {
            var badgeFrameLayoutBackground = new PaintDrawable();

            badgeFrameLayoutBackground.Paint.Color =
                color.IsDefault ? XColor.FromRgb(255, 59, 48).ToAndroid() : color.ToAndroid();

            badgeFrameLayoutBackground.Shape = new RectShape();
            badgeFrameLayoutBackground.SetCornerRadius(TypedValue.ApplyDimension(ComplexUnitType.Dip, 8,
                                                                                 context.Resources.DisplayMetrics));

            return(badgeFrameLayoutBackground);
        }
        protected override void OnAttached()
        {
            try
            {
                var effect = (GradientEffect)Element.Effects.FirstOrDefault(e => e is GradientEffect);

                var nativeView = Control ?? Container;

                var colors = effect.ColorList.Select(i => i.ToAndroid().ToArgb()).ToArray();

                var paint = new PaintDrawable();
                paint.Shape = new RectShape();
                paint.SetShaderFactory(new GradientShaderFactory(colors, effect.LocationList, Shader.TileMode.Mirror, effect.Mode));

                nativeView.SetBackgroundDrawable(paint);
            }
            catch (Exception ex)
            {
            }
        }
        private static Drawable GetBackgroundDrawable(Brush background, Windows.Foundation.Rect drawArea, Paint fillPaint, Path maskingPath = null)
        {
            if (background is ImageBrush)
            {
                throw new InvalidOperationException($"This method should not be called for ImageBrush, use {nameof(DispatchSetImageBrushAsBackground)} instead");
            }

            if (maskingPath == null)
            {
                var solidBrush = background as SolidColorBrush;

                if (solidBrush != null)
                {
                    return(new ColorDrawable(solidBrush.ColorWithOpacity));
                }

                if (fillPaint != null)
                {
                    var linearDrawable = new PaintDrawable();
                    var drawablePaint  = linearDrawable.Paint;
                    drawablePaint.Color = fillPaint.Color;
                    drawablePaint.SetShader(fillPaint.Shader);
                    SetDrawableAlpha(linearDrawable, fillPaint.Alpha);

                    return(linearDrawable);
                }

                return(null);
            }

            var drawable = new PaintDrawable();

            drawable.Shape = new PathShape(maskingPath, (float)drawArea.Width, (float)drawArea.Height);
            var paint = drawable.Paint;

            paint.Color = fillPaint.Color;
            paint.SetShader(fillPaint.Shader);
            SetDrawableAlpha(drawable, fillPaint.Alpha);
            return(drawable);
        }
        public static void SetTheme(SeekBar seekBar, FlatTheme theme)
        {
            // setting thumb
            var thumb = new PaintDrawable(theme.DarkAccentColor);

            thumb.SetCornerRadius(15);
            thumb.SetIntrinsicWidth(30);
            thumb.SetIntrinsicHeight(30);
            seekBar.SetThumb(thumb);

            // progress
            var progress = new PaintDrawable(theme.BackgroundColor);

            progress.SetCornerRadius(10);
            progress.SetIntrinsicHeight(10);
            progress.SetIntrinsicWidth(5);
            progress.SetDither(true);
            var progressClip = new ClipDrawable(progress, GravityFlags.Left, ClipDrawableOrientation.Horizontal);

            // secondary progress
            var secondary = new PaintDrawable(theme.LightAccentColor);

            secondary.SetCornerRadius(10);
            secondary.SetIntrinsicHeight(10);
            var secondaryProgressClip = new ClipDrawable(secondary, GravityFlags.Left, ClipDrawableOrientation.Horizontal);

            // background
            PaintDrawable background = new PaintDrawable(theme.VeryLightAccentColor);

            background.SetCornerRadius(10);
            background.SetIntrinsicHeight(10);

            // applying drawable
            LayerDrawable ld = (LayerDrawable)seekBar.ProgressDrawable;

            ld.SetDrawableByLayerId(Android.Resource.Id.Background, background);
            ld.SetDrawableByLayerId(Android.Resource.Id.Progress, progressClip);
            ld.SetDrawableByLayerId(Android.Resource.Id.SecondaryProgress, secondaryProgressClip);
        }
Example #9
0
        //Functions
        public void SetContent(Video video, PlayList playlist)
        {
            var lblSize = Device.GetNamedSize(NamedSize.Large, typeof(Label));
            var btnSize = Device.GetNamedSize(NamedSize.Large, typeof(Button));

            //view objects
#if __IOS__
            innerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(4, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(4, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };
#endif
#if __ANDROID__
            innerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(4, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(5, GridUnitType.Star)
                    }
                }
            };
            buttonGrid = new Grid
            {
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };
#endif

            outerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

#if __ANDROID__
            var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174));
            pd.SetCornerRadius(100);

            var pdRed = new PaintDrawable(Android.Graphics.Color.Red);
            pdRed.SetCornerRadius(100);

            androidVideoNameLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidVideoNameLbl.Text     = video.Name;
            androidVideoNameLbl.Typeface = Constants.COMMONFONT;
            androidVideoNameLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 100);
            androidVideoNameLbl.SetTextColor(Android.Graphics.Color.AntiqueWhite);
            androidVideoNameLbl.Gravity = Android.Views.GravityFlags.Center;
            androidVideoNameLbl.SetTypeface(androidVideoNameLbl.Typeface, Android.Graphics.TypefaceStyle.Bold);

            androidVideoDescriptionLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidVideoDescriptionLbl.Text     = video.Description;
            androidVideoDescriptionLbl.Typeface = Constants.COMMONFONT;
            androidVideoDescriptionLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 50);
            androidVideoDescriptionLbl.SetTextColor(Android.Graphics.Color.Black);
            androidVideoDescriptionLbl.Gravity = Android.Views.GravityFlags.Start;

            androidPlayImgBtn = new Android.Widget.ImageButton(MainApplication.ActivityContext);
            androidPlayImgBtn.SetAdjustViewBounds(true);
            androidPlayImgBtn.SetImageResource(2130837817);
            androidPlayImgBtn.SetBackground(pd);
            androidPlayImgBtn.Click += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await PlayAndroidVideo(sender, e);

                ToggleButtons();
            };

            androidImgDeleteBtn = new Android.Widget.ImageButton(MainApplication.ActivityContext);
            androidImgDeleteBtn.SetAdjustViewBounds(true);
            androidImgDeleteBtn.SetImageResource(2130837823);
            androidImgDeleteBtn.SetBackground(pdRed);
            androidImgDeleteBtn.Click += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await DeleteFromPlaylist(sender, e);

                ToggleButtons();
            };

            androidQualityBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidQualityBtn.Text     = "SD";
            androidQualityBtn.Typeface = Constants.COMMONFONT;
            androidQualityBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidQualityBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidQualityBtn.SetBackground(pd);
            androidQualityBtn.Gravity = Android.Views.GravityFlags.Center;
            androidQualityBtn.SetAllCaps(false);
            androidQualityBtn.Click += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await ChangeVideoQuality(sender, e);

                ToggleButtons();
            };

            contentViewNameLbl                = new ContentView();
            contentViewNameLbl.Content        = androidVideoNameLbl.ToView();
            contentViewDescriptionLbl         = new ContentView();
            contentViewDescriptionLbl.Content = androidVideoDescriptionLbl.ToView();
            contentViewPlayBtn                = new ContentView();
            contentViewPlayBtn.Content        = androidPlayImgBtn.ToView();
            contentViewDeleteBtn              = new ContentView();
            contentViewDeleteBtn.Content      = androidImgDeleteBtn.ToView();
            contentViewQualityBtn             = new ContentView();
            contentViewQualityBtn.Content     = androidQualityBtn.ToView();
#endif

            backBtn = new Button
            {
                Style = (Style)Application.Current.Resources["common-red-btn"],
                Image = "back.png"
            };
            videoNameLbl = new Label
            {
                Text                    = video.Name,
                FontFamily              = "AmericanTypewriter-Bold",
                FontSize                = lblSize,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                TextColor               = Color.White
            };

            videoDescription = new Label
            {
                Text                    = video.Description,
                FontFamily              = "AmericanTypewriter-Bold",
                VerticalTextAlignment   = TextAlignment.Start,
                HorizontalTextAlignment = TextAlignment.Start,
                FontSize                = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                LineBreakMode           = LineBreakMode.WordWrap,
            };

            videoDescriptionScrollView = new ScrollView
            {
                Padding     = 0,
                Orientation = ScrollOrientation.Vertical,
#if __ANDROID__
                Content           = contentViewDescriptionLbl,
                IsClippedToBounds = true
#endif
#if __IOS__
                Content = videoDescription,
#endif
            };

            videoImage = new Image
            {
                Source = video.Image,
                Aspect = Aspect.AspectFill
            };
            videoFrame = new Frame
            {
                Content         = videoImage,
                BorderColor     = Color.Black,
                BackgroundColor = Color.Black,
                HasShadow       = false,
                Padding         = 3
            };
            playBtn = new Button
            {
                Style = (Style)Application.Current.Resources["common-blue-btn"],
                Image = "play.png"
            };
            deleteBtn = new Button
            {
                Style = (Style)Application.Current.Resources["common-delete-btn"]
            };

            qualityBtn = new Button
            {
                Style      = (Style)Application.Current.Resources["common-blue-btn"],
                Text       = "SD",
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = btnSize * 2,
            };

            //Events
            backBtn.Clicked += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await Navigation.PopModalAsync();

                ToggleButtons();
            };
            deleteBtn.Clicked += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await DeleteFromPlaylist(sender, e);

                ToggleButtons();
            };
            qualityBtn.Clicked += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await ChangeVideoQuality(sender, e);

                ToggleButtons();
            };
#if __IOS__
            playBtn.Clicked += PlayIOSVideo;
#endif


#if __ANDROID__
            //building grid
            buttonGrid.Children.Add(contentViewPlayBtn, 0, 0);
            buttonGrid.Children.Add(contentViewDeleteBtn, 1, 0);
            buttonGrid.Children.Add(contentViewQualityBtn, 2, 0);

            innerGrid.Children.Add(videoFrame, 0, 0);
            innerGrid.Children.Add(contentViewNameLbl, 0, 0);
            innerGrid.Children.Add(buttonGrid, 0, 1);

            //XAMARIN BUG - ADDING SCROLLVIEW BEFORE OTHER ELEMENTS WILL CAUSE CONTENTS TO OVERFLOW.. ADD TO END OF LAYOUT..
            innerGrid.Children.Add(videoDescriptionScrollView, 0, 2);
#endif
#if __IOS__
            //building grid
            innerGrid.Children.Add(videoFrame, 0, 0);
            Grid.SetColumnSpan(videoFrame, 4);
            innerGrid.Children.Add(videoNameLbl, 0, 0);
            Grid.SetColumnSpan(videoNameLbl, 4);
            innerGrid.Children.Add(playBtn, 0, 1);
            Grid.SetColumnSpan(playBtn, 3);
            innerGrid.Children.Add(qualityBtn, 3, 1);
            innerGrid.Children.Add(videoDescriptionScrollView, 0, 2);
            Grid.SetColumnSpan(videoDescriptionScrollView, 4);
            innerGrid.Children.Add(deleteBtn, 3, 3);
            innerGrid.Children.Add(backBtn, 0, 3);
            Grid.SetColumnSpan(backBtn, 3);
#endif
            outerGrid.Children.Add(innerGrid, 0, 0);

            Content = outerGrid;
        }
Example #10
0
        private void BuildPageObjects()
        {
            var lblSize = Device.GetNamedSize(NamedSize.Large, typeof(Label));
            var btnSize = Device.GetNamedSize(NamedSize.Large, typeof(Button));


            innerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(2, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                },
                ColumnDefinitions = new ColumnDefinitionCollection {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };
            outerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

#if __ANDROID__
            var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174));
            pd.SetCornerRadius(100);

            androidVideo1Lbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidVideo1Lbl.Text     = "Spider Guard Stuff!";
            androidVideo1Lbl.Typeface = Constants.COMMONFONT;
            androidVideo1Lbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
            androidVideo1Lbl.SetTextColor(Android.Graphics.Color.Rgb(241, 236, 206));
            androidVideo1Lbl.Gravity = Android.Views.GravityFlags.Center;
            androidVideo1Lbl.Click  += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                VideoData video = VimeoInfo.data[0];
                await Navigation.PushModalAsync(new VideoDetailPage(video));

                ToggleButtons();
            };
            androidVideo1Lbl.SetTypeface(androidVideo1Lbl.Typeface, Android.Graphics.TypefaceStyle.Bold);

            contentViewVideo1Lbl         = new ContentView();
            contentViewVideo1Lbl.Content = androidVideo1Lbl.ToView();

            androidVideo2Lbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidVideo2Lbl.Text     = "Spider Guard Stuff!";
            androidVideo2Lbl.Typeface = Constants.COMMONFONT;
            androidVideo2Lbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
            androidVideo2Lbl.SetTextColor(Android.Graphics.Color.Rgb(241, 236, 206));
            androidVideo2Lbl.Gravity = Android.Views.GravityFlags.Center;
            androidVideo2Lbl.Click  += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                VideoData video = VimeoInfo.data[1];
                await Navigation.PushModalAsync(new VideoDetailPage(video));

                ToggleButtons();
            };
            androidVideo2Lbl.SetTypeface(androidVideo2Lbl.Typeface, Android.Graphics.TypefaceStyle.Bold);


            contentViewVideo2Lbl         = new ContentView();
            contentViewVideo2Lbl.Content = androidVideo2Lbl.ToView();

            androidWhatsNewLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidWhatsNewLbl.Text     = "What's New";
            androidWhatsNewLbl.Typeface = Constants.COMMONFONT;
            androidWhatsNewLbl.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidWhatsNewLbl.SetTextColor(Android.Graphics.Color.Black);
            androidWhatsNewLbl.Gravity = Android.Views.GravityFlags.Center;

            contenViewWhatsNewLbl         = new ContentView();
            contenViewWhatsNewLbl.Content = androidWhatsNewLbl.ToView();

            androidPlayListLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidPlayListLbl.Text     = "Playlists";
            androidPlayListLbl.Typeface = Constants.COMMONFONT;
            androidPlayListLbl.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidPlayListLbl.SetTextColor(Android.Graphics.Color.Black);
            androidPlayListLbl.Gravity = Android.Views.GravityFlags.Center;

            contentViewPlayListLbl         = new ContentView();
            contentViewPlayListLbl.Content = androidPlayListLbl.ToView();

            androidAddPlaylistBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidAddPlaylistBtn.Text     = "Create";
            androidAddPlaylistBtn.Typeface = Constants.COMMONFONT;
            androidAddPlaylistBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidAddPlaylistBtn.SetBackground(pd);
            androidAddPlaylistBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidAddPlaylistBtn.Gravity = Android.Views.GravityFlags.Center;
            androidAddPlaylistBtn.SetAllCaps(false);
            androidAddPlaylistBtn.Click += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await Navigation.PushModalAsync(new PlaylistCreatePage());

                ToggleButtons();
            };

            androidViewPlaylistBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidViewPlaylistBtn.Text     = "View";
            androidViewPlaylistBtn.Typeface = Constants.COMMONFONT;
            androidViewPlaylistBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidViewPlaylistBtn.SetBackground(pd);
            androidViewPlaylistBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidViewPlaylistBtn.Gravity = Android.Views.GravityFlags.Center;
            androidViewPlaylistBtn.SetAllCaps(false);
            androidViewPlaylistBtn.Click += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await Navigation.PushModalAsync(new PlaylistViewPage());

                ToggleButtons();
            };
#endif
            whatsNewLbl = new Label
            {
                Text = "What's New",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 2,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize,
#endif
                VerticalTextAlignment   = TextAlignment.End,
                HorizontalTextAlignment = TextAlignment.Center
            };
            video1Image = new Image
            {
                Aspect = Aspect.AspectFill
            };
            video1Frame = new Frame
            {
                Content         = video1Image,
                BorderColor     = Color.Black,
                BackgroundColor = Color.Black,
                HasShadow       = false,
                Padding         = 3
            };
            video1Lbl = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize * .75,
#endif
                Text  = "Spider Guard Stuff!",
                Style = (Style)Application.Current.Resources["common-technique-lbl"]
            };
            video1Tap         = new TapGestureRecognizer();
            video1Tap.Tapped += async(sender, e) =>
            {
                ToggleButtons();
                VideoData video = VimeoInfo.data[0];
                await Navigation.PushModalAsync(new VideoDetailPage(video));

                ToggleButtons();
            };
            video1Lbl.GestureRecognizers.Add(video1Tap);
            video2Image = new Image
            {
                Aspect = Aspect.AspectFill
            };
            video2Frame = new Frame
            {
                Content         = video2Image,
                BorderColor     = Color.Black,
                BackgroundColor = Color.Black,
                HasShadow       = false,
                Padding         = 3
            };
            video2Lbl = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize * .75,
#endif
                Text  = "Spider Guard Stuff!",
                Style = (Style)Application.Current.Resources["common-technique-lbl"]
            };
            video2Tap         = new TapGestureRecognizer();
            video2Tap.Tapped += async(sender, e) =>
            {
                ToggleButtons();
                VideoData video = VimeoInfo.data[1];
                await Navigation.PushModalAsync(new VideoDetailPage(video));

                ToggleButtons();
            };
            video2Lbl.GestureRecognizers.Add(video2Tap);

            playListLbl = new Label
            {
                Text = "Playlists",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 2,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize,
#endif
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
            };

            addPlaylistBtn = new Button
            {
                Style = (Style)Application.Current.Resources["common-blue-btn"],
                Text  = "Create",
#if __IOS__
                FontSize = btnSize * 1.5,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = btnSize * .75,
                Margin     = -5,
#endif
            };
            viewPlaylistBtn = new Button
            {
                Style = (Style)Application.Current.Resources["common-blue-btn"],
                Text  = "View",
#if __IOS__
                FontSize = btnSize * 1.5,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = btnSize * .75,
                Margin     = -5,
#endif
            };

            timeOutLbl = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
#endif
                Text                    = "Network Has Timed Out! \n Click To Try Again!",
                LineBreakMode           = LineBreakMode.WordWrap,
                FontSize                = lblSize,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                HorizontalOptions       = LayoutOptions.CenterAndExpand,
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                TextColor               = Color.White
            };
            timeOutFrame = new Frame
            {
                Content           = timeOutLbl,
                BorderColor       = Color.Black,
                BackgroundColor   = Color.Black,
                HasShadow         = false,
                Padding           = 3,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand
            };
            timeOutTap         = new TapGestureRecognizer();
            timeOutTap.Tapped += (sender, e) =>
            {
                ToggleButtons();
                SetContent(this.account);
                ToggleButtons();
            };
            timeOutLbl.GestureRecognizers.Add(timeOutTap);
            activityIndicator = new ActivityIndicator
            {
                Style = (Style)Application.Current.Resources["common-activity-indicator"]
            };

            //events
            addPlaylistBtn.Clicked += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await Navigation.PushModalAsync(new PlaylistCreatePage());

                ToggleButtons();
            };
            viewPlaylistBtn.Clicked += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await Navigation.PushModalAsync(new PlaylistViewPage());

                ToggleButtons();
            };

            outerGrid.Children.Add(innerGrid, 0, 0);
            Content = outerGrid;
        }
Example #11
0
        private void BuildPageObjects()
        {
            var btnSize   = Device.GetNamedSize(NamedSize.Large, typeof(Button));
            var lblSize   = Device.GetNamedSize(NamedSize.Large, typeof(Label));
            var entrySize = Device.GetNamedSize(NamedSize.Large, typeof(Entry));

            stackLayout = new StackLayout();
            scrollView  = new ScrollView();
            buttonGrid  = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(3, GridUnitType.Star)
                    }
                }
            };

            headerLbl = new Label
            {
                Text = "Change Password",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 2,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize,
#endif
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalOptions         = LayoutOptions.StartAndExpand,
                HorizontalOptions       = LayoutOptions.CenterAndExpand
            };

            secretQuestionLbl = new Label
            {
                Text = _user.SecretQuestion,
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 1.5,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize * .75,
#endif
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalOptions       = LayoutOptions.FillAndExpand
            };

            secretQuestionEntry = new Entry
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = entrySize * 1.5,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = entrySize * .75,
#endif
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            newPasswordLbl = new Label
            {
                Text = "New Password",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 1.5,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize * .75,
#endif
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                HorizontalOptions       = LayoutOptions.CenterAndExpand
            };

            newPasswordEntry = new Entry
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = entrySize * 1.5,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = entrySize * .75,
#endif
                IsPassword        = true,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            backBtn = new Button
            {
                Image = "back.png",
                Style = (Style)Application.Current.Resources["common-red-btn"]
            };

            submitBtn = new Button
            {
                Style = (Style)Application.Current.Resources["common-blue-btn"],

#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = btnSize * 1.5,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = btnSize * .75,
#endif
                Text = "Submit"
            };

#if __ANDROID__
            var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174));
            pd.SetCornerRadius(100);

            innerGrid = new Grid();
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(2, GridUnitType.Star)
            });
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(2, GridUnitType.Star)
            });

            outerGrid = new Grid();
            outerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });

            androidSecretQuestionLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidSecretQuestionLbl.Text     = _user.SecretQuestion;
            androidSecretQuestionLbl.Typeface = Constants.COMMONFONT;
            androidSecretQuestionLbl.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidSecretQuestionLbl.SetTextColor(Android.Graphics.Color.Black);
            androidSecretQuestionLbl.Gravity = Android.Views.GravityFlags.Center;

            androidSecretQuestionEntry          = new Android.Widget.EditText(MainApplication.ActivityContext);
            androidSecretQuestionEntry.Typeface = Constants.COMMONFONT;
            androidSecretQuestionEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
            androidSecretQuestionEntry.SetTextColor(Android.Graphics.Color.Black);
            androidSecretQuestionEntry.Gravity   = Android.Views.GravityFlags.Start;
            androidSecretQuestionEntry.InputType = Android.Text.InputTypes.TextVariationShortMessage;

            androidNewPasswordLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidNewPasswordLbl.Text     = "New Password";
            androidNewPasswordLbl.Typeface = Constants.COMMONFONT;
            androidNewPasswordLbl.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidNewPasswordLbl.SetTextColor(Android.Graphics.Color.Black);
            androidNewPasswordLbl.Gravity = Android.Views.GravityFlags.Center;

            androidNewPasswordEntry          = new Android.Widget.EditText(MainApplication.ActivityContext);
            androidNewPasswordEntry.Typeface = Constants.COMMONFONT;
            androidNewPasswordEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
            androidNewPasswordEntry.SetTextColor(Android.Graphics.Color.Black);
            androidNewPasswordEntry.Gravity              = Android.Views.GravityFlags.Start;
            androidNewPasswordEntry.InputType            = Android.Text.InputTypes.TextVariationPassword;
            androidNewPasswordEntry.TransformationMethod = new PasswordTransformationMethod();

            androidSubmitBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidSubmitBtn.Text     = "Change Password";
            androidSubmitBtn.Typeface = Constants.COMMONFONT;
            androidSubmitBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidSubmitBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidSubmitBtn.SetBackground(pd);
            androidSubmitBtn.SetAllCaps(false);
            androidSubmitBtn.Click += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await ChangePassword(sender, e);

                ToggleButtons();
            };

            contentViewAndroidSecretQuestionLbl         = new ContentView();
            contentViewAndroidSecretQuestionLbl.Content = androidSecretQuestionLbl.ToView();

            contentViewAndroidSecretQuestionEntry         = new ContentView();
            contentViewAndroidSecretQuestionEntry.Content = androidSecretQuestionEntry.ToView();

            contentViewAndroidNewPasswordLbl         = new ContentView();
            contentViewAndroidNewPasswordLbl.Content = androidNewPasswordLbl.ToView();

            contentViewAndroidNewPasswordEntry         = new ContentView();
            contentViewAndroidNewPasswordEntry.Content = androidNewPasswordEntry.ToView();

            contentViewAndroidSubmitBtn         = new ContentView();
            contentViewAndroidSubmitBtn.Content = androidSubmitBtn.ToView();
#endif

            //events
            backBtn.Clicked += (sender, e) =>
            {
                backBtn.IsEnabled = false;
                Navigation.PopModalAsync();
                backBtn.IsEnabled = true;
            };
            submitBtn.Clicked += async(object sender, EventArgs e) => {
                ToggleButtons();
                await ChangePassword(sender, e);

                ToggleButtons();
            };

            //layout
#if __ANDROID__
            innerGrid.Children.Add(contentViewAndroidSecretQuestionLbl, 0, 3);
            innerGrid.Children.Add(contentViewAndroidSecretQuestionEntry, 0, 4);
            innerGrid.Children.Add(contentViewAndroidNewPasswordLbl, 0, 6);
            innerGrid.Children.Add(contentViewAndroidNewPasswordEntry, 0, 7);
            innerGrid.Children.Add(contentViewAndroidSubmitBtn, 0, 10);

            outerGrid.Children.Add(innerGrid, 0, 0);

            Content = outerGrid;
#endif
#if __IOS__
            buttonGrid.Children.Add(backBtn, 0, 0);
            buttonGrid.Children.Add(submitBtn, 1, 0);

            stackLayout.Children.Add(headerLbl);
            stackLayout.Children.Add(secretQuestionLbl);
            stackLayout.Children.Add(secretQuestionEntry);
            stackLayout.Children.Add(newPasswordLbl);
            stackLayout.Children.Add(newPasswordEntry);
            stackLayout.Children.Add(buttonGrid);

            scrollView.Content = stackLayout;

            Content = scrollView;
#endif
        }
        private void BuildPageObjects()
        {
            var btnSize = Device.GetNamedSize(NamedSize.Large, typeof(Button));
            var lblSize = Device.GetNamedSize(NamedSize.Large, typeof(Label));

            innerGrid = new Grid();
#if __ANDROID__
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(6, GridUnitType.Star)
            });
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
#endif
#if __IOS__
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(4, GridUnitType.Star)
            });
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            innerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
#endif

            outerGrid = new Grid();
            outerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });

            accountTitle                = new Label();
            accountTitle.FontFamily     = "AmericanTypewriter-Bold";
            accountTitle.FontSize       = lblSize * 2;
            accountTitle.Text           = "Mahecha BJJ Account";
            accountTitle.TextColor      = Color.Black;
            accountTitle.FontAttributes = FontAttributes.Bold;

            accountInfo            = new Label();
            accountInfo.FontFamily = "AmericanTypewriter-Bold";
            accountInfo.FontSize   = lblSize;
            accountInfo.Text       = "-Ability to create and manage you're own playlists.\n-Access to Mahecha BJJ Web Application(Coming soon)";
            accountInfo.TextColor  = Color.Black;

            accountBtn            = new Button();
            accountBtn.Style      = (Style)Application.Current.Resources["common-blue-btn"];
            accountBtn.FontFamily = "AmericanTypewriter-Bold";
            accountBtn.FontSize   = btnSize * 2;
            accountBtn.Text       = "Create";
            accountBtn.Clicked   += async(sender, e) =>
            {
                ToggleButtons();
                await Navigation.PushModalAsync(new SignUpPage(package));

                ToggleButtons();
            };

            noAccountBtn            = new Button();
            noAccountBtn.Style      = (Style)Application.Current.Resources["common-red-btn"];
            noAccountBtn.FontFamily = "AmericanTypewriter-Bold";
            noAccountBtn.FontSize   = btnSize * 2;
            noAccountBtn.Text       = "No Account";
            noAccountBtn.Clicked   += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await Navigation.PushModalAsync(new SummaryPage(package));

                ToggleButtons();
            };

            backBtn                   = new Button();
            backBtn.Style             = (Style)Application.Current.Resources["common-red-btn"];
            backBtn.Image             = "back.png";
            backBtn.VerticalOptions   = LayoutOptions.FillAndExpand;
            backBtn.HorizontalOptions = LayoutOptions.FillAndExpand;
            backBtn.Clicked          += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await Navigation.PopModalAsync();

                ToggleButtons();
            };

#if __ANDROID__
            var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174));
            pd.SetCornerRadius(100);

            androidNoAccountBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidNoAccountBtn.Text     = "No Account";
            androidNoAccountBtn.Typeface = Constants.COMMONFONT;
            androidNoAccountBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidNoAccountBtn.SetBackground(pd);
            androidNoAccountBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidNoAccountBtn.Gravity = Android.Views.GravityFlags.Center;
            androidNoAccountBtn.Click  += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await Navigation.PushModalAsync(new SummaryPage(package));

                ToggleButtons();
            };
            androidNoAccountBtn.SetAllCaps(false);

            androidAccountBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidAccountBtn.Text     = "Create";
            androidAccountBtn.Typeface = Constants.COMMONFONT;
            androidAccountBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidAccountBtn.SetBackground(pd);
            androidAccountBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidAccountBtn.Gravity = Android.Views.GravityFlags.Center;
            androidAccountBtn.Click  += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await Navigation.PushModalAsync(new SignUpPage(package));

                ToggleButtons();
            };
            androidAccountBtn.SetAllCaps(false);

            androidAccountTitle          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidAccountTitle.Text     = "Mahecha BJJ Account";
            androidAccountTitle.Typeface = Constants.COMMONFONT;
            androidAccountTitle.SetTextSize(Android.Util.ComplexUnitType.Fraction, 100);
            androidAccountTitle.SetTextColor(Android.Graphics.Color.Black);
            androidAccountTitle.Gravity = Android.Views.GravityFlags.Center;
            androidAccountTitle.SetTypeface(androidAccountTitle.Typeface, Android.Graphics.TypefaceStyle.Bold);

            androidAccountInfo      = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidAccountInfo.Text = "-Ability to create and manage you're own playlists.\n-Access to Mahecha BJJ Web Application(Coming soon)";
            androidAccountInfo.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
            androidAccountInfo.Typeface = Constants.COMMONFONT;
            androidAccountInfo.SetTextColor(Android.Graphics.Color.Black);
            androidAccountInfo.Gravity = Android.Views.GravityFlags.Start;
#endif
        }
Example #13
0
        private void BuildPageObjects()
        {
            var btnSize   = Device.GetNamedSize(NamedSize.Large, typeof(Button));
            var lblSize   = Device.GetNamedSize(NamedSize.Large, typeof(Label));
            var entrySize = Device.GetNamedSize(NamedSize.Large, typeof(Entry));

            stackLayout = new StackLayout();
            entryLayout = new StackLayout();
            buttonGrid  = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

#if __ANDROID__
            var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174));
            pd.SetCornerRadius(100);

            outerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            innerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            androidHeaderLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidHeaderLbl.Text     = "Forgot Password";
            androidHeaderLbl.Typeface = Constants.COMMONFONT;
            androidHeaderLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 100);
            androidHeaderLbl.SetTextColor(Android.Graphics.Color.Black);
            androidHeaderLbl.Gravity = Android.Views.GravityFlags.Center;

            androidEmailLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidEmailLbl.Text     = "E-Mail Address";
            androidEmailLbl.Typeface = Constants.COMMONFONT;
            androidEmailLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 100);
            androidEmailLbl.SetTextColor(Android.Graphics.Color.Black);
            androidEmailLbl.Gravity = Android.Views.GravityFlags.Center;

            androidEmailEntry          = new Android.Widget.EditText(MainApplication.ActivityContext);
            androidEmailEntry.Hint     = "Enter E-Mail";
            androidEmailEntry.Typeface = Constants.COMMONFONT;
            androidEmailEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
            androidEmailEntry.SetTextColor(Android.Graphics.Color.Black);
            androidEmailEntry.Gravity   = Android.Views.GravityFlags.Center;
            androidEmailEntry.InputType = Android.Text.InputTypes.TextVariationEmailAddress;

            androidNextBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidNextBtn.Text     = "Next";
            androidNextBtn.Typeface = Constants.COMMONFONT;
            androidNextBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidNextBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidNextBtn.Gravity = Android.Views.GravityFlags.Center;
            androidNextBtn.SetBackground(pd);
            androidNextBtn.Click += async(object sender, EventArgs e) => {
                ToggleButtons();
                await CheckIfUserExists(sender, e);

                ToggleButtons();
            };

            androidNextImgBtn = new Android.Widget.ImageButton(MainApplication.ActivityContext);
            androidNextImgBtn.SetImageResource(2130837802);
            androidNextImgBtn.SetAdjustViewBounds(true);
            androidNextImgBtn.SetBackground(pd);
            androidNextImgBtn.Click += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await CheckIfUserExists(sender, e);

                ToggleButtons();
            };

            contentViewHeaderLbl          = new ContentView();
            contentViewHeaderLbl.Content  = androidHeaderLbl.ToView();
            contentViewEmailLbl           = new ContentView();
            contentViewEmailLbl.Content   = androidEmailLbl.ToView();
            contentViewEmailEntry         = new ContentView();
            contentViewEmailEntry.Content = androidEmailEntry.ToView();
            contentViewNextBtn            = new ContentView();
            contentViewNextBtn.Content    = androidNextImgBtn.ToView();
#endif

            headerLbl = new Label
            {
                Text = "Forgot Password",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 1.5,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize,
#endif
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalOptions         = LayoutOptions.StartAndExpand
            };


            emailLbl = new Label
            {
                Text = "E-Mail Address",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 1.5,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize * .75,
#endif
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center
            };

            emailEntry = new Entry
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = entrySize * 1.25,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = entrySize * .75,
#endif
                Placeholder = "Enter E-Mail"
            };

            backBtn = new Button
            {
                Image = "back.png",
                Style = (Style)Application.Current.Resources["common-red-btn"]
            };

            nextBtn = new Button
            {
                Style             = (Style)Application.Current.Resources["common-blue-btn"],
                Image             = "next.png",
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            //events
            backBtn.Clicked += async(object sender, EventArgs e) => {
                ToggleButtons();
                await Navigation.PopModalAsync();

                ToggleButtons();
            };
            nextBtn.Clicked += async(object sender, EventArgs e) => {
                ToggleButtons();
                await CheckIfUserExists(sender, e);

                ToggleButtons();
            };

            //building layouts
#if __ANDROID__
            innerGrid.Children.Add(contentViewHeaderLbl, 0, 0);
            innerGrid.Children.Add(contentViewEmailLbl, 0, 3);
            innerGrid.Children.Add(contentViewEmailEntry, 0, 4);
            innerGrid.Children.Add(contentViewNextBtn, 0, 7);

            outerGrid.Children.Add(innerGrid, 0, 0);

            Content = outerGrid;
#endif
#if __IOS__
            buttonGrid.Children.Add(backBtn, 0, 0);
            buttonGrid.Children.Add(nextBtn, 1, 0);

            entryLayout.Children.Add(emailLbl);
            entryLayout.Children.Add(emailEntry);
            entryLayout.HorizontalOptions = LayoutOptions.FillAndExpand;
            entryLayout.VerticalOptions   = LayoutOptions.FillAndExpand;
            stackLayout.Children.Add(headerLbl);
            stackLayout.Children.Add(entryLayout);
            stackLayout.Children.Add(buttonGrid);

            Content = stackLayout;
#endif
        }
Example #14
0
        //functions
        private void SetContent()
        {
            var btnSize   = Device.GetNamedSize(NamedSize.Large, typeof(Button));
            var lblSize   = Device.GetNamedSize(NamedSize.Large, typeof(Label));
            var entrySize = Device.GetNamedSize(NamedSize.Large, typeof(Entry));

            //View objects
            beltLbl = new Label
            {
                Text = "Belt",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 1.5,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize,
                Margin     = new Thickness(0, -5, 0, -5),
#endif
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalOptions       = LayoutOptions.FillAndExpand
            };
            beltList = new ObservableCollection <string>();
            beltList.Add("White");
            beltList.Add("Blue");
            beltList.Add("Purple");
            beltList.Add("Brown");
            beltList.Add("Black");
            beltPicker = new Picker
            {
                Title       = "Choose Your Rank",
                ItemsSource = beltList
            };
            nameLbl = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 1.5,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize,
                Margin     = new Thickness(0, -5, 0, -5),
#endif
                Text = "Name",
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalOptions       = LayoutOptions.FillAndExpand
            };
            nameEntry = new Entry
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = entrySize,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = entrySize * .5,
                Margin     = new Thickness(0, -5, 0, -5),
#endif
                Placeholder       = "Brian Mahecha",
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            emailAddressLbl = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 1.5,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize,
                Margin     = new Thickness(0, -5, 0, -5),
#endif
                Text = "E-Mail Address",
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalOptions       = LayoutOptions.FillAndExpand
            };
            emailAddressEntry = new Entry
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = entrySize,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                Margin     = new Thickness(0, -5, 0, -5),
                FontSize   = entrySize * .5,
#endif
                Placeholder       = "*****@*****.**",
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            passWordLbl = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 1.5,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                Margin     = new Thickness(0, -5, 0, -5),
                FontSize   = lblSize,
#endif
                Text = "Password",
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalOptions       = LayoutOptions.FillAndExpand
            };
            passWordEntry = new Entry
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = entrySize,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                Margin     = new Thickness(0, -5, 0, -5),
                FontSize   = entrySize * .5,
#endif
                IsPassword        = true,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            secretQuestionLbl = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 1.5,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                Margin     = new Thickness(0, -5, 0, -5),
                FontSize   = lblSize,
#endif
                Text = "Secret Questions",
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalOptions       = LayoutOptions.FillAndExpand
            };
            secretQuestionList = new ObservableCollection <String>();
            secretQuestionList.Add("What city were you born in?");
            secretQuestionList.Add("What city was your high school?");
            secretQuestionList.Add("Name of favorite instructor.");
            secretQuestionPicker = new Picker
            {
                Title       = "Select a secret question to answer!",
                ItemsSource = secretQuestionList
            };
            secretQuestionEntry = new Entry
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = entrySize,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                Margin     = new Thickness(0, -5, 0, -5),
                FontSize   = entrySize * .5,
#endif
                Placeholder       = "Answer for your own security!",
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            nextBtn = new Button
            {
                Style             = (Style)Application.Current.Resources["common-blue-btn"],
                Image             = "next.png",
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            backBtn = new Button
            {
                Style             = (Style)Application.Current.Resources["common-red-btn"],
                Image             = "back.png",
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            clearBtn = new Button
            {
                Style = (Style)Application.Current.Resources["common-red-btn"],
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
#endif
                Text     = "Clear",
                FontSize = btnSize
            };

#if __ANDROID__
            var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174));
            pd.SetCornerRadius(100);

            androidNameEntry          = new Android.Widget.EditText(MainApplication.ActivityContext);
            androidNameEntry.Hint     = "Name";
            androidNameEntry.Typeface = Constants.COMMONFONT;
            androidNameEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
            androidNameEntry.SetTextColor(Android.Graphics.Color.Black);
            androidNameEntry.Gravity   = Android.Views.GravityFlags.Start;
            androidNameEntry.InputType = Android.Text.InputTypes.TextVariationPersonName;

            androidBeltLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidBeltLbl.Text     = "Belt";
            androidBeltLbl.Typeface = Constants.COMMONFONT;
            androidBeltLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
            androidBeltLbl.SetTextColor(Android.Graphics.Color.Black);
            androidBeltLbl.Gravity = Android.Views.GravityFlags.Start;

            androidEmailAddressEntry          = new Android.Widget.EditText(MainApplication.ActivityContext);
            androidEmailAddressEntry.Hint     = "E-Mail Address";
            androidEmailAddressEntry.Typeface = Constants.COMMONFONT;
            androidEmailAddressEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
            androidEmailAddressEntry.SetTextColor(Android.Graphics.Color.Black);
            androidEmailAddressEntry.Gravity   = Android.Views.GravityFlags.Start;
            androidEmailAddressEntry.InputType = Android.Text.InputTypes.TextVariationEmailAddress;

            androidPassWordEntry          = new Android.Widget.EditText(MainApplication.ActivityContext);
            androidPassWordEntry.Hint     = "Password";
            androidPassWordEntry.Typeface = Constants.COMMONFONT;
            androidPassWordEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
            androidPassWordEntry.SetTextColor(Android.Graphics.Color.Black);
            androidPassWordEntry.Gravity              = Android.Views.GravityFlags.Start;
            androidPassWordEntry.InputType            = Android.Text.InputTypes.TextVariationPassword;
            androidPassWordEntry.TransformationMethod = new PasswordTransformationMethod();

            androidSecretQuestionsLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidSecretQuestionsLbl.Text     = "Secret Questions";
            androidSecretQuestionsLbl.Typeface = Constants.COMMONFONT;
            androidSecretQuestionsLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
            androidSecretQuestionsLbl.SetTextColor(Android.Graphics.Color.Black);
            androidSecretQuestionsLbl.Gravity = Android.Views.GravityFlags.Start;

            androidSecretQuestionEntry          = new Android.Widget.EditText(MainApplication.ActivityContext);
            androidSecretQuestionEntry.Hint     = "Answer for your own security!";
            androidSecretQuestionEntry.Typeface = Constants.COMMONFONT;
            androidSecretQuestionEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
            androidSecretQuestionEntry.SetTextColor(Android.Graphics.Color.Black);
            androidSecretQuestionEntry.Gravity   = Android.Views.GravityFlags.Start;
            androidSecretQuestionEntry.InputType = Android.Text.InputTypes.TextVariationShortMessage;

            androidNextImgBtn = new Android.Widget.ImageButton(MainApplication.ActivityContext);
            androidNextImgBtn.SetImageResource(2130837802);
            androidNextImgBtn.SetAdjustViewBounds(true);
            androidNextImgBtn.SetBackground(pd);
            androidNextImgBtn.Click += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await Validate();

                ToggleButtons();
            };
#endif

            //Events
            nextBtn.Clicked += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await Validate();

                ToggleButtons();
            };
            backBtn.Clicked += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await Navigation.PopModalAsync();

                ToggleButtons();
            };
            //passWordRepeatEntry.Unfocused += PasswordMatch;
            //TODO add specific validation events to make sure entries are correct.

            tableView = new TableView();
            tableView.BackgroundColor = Color.FromHex("#F1ECCE");
            tableView.Intent          = TableIntent.Form;
            tableView.Root            = new TableRoot()
            {
                new TableSection()
                {
                    new ViewCell {
                        View = nameLbl
                    },
                    new ViewCell {
                        View = nameEntry
                    },
                    new ViewCell {
                        View = emailAddressLbl
                    },
                    new ViewCell {
                        View = emailAddressEntry
                    },
                    new ViewCell {
                        View = beltLbl
                    },
                    new ViewCell {
                        View = beltPicker
                    },
                    new ViewCell {
                        View = passWordLbl
                    },
                    new ViewCell {
                        View = passWordEntry
                    },
                    new ViewCell {
                        View = secretQuestionLbl
                    },
                    new ViewCell {
                        View = secretQuestionPicker
                    },
                    new ViewCell {
                        View = secretQuestionEntry
                    }
                }
            };
#if __IOS__
            buttonGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };
            buttonGrid.Children.Add(backBtn, 0, 0);
            buttonGrid.Children.Add(nextBtn, 1, 0);
#endif
#if __ANDROID__
            buttonGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };
            buttonGrid.Children.Add(androidNextImgBtn.ToView(), 0, 0);
#endif

            scrollView = new ScrollView();
#if __IOS__
            stackLayout = new StackLayout
            {
                Children =
                {
                    tableView
                }
            };
#endif
#if __ANDROID__
            stackLayout = new StackLayout
            {
                Children =
                {
                    androidNameEntry.ToView(),
                    androidEmailAddressEntry.ToView(),
                    androidBeltLbl.ToView(),
                    beltPicker,
                    androidPassWordEntry.ToView(),
                    androidSecretQuestionsLbl.ToView(),
                    secretQuestionPicker,
                    androidSecretQuestionEntry.ToView()
                }
            };
#endif
            scrollView.Content = stackLayout;
#if __ANDROID__
            scrollView.IsClippedToBounds = true;
#endif

#if __IOS__
            innerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(9, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };
#endif
#if __ANDROID__
            innerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(9, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };
#endif
            outerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };
            innerGrid.Children.Add(scrollView, 0, 0);
            innerGrid.Children.Add(buttonGrid, 0, 1);
            outerGrid.Children.Add(innerGrid);
            Content = outerGrid;
        }
Example #15
0
        //functions
        private void BuildPageObjects()
        {
            var btnSize   = Device.GetNamedSize(NamedSize.Large, typeof(Button));
            var lblSize   = Device.GetNamedSize(NamedSize.Large, typeof(Label));
            var entrySize = Device.GetNamedSize(NamedSize.Large, typeof(Entry));

            scrollView               = new ScrollView();
            stackLayout              = new StackLayout();
            buttonLayout             = new StackLayout();
            emailLayout              = new StackLayout();
            passwordLayout           = new StackLayout();
            innerStackLayout         = new StackLayout();
            innerStackLayout.Spacing = 50;
            //View objects
            innerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(7, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(2, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(2, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(2, GridUnitType.Star)
                    }
                }
            };
            outerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };
            buttonGrid = new Grid
            {
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {
                        Width = new GridLength(3, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };
            emailGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(3, GridUnitType.Star)
                    }
                }
            };
            passwordGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(3, GridUnitType.Star)
                    }
                }
            };
            mahechaLogo = new Image
            {
                Source = ImageSource.FromResource("mahechabjjlogo.png"),
                Aspect = Aspect.AspectFit
            };
            emailImg = new Image
            {
                Source = "mail.png",
                Aspect = Aspect.AspectFit
            };
            emailLbl = new Label
            {
                Text = "E-Mail Address",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 2,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize,
                Margin     = -5,
#endif
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center
            };
            emailEntry = new Entry
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
#endif
#if __ANDROID__
                FontFamily  = "Roboto Bold",
                Placeholder = "E-Mail Address",
#endif
                FontSize          = entrySize,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            passwordImg = new Image
            {
                Source = "password.png",
                Aspect = Aspect.AspectFit
            };
            passwordLbl = new Label
            {
                Text = "Password",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 2,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize,
                Margin     = -5,
#endif
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center
            };
            passwordEntry = new Entry
            {
                IsPassword = true,
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
#endif
#if __ANDROID__
                FontFamily  = "Roboto Bold",
                Placeholder = "Password",
#endif
                FontSize          = entrySize,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            loginBtn = new Button
            {
                Text              = "Login",
                FontFamily        = "AmericanTypewriter-Bold",
                FontSize          = btnSize * 2,
                Style             = (Style)Application.Current.Resources["common-blue-btn"],
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            backBtn = new Button
            {
                Image             = "back.png",
                Style             = (Style)Application.Current.Resources["common-red-btn"],
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            forgotPasswordBtn = new Button
            {
                Image             = "forgotpassword.png",
                Style             = (Style)Application.Current.Resources["common-blue-btn"],
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

#if __ANDROID__
            var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174));
            pd.SetCornerRadius(100);

            var pdTwo = new PaintDrawable(Android.Graphics.Color.Rgb(124, 37, 41));
            pdTwo.SetCornerRadius(100);

            androidLoginBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidLoginBtn.Text     = "Login";
            androidLoginBtn.Typeface = Constants.COMMONFONT;
            androidLoginBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidLoginBtn.SetBackground(pd);
            androidLoginBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidLoginBtn.Gravity = Android.Views.GravityFlags.Center;
            androidLoginBtn.SetAllCaps(false);

            androidForgotPasswordBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidForgotPasswordBtn.Text     = "?";
            androidForgotPasswordBtn.Typeface = Constants.COMMONFONT;
            androidForgotPasswordBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidForgotPasswordBtn.SetBackground(pdTwo);
            androidForgotPasswordBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidForgotPasswordBtn.Gravity = Android.Views.GravityFlags.Center;
            androidForgotPasswordBtn.SetAllCaps(false);

            androidForgetPasswordImgBtn = new Android.Widget.ImageButton(MainApplication.ActivityContext);
            androidForgetPasswordImgBtn.SetImageResource(2130837598);
            androidForgetPasswordImgBtn.SetAdjustViewBounds(true);
            androidForgetPasswordImgBtn.SetBackground(pdTwo);

            androidEmailEntry          = new Android.Widget.EditText(MainApplication.ActivityContext);
            androidEmailEntry.Typeface = Constants.COMMONFONT;
            androidEmailEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
            androidEmailEntry.SetPadding(0, 10, 0, 10);
            androidEmailEntry.SetTextColor(Android.Graphics.Color.Black);
            androidEmailEntry.InputType = Android.Text.InputTypes.TextVariationEmailAddress;

            androidImageEmail = new Android.Widget.ImageView(MainApplication.ActivityContext);
            androidImageEmail.SetImageResource(2130837780);
            androidImageEmail.SetAdjustViewBounds(true);

            androidPasswordEntry          = new Android.Widget.EditText(MainApplication.ActivityContext);
            androidPasswordEntry.Typeface = Constants.COMMONFONT;
            androidPasswordEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
            androidPasswordEntry.SetPadding(0, 0, 0, 0);
            androidPasswordEntry.SetTextColor(Android.Graphics.Color.Black);
            androidPasswordEntry.SetHighlightColor(Android.Graphics.Color.Transparent);
            androidPasswordEntry.InputType            = Android.Text.InputTypes.TextVariationWebPassword;
            androidPasswordEntry.TransformationMethod = new PasswordTransformationMethod();

            androidImagePassword = new Android.Widget.ImageView(MainApplication.ActivityContext);
            androidImagePassword.SetImageResource(2130837816);
            androidImagePassword.SetAdjustViewBounds(true);
#endif
            //Events
            loginBtn.Clicked += async(object sender, EventArgs e) => {
                ToggleButtons();
                await Validate(sender, e);

                ToggleButtons();
            };
            backBtn.Clicked += async(object sender, EventArgs e) => {
                ToggleButtons();
                await Navigation.PopModalAsync();

                ToggleButtons();
            };
            forgotPasswordBtn.Clicked += async(object sender, EventArgs e) => {
                ToggleButtons();
                await Navigation.PushModalAsync(new ForgotPasswordPage());

                ToggleButtons();
            };

#if __ANDROID__
            androidLoginBtn.Click += async(object sender, EventArgs e) => {
                ToggleButtons();
                await Validate(sender, e);

                ToggleButtons();
            };
            androidForgetPasswordImgBtn.Click += async(object sender, EventArgs e) => {
                ToggleButtons();
                await Navigation.PushModalAsync(new ForgotPasswordPage());

                ToggleButtons();
            };
#endif

#if __IOS__
            buttonLayout.Children.Add(backBtn);
            buttonLayout.Children.Add(loginBtn);
            buttonLayout.Children.Add(forgotPasswordBtn);
            buttonLayout.Orientation = StackOrientation.Horizontal;
            emailLayout.Children.Add(emailImg);
            emailLayout.Children.Add(emailEntry);
            emailLayout.Orientation = StackOrientation.Horizontal;
            passwordLayout.Children.Add(passwordImg);
            passwordLayout.Children.Add(passwordEntry);
            passwordLayout.Orientation = StackOrientation.Horizontal;
            innerStackLayout.Children.Add(emailLayout);
            innerStackLayout.Children.Add(passwordLayout);
            //innerStackLayout.Children.Add(emailImg);
            //innerStackLayout.Children.Add(emailEntry);

            //innerStackLayout.Children.Add(passwordImg);
            //innerStackLayout.Children.Add(passwordEntry);
            innerStackLayout.Children.Add(buttonLayout);
            stackLayout.Children.Add(mahechaLogo);
            stackLayout.Children.Add(innerStackLayout);
            stackLayout.Orientation       = StackOrientation.Vertical;
            stackLayout.VerticalOptions   = LayoutOptions.CenterAndExpand;
            stackLayout.HorizontalOptions = LayoutOptions.CenterAndExpand;

            scrollView.Content = stackLayout;
            Content            = scrollView;
#endif
#if __ANDROID__
            buttonGrid.Children.Add(androidLoginBtn.ToView(), 0, 0);
            buttonGrid.Children.Add(androidForgetPasswordImgBtn.ToView(), 1, 0);
            emailGrid.Children.Add(androidImageEmail.ToView(), 0, 0);
            emailGrid.Children.Add(androidEmailEntry.ToView(), 1, 0);
            emailGrid.Padding = new Thickness(10, 0);
            passwordGrid.Children.Add(androidImagePassword.ToView(), 0, 0);
            passwordGrid.Children.Add(androidPasswordEntry.ToView(), 1, 0);
            passwordGrid.Padding = new Thickness(10, 0);
            innerGrid.Children.Add(mahechaLogo, 0, 0);
            innerGrid.Children.Add(emailGrid, 0, 2);
            innerGrid.Children.Add(passwordGrid, 0, 4);
            innerGrid.Children.Add(buttonGrid, 0, 6);

            outerGrid.Children.Add(innerGrid, 0, 0);

            Content = outerGrid;
#endif
        }
Example #16
0
        public static void SetTheme(Android.Widget.CheckBox checkBox,
                                    int radius, int size, int border, Android.Graphics.Color background)
        {
            // creating unchecked-enabled state drawable
            GradientDrawable uncheckedEnabled = new GradientDrawable();

            uncheckedEnabled.SetCornerRadius(radius);
            uncheckedEnabled.SetSize(size, size);
            uncheckedEnabled.SetColor(Android.Graphics.Color.Transparent);
            uncheckedEnabled.SetStroke(border, Android.Graphics.Color.Black);

            // creating checked-enabled state drawable
            GradientDrawable checkedOutside = new GradientDrawable();

            checkedOutside.SetCornerRadius(radius);
            checkedOutside.SetSize(size, size);
            checkedOutside.SetColor(Android.Graphics.Color.Transparent);
            checkedOutside.SetStroke(border, Android.Graphics.Color.Black);

            PaintDrawable checkedCore = new PaintDrawable(background);

            checkedCore.SetCornerRadius(radius);
            checkedCore.SetIntrinsicHeight(size);
            checkedCore.SetIntrinsicWidth(size);
            InsetDrawable checkedInside = new InsetDrawable(checkedCore, border + 2, border + 2, border + 2, border + 2);

            Drawable[]    checkedEnabledDrawable = { checkedOutside, checkedInside };
            LayerDrawable checkedEnabled         = new LayerDrawable(checkedEnabledDrawable);

            // creating unchecked-enabled state drawable
            GradientDrawable uncheckedDisabled = new GradientDrawable();

            uncheckedDisabled.SetCornerRadius(radius);
            uncheckedDisabled.SetSize(size, size);
            uncheckedDisabled.SetColor(Android.Graphics.Color.Transparent);
            uncheckedDisabled.SetStroke(border, Android.Graphics.Color.Black);

            // creating checked-disabled state drawable
            GradientDrawable checkedOutsideDisabled = new GradientDrawable();

            checkedOutsideDisabled.SetCornerRadius(radius);
            checkedOutsideDisabled.SetSize(size, size);
            checkedOutsideDisabled.SetColor(Android.Graphics.Color.Transparent);
            checkedOutsideDisabled.SetStroke(border, Android.Graphics.Color.Black);

            PaintDrawable checkedCoreDisabled = new PaintDrawable(background);

            checkedCoreDisabled.SetCornerRadius(radius);
            checkedCoreDisabled.SetIntrinsicHeight(size);
            checkedCoreDisabled.SetIntrinsicWidth(size);
            InsetDrawable checkedInsideDisabled = new InsetDrawable(checkedCoreDisabled, border + 2, border + 2, border + 2, border + 2);

            Drawable[]    checkedDisabledDrawable = { checkedOutsideDisabled, checkedInsideDisabled };
            LayerDrawable checkedDisabled         = new LayerDrawable(checkedDisabledDrawable);


            StateListDrawable states = new StateListDrawable();

            states.AddState(new int[] { -Android.Resource.Attribute.StateChecked, Android.Resource.Attribute.StateEnabled }, uncheckedEnabled);
            states.AddState(new int[] { Android.Resource.Attribute.StateChecked, Android.Resource.Attribute.StateEnabled }, checkedEnabled);
            states.AddState(new int[] { -Android.Resource.Attribute.StateChecked, -Android.Resource.Attribute.StateEnabled }, uncheckedDisabled);
            states.AddState(new int[] { Android.Resource.Attribute.StateChecked, -Android.Resource.Attribute.StateEnabled }, checkedDisabled);
            checkBox.SetButtonDrawable(states);

            // setting padding for avoiding text to be appear on icon
            checkBox.SetPadding(size / 4 * 5, 0, 0, 0);
            checkBox.SetTextColor(Android.Graphics.Color.LightYellow);
            checkBox.SetTextSize(Android.Util.ComplexUnitType.Sp, 10);
            checkBox.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
        }
        public static void SetTheme(ToggleButton toggleButton, FlatTheme theme, int padding, int size)
        {
            toggleButton.SetWidth(size * 5);
            toggleButton.SetHeight(size);

            //setTextOff("");
            //setTextOn("");

            int radius = size - 4;

            float[] outerR = new float[] { radius, radius, radius, radius, radius, radius, radius, radius };

            // creating unchecked-enabled state drawable
            var uncheckedEnabledFrontCore = new ShapeDrawable(new RoundRectShape(outerR, null, null));

            uncheckedEnabledFrontCore.Paint.Color = theme.LightAccentColor;
            var uncheckedEnabledFront = new InsetDrawable(uncheckedEnabledFrontCore, 5);

            var uncheckedEnabledBack = new ShapeDrawable(new RoundRectShape(outerR, null, null));

            uncheckedEnabledBack.Paint.Color = Color.ParseColor("#f2f2f2");
            uncheckedEnabledBack.SetPadding(0, 0, size / 2 * 5, 0);

            Drawable[] d1 = { uncheckedEnabledBack, uncheckedEnabledFront };
            var        uncheckedEnabled = new LayerDrawable(d1);

            // creating checked-enabled state drawable
            var checkedEnabledFrontCore = new ShapeDrawable(new RoundRectShape(outerR, null, null));

            checkedEnabledFrontCore.Paint.Color = theme.LightAccentColor;
            var checkedEnabledFront = new InsetDrawable(checkedEnabledFrontCore, 5);

            ShapeDrawable checkedEnabledBack = new ShapeDrawable(new RoundRectShape(outerR, null, null));

            checkedEnabledBack.Paint.Color = theme.VeryLightAccentColor;
            checkedEnabledBack.SetPadding(size / 2 * 5, 0, 0, 0);

            Drawable[]    d2             = { checkedEnabledBack, checkedEnabledFront };
            LayerDrawable checkedEnabled = new LayerDrawable(d2);

            // creating unchecked-disabled state drawable
            ShapeDrawable uncheckedDisabledFrontCore = new ShapeDrawable(new RoundRectShape(outerR, null, null));

            uncheckedDisabledFrontCore.Paint.Color = Color.ParseColor("#d2d2d2");
            InsetDrawable uncheckedDisabledFront = new InsetDrawable(uncheckedDisabledFrontCore, 5);

            ShapeDrawable uncheckedDisabledBack = new ShapeDrawable(new RoundRectShape(outerR, null, null));

            uncheckedDisabledBack.Paint.Color = Color.ParseColor("#f2f2f2");
            uncheckedDisabledBack.SetPadding(0, 0, size / 2 * 5, 0);

            Drawable[]    d3 = { uncheckedDisabledBack, uncheckedDisabledFront };
            LayerDrawable uncheckedDisabled = new LayerDrawable(d3);

            // creating checked-disabled state drawable
            ShapeDrawable checkedDisabledFrontCore = new ShapeDrawable(new RoundRectShape(outerR, null, null));

            checkedDisabledFrontCore.Paint.Color = theme.VeryLightAccentColor;
            InsetDrawable checkedDisabledFront = new InsetDrawable(checkedDisabledFrontCore, 5);

            ShapeDrawable checkedDisabledBack = new ShapeDrawable(new RoundRectShape(outerR, null, null));

            checkedDisabledBack.Paint.Color = Color.ParseColor("#f2f2f2");
            checkedDisabledBack.SetPadding(size / 2 * 5, 0, 0, 0);

            Drawable[]    d4 = { checkedDisabledBack, checkedDisabledFront };
            LayerDrawable checkedDisabled = new LayerDrawable(d4);

            toggleButton.SetPadding(0, padding, 0, padding);

            PaintDrawable paintDrawable = new PaintDrawable(theme.BackgroundColor);

            paintDrawable.SetIntrinsicHeight(size);
            paintDrawable.SetIntrinsicWidth(size);
            paintDrawable.SetPadding(size, 0, 0, 0);

            StateListDrawable states = new StateListDrawable();

            states.AddState(new int[] { -Android.Resource.Attribute.StateChecked, Android.Resource.Attribute.StateEnabled },
                            new InsetDrawable(uncheckedEnabled, padding * 2));
            states.AddState(new int[] { Android.Resource.Attribute.StateChecked, Android.Resource.Attribute.StateEnabled },
                            new InsetDrawable(checkedEnabled, padding * 2));
            states.AddState(new int[] { -Android.Resource.Attribute.StateChecked, -Android.Resource.Attribute.StateEnabled },
                            new InsetDrawable(uncheckedDisabled, padding * 2));
            states.AddState(new int[] { Android.Resource.Attribute.StateChecked, -Android.Resource.Attribute.StateEnabled },
                            new InsetDrawable(checkedDisabled, padding * 2));

            toggleButton.SetBackgroundDrawable(states);

            toggleButton.SetTextSize(ComplexUnitType.Sp, 0);
        }
Example #18
0
        public void BuildPageObjects()
        {
            //outer Grid
            outerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };
            //inner Grid
            innerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection {
                    new RowDefinition {
                        Height = new GridLength(5, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            //view objects
            mahechaLogo = new Image
            {
                Source = ImageSource.FromResource("mahechabjjlogo.png"),
                Aspect = Aspect.AspectFit
            };
            var size = Device.GetNamedSize(NamedSize.Large, typeof(Button));

            loginBtn = new Button
            {
                Text     = "Login",
                FontSize = size * 2,
                Style    = (Style)Application.Current.Resources["common-blue-btn"]
            };
            signUpBtn = new Button
            {
                Text     = "Sign Up",
                FontSize = size * 2,
                Style    = (Style)Application.Current.Resources["common-blue-btn"]
            };
            blogBtn = new Button
            {
                Text     = "Learn More",
                FontSize = size * 2,
                Style    = (Style)Application.Current.Resources["common-blue-btn"]
            };

            restoreBtn          = new Button();
            restoreBtn.Text     = "Restore Packages";
            restoreBtn.Style    = (Style)Application.Current.Resources["common-blue-btn"];
            restoreBtn.FontSize = size * 1.5;

#if __ANDROID__
            var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174));
            pd.SetCornerRadius(100);

            androidLoginBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidLoginBtn.Text     = "Login";
            androidLoginBtn.Typeface = Constants.COMMONFONT;
            androidLoginBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidLoginBtn.SetBackground(pd);
            androidLoginBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidLoginBtn.Gravity = Android.Views.GravityFlags.Center;
            androidLoginBtn.SetAllCaps(false);

            androidSignUpBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidSignUpBtn.Text     = "Sign Up";
            androidSignUpBtn.Typeface = Constants.COMMONFONT;
            androidSignUpBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidSignUpBtn.SetBackground(pd);
            androidSignUpBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidSignUpBtn.Gravity = Android.Views.GravityFlags.Center;
            androidSignUpBtn.SetAllCaps(false);

            androidBlogBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidBlogBtn.Text     = "Learn More";
            androidBlogBtn.Typeface = Constants.COMMONFONT;
            androidBlogBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidBlogBtn.SetBackground(pd);
            androidBlogBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidBlogBtn.Gravity = Android.Views.GravityFlags.Center;
            androidBlogBtn.SetAllCaps(false);

            androidRestoreBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidRestoreBtn.Text     = "Restore Packages";
            androidRestoreBtn.Typeface = Constants.COMMONFONT;
            androidRestoreBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidRestoreBtn.SetBackground(pd);
            androidRestoreBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidRestoreBtn.Gravity = Android.Views.GravityFlags.Center;
            androidRestoreBtn.SetAllCaps(false);
#endif

            //Button events
#if __ANDROID__
            //androidLoginBtn.Click += Login;
            androidLoginBtn.Click += async(object sender, EventArgs e) => {
                /*if (isButtonPressed)
                 * {
                 *  return;
                 * }
                 * else
                 * {
                 *  isButtonPressed = true;
                 *  await Navigation.PushModalAsync(new LoginPage());
                 * }
                 * isButtonPressed = false;*/
                ToggleButtons();
                await Navigation.PushModalAsync(new LoginPage());

                ToggleButtons();
            };

            androidSignUpBtn.Click += async(object sender, EventArgs e) => {
                ToggleButtons();
                await Navigation.PushModalAsync(new PackagePage());

                ToggleButtons();
            };

            androidBlogBtn.Click += async(object sender, EventArgs e) => {
                ToggleButtons();
                await Navigation.PushModalAsync(new BlogViewPage());

                ToggleButtons();
            };

            androidRestoreBtn.Click += async(object sender, EventArgs e) => {
                ToggleButtons();
                await CheckIfUserHasPackage(sender, e);

                ToggleButtons();
            };
#endif
#if __IOS__
            loginBtn.Clicked += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await Navigation.PushModalAsync(new LoginPage());

                ToggleButtons();
            };

            signUpBtn.Clicked += async(sender, args) =>
            {
                ToggleButtons();
                await Navigation.PushModalAsync(new PackagePage());

                ToggleButtons();
            };

            blogBtn.Clicked += async(sender, e) =>
            {
                ToggleButtons();
                await Navigation.PushModalAsync(new BlogViewPage());

                ToggleButtons();
            };

            restoreBtn.Clicked += async(sender, e) =>
            {
                ToggleButtons();
                await CheckIfUserHasPackage(sender, e);

                ToggleButtons();
            };
#endif

            //building Grid
#if __ANDROID__
            innerGrid.Children.Add(androidLoginBtn.ToView(), 0, 1);
            innerGrid.Children.Add(androidSignUpBtn.ToView(), 0, 2);
            innerGrid.Children.Add(androidBlogBtn.ToView(), 0, 3);
            innerGrid.Children.Add(androidRestoreBtn.ToView(), 0, 4);
#endif
#if __IOS__
            innerGrid.Children.Add(loginBtn, 0, 1);
            innerGrid.Children.Add(signUpBtn, 0, 2);
            innerGrid.Children.Add(blogBtn, 0, 3);
            innerGrid.Children.Add(restoreBtn, 0, 4);
#endif


            innerGrid.Children.Add(mahechaLogo, 0, 0);

            outerGrid.Children.Add(innerGrid, 0, 0);

            Content = outerGrid;
        }
Example #19
0
        //functions
        public void BuildPageObjects()
        {
            var lblSize = Device.GetNamedSize(NamedSize.Large, typeof(Label));
            var btnSize = Device.GetNamedSize(NamedSize.Large, typeof(Button));

            //Layout
            innerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    #if __ANDROID__
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
#endif
#if __IOS__
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
#endif
                },
#if __IOS__
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
#endif
            };
            outerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            //View objects
            playListNameLbl = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 2,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize,
                Margin     = -5,
#endif
                Text = "Name:"
            };
            playListNameEntry = new Entry
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize * .75,
#endif
                Placeholder = "Leg Lasso List"
            };
            playListDescriptionLbl = new Label
            {
                Text = "Description:",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 2,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize,
                Margin     = -5,
#endif
            };
            playListDescriptionEditor = new Editor
            {
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Editor)),
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
#endif
#if __ANDROID__
                FontFamily      = "Roboto Bold",
                BackgroundColor = Color.White
#endif
            };
            editorFrame = new Frame
            {
                Content         = playListDescriptionEditor,
                BorderColor     = Color.Black,
                BackgroundColor = Color.Black,
                HasShadow       = false,
                Padding         = 3
            };
            backBtn = new Button
            {
                Style = (Style)Application.Current.Resources["common-red-btn"],
                Image = "back.png"
            };
            createBtn = new Button
            {
                Style = (Style)Application.Current.Resources["common-blue-btn"],
                Text  = "Create",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = btnSize * 2,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = btnSize * 1.25,
#endif
            };

#if __ANDROID__
            var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174));
            pd.SetCornerRadius(100);

            androidPlaylistNameEntry          = new Android.Widget.EditText(MainApplication.ActivityContext);
            androidPlaylistNameEntry.Hint     = "Enter Name";
            androidPlaylistNameEntry.Typeface = Constants.COMMONFONT;
            androidPlaylistNameEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 100);
            androidPlaylistNameEntry.SetTextColor(Android.Graphics.Color.Black);
            androidPlaylistNameEntry.Gravity   = Android.Views.GravityFlags.Start;
            androidPlaylistNameEntry.InputType = Android.Text.InputTypes.TextFlagNoSuggestions;

            androidPlaylistDescriptionEntry          = new Android.Widget.EditText(MainApplication.ActivityContext);
            androidPlaylistDescriptionEntry.Hint     = "Enter Description";
            androidPlaylistDescriptionEntry.Typeface = Constants.COMMONFONT;
            androidPlaylistDescriptionEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
            androidPlaylistDescriptionEntry.SetTextColor(Android.Graphics.Color.Black);
            androidPlaylistDescriptionEntry.Gravity   = Android.Views.GravityFlags.Start;
            androidPlaylistDescriptionEntry.InputType = Android.Text.InputTypes.TextVariationLongMessage;

            androidCreateBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidCreateBtn.Text     = "Create Playlist";
            androidCreateBtn.Typeface = Constants.COMMONFONT;
            androidCreateBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidCreateBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidCreateBtn.SetBackground(pd);
            androidCreateBtn.Gravity = Android.Views.GravityFlags.Center;
            androidCreateBtn.SetAllCaps(false);
            androidCreateBtn.Click += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await CreatePlaylist(sender, e);

                ToggleButtons();
            };


            contentViewAndroidPlaylistNameEntry                = new ContentView();
            contentViewAndroidPlaylistNameEntry.Content        = androidPlaylistNameEntry.ToView();
            contentViewAndroidPlaylistDescriptionEntry         = new ContentView();
            contentViewAndroidPlaylistDescriptionEntry.Content = androidPlaylistDescriptionEntry.ToView();
            contentViewAndroidCreateBtn         = new ContentView();
            contentViewAndroidCreateBtn.Content = androidCreateBtn.ToView();
#endif

            //events
            backBtn.Clicked += async(object sender, EventArgs e) => {
                ToggleButtons();
                await Navigation.PopModalAsync();

                ToggleButtons();
            };
            createBtn.Clicked += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await CreatePlaylist(sender, e);

                ToggleButtons();
            };


#if __IOS__
            //building grid
            innerGrid.Children.Add(playListNameLbl, 0, 0);
            playListNameLbl.VerticalTextAlignment   = TextAlignment.Center;
            playListNameLbl.HorizontalTextAlignment = TextAlignment.Center;
            Grid.SetColumnSpan(playListNameLbl, 2);
            innerGrid.Children.Add(playListNameEntry, 0, 1);
            Grid.SetColumnSpan(playListNameEntry, 2);
            innerGrid.Children.Add(playListDescriptionLbl, 0, 2);
            Grid.SetColumnSpan(playListDescriptionLbl, 2);
            playListDescriptionLbl.VerticalTextAlignment   = TextAlignment.Center;
            playListDescriptionLbl.HorizontalTextAlignment = TextAlignment.Center;
            innerGrid.Children.Add(editorFrame, 0, 3);
            Grid.SetRowSpan(editorFrame, 3);
            Grid.SetColumnSpan(editorFrame, 2);

            innerGrid.Children.Add(backBtn, 0, 7);
            innerGrid.Children.Add(createBtn, 1, 7);
#endif
#if __ANDROID__
            //building grid
            innerGrid.Children.Add(contentViewAndroidPlaylistNameEntry, 0, 2);
            innerGrid.Children.Add(contentViewAndroidPlaylistDescriptionEntry, 0, 3);
            innerGrid.Children.Add(contentViewAndroidCreateBtn, 0, 6);
#endif

            outerGrid.Children.Add(innerGrid, 0, 0);

            Content = outerGrid;
        }
        private void SetContent(bool hasUser)
        {
            var btnSize   = Device.GetNamedSize(NamedSize.Large, typeof(Button));
            var lblSize   = Device.GetNamedSize(NamedSize.Large, typeof(Label));
            var entrySize = Device.GetNamedSize(NamedSize.Large, typeof(Entry));

            outerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

#if __IOS__
            buttonGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };
#endif
#if __ANDROID__
            buttonGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };
#endif

#if __ANDROID__
            var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174));
            pd.SetCornerRadius(100);

            androidSummaryLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidSummaryLbl.Text     = "Summary";
            androidSummaryLbl.Typeface = Constants.COMMONFONT;
            androidSummaryLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 100);
            androidSummaryLbl.SetTextColor(Android.Graphics.Color.Black);
            androidSummaryLbl.Gravity = Android.Views.GravityFlags.Start;
            androidSummaryLbl.SetTypeface(androidSummaryLbl.Typeface, Android.Graphics.TypefaceStyle.Bold);

            androidPackageLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidPackageLbl.Text     = $"Package: {packageName}";
            androidPackageLbl.Typeface = Constants.COMMONFONT;
            androidPackageLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
            androidPackageLbl.SetTextColor(Android.Graphics.Color.Black);
            androidPackageLbl.Gravity = Android.Views.GravityFlags.Start;

            androidPriceLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidPriceLbl.Text     = $"Price: {packagePrice}";
            androidPriceLbl.Typeface = Constants.COMMONFONT;
            androidPriceLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
            androidPriceLbl.SetTextColor(Android.Graphics.Color.Black);
            androidPriceLbl.Gravity = Android.Views.GravityFlags.Start;

            androidSignUpBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidSignUpBtn.Text     = "Sign Up";
            androidSignUpBtn.Typeface = Constants.COMMONFONT;
            androidSignUpBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidSignUpBtn.SetBackground(pd);
            androidSignUpBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidSignUpBtn.Gravity = Android.Views.GravityFlags.Center;
            androidSignUpBtn.Click  += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await SignUp();

                ToggleButtons();
            };
            androidSignUpBtn.SetAllCaps(false);

            if (hasUser)
            {
                androidUserDetailsLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
                androidUserDetailsLbl.Text     = "User Details";
                androidUserDetailsLbl.Typeface = Constants.COMMONFONT;
                androidUserDetailsLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 100);
                androidUserDetailsLbl.SetTextColor(Android.Graphics.Color.Black);
                androidUserDetailsLbl.Gravity = Android.Views.GravityFlags.Start;
                androidUserDetailsLbl.SetTypeface(androidUserDetailsLbl.Typeface, Android.Graphics.TypefaceStyle.Bold);

                androidNameLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
                androidNameLbl.Text     = $"Name: {user.Name}";
                androidNameLbl.Typeface = Constants.COMMONFONT;
                androidNameLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
                androidNameLbl.SetTextColor(Android.Graphics.Color.Black);
                androidNameLbl.Gravity = Android.Views.GravityFlags.Start;

                androidEmailLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
                androidEmailLbl.Text     = $"E-Mail: {user.Email}";
                androidEmailLbl.Typeface = Constants.COMMONFONT;
                androidEmailLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
                androidEmailLbl.SetTextColor(Android.Graphics.Color.Black);
                androidEmailLbl.Gravity = Android.Views.GravityFlags.Start;

                androidBeltLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
                androidBeltLbl.Text     = $"Belt: {user.Belt}";
                androidBeltLbl.Typeface = Constants.COMMONFONT;
                androidBeltLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
                androidBeltLbl.SetTextColor(Android.Graphics.Color.Black);
                androidBeltLbl.Gravity = Android.Views.GravityFlags.Start;

                androidSecretQuestionLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
                androidSecretQuestionLbl.Text     = $"Secret Question: {user.SecretQuestion}";
                androidSecretQuestionLbl.Typeface = Constants.COMMONFONT;
                androidSecretQuestionLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
                androidSecretQuestionLbl.SetTextColor(Android.Graphics.Color.Black);
                androidSecretQuestionLbl.Gravity = Android.Views.GravityFlags.Start;

                androidSecretQuestionAnswerLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
                androidSecretQuestionAnswerLbl.Text     = $"Answer: {user.SecretQuestionAnswer}";
                androidSecretQuestionAnswerLbl.Typeface = Constants.COMMONFONT;
                androidSecretQuestionAnswerLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);
                androidSecretQuestionAnswerLbl.SetTextColor(Android.Graphics.Color.Black);
                androidSecretQuestionAnswerLbl.Gravity = Android.Views.GravityFlags.Start;
            }
#endif

            backBtn = new Button
            {
                Style             = (Style)Application.Current.Resources["common-red-btn"],
                Image             = "back.png",
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            backBtn.Clicked += async(sender, e) =>
            {
                ToggleButtons();
                await Navigation.PopModalAsync();

                ToggleButtons();
            };

            signUpBtn = new Button
            {
                Style = (Style)Application.Current.Resources["common-blue-btn"],
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = btnSize * 1.5,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = btnSize,
#endif
                Text              = "Sign Up",
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            signUpBtn.Clicked += async(sender, e) =>
            {
                ToggleButtons();
                await SignUp();

                ToggleButtons();
            };

#if __IOS__
            buttonGrid.Children.Add(backBtn, 0, 0);
            buttonGrid.Children.Add(signUpBtn, 1, 0);
#endif

            summaryLbl = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 1.5,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize,
#endif
                Text                    = "Summary",
                LineBreakMode           = LineBreakMode.WordWrap,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalOptions       = LayoutOptions.FillAndExpand
            };

            userDetailsLbl = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize * 1.5,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize,
#endif
                Text                    = "User Details",
                LineBreakMode           = LineBreakMode.WordWrap,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalOptions       = LayoutOptions.FillAndExpand
            };



            packageLbl = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize * .75,
#endif
                Text                    = $"Package: {packageName}",
                LineBreakMode           = LineBreakMode.WordWrap,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalOptions       = LayoutOptions.FillAndExpand
            };

            priceLbl = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize * .75,
#endif
                Text                    = $"Price: {packagePrice}",
                LineBreakMode           = LineBreakMode.WordWrap,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalOptions       = LayoutOptions.FillAndExpand
            };

            packageImage = new Image();
            if (packageName.Equals("Gi Jiu-Jitsu Package"))
            {
                packageImage.Source = "gi.jpg";
            }
            else if (packageName.Equals("No-Gi Jiu-Jitsu Package"))
            {
                packageImage.Source = "nogi6.jpeg";
            }
            else
            {
                packageImage.Source = "sweep.JPG";
            }
            packageImage.Aspect = Aspect.AspectFit;

            if (hasUser)
            {
                nameLbl = new Label
                {
#if __IOS__
                    FontFamily = "AmericanTypewriter-Bold",
                    FontSize   = lblSize,
#endif
#if __ANDROID__
                    FontFamily = "Roboto Bold",
                    FontSize   = lblSize * .75,
#endif
                    Text                    = $"Name: {user.Name}",
                    LineBreakMode           = LineBreakMode.WordWrap,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Start,
                    VerticalOptions         = LayoutOptions.FillAndExpand,
                    HorizontalOptions       = LayoutOptions.FillAndExpand
                };

                emailLbl = new Label
                {
#if __IOS__
                    FontFamily = "AmericanTypewriter-Bold",
                    FontSize   = lblSize,
#endif
#if __ANDROID__
                    FontFamily = "Roboto Bold",
                    FontSize   = lblSize * .75,
#endif
                    Text                    = $"E-Mail: {user.Email}",
                    LineBreakMode           = LineBreakMode.WordWrap,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Start,
                    VerticalOptions         = LayoutOptions.FillAndExpand,
                    HorizontalOptions       = LayoutOptions.FillAndExpand
                };

                beltLbl = new Label
                {
#if __IOS__
                    FontFamily = "AmericanTypewriter-Bold",
                    FontSize   = lblSize,
#endif
#if __ANDROID__
                    FontFamily = "Roboto Bold",
                    FontSize   = lblSize * .75,
#endif
                    Text                    = $"Belt: {user.Belt}",
                    LineBreakMode           = LineBreakMode.WordWrap,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Start,
                    VerticalOptions         = LayoutOptions.FillAndExpand,
                    HorizontalOptions       = LayoutOptions.FillAndExpand
                };

                secretQuestionLbl = new Label
                {
#if __IOS__
                    FontFamily = "AmericanTypewriter-Bold",
                    FontSize   = lblSize,
#endif
#if __ANDROID__
                    FontFamily = "Roboto Bold",
                    FontSize   = lblSize * .75,
#endif
                    Text                    = $"Secret Question: {user.SecretQuestion}",
                    LineBreakMode           = LineBreakMode.WordWrap,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Start,
                    VerticalOptions         = LayoutOptions.FillAndExpand,
                    HorizontalOptions       = LayoutOptions.FillAndExpand
                };

                secretQuestionAnswerLbl = new Label
                {
#if __IOS__
                    FontFamily = "AmericanTypewriter-Bold",
                    FontSize   = lblSize,
#endif
#if __ANDROID__
                    FontFamily = "Roboto Bold",
                    FontSize   = lblSize * .75,
#endif
                    Text                    = $"Answer: {user.SecretQuestionAnswer}",
                    LineBreakMode           = LineBreakMode.WordWrap,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Start,
                    VerticalOptions         = LayoutOptions.FillAndExpand,
                    HorizontalOptions       = LayoutOptions.FillAndExpand
                };

#if __IOS__
                innerGrid = new Grid
                {
                    RowDefinitions = new RowDefinitionCollection
                    {
                        new RowDefinition {
                            Height = new GridLength(1, GridUnitType.Star)
                        },
                        new RowDefinition {
                            Height = new GridLength(1, GridUnitType.Star)
                        },
                        new RowDefinition {
                            Height = new GridLength(1, GridUnitType.Star)
                        },
                        new RowDefinition {
                            Height = new GridLength(1, GridUnitType.Star)
                        },
                        new RowDefinition {
                            Height = new GridLength(1, GridUnitType.Star)
                        },
                        new RowDefinition {
                            Height = new GridLength(1, GridUnitType.Star)
                        },
                        new RowDefinition {
                            Height = new GridLength(1, GridUnitType.Star)
                        },
                        new RowDefinition {
                            Height = new GridLength(1, GridUnitType.Star)
                        },
                        new RowDefinition {
                            Height = new GridLength(1, GridUnitType.Star)
                        },
                        new RowDefinition {
                            Height = new GridLength(2, GridUnitType.Star)
                        }
                    }
                };
#endif
#if __ANDROID__
                innerGrid = new Grid
                {
                    RowDefinitions = new RowDefinitionCollection
                    {
                        new RowDefinition {
                            Height = new GridLength(9, GridUnitType.Star)
                        },
                        new RowDefinition {
                            Height = new GridLength(1, GridUnitType.Star)
                        }
                    }
                };
#endif

#if __ANDROID__
                stackLayout = new StackLayout
                {
                    Children =
                    {
                        androidSummaryLbl.ToView(),
                        androidPackageLbl.ToView(),
                        androidPriceLbl.ToView(),
                        androidUserDetailsLbl.ToView(),
                        androidNameLbl.ToView(),
                        androidEmailLbl.ToView(),
                        androidBeltLbl.ToView(),
                        androidSecretQuestionLbl.ToView(),
                        androidSecretQuestionAnswerLbl.ToView()
                    }
                };
                stackLayout.VerticalOptions   = LayoutOptions.CenterAndExpand;
                stackLayout.HorizontalOptions = LayoutOptions.CenterAndExpand;
                scrollView = new ScrollView
                {
                    Content = stackLayout,
                #if __ANDROID__
                    IsClippedToBounds = true
#endif
                };
#endif
#if __IOS__
                innerGrid.Children.Add(summaryLbl, 0, 0);
                innerGrid.Children.Add(packageLbl, 0, 1);
                innerGrid.Children.Add(priceLbl, 0, 2);
                innerGrid.Children.Add(userDetailsLbl, 0, 3);
                innerGrid.Children.Add(nameLbl, 0, 4);
                innerGrid.Children.Add(emailLbl, 0, 5);
                innerGrid.Children.Add(beltLbl, 0, 6);
                innerGrid.Children.Add(secretQuestionLbl, 0, 7);
                innerGrid.Children.Add(secretQuestionAnswerLbl, 0, 8);
                innerGrid.Children.Add(buttonGrid, 0, 9);
#endif
#if __ANDROID__
                buttonGrid.Children.Add(androidSignUpBtn.ToView(), 0, 0);

                innerGrid.Children.Add(scrollView, 0, 0);
                innerGrid.Children.Add(buttonGrid, 0, 1);
#endif
            }
            else
            {
                innerGrid = new Grid();
                innerGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                innerGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                innerGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                innerGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(4, GridUnitType.Star)
                });
                innerGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });
#if __IOS__
                innerGrid.Children.Add(summaryLbl, 0, 0);
                innerGrid.Children.Add(packageLbl, 0, 1);
                innerGrid.Children.Add(priceLbl, 0, 2);
                innerGrid.Children.Add(packageImage, 0, 3);
                innerGrid.Children.Add(buttonGrid, 0, 4);
#endif
#if __ANDROID__
                buttonGrid.Children.Add(androidSignUpBtn.ToView(), 0, 0);

                innerGrid.Children.Add(androidSummaryLbl.ToView(), 0, 0);
                innerGrid.Children.Add(androidPackageLbl.ToView(), 0, 1);
                innerGrid.Children.Add(androidPriceLbl.ToView(), 0, 2);
                innerGrid.Children.Add(packageImage, 0, 3);
                innerGrid.Children.Add(buttonGrid, 0, 4);
#endif
            }

            outerGrid.Children.Add(innerGrid, 0, 0);

            Content = outerGrid;
        }
Example #21
0
        public void SetContent()
        {
            var lblSize = Device.GetNamedSize(NamedSize.Large, typeof(Label));
            var btnSize = Device.GetNamedSize(NamedSize.Large, typeof(Button));

            //view objects
#if __IOS__
            innerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(4, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(3, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };
#endif
#if __ANDROID__
            innerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(4, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(4, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };
            if (userHasAccount)
            {
                buttonGrid = new Grid
                {
                    ColumnDefinitions = new ColumnDefinitionCollection
                    {
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Star)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Star)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Star)
                        }
                    }
                };
            }
            else
            {
                buttonGrid = new Grid
                {
                    ColumnDefinitions = new ColumnDefinitionCollection
                    {
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Star)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Star)
                        }
                    }
                };
            }
#endif

            outerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

#if __ANDROID__
            var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174));
            pd.SetCornerRadius(100);

            androidVideoNameLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidVideoNameLbl.Text     = videoTechnique.name;
            androidVideoNameLbl.Typeface = Constants.COMMONFONT;
            androidVideoNameLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 100);
            androidVideoNameLbl.SetTextColor(Android.Graphics.Color.Rgb(241, 236, 206));
            androidVideoNameLbl.Gravity = Android.Views.GravityFlags.Center;
            androidVideoNameLbl.SetTypeface(androidVideoNameLbl.Typeface, Android.Graphics.TypefaceStyle.Bold);

            androidVideoDescriptionLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidVideoDescriptionLbl.Text     = videoTechnique.description;
            androidVideoDescriptionLbl.Typeface = Constants.COMMONFONT;
            androidVideoDescriptionLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 50);
            androidVideoDescriptionLbl.SetTextColor(Android.Graphics.Color.Black);
            androidVideoDescriptionLbl.Gravity = Android.Views.GravityFlags.Start;

            androidPlayImgBtn = new Android.Widget.ImageButton(MainApplication.ActivityContext);
            androidPlayImgBtn.SetAdjustViewBounds(true);
            androidPlayImgBtn.SetImageResource(2130837817);
            androidPlayImgBtn.SetBackground(pd);
            androidPlayImgBtn.Click += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await PlayAndroidVideo(sender, e);

                ToggleButtons();
            };

            androidAddBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidAddBtn.Text     = "+";
            androidAddBtn.Typeface = Constants.COMMONFONT;
            androidAddBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidAddBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidAddBtn.SetBackground(pd);
            androidAddBtn.Gravity = Android.Views.GravityFlags.Center;
            androidAddBtn.SetAllCaps(false);
            androidAddBtn.Click += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await AddVideoToPlaylist(sender, e);

                ToggleButtons();
            };

            androidQualityBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidQualityBtn.Text     = "SD";
            androidQualityBtn.Typeface = Constants.COMMONFONT;
            androidQualityBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidQualityBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidQualityBtn.SetBackground(pd);
            androidQualityBtn.Gravity = Android.Views.GravityFlags.Center;
            androidQualityBtn.SetAllCaps(false);
            androidQualityBtn.Click += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await ChangeVideoQuality(sender, e);

                ToggleButtons();
            };

            contentViewNameLbl                = new ContentView();
            contentViewNameLbl.Content        = androidVideoNameLbl.ToView();
            contentViewDescriptionLbl         = new ContentView();
            contentViewDescriptionLbl.Content = androidVideoDescriptionLbl.ToView();
            contentViewPlayBtn                = new ContentView();
            contentViewPlayBtn.Content        = androidPlayImgBtn.ToView();
            contentViewAddBtn             = new ContentView();
            contentViewAddBtn.Content     = androidAddBtn.ToView();
            contentViewQualityBtn         = new ContentView();
            contentViewQualityBtn.Content = androidQualityBtn.ToView();
#endif

            backBtn = new Button
            {
                Image = "back.png",
                Style = (Style)Application.Current.Resources["common-red-btn"]
            };
            videoNameLbl = new Label
            {
                Style = (Style)Application.Current.Resources["common-technique-lbl"],
                Text  = videoTechnique.name,
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = lblSize,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = lblSize * .75,
#endif
            };

            videoDescription = new Label
            {
                Text = videoTechnique.description,
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                TextColor  = Color.Black,
#endif
                VerticalTextAlignment   = TextAlignment.Start,
                HorizontalTextAlignment = TextAlignment.Start,
                LineBreakMode           = LineBreakMode.WordWrap,
            };

            videoDescriptionScrollView = new ScrollView
            {
                Padding = 0,
#if __ANDROID__
                Content           = contentViewDescriptionLbl,
                IsClippedToBounds = true,
#endif
#if __IOS__
                Content = videoDescription,
#endif
                Orientation = ScrollOrientation.Vertical
            };

            videoImage = new Image
            {
                Source = videoTechnique.pictures.sizes[4].link,
                Aspect = Aspect.AspectFill
            };
            videoFrame = new Frame
            {
                Content         = videoImage,
                BorderColor     = Color.Black,
                BackgroundColor = Color.Black,
                HasShadow       = false,
                Padding         = 3
            };
            playBtn = new Button
            {
                Style = (Style)Application.Current.Resources["common-blue-btn"],
                Image = "play.png"
            };
            addBtn = new Button
            {
                Style = (Style)Application.Current.Resources["common-blue-btn"],
                Text  = "+",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = btnSize * 3,
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
                FontSize   = btnSize,
                Margin     = -5,
#endif
            };

            qualityBtn = new Button
            {
                Style      = (Style)Application.Current.Resources["common-blue-btn"],
                Text       = "SD",
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = btnSize * 2,
            };

            //Events
            backBtn.Clicked += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await Navigation.PopModalAsync();

                ToggleButtons();
            };
            addBtn.Clicked += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await AddVideoToPlaylist(sender, e);

                ToggleButtons();
            };
            qualityBtn.Clicked += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await ChangeVideoQuality(sender, e);

                ToggleButtons();
            };
#if __IOS__
            playBtn.Clicked += PlayIOSVideo;
#endif
#if __ANDROID__
            playBtn.Clicked += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await PlayAndroidVideo(sender, e);

                ToggleButtons();
            };
#endif

            if (userHasAccount)
            {
                //building grid
                innerGrid.Children.Add(videoFrame, 0, 0);
#if __IOS__
                Grid.SetColumnSpan(videoFrame, 4);

                innerGrid.Children.Add(videoNameLbl, 0, 0);
                Grid.SetColumnSpan(videoNameLbl, 4);
                innerGrid.Children.Add(playBtn, 0, 1);
                Grid.SetColumnSpan(playBtn, 2);
                innerGrid.Children.Add(addBtn, 2, 1);
                innerGrid.Children.Add(qualityBtn, 3, 1);

                innerGrid.Children.Add(videoDescriptionScrollView, 0, 2);
                Grid.SetColumnSpan(videoDescriptionScrollView, 4);
                innerGrid.Children.Add(backBtn, 0, 3);
                Grid.SetColumnSpan(backBtn, 4);
#endif
#if __ANDROID__
                buttonGrid.Children.Add(contentViewPlayBtn, 0, 0);
                buttonGrid.Children.Add(contentViewAddBtn, 1, 0);
                buttonGrid.Children.Add(contentViewQualityBtn, 2, 0);

                innerGrid.Children.Add(contentViewNameLbl, 0, 0);
                innerGrid.Children.Add(buttonGrid, 0, 1);
                innerGrid.Children.Add(videoDescriptionScrollView, 0, 2);
                Grid.SetRowSpan(videoDescriptionScrollView, 2);
#endif
            }
            else
            {
                //building grid
#if __ANDROID__
                buttonGrid.Children.Add(contentViewPlayBtn, 0, 0);
                buttonGrid.Children.Add(contentViewQualityBtn, 1, 0);

                innerGrid.Children.Add(videoFrame, 0, 0);
                innerGrid.Children.Add(contentViewNameLbl, 0, 0);
                innerGrid.Children.Add(buttonGrid, 0, 1);
                innerGrid.Children.Add(videoDescriptionScrollView, 0, 2);
#endif
#if __IOS__
                innerGrid.Children.Add(videoFrame, 0, 0);
                Grid.SetColumnSpan(videoFrame, 4);
                innerGrid.Children.Add(videoNameLbl, 0, 0);
                Grid.SetColumnSpan(videoNameLbl, 4);
                innerGrid.Children.Add(playBtn, 0, 1);
                Grid.SetColumnSpan(playBtn, 2);
                innerGrid.Children.Add(qualityBtn, 2, 1);
                Grid.SetColumnSpan(qualityBtn, 2);
                innerGrid.Children.Add(videoDescriptionScrollView, 0, 2);
                Grid.SetColumnSpan(videoDescriptionScrollView, 4);
#endif
#if __ANDROID__
                Grid.SetRowSpan(videoDescriptionScrollView, 2);
#endif
#if __IOS__
                innerGrid.Children.Add(backBtn, 0, 3);
                Grid.SetColumnSpan(backBtn, 4);
#endif
            }



            outerGrid.Children.Add(innerGrid, 0, 0);

            Content = outerGrid;
        }
Example #22
0
        public void SetContent(bool modal)
        {
            var btnSize = Device.GetNamedSize(NamedSize.Large, typeof(Button));

            //View Objects

            activityIndicator = new ActivityIndicator
            {
                Style = (Style)Application.Current.Resources["common-activity-indicator"]
            };

            //View Objects
            innerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(10, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            outerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };


            searchBar = new SearchBar
            {
                Placeholder       = "Enter technique to search for...",
                BackgroundColor   = Color.FromHex("#F1ECCE"),
                CancelButtonColor = Color.Red,
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
#endif
            };

            loadBtn = new Button
            {
                Style      = (Style)Application.Current.Resources["common-blue-btn"],
                Text       = "Load More...",
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = btnSize * 1.5,
            };

            backBtn = new Button
            {
                Style = (Style)Application.Current.Resources["common-red-btn"],
                Image = "back.png"
            };

#if __ANDROID__
            var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174));
            pd.SetCornerRadius(100);

            androidLoadBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidLoadBtn.Text     = "Load More...";
            androidLoadBtn.Typeface = Constants.COMMONFONT;
            androidLoadBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidLoadBtn.SetBackground(pd);
            androidLoadBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidLoadBtn.Gravity = Android.Views.GravityFlags.Center;
            androidLoadBtn.SetAllCaps(false);
            androidLoadBtn.Click += async(object sender, EventArgs e) => {
                ToggleButtons();
                await LoadMoreVideos(sender, e);

                ToggleButtons();
            };

            contentViewLoadBtn         = new ContentView();
            contentViewLoadBtn.Content = androidLoadBtn.ToView();
#endif

            videoListView = new ListView
            {
                ItemsSource         = searchedVideos,
                BackgroundColor     = Color.FromHex("#F1ECCE"),
                HasUnevenRows       = true,
                SeparatorVisibility = SeparatorVisibility.None,
                ItemTemplate        = new DataTemplate(() =>
                {
                    videoGrid = new Grid();
                    videoGrid.RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    });

                    videoImage = new Image();
#if __IOS__
                    videoImage.SetBinding(Image.SourceProperty, "pictures.sizes[3].link");
                    videoImage.Aspect = Aspect.Fill;
#endif
#if __ANDROID__
                    videoImage.SetBinding(Image.SourceProperty, "pictures.sizes[4].link");
                    videoImage.Aspect = Aspect.AspectFill;
#endif

                    videoLbl = new Label();
                    videoLbl.SetBinding(Label.TextProperty, "name");
                    videoLbl.VerticalTextAlignment   = TextAlignment.Center;
                    videoLbl.HorizontalTextAlignment = TextAlignment.Center;
                    videoLbl.FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label));

#if __IOS__
                    videoLbl.Style      = (Style)Application.Current.Resources["common-technique-lbl"];
                    videoLbl.FontFamily = "AmericanTypewriter-Bold";
#endif
#if __ANDROID__
                    videoLbl.FontFamily     = "american_typewriter_bold_bt.ttf#american_typewriter_bold_bt";
                    videoLbl.TextColor      = Color.AntiqueWhite;
                    videoLbl.FontAttributes = FontAttributes.Bold;
#endif


                    videoFrame                 = new Frame();
                    videoFrame.Content         = videoImage;
                    videoFrame.BorderColor     = Color.Black;
                    videoFrame.BackgroundColor = Color.Black;
                    videoFrame.HasShadow       = false;
                    videoFrame.Padding         = 3;

                    //building grid
                    videoGrid.Children.Add(videoFrame, 0, 0);
                    videoGrid.Children.Add(videoLbl, 0, 0);

                    return(new ViewCell
                    {
                        View = new StackLayout
                        {
                            Orientation = StackOrientation.Vertical,
                            Spacing = 0,
                            Padding = new Thickness(0, 5, 0, 5),
                            Children =
                            {
                                videoGrid
                            }
                        }
                    });
                })
            };

            //Events
            searchBar.SearchButtonPressed += (object sender, EventArgs e) =>
            {
                ToggleButtons();
                SearchVimeo(false);
                ToggleButtons();
            };
            searchBar.Focused += (object sender, FocusEventArgs e) => {
                FocusSearchBar(sender, e);
            };

            videoListView.ItemSelected += async(object sender, SelectedItemChangedEventArgs e) => {
                if (isPressed)
                {
                    return;
                }
                else
                {
                    isPressed = true;
                    ToggleButtons();
                    await LoadVideo(sender, e);
                }
                isPressed = false;
                ToggleButtons();
            };
            backBtn.Clicked += (object sender, EventArgs e) =>
            {
                ToggleButtons();
                Navigation.PopModalAsync();
                ToggleButtons();
            };
            loadBtn.Clicked += async(object sender, EventArgs e) => {
                ToggleButtons();
                await LoadMoreVideos(sender, e);

                ToggleButtons();
            };

            //Building grid
            if (modal)
            {
#if __ANDROID__
                innerGrid.Children.Add(videoListView, 0, 0);
#endif
#if __IOS__
                innerGrid.Children.Add(backBtn, 0, 0);
                innerGrid.Children.Add(videoListView, 0, 1);
#endif
            }
            else
            {
                innerGrid.Children.Add(searchBar, 0, 0);
                innerGrid.Children.Add(videoListView, 0, 1);
            }

            if (moreToLoad)
            {
#if __ANDROID__
                innerGrid.Children.Add(contentViewLoadBtn, 0, 2);
                Grid.SetRowSpan(videoListView, 2);
#endif
#if __IOS__
                innerGrid.Children.Add(loadBtn, 0, 2);
                Grid.SetRowSpan(videoListView, 1);
#endif
            }
            else
            {
#if __ANDROID__
                innerGrid.Children.Remove(contentViewLoadBtn);
                if (modal)
                {
                    Grid.SetRowSpan(videoListView, 3);
                }
                else
                {
                    Grid.SetRowSpan(videoListView, 2);
                }
#endif
#if __IOS__
                innerGrid.Children.Remove(loadBtn);
                Grid.SetRowSpan(videoListView, 2);
#endif
            }
            innerGrid.Children.Add(activityIndicator, 0, 0);
            Grid.SetRowSpan(activityIndicator, 3);

            outerGrid.Children.Add(innerGrid, 0, 0);

            Content = outerGrid;
        }
Example #23
0
        public static void SetTheme(CheckBox checkBox, FlatTheme theme,
                                    FlatUI.FlatFontFamily fontFamily, FlatUI.FlatFontWeight fontWeight, int radius, int size, int border)
        {
            // creating unchecked-enabled state drawable
            GradientDrawable uncheckedEnabled = new GradientDrawable();

            uncheckedEnabled.SetCornerRadius(radius);
            uncheckedEnabled.SetSize(size, size);
            uncheckedEnabled.SetColor(Color.Transparent);
            uncheckedEnabled.SetStroke(border, theme.LightAccentColor);

            // creating checked-enabled state drawable
            GradientDrawable checkedOutside = new GradientDrawable();

            checkedOutside.SetCornerRadius(radius);
            checkedOutside.SetSize(size, size);
            checkedOutside.SetColor(Color.Transparent);
            checkedOutside.SetStroke(border, theme.LightAccentColor);

            PaintDrawable checkedCore = new PaintDrawable(theme.LightAccentColor);

            checkedCore.SetCornerRadius(radius);
            checkedCore.SetIntrinsicHeight(size);
            checkedCore.SetIntrinsicWidth(size);
            InsetDrawable checkedInside = new InsetDrawable(checkedCore, border + 2, border + 2, border + 2, border + 2);

            Drawable[]    checkedEnabledDrawable = { checkedOutside, checkedInside };
            LayerDrawable checkedEnabled         = new LayerDrawable(checkedEnabledDrawable);

            // creating unchecked-enabled state drawable
            GradientDrawable uncheckedDisabled = new GradientDrawable();

            uncheckedDisabled.SetCornerRadius(radius);
            uncheckedDisabled.SetSize(size, size);
            uncheckedDisabled.SetColor(Color.Transparent);
            uncheckedDisabled.SetStroke(border, theme.VeryLightAccentColor);

            // creating checked-disabled state drawable
            GradientDrawable checkedOutsideDisabled = new GradientDrawable();

            checkedOutsideDisabled.SetCornerRadius(radius);
            checkedOutsideDisabled.SetSize(size, size);
            checkedOutsideDisabled.SetColor(Color.Transparent);
            checkedOutsideDisabled.SetStroke(border, theme.VeryLightAccentColor);

            PaintDrawable checkedCoreDisabled = new PaintDrawable(theme.VeryLightAccentColor);

            checkedCoreDisabled.SetCornerRadius(radius);
            checkedCoreDisabled.SetIntrinsicHeight(size);
            checkedCoreDisabled.SetIntrinsicWidth(size);
            InsetDrawable checkedInsideDisabled = new InsetDrawable(checkedCoreDisabled, border + 2, border + 2, border + 2, border + 2);

            Drawable[]    checkedDisabledDrawable = { checkedOutsideDisabled, checkedInsideDisabled };
            LayerDrawable checkedDisabled         = new LayerDrawable(checkedDisabledDrawable);


            StateListDrawable states = new StateListDrawable();

            states.AddState(new int[] { -Android.Resource.Attribute.StateChecked, Android.Resource.Attribute.StateEnabled }, uncheckedEnabled);
            states.AddState(new int[] { Android.Resource.Attribute.StateChecked, Android.Resource.Attribute.StateEnabled }, checkedEnabled);
            states.AddState(new int[] { -Android.Resource.Attribute.StateChecked, -Android.Resource.Attribute.StateEnabled }, uncheckedDisabled);
            states.AddState(new int[] { Android.Resource.Attribute.StateChecked, -Android.Resource.Attribute.StateEnabled }, checkedDisabled);
            checkBox.SetButtonDrawable(states);

            // setting padding for avoiding text to be appear on icon
            checkBox.SetPadding(size / 4 * 5, 0, 0, 0);
            checkBox.SetTextColor(theme.LightAccentColor);

            var typeface = FlatUI.GetFont(checkBox.Context, fontFamily, fontWeight);

            if (typeface != null)
            {
                checkBox.SetTypeface(typeface, TypefaceStyle.Normal);
            }
        }
        private static Drawable GetOverlayDrawable(Paint strokePaint, Thickness physicalBorderThickness, global::System.Drawing.Size viewSize, Path path = null)
        {
            if (strokePaint != null)
            {
                // Alias the stroke to reduce interop
                var paintStyleStroke = Paint.Style.Stroke;

                if (path != null)
                {
                    var drawable = new PaintDrawable();
                    drawable.Shape = new PathShape(path, viewSize.Width, viewSize.Height);
                    var paint = drawable.Paint;
                    paint.Color = strokePaint.Color;
                    paint.SetShader(strokePaint.Shader);
                    paint.StrokeWidth = (float)physicalBorderThickness.Top;
                    paint.SetStyle(paintStyleStroke);
                    paint.Alpha = strokePaint.Alpha;
                    return(drawable);
                }
                else if (viewSize != null && !viewSize.IsEmpty)
                {
                    var drawables = new List <Drawable>();

                    if (physicalBorderThickness.Top != 0)
                    {
                        var adjustY = (float)physicalBorderThickness.Top / 2;

                        using (var line = new Path())
                        {
                            line.MoveTo((float)physicalBorderThickness.Left, (float)adjustY);
                            line.LineTo(viewSize.Width - (float)physicalBorderThickness.Right, (float)adjustY);
                            line.Close();

                            var lineDrawable = new PaintDrawable();
                            lineDrawable.Shape = new PathShape(line, viewSize.Width, viewSize.Height);
                            var paint = lineDrawable.Paint;
                            paint.Color = strokePaint.Color;
                            paint.SetShader(strokePaint.Shader);
                            paint.StrokeWidth = (float)physicalBorderThickness.Top;
                            paint.SetStyle(paintStyleStroke);
                            paint.Alpha = strokePaint.Alpha;
                            drawables.Add(lineDrawable);
                        }
                    }

                    if (physicalBorderThickness.Right != 0)
                    {
                        var adjustX = physicalBorderThickness.Right / 2;

                        using (var line = new Path())
                        {
                            line.MoveTo((float)(viewSize.Width - adjustX), 0);
                            line.LineTo((float)(viewSize.Width - adjustX), viewSize.Height);
                            line.Close();

                            var lineDrawable = new PaintDrawable();
                            lineDrawable.Shape = new PathShape(line, viewSize.Width, viewSize.Height);
                            var paint = lineDrawable.Paint;
                            paint.Color = strokePaint.Color;
                            paint.SetShader(strokePaint.Shader);
                            paint.StrokeWidth = (float)physicalBorderThickness.Right;
                            paint.SetStyle(paintStyleStroke);
                            paint.Alpha = strokePaint.Alpha;
                            drawables.Add(lineDrawable);
                        }
                    }

                    if (physicalBorderThickness.Bottom != 0)
                    {
                        var adjustY = physicalBorderThickness.Bottom / 2;

                        using (var line = new Path())
                        {
                            line.MoveTo((float)physicalBorderThickness.Left, (float)(viewSize.Height - adjustY));
                            line.LineTo(viewSize.Width - (float)physicalBorderThickness.Right, (float)(viewSize.Height - adjustY));
                            line.Close();

                            var lineDrawable = new PaintDrawable();
                            lineDrawable.Shape = new PathShape(line, viewSize.Width, viewSize.Height);
                            var paint = lineDrawable.Paint;
                            paint.Color = strokePaint.Color;
                            paint.SetShader(strokePaint.Shader);
                            paint.StrokeWidth = (float)physicalBorderThickness.Bottom;
                            paint.SetStyle(paintStyleStroke);
                            paint.Alpha = strokePaint.Alpha;
                            drawables.Add(lineDrawable);
                        }
                    }

                    if (physicalBorderThickness.Left != 0)
                    {
                        var adjustX = physicalBorderThickness.Left / 2;

                        using (var line = new Path())
                        {
                            line.MoveTo((float)adjustX, 0);
                            line.LineTo((float)adjustX, viewSize.Height);
                            line.Close();

                            var lineDrawable = new PaintDrawable();
                            lineDrawable.Shape = new PathShape(line, viewSize.Width, viewSize.Height);
                            var paint = lineDrawable.Paint;
                            paint.Color = strokePaint.Color;
                            paint.SetShader(strokePaint.Shader);
                            paint.StrokeWidth = (float)physicalBorderThickness.Left;
                            paint.SetStyle(paintStyleStroke);
                            paint.Alpha = strokePaint.Alpha;
                            drawables.Add(lineDrawable);
                        }
                    }

                    return(new LayerDrawable(drawables.ToArray()));
                }
            }

            return(null);
        }
Example #25
0
        private void SetContent()
        {
            var btnSize   = Device.GetNamedSize(NamedSize.Large, typeof(Button));
            var lblSize   = Device.GetNamedSize(NamedSize.Large, typeof(Label));
            var entrySize = Device.GetNamedSize(NamedSize.Large, typeof(Entry));

            outerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            innerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
#if __ANDROID__
                    new RowDefinition {
                        Height = new GridLength(6, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
#endif
#if __IOS__
                    new RowDefinition {
                        Height = new GridLength(9, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
#endif
                }
            };

            buttonGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            giStackLayout   = new StackLayout();
            noGiStackLayout = new StackLayout();

            #region GI
#if __ANDROID__
            androidGiTitle          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidGiTitle.Text     = "Gi";
            androidGiTitle.Typeface = Constants.COMMONFONT;
            androidGiTitle.SetTextSize(Android.Util.ComplexUnitType.Fraction, 100);
            androidGiTitle.SetTextColor(Android.Graphics.Color.Black);
            androidGiTitle.Gravity = Android.Views.GravityFlags.Start;
            androidGiTitle.SetTypeface(androidGiTitle.Typeface, Android.Graphics.TypefaceStyle.Bold);
            contentViewGiTitle         = new ContentView();
            contentViewGiTitle.Content = androidGiTitle.ToView();

            androidGiPrice          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidGiPrice.Text     = "$19.99";
            androidGiPrice.Typeface = Constants.COMMONFONT;
            androidGiPrice.SetTextSize(Android.Util.ComplexUnitType.Fraction, 100);
            androidGiPrice.SetTextColor(Android.Graphics.Color.Black);
            androidGiPrice.Gravity = Android.Views.GravityFlags.Start;
            androidGiPrice.SetTypeface(androidGiPrice.Typeface, Android.Graphics.TypefaceStyle.Bold);
            contentViewGiPrice         = new ContentView();
            contentViewGiPrice.Content = androidGiPrice.ToView();

            androidGiBody          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidGiBody.Text     = "This library is growing constantly and there is no end in sight. The beauty of this package is that you get to follow our system as we develop and implement new transitions and positions. We’re constantly pushing the barrier in terms of our style and approach to Jiu-Jitsu. Every position that gets posted has been drilled to death and executed at the highest levels of competition. We’re proud of this; something I see wrong with other instructional resources is positions are shown that I know they have never ever hit in a competition or anything. You never have to worry about that with our techniques. One of the biggest advantages of our app is that you have direct access to us, if you have any questions or concerns; contacting us is a click away. Let’s grow and develop our Jiu Jitsu together!";
            androidGiBody.Typeface = Constants.COMMONFONT;
            androidGiBody.SetTextSize(Android.Util.ComplexUnitType.Fraction, 50);
            androidGiBody.SetTextColor(Android.Graphics.Color.Black);
            androidGiBody.Gravity = Android.Views.GravityFlags.Start;
            androidGiBody.SetTypeface(androidGiBody.Typeface, Android.Graphics.TypefaceStyle.Bold);

            contentViewGiTitle         = new ContentView();
            contentViewGiTitle.Content = androidGiBody.ToView();
            contentViewGiPrice         = new ContentView();
            contentViewGiPrice.Content = androidGiPrice.ToView();
            contentViewGiBody          = new ContentView();
            contentViewGiBody.Content  = androidGiBody.ToView();
#endif

            giTitle = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
#endif
                Text           = "Gi",
                FontSize       = lblSize * 2,
                TextColor      = Color.Black,
                FontAttributes = FontAttributes.Bold
            };

            giPrice = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
#endif
                Text           = "$19.99 (One Time Purchase)",
                FontSize       = lblSize * 1.5,
                TextColor      = Color.Black,
                FontAttributes = FontAttributes.Bold
            };

            giBody = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
#endif
                Text           = "This library is growing constantly and there is no end in sight. The beauty of this package is that you get to follow our system as we develop and implement new transitions and positions. We’re constantly pushing the barrier in terms of our style and approach to Jiu-Jitsu. Every position that gets posted has been drilled to death and executed at the highest levels of competition. We’re proud of this; something I see wrong with other instructional resources is positions are shown that I know they have never ever hit in a competition or anything. You never have to worry about that with our techniques. One of the biggest advantages of our app is that you have direct access to us, if you have any questions or concerns; contacting us is a click away. Let’s grow and develop our Jiu Jitsu together!",
                FontSize       = lblSize,
                TextColor      = Color.Black,
                FontAttributes = FontAttributes.Bold
            };

            giImage = new Image
            {
                Source = "gi.jpg",
                Aspect = Aspect.AspectFit
            };

            giImageFrame = new Frame
            {
                BorderColor     = Color.Black,
                BackgroundColor = Color.Black,
                Padding         = 2,
                Content         = giImage,
                HasShadow       = false
            };

            giScrollView = new ScrollView
            {
                BackgroundColor = Color.FromRgb(57, 172, 166),
                Content         = giStackLayout,
#if __ANDROID__
                IsClippedToBounds = true
#endif
            };

            giFrame = new Frame
            {
                BorderColor     = Color.Black,
                BackgroundColor = Color.Black,
                #if __ANDROID__
                Padding = 0,
#endif
#if __IOS__
                Padding = 5,
#endif
                Content   = giScrollView,
                HasShadow = false
            };
            #endregion
            #region NOGI
#if __ANDROID__
            androidNoGiTitle          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidNoGiTitle.Text     = "No-Gi";
            androidNoGiTitle.Typeface = Constants.COMMONFONT;
            androidNoGiTitle.SetTextSize(Android.Util.ComplexUnitType.Fraction, 100);
            androidNoGiTitle.SetTextColor(Android.Graphics.Color.Black);
            androidNoGiTitle.Gravity = Android.Views.GravityFlags.Start;
            androidNoGiTitle.SetTypeface(androidNoGiTitle.Typeface, Android.Graphics.TypefaceStyle.Bold);

            androidNoGiPrice          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidNoGiPrice.Text     = "$19.99";
            androidNoGiPrice.Typeface = Constants.COMMONFONT;
            androidNoGiPrice.SetTextSize(Android.Util.ComplexUnitType.Fraction, 100);
            androidNoGiPrice.SetTextColor(Android.Graphics.Color.Black);
            androidNoGiPrice.Gravity = Android.Views.GravityFlags.Start;
            androidNoGiPrice.SetTypeface(androidNoGiPrice.Typeface, Android.Graphics.TypefaceStyle.Bold);

            androidNoGiBody          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidNoGiBody.Text     = "Just like the other packages, the No-Gi library is constantly being updated. So that means you’ll grow along with us. As we come up with new tweaks and transitions you’ll see it first as we are constantly updating our libraries. Through these techniques and positions your game will be brought to a new technical level. All the while being exposed to a unique point of view on approaching Jiu Jitsu. Some of the biggest advantages of this package is that you have direct access to us, the ones who implement and recorded these techniques. We love to hear from our members and never ignore anyone. Lets grow together!";
            androidNoGiBody.Typeface = Constants.COMMONFONT;
            androidNoGiBody.SetTextSize(Android.Util.ComplexUnitType.Fraction, 50);
            androidNoGiBody.SetTextColor(Android.Graphics.Color.Black);
            androidNoGiBody.Gravity = Android.Views.GravityFlags.Start;
            androidNoGiBody.SetTypeface(androidNoGiBody.Typeface, Android.Graphics.TypefaceStyle.Bold);

            contentViewNoGiTitle         = new ContentView();
            contentViewNoGiTitle.Content = androidNoGiTitle.ToView();
            contentViewNoGiPrice         = new ContentView();
            contentViewNoGiPrice.Content = androidNoGiPrice.ToView();
            contentViewNoGiBody          = new ContentView();
            contentViewNoGiBody.Content  = androidNoGiBody.ToView();
#endif

            noGiTitle = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
#endif
                Text           = "No-Gi",
                FontSize       = lblSize * 2,
                TextColor      = Color.Black,
                FontAttributes = FontAttributes.Bold
            };

            noGiPrice = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
#endif
                Text           = "$19.99 (One Time Purchase)",
                FontSize       = lblSize * 1.5,
                TextColor      = Color.Black,
                FontAttributes = FontAttributes.Bold
            };

            noGiBody = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
#endif
                Text           = "Just like the other packages, the No-Gi library is constantly being updated. So that means you’ll grow along with us. As we come up with new tweaks and transitions you’ll see it first as we are constantly updating our libraries. Through these techniques and positions your game will be brought to a new technical level. All the while being exposed to a unique point of view on approaching Jiu Jitsu. Some of the biggest advantages of this package is that you have direct access to us, the ones who implement and recorded these techniques. We love to hear from our members and never ignore anyone. Lets grow together!",
                FontSize       = lblSize,
                TextColor      = Color.Black,
                FontAttributes = FontAttributes.Bold
            };

            noGiImage = new Image
            {
                Source = "nogi6.jpeg",
                Aspect = Aspect.AspectFit
            };

            noGiImageFrame = new Frame
            {
                BorderColor     = Color.Black,
                BackgroundColor = Color.Black,
                Padding         = 2,
                Content         = noGiImage,
                HasShadow       = false
            };

            noGiScrollView = new ScrollView
            {
                BackgroundColor = Color.FromRgb(57, 172, 166),
                Content         = noGiStackLayout,
#if __ANDROID__
                IsClippedToBounds = true,
                Padding           = new Thickness(5, 5, 5, 0)
#endif
            };

            noGiFrame = new Frame
            {
                BorderColor     = Color.Black,
                BackgroundColor = Color.Black,
#if __ANDROID__
                Padding = 0,
#endif
#if __IOS__
                Padding = 5,
#endif
                Content   = noGiScrollView,
                HasShadow = false
            };
            #endregion

            backBtn = new Button
            {
                Image = "back.png",
                Style = (Style)Application.Current.Resources["common-red-btn"]
            };

            purchaseBtn = new Button
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = btnSize * 1.5,
#endif
                Text              = "Purchase",
                BackgroundColor   = Color.FromRgb(58, 93, 174),
                TextColor         = Color.Black,
                BorderWidth       = 3,
                BorderColor       = Color.Black,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

#if __ANDROID__
            var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174));
            pd.SetCornerRadius(100);

            androidPurchaseBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidPurchaseBtn.Text     = "Purchase";
            androidPurchaseBtn.Typeface = Constants.COMMONFONT;
            androidPurchaseBtn.SetBackground(pd);
            androidPurchaseBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidPurchaseBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidPurchaseBtn.Gravity = Android.Views.GravityFlags.Center;
            androidPurchaseBtn.SetAllCaps(false);
            androidPurchaseBtn.Click += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await PurchasePackage();

                ToggleButtons();
            };

            contentViewPurchaseBtn         = new ContentView();
            contentViewPurchaseBtn.Content = androidPurchaseBtn.ToView();
#endif

            //events
            backBtn.Clicked += (object sender, EventArgs e) =>
            {
                ToggleButtons();
                Navigation.PopModalAsync();
                ToggleButtons();
            };
            purchaseBtn.Clicked += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await PurchasePackage();

                ToggleButtons();
            };

#if __ANDROID__
            giStackLayout.Children.Add(contentViewGiTitle);
            giStackLayout.Children.Add(contentViewGiPrice);
            giStackLayout.Children.Add(contentViewGiBody);
            giStackLayout.Children.Add(giImageFrame);
            giStackLayout.Orientation = StackOrientation.Vertical;
            noGiStackLayout.Children.Add(contentViewNoGiTitle);
            noGiStackLayout.Children.Add(contentViewNoGiPrice);
            noGiStackLayout.Children.Add(contentViewNoGiBody);
            noGiStackLayout.Children.Add(noGiImageFrame);
            noGiStackLayout.Orientation = StackOrientation.Vertical;
#endif
#if __IOS__
            buttonGrid.Children.Add(backBtn, 0, 0);
            buttonGrid.Children.Add(purchaseBtn, 1, 0);

            giStackLayout.Children.Add(giTitle);
            giStackLayout.Children.Add(giPrice);
            giStackLayout.Children.Add(giBody);
            giStackLayout.Children.Add(giImageFrame);
            giStackLayout.Orientation = StackOrientation.Vertical;
            noGiStackLayout.Children.Add(noGiTitle);
            noGiStackLayout.Children.Add(noGiPrice);
            noGiStackLayout.Children.Add(noGiBody);
            noGiStackLayout.Children.Add(noGiImageFrame);
            noGiStackLayout.Orientation = StackOrientation.Vertical;
#endif

            if (this.package == Package.Gi)
            {
                innerGrid.Children.Add(giFrame, 0, 0);
            }
            else
            {
                innerGrid.Children.Add(noGiFrame, 0, 0);
            }

#if __ANDROID__
            innerGrid.Children.Add(contentViewPurchaseBtn, 0, 1);
            outerGrid.Children.Add(innerGrid, 0, 0);
#endif
#if __IOS__
            innerGrid.Children.Add(buttonGrid, 0, 1);
            outerGrid.Children.Add(innerGrid, 0, 0);
#endif

            Content = outerGrid;
        }
Example #26
0
        private IDisposable BuildDrawableLayer()
        {
            if (_controlHeight == 0 || _controlWidth == 0)
            {
                return(Disposable.Empty);
            }

            var drawables = new List <Drawable>();

            var path = GetPath();

            if (path == null)
            {
                return(Disposable.Empty);
            }

            // Scale the path using its Stretch
            Android.Graphics.Matrix matrix = new Android.Graphics.Matrix();
            switch (this.Stretch)
            {
            case Media.Stretch.Fill:
            case Media.Stretch.None:
                matrix.SetScale((float)_scaleX, (float)_scaleY);
                break;

            case Media.Stretch.Uniform:
                var scale = Math.Min(_scaleX, _scaleY);
                matrix.SetScale((float)scale, (float)scale);
                break;

            case Media.Stretch.UniformToFill:
                scale = Math.Max(_scaleX, _scaleY);
                matrix.SetScale((float)scale, (float)scale);
                break;
            }
            path.Transform(matrix);

            // Move the path using its alignements
            var translation = new Android.Graphics.Matrix();

            var pathBounds = new RectF();

            // Compute the bounds. This is needed for stretched shapes and stroke thickness translation calculations.
            path.ComputeBounds(pathBounds, true);

            if (Stretch == Stretch.None)
            {
                // Since we are not stretching, ensure we are using (0, 0) as origin.
                pathBounds.Left = 0;
                pathBounds.Top  = 0;
            }

            if (!ShouldPreserveOrigin)
            {
                //We need to translate the shape to take in account the stroke thickness
                translation.SetTranslate((float)(-pathBounds.Left + PhysicalStrokeThickness * 0.5f), (float)(-pathBounds.Top + PhysicalStrokeThickness * 0.5f));
            }

            path.Transform(translation);

            // Draw the fill
            var drawArea = new Foundation.Rect(0, 0, _controlWidth, _controlHeight);

            var imageBrushFill = Fill as ImageBrush;

            if (imageBrushFill != null)
            {
                var bitmapDrawable = new BitmapDrawable(Context.Resources, imageBrushFill.TryGetBitmap(drawArea, () => RefreshShape(forceRefresh: true), path));
                drawables.Add(bitmapDrawable);
            }
            else
            {
                var fill      = Fill ?? SolidColorBrushHelper.Transparent;
                var fillPaint = fill.GetFillPaint(drawArea);

                var lineDrawable = new PaintDrawable();
                lineDrawable.Shape       = new PathShape(path, (float)_controlWidth, (float)_controlHeight);
                lineDrawable.Paint.Color = fillPaint.Color;
                lineDrawable.Paint.SetShader(fillPaint.Shader);
                lineDrawable.Paint.SetStyle(Paint.Style.Fill);
                lineDrawable.Paint.Alpha = fillPaint.Alpha;

                this.SetStrokeDashEffect(lineDrawable.Paint);

                drawables.Add(lineDrawable);
            }

            // Draw the contour
            if (Stroke != null)
            {
                using (var strokeBrush = new Paint(Stroke.GetStrokePaint(drawArea)))
                {
                    var lineDrawable = new PaintDrawable();
                    lineDrawable.Shape       = new PathShape(path, (float)_controlWidth, (float)_controlHeight);
                    lineDrawable.Paint.Color = strokeBrush.Color;
                    lineDrawable.Paint.SetShader(strokeBrush.Shader);
                    lineDrawable.Paint.StrokeWidth = (float)PhysicalStrokeThickness;
                    lineDrawable.Paint.SetStyle(Paint.Style.Stroke);
                    lineDrawable.Paint.Alpha = strokeBrush.Alpha;

                    this.SetStrokeDashEffect(lineDrawable.Paint);

                    drawables.Add(lineDrawable);
                }
            }

            var layerDrawable = new LayerDrawable(drawables.ToArray());

            // Set bounds must always be called, otherwise the android layout engine can't determine
            // the rendering size. See Drawable documentation for details.
            layerDrawable.SetBounds(0, 0, (int)_controlWidth, (int)_controlHeight);

            return(SetOverlay(this, layerDrawable));
        }
        //functions
        public void BuildPageObjects()
        {
            var lblSize = Device.GetNamedSize(NamedSize.Large, typeof(Label));
            var btnSize = Device.GetNamedSize(NamedSize.Large, typeof(Button));

            outerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };
            innerGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            userCredentialStack = new StackLayout();

            //load User
            var size = Device.GetNamedSize(NamedSize.Large, typeof(Button));

            //grid definiton

            nameLbl = new Label
            {
                Text = "Name",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = size * 1.5,
                HorizontalTextAlignment = TextAlignment.Center,
#endif
                VerticalTextAlignment = TextAlignment.Center,
                VerticalOptions       = LayoutOptions.FillAndExpand,
                HorizontalOptions     = LayoutOptions.FillAndExpand
            };

            nameTextLbl = new Label
            {
                Text = "Jon",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = size,
#endif
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalOptions       = LayoutOptions.FillAndExpand
            };
            emailLbl = new Label
            {
                Text = "E-Mail",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = size * 1.5,
                HorizontalTextAlignment = TextAlignment.Center,
#endif
                VerticalTextAlignment = TextAlignment.Center,
                VerticalOptions       = LayoutOptions.FillAndExpand,
                HorizontalOptions     = LayoutOptions.FillAndExpand
            };
            emailTextLbl = new Label
            {
                Text = "Doe",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = size,
#endif
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                LineBreakMode           = LineBreakMode.TailTruncation,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalOptions       = LayoutOptions.FillAndExpand
            };
            beltLbl = new Label
            {
                Text = "Belt",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = size * 1.5,
                HorizontalTextAlignment = TextAlignment.Center,
#endif
                VerticalTextAlignment = TextAlignment.Center,
                VerticalOptions       = LayoutOptions.FillAndExpand,
                HorizontalOptions     = LayoutOptions.FillAndExpand
            };
            beltTextLbl = new Label
            {
                Text = "White",
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = size,
#endif
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalOptions       = LayoutOptions.FillAndExpand
            };
            packageBtn = new Button
            {
                Style      = (Style)Application.Current.Resources["common-blue-btn"],
                Text       = "Packages",
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = size * 2
            };
            contactUsBtn = new Button
            {
                Style      = (Style)Application.Current.Resources["common-blue-btn"],
                Text       = "Contact Us",
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = size * 2
            };
            logOutBtn = new Button
            {
                Style      = (Style)Application.Current.Resources["common-blue-btn"],
                Text       = "Log Out",
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = size * 2
            };

            loginBtn       = new Button();
            loginBtn.Style = (Style)Application.Current.Resources["common-blue-btn"];
            loginBtn.Text  = "Login";
#if __IOS__
            loginBtn.FontFamily = "AmericanTypewriter-Bold";
            loginBtn.FontSize   = size * 2;
#endif
            loginBtn.Clicked += (object sender, EventArgs e) => {
                Navigation.PushModalAsync(new LoginPage());
            };

            settingsBtn = new Button
            {
                Style      = (Style)Application.Current.Resources["common-blue-btn"],
                Text       = "Settings",
                FontFamily = "AmericanTypewriter-Bold",
                FontSize   = size * 2
            };

            createAccountBtn            = new Button();
            createAccountBtn.Text       = "Create Account";
            createAccountBtn.Style      = (Style)Application.Current.Resources["common-blue-btn"];
            createAccountBtn.FontFamily = "AmericanTypewriter-Bold";
            createAccountBtn.FontSize   = btnSize * 2;
            createAccountBtn.Clicked   += async(object sender, EventArgs e) => {
                ToggleButtons();
                await Navigation.PushModalAsync(new SignUpPage());

                ToggleButtons();
            };

            timeOutLbl = new Label
            {
#if __IOS__
                FontFamily = "AmericanTypewriter-Bold",
#endif
#if __ANDROID__
                FontFamily = "Roboto Bold",
#endif
                Text                    = "Network Has Timed Out! \n Click To Try Again!",
                LineBreakMode           = LineBreakMode.WordWrap,
                FontSize                = lblSize,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                HorizontalOptions       = LayoutOptions.CenterAndExpand,
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                TextColor               = Color.White
            };
            timeOutFrame = new Frame
            {
                Content           = timeOutLbl,
                BorderColor       = Color.Black,
                BackgroundColor   = Color.Black,
                HasShadow         = false,
                Padding           = 3,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand
            };
            timeOutTap         = new TapGestureRecognizer();
            timeOutTap.Tapped += (sender, e) =>
            {
                ToggleButtons();
                SetContent();
                ToggleButtons();
            };
            timeOutLbl.GestureRecognizers.Add(timeOutTap);
            activityIndicator = new ActivityIndicator
            {
                Style = (Style)Application.Current.Resources["common-activity-indicator"]
            };

#if __ANDROID__
            var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174));
            pd.SetCornerRadius(100);

            androidNameLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidNameLbl.Text     = "Name:";
            androidNameLbl.Typeface = Constants.COMMONFONT;
            androidNameLbl.SetTextColor(Android.Graphics.Color.Black);
            androidNameLbl.Gravity = Android.Views.GravityFlags.Start;
            androidNameLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);

            androidEmailLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidEmailLbl.Text     = "Email:";
            androidEmailLbl.Typeface = Constants.COMMONFONT;
            androidEmailLbl.SetTextColor(Android.Graphics.Color.Black);
            androidEmailLbl.Gravity = Android.Views.GravityFlags.Start;
            androidEmailLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);

            androidBeltLbl          = new Android.Widget.TextView(MainApplication.ActivityContext);
            androidBeltLbl.Text     = "Belt:";
            androidBeltLbl.Typeface = Constants.COMMONFONT;
            androidBeltLbl.SetTextColor(Android.Graphics.Color.Black);
            androidBeltLbl.Gravity = Android.Views.GravityFlags.Start;
            androidBeltLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75);

            androidPackageBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidPackageBtn.Text     = "Packages";
            androidPackageBtn.Typeface = Constants.COMMONFONT;
            androidPackageBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidPackageBtn.SetBackground(pd);
            androidPackageBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidPackageBtn.Gravity = Android.Views.GravityFlags.Center;
            androidPackageBtn.SetAllCaps(false);
            androidPackageBtn.Click += async(object sender, EventArgs e) => {
                ToggleButtons();
                await SetPackages();

                ToggleButtons();
            };

            androidContactUsBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidContactUsBtn.Text     = "Contact Us";
            androidContactUsBtn.Typeface = Constants.COMMONFONT;
            androidContactUsBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidContactUsBtn.SetBackground(pd);
            androidContactUsBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidContactUsBtn.Gravity = Android.Views.GravityFlags.Center;
            androidContactUsBtn.SetAllCaps(false);
            androidContactUsBtn.Click += (object sender, EventArgs e) => {
                ToggleButtons();
                ContactUs();
                ToggleButtons();
            };

            androidLogOutBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidLogOutBtn.Text     = "Log Out";
            androidLogOutBtn.Typeface = Constants.COMMONFONT;
            androidLogOutBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidLogOutBtn.SetBackground(pd);
            androidLogOutBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidLogOutBtn.Gravity = Android.Views.GravityFlags.Center;
            androidLogOutBtn.SetAllCaps(false);
            androidLogOutBtn.Click += async(object sender, EventArgs e) => {
                ToggleButtons();
                await LogOutClick();

                ToggleButtons();
            };

            androidLoginBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidLoginBtn.Text     = "Login";
            androidLoginBtn.Typeface = Constants.COMMONFONT;
            androidLoginBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidLoginBtn.SetBackground(pd);
            androidLoginBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidLoginBtn.Gravity = Android.Views.GravityFlags.Center;
            androidLoginBtn.SetAllCaps(false);
            androidLoginBtn.Click += async(sender, e) => {
                ToggleButtons();
                await Navigation.PushModalAsync(new LoginPage());

                ToggleButtons();
            };

            androidSettingsBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidSettingsBtn.Text     = "Change Password";
            androidSettingsBtn.Typeface = Constants.COMMONFONT;
            androidSettingsBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidSettingsBtn.SetBackground(pd);
            androidSettingsBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidSettingsBtn.Gravity = Android.Views.GravityFlags.Center;
            androidSettingsBtn.SetAllCaps(false);
            androidSettingsBtn.Click += async(object sender, EventArgs e) => {
                ToggleButtons();
                await Navigation.PushModalAsync(new ChangePasswordPage(user));

                ToggleButtons();
            };

            androidCreateAccountBtn          = new Android.Widget.Button(MainApplication.ActivityContext);
            androidCreateAccountBtn.Text     = "Create Account";
            androidCreateAccountBtn.Typeface = Constants.COMMONFONT;
            androidCreateAccountBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform);
            androidCreateAccountBtn.SetBackground(pd);
            androidCreateAccountBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255));
            androidCreateAccountBtn.Gravity = Android.Views.GravityFlags.Center;
            androidCreateAccountBtn.SetAllCaps(false);
            androidCreateAccountBtn.Click += async(object sender, EventArgs e) => {
                ToggleButtons();
                await Navigation.PushModalAsync(new SignUpPage());

                ToggleButtons();
            };

            contentViewNameLbl         = new ContentView();
            contentViewNameLbl.Content = androidNameLbl.ToView();

            contentViewEmailLbl         = new ContentView();
            contentViewEmailLbl.Content = androidEmailLbl.ToView();

            contentViewBeltLbl         = new ContentView();
            contentViewBeltLbl.Content = androidBeltLbl.ToView();
#endif

            //Events
            packageBtn.Clicked += async(object sender, EventArgs e) =>
            {
                ToggleButtons();
                await SetPackages();

                ToggleButtons();
            };
            contactUsBtn.Clicked += (sender, e) =>
            {
                ToggleButtons();
                ContactUs();
                ToggleButtons();
            };
            logOutBtn.Clicked += async(sender, e) =>
            {
                ToggleButtons();
                await LogOutClick();

                ToggleButtons();
            };
            settingsBtn.Clicked += async(sender, e) =>
            {
                ToggleButtons();
                await Settings();

                ToggleButtons();
            };

            outerGrid.Children.Add(innerGrid, 0, 0);

            Content = outerGrid;
        }