Skip to content

Commit

Permalink
Fix Compatibility Cell templates (dotnet#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
myroot committed Aug 25, 2022
1 parent 54c98c3 commit cf930c2
Showing 1 changed file with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static View CreateContent(TextCell textcell)
{
Spacing = 0,
HorizontalOptions = LayoutOptions.Fill,
Padding = new Thickness(10, 5),
Margin = new Thickness(10, 5),
Children =
{
text,
Expand All @@ -128,19 +128,13 @@ static View CreateContent(ImageCell imageCell)
HorizontalOptions = LayoutOptions.Fill,
ColumnDefinitions =
{
new ColumnDefinition
{
Width = new GridLength(2, GridUnitType.Star)
},
new ColumnDefinition
{
Width = new GridLength(8, GridUnitType.Star)
},
}
new ColumnDefinition(GridLength.Auto),
new ColumnDefinition(GridLength.Star)
},
Margin = new Thickness(10, 5),
};
var img = new Image
{
HorizontalOptions = LayoutOptions.Start,
Aspect = Aspect.AspectFit,
};
img.SetBinding(Image.SourceProperty, new Binding("ImageSource", source: imageCell));
Expand All @@ -164,9 +158,9 @@ static View CreateContent(EntryCell entryCell)
#pragma warning disable CS0612 // Type or member is obsolete
label.FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
#pragma warning restore CS0612 // Type or member is obsolete
label.Margin = new Thickness(20, 0, 0, 0);
var layout = new Controls.StackLayout
{
Margin = new Thickness(10, 5),
HorizontalOptions = LayoutOptions.Fill,
Children =
{
Expand All @@ -180,10 +174,13 @@ static View CreateContent(EntryCell entryCell)

static View CreateContent(SwitchCell switchCell)
{
#pragma warning disable CS0618
var text = new Label
{
HorizontalOptions = LayoutOptions.Start
VerticalTextAlignment = TextAlignment.Center,
HorizontalOptions = LayoutOptions.StartAndExpand,
};
#pragma warning restore CS0618
text.SetBinding(Label.TextProperty, new Binding("Text", source: switchCell));

var sw = new Switch
Expand All @@ -195,8 +192,7 @@ static View CreateContent(SwitchCell switchCell)

var layout = new Controls.StackLayout
{
Padding = new Thickness(10, 5),
Spacing = 0,
Margin = new Thickness(10, 5),
HorizontalOptions = LayoutOptions.Fill,
Orientation = StackOrientation.Horizontal,
Children =
Expand All @@ -218,6 +214,7 @@ class CellContentView : ContentView
BindableObject _target;
public CellContentView(BindableObject target, BindableObject container = null, bool hasVisualState = true, bool hasSeparator = true)
{
BackgroundColor = Colors.Transparent;
var separator = new BoxView
{
Margin = new Thickness(10, 0),
Expand Down Expand Up @@ -281,7 +278,7 @@ void SetupVisualState()
var selected = new VisualState
{
Name = VisualStateManager.CommonStates.Selected,
TargetType = typeof(View),
TargetType = typeof(Controls.Layout),
Setters =
{
new Setter
Expand All @@ -295,7 +292,7 @@ void SetupVisualState()
var normal = new VisualState
{
Name = VisualStateManager.CommonStates.Normal,
TargetType = typeof(View),
TargetType = typeof(Controls.Layout),
Setters =
{
new Setter
Expand All @@ -308,7 +305,7 @@ void SetupVisualState()
var focused = new VisualState
{
Name = VisualStateManager.CommonStates.Focused,
TargetType = typeof(View),
TargetType = typeof(Controls.Layout),
Setters =
{
new Setter
Expand Down

0 comments on commit cf930c2

Please sign in to comment.