/// <summary> /// Initializes a new instance of the <see cref="NControl.Controls.RippleButton"/> class. /// </summary> public RippleButton() { _layout = new RelativeLayout { IsClippedToBounds = true }; // Add ripple thing _rippler = new RippleControl { InputTransparent = true, }; _layout.Children.Add(_rippler, () => _layout.Bounds); // Add title and icon _labelText = new Label { BackgroundColor = Color.Transparent, XAlign = TextAlignment.Center, YAlign = TextAlignment.Center, TextColor = Color.Black, InputTransparent = true, }; _layout.Children.Add(_labelText, () => GetTextRectangleForImagePosition(_layout)); _iconLabel = new FontAwesomeLabel { BackgroundColor = Color.Transparent, FontSize = 18, TextColor = (Color)IconColorProperty.DefaultValue, InputTransparent = true, }; _layout.Children.Add(_iconLabel, () => GetIconRectangleForImagePosition(_layout)); Content = _layout; }
/// <summary> /// Initializes a new instance of the <see cref="NControl.Controls.ActionButton"/> class. /// </summary> public ActionButton() { var layout = new Grid { Padding = 0, ColumnSpacing = 0, RowSpacing = 0 }; ButtonShadowElement = new NControlView { DrawingFunction = (canvas, rect) => { // Draw shadow rect.Inflate(new NGraphics.Size(-4)); rect.Y += 4; Device.OnPlatform( //iOS () => canvas.DrawEllipse(rect, null, new NGraphics.RadialGradientBrush( new NGraphics.Color(0, 0, 0, 200), NGraphics.Colors.Clear)), // Android () => canvas.DrawEllipse(rect, null, new NGraphics.RadialGradientBrush( new NGraphics.Point(rect.Width / 2, (rect.Height / 2) + 2), new NGraphics.Size(rect.Width, rect.Height), new NGraphics.Color(0, 0, 0, 200), NGraphics.Colors.Clear)), // WP () => canvas.DrawEllipse(rect, null, new NGraphics.RadialGradientBrush( new NGraphics.Color(0, 0, 0, 200), NGraphics.Colors.Clear)), null ); }, }; ButtonElement = new NControlView { DrawingFunction = (canvas, rect) => { // Draw button circle rect.Inflate(new NGraphics.Size(-8)); canvas.DrawEllipse(rect, null, new NGraphics.SolidBrush(ButtonColor.ToNColor())); } }; ButtonIconLabel = new FontAwesomeLabel { XAlign = TextAlignment.Center, YAlign = TextAlignment.Center, TextColor = Color.White, Text = FontAwesomeLabel.FAPlus, FontSize = 14, }; layout.Children.Add(ButtonShadowElement); layout.Children.Add(ButtonElement); layout.Children.Add(ButtonIconLabel); Content = layout; }
/// <summary> /// Initializes a new instance of the <see cref="Clooger.FormsApp.UserControls.TabBarButton"/> class. /// </summary> public TabBarButton(string imageName, string buttonText) { if (!string.IsNullOrWhiteSpace(imageName)) { _imageLabel = new FontAwesomeLabel { Text = imageName, XAlign = TextAlignment.Center, YAlign = TextAlignment.Center, TextColor = DarkTextColor, IsVisible = true }; _selectedImageLabel = new FontAwesomeLabel { Text = imageName, XAlign = TextAlignment.Center, YAlign = TextAlignment.Center, TextColor = AccentColor, IsVisible = false, }; } _label = new Label { Text = buttonText, XAlign = TextAlignment.Center, YAlign = TextAlignment.Center, FontSize = 14, LineBreakMode = LineBreakMode.TailTruncation, TextColor = DarkTextColor, }; Content = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center, Padding = 10, }; if (!string.IsNullOrWhiteSpace(imageName)) { (Content as StackLayout).Children.Add(new Grid { ColumnSpacing = 0, RowSpacing = 0, Padding = 0, HeightRequest = 38, Children = { _imageLabel, _selectedImageLabel } }); } (Content as StackLayout).Children.Add(_label); }
/// <summary> /// Initializes a new instance of the <see cref="NControl.Controls.RippleButton"/> class. /// </summary> public RippleButton() { _layout = new RelativeLayout {IsClippedToBounds = true}; // Add the bottom button _clickTarget = new Button { Text = "", BorderColor = Color.Transparent, BorderWidth = 0, BackgroundColor = Color.Transparent, }; _layout.Children.Add (_clickTarget, () => _layout.Bounds); // Add ripple thing _rippler = new RippleControl{ InputTransparent = true, }; _layout.Children.Add (_rippler, () => _layout.Bounds); // Add title and icon _labelText = new Label{ BackgroundColor = Color.Transparent, XAlign = TextAlignment.Center, YAlign = TextAlignment.Center, TextColor = Color.Black, InputTransparent = true, }; _layout.Children.Add (_labelText, ()=> GetTextRectangleForImagePosition(_layout)); _iconLabel = new FontAwesomeLabel{ BackgroundColor = Color.Transparent, FontSize = 18, TextColor = (Color)IconColorProperty.DefaultValue, InputTransparent = true, }; _layout.Children.Add (_iconLabel, () => GetIconRectangleForImagePosition(_layout)); Content = _layout; }
/// <summary> /// Initializes a new instance of the <see cref="NControl.Controls.ActionButton"/> class. /// </summary> public ActionButton() { var layout = new Grid{Padding = 0, ColumnSpacing = 0, RowSpacing = 0}; ButtonShadowElement = new NControlView{ DrawingFunction = (canvas, rect) => { // Draw shadow rect.Inflate(new NGraphics.Size(-4)); rect.Y += 4; Device.OnPlatform( //iOS () => canvas.DrawEllipse (rect, null, new NGraphics.RadialGradientBrush ( new NGraphics.Color(0, 0, 0, 200), NGraphics.Colors.Clear)), // Android () => canvas.DrawEllipse (rect, null, new NGraphics.RadialGradientBrush ( new NGraphics.Point(rect.Width/2, (rect.Height/2)+2), new NGraphics.Size(rect.Width, rect.Height), new NGraphics.Color(0, 0, 0, 200), NGraphics.Colors.Clear)), // WP () => canvas.DrawEllipse (rect, null, new NGraphics.RadialGradientBrush ( new NGraphics.Color(0, 0, 0, 200), NGraphics.Colors.Clear)), null ); }, }; ButtonElement = new NControlView{ DrawingFunction = (canvas, rect) => { // Draw button circle rect.Inflate (new NGraphics.Size (-8)); canvas.DrawEllipse (rect, null, new NGraphics.SolidBrush(ButtonColor.ToNColor())); } }; ButtonIconLabel = new FontAwesomeLabel{ XAlign = TextAlignment.Center, YAlign = TextAlignment.Center, TextColor = Color.White, Text = FontAwesomeLabel.FAPlus, FontSize = 14, }; layout.Children.Add (ButtonShadowElement); layout.Children.Add (ButtonElement); layout.Children.Add (ButtonIconLabel); Content = layout; }
/// <summary> /// Initializes a new instance of the <see cref="Clooger.FormsApp.UserControls.TabBarButton"/> class. /// </summary> public TabBarButton(string imageName, string buttonText) { if (!string.IsNullOrWhiteSpace (imageName)) { _imageLabel = new FontAwesomeLabel { Text = imageName, XAlign = TextAlignment.Center, YAlign = TextAlignment.Center, TextColor = DarkTextColor, IsVisible = true }; _selectedImageLabel = new FontAwesomeLabel { Text = imageName, XAlign = TextAlignment.Center, YAlign = TextAlignment.Center, TextColor = AccentColor, IsVisible = false, }; } _label = new Label { Text = buttonText, XAlign = TextAlignment.Center, YAlign = TextAlignment.Center, FontSize = 14, LineBreakMode = LineBreakMode.TailTruncation, TextColor = DarkTextColor, }; Content = new StackLayout{ Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center, Padding = 10, }; if (!string.IsNullOrWhiteSpace (imageName)) (Content as StackLayout).Children.Add (new Grid { ColumnSpacing = 0, RowSpacing = 0, Padding = 0, HeightRequest = 38, Children = { _imageLabel, _selectedImageLabel } }); (Content as StackLayout).Children.Add (_label); }