Skip to content

Commit

Permalink
Fix Android SwitchCell
Browse files Browse the repository at this point in the history
  • Loading branch information
muak committed Sep 6, 2023
1 parent 1a54046 commit e4532c7
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 47 deletions.
5 changes: 2 additions & 3 deletions Sample/ViewModels/CustomHeaderViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ public class CustomHeaderViewModel:BindableBase
public ReactivePropertySlim<bool> IsAgree { get; } = new ReactivePropertySlim<bool>();

public CustomHeaderViewModel()
{
//Description.Value = "退会すると、診察券登録はすべて解除され、利用規約に従いデータは適切に処理されます。";
Description.Value = "Upon withdrawal, all medical ticket registrations will be cancelled and data will be properly processed in accordance with the Terms of Use.";
{
Description.Value = "Text TextText Text Text Text Text Text Text Text Text Text Text Text Text Text End";
}
}

88 changes: 45 additions & 43 deletions Sample/Views/CustomHeaderPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,58 @@
xmlns:sv="clr-namespace:AiForms.Settings;assembly=SettingsView"
x:Class="Sample.Views.CustomHeaderPage"
Title="CustomHeaderPage">

<sv:SettingsView HeaderBackgroundColor="LightGray">
<sv:Section>
<sv:Section.HeaderView>
<StackLayout>
<Border Grid.Row="0"
Stroke="Red"
StrokeThickness="{OnPlatform iOS=3,Android=1}"
Padding="8" BackgroundColor="#FFDDDD"
Margin="16,8,16,8" StrokeShape="RoundRectangle 16">
<Grid RowDefinitions="*,Auto" BackgroundColor="LightGray">
<sv:SettingsView HeaderBackgroundColor="LightGray" Grid.Row="0">
<sv:Section>
<sv:Section.HeaderView>
<Grid RowDefinitions="Auto,Auto" Padding="16,8,16,8">
<Border Grid.Row="0"
Stroke="Red"
StrokeThickness="{OnPlatform iOS=3,Android=1}"
Padding="8" BackgroundColor="#FFDDDD"
Margin="0,8,0,8" StrokeShape="RoundRectangle 16">

<Grid ColumnDefinitions="30,*,12" RowDefinitions="Auto">
<Grid ColumnDefinitions="Auto,*,Auto" RowDefinitions="Auto">

<Image Grid.Column="0"
Source="dotnet_bot"
WidthRequest="30" HeightRequest="30"
VerticalOptions="Center" />
<Label Grid.Column="1" Text="Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text End"
<Image Grid.Column="0"
Source="dotnet_bot"
WidthRequest="30" HeightRequest="30"
VerticalOptions="Center" />
<Label Grid.Column="1" Text="{Binding Description.Value}"
TextColor="Black"
FontSize="18"
LineBreakMode="WordWrap"
/>
<Image Grid.Column="2" Source="ic_close"
WidthRequest="12" HeightRequest="12"
VerticalOptions="Center" />
</Grid>
</Border>
<StackLayout Orientation="Horizontal" Spacing="0" Grid.Row="1"
>

<CheckBox IsChecked="{Binding IsAgree.Value}" Color="Orange"
VerticalOptions="Center" WidthRequest="36" x:Name="agreeCheckbox" />
<Label Text="I Agree"
TextColor="Black"
FontSize="16"
LineBreakMode="CharacterWrap"
/>
<Image Grid.Column="2" Source="ic_close"
WidthRequest="12" HeightRequest="12"
FontSize="18"
VerticalOptions="Center" />
</Grid>
</Border>
<StackLayout Orientation="Horizontal" Spacing="0" Grid.Row="1"
Margin="16,8,16,8">

<CheckBox IsChecked="{Binding IsAgree.Value}" Color="Orange"
VerticalOptions="Center" WidthRequest="36" x:Name="agreeCheckbox" />
<Label Text="I Agree"
TextColor="Black"
FontSize="16"
VerticalOptions="Center" />
</StackLayout>
</StackLayout>
</StackLayout>
</Grid>

</sv:Section.HeaderView>
</sv:Section>
</sv:Section.HeaderView>
</sv:Section>

<sv:Section Title="TitleA">
<sv:LabelCell Title="Label" />
</sv:Section>
<sv:Section Title="TitleA">
<sv:LabelCell Title="Label" />
</sv:Section>

<sv:Section Title="TitleB">
<sv:LabelCell Title="Label" />
</sv:Section>
<sv:Section Title="TitleB">
<sv:LabelCell Title="Label" />
</sv:Section>

</sv:SettingsView>
</sv:SettingsView>

<Button Grid.Row="1" Text="Button" Margin="32,16,32,16" />
</Grid>
</ContentPage>
2 changes: 1 addition & 1 deletion SettingsView/Platforms/Android/Cells/SwitchCellView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public SwitchCellView(Context context, CellBase cell) : base(context, cell)
_switch = new SwitchCompat(context);

_switch.SetOnCheckedChangeListener(this);
_switch.Gravity = Android.Views.GravityFlags.Right;
_switch.Gravity = Android.Views.GravityFlags.Right | GravityFlags.CenterVertical;

var switchParam = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WrapContent,
Expand Down

0 comments on commit e4532c7

Please sign in to comment.