-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from ZeroGachis/feature/choice-chips-component
✨Choice chips component
- Loading branch information
Showing
5 changed files
with
180 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Smartway.UiComponent.Inputs.Chips" | ||
x:Name="Chip"> | ||
<ContentView.Resources> | ||
<Style TargetType="{x:Type Frame}" x:Key="RoundBtn"> | ||
<Setter Property="BorderColor" Value="#E2E4F0"/> | ||
<Setter Property="CornerRadius" Value="80" /> | ||
<Setter Property="BackgroundColor" Value="White"/> | ||
<Setter Property="Margin" Value="0"/> | ||
<Setter Property="Padding" Value="16,12" /> | ||
<Setter Property="HasShadow" Value="False" /> | ||
</Style> | ||
<Style TargetType="{x:Type Frame}" x:Key="RoundBtnSelected"> | ||
<Setter Property="BorderColor" Value="Black"/> | ||
<Setter Property="CornerRadius" Value="80" /> | ||
<Setter Property="BackgroundColor" Value="#EBEBEB"/> | ||
<Setter Property="Margin" Value="0"/> | ||
<Setter Property="Padding" Value="16,12" /> | ||
<Setter Property="HasShadow" Value="False" /> | ||
</Style> | ||
<Style TargetType="{x:Type Label}" x:Key="ChipsLabel"> | ||
<Setter Property="FontFamily" Value="OpenSans"/> | ||
<Setter Property="FontSize" Value="14"/> | ||
<Setter Property="HorizontalTextAlignment" Value="Center"/> | ||
</Style> | ||
</ContentView.Resources> | ||
<ContentView.Content> | ||
<Frame Style="{StaticResource RoundBtn}"> | ||
<Frame.GestureRecognizers> | ||
<TapGestureRecognizer Tapped="OnTapped" /> | ||
</Frame.GestureRecognizers> | ||
<Frame.Triggers> | ||
<DataTrigger TargetType="Frame" Binding="{Binding Source={x:Reference Chip}, Path=IsSelected}" Value="True"> | ||
<Setter Property="Style" Value="{StaticResource RoundBtnSelected}" /> | ||
</DataTrigger> | ||
<DataTrigger TargetType="Frame" Binding="{Binding Source={x:Reference Chip}, Path=IsSelected}" Value="False"> | ||
<Setter Property="Style" Value="{StaticResource RoundBtn}" /> | ||
</DataTrigger> | ||
</Frame.Triggers> | ||
<Label Style="{StaticResource ChipsLabel}" Text="{Binding Source={x:Reference Chip}, Path=Label}" /> | ||
</Frame> | ||
</ContentView.Content> | ||
</ContentView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.Windows.Input; | ||
using Xamarin.Forms; | ||
using Xamarin.Forms.Xaml; | ||
|
||
namespace Smartway.UiComponent.Inputs | ||
{ | ||
[ContentProperty("CustomContent")] | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
public partial class Chips: ContentView | ||
{ | ||
public static readonly BindableProperty IsSelectedProperty = | ||
BindableProperty.Create(nameof(IsSelected), typeof(bool), typeof(Chips), false); | ||
|
||
public static readonly BindableProperty LabelProperty = BindableProperty.Create(nameof(Label), typeof(string), | ||
typeof(Chips)); | ||
|
||
public static readonly BindableProperty CommandProperty = | ||
BindableProperty.Create(nameof(Command), typeof(ICommand), typeof(Chips)); | ||
|
||
public bool IsSelected | ||
{ | ||
get => (bool) GetValue(IsSelectedProperty); | ||
set => SetValue(IsSelectedProperty, value); | ||
} | ||
|
||
public string Label | ||
{ | ||
get => (string) GetValue(LabelProperty); | ||
set => SetValue(LabelProperty, value); | ||
} | ||
|
||
public ICommand Command | ||
{ | ||
get => (ICommand) GetValue(CommandProperty); | ||
set => SetValue(CommandProperty, value); | ||
} | ||
|
||
public Chips() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void OnTapped(object sender, EventArgs e) | ||
{ | ||
IsSelected = !IsSelected; | ||
Command?.Execute(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters