AndreiMisiukevich / CardView

CardsView | CarouselView | CoverflowView | CubeView for Xamarin.Forms
MIT License
710 stars 114 forks source link

ListView in CarouselView not rendering properly on iPhone 11 or X #345

Closed ericallen13 closed 4 years ago

ericallen13 commented 4 years ago

There seems to be an issue with the phones that have cutouts around space allocation of ListViews within CarouselViews when in landscape mode. When displayed in landscape mode the ListView is getting pushed over to one side or the other by blank space.

The following XAML displays as intended on android and all iOS phones that don't use the cutout but for whatever reason the cutout seems break the listview's width.

`

                    <cards:CardViewExtended.ItemTemplate>

                        <DataTemplate>
                            <ViewCell>
                                <StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                                    <ListView HorizontalOptions="FillAndExpand" ItemsSource="{Binding BindingContext.Metrics, Source={x:Reference Main}}" VerticalOptions="FillAndExpand" HasUnevenRows="True" >
                                    <ListView.ItemTemplate>
                                        <DataTemplate>
                                            <ViewCell>

                                                    <Grid HorizontalOptions="FillAndExpand" RowSpacing="0" Padding="0,10,0,10">
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="*"/>
                                                        </Grid.RowDefinitions>
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="2.3*"/>
                                                            <ColumnDefinition Width="*"/>
                                                            <ColumnDefinition Width="*"/>

                                                            <ColumnDefinition Width="{Binding BindingContext.WideScreen, Source={x:Reference Main}, Converter={x:StaticResource WideScreenColumnSizeConverter}}"/>
                                                            <ColumnDefinition Width="{Binding BindingContext.WideScreen, Source={x:Reference Main}, Converter={x:StaticResource WideScreenColumnSizeConverter}}"/>
                                                        </Grid.ColumnDefinitions>

                                                        <StackLayout BackgroundColor="Red" Orientation="Vertical" Grid.Row="0" VerticalOptions="FillAndExpand" Padding="0,0,0,2" HorizontalOptions="FillAndExpand" >
                                                            <Label Text="asd" VerticalTextAlignment="End" HorizontalTextAlignment="Start" TextColor="#0093CA" FontSize="15"  />

                                                            <Label Text="asd" VerticalOptions="FillAndExpand"  VerticalTextAlignment="Start"  FontSize="13" TextColor="#666666" Grid.Column="0" WidthRequest="80" />
                                                        </StackLayout>
                                                        <StackLayout Grid.Column="1" HorizontalOptions="FillAndExpand" BackgroundColor="Pink" VerticalOptions="FillAndExpand">
                                                            <Label Text="asdasd"  Grid.Row="0" TextColor="Black" FontSize="14"  HorizontalTextAlignment="Center" HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand" VerticalTextAlignment="Center" />
                                                        </StackLayout>
                                                        <Label Text="asd" BackgroundColor="Orange" FontSize="14" VerticalOptions="FillAndExpand" TextColor="red"  VerticalTextAlignment="Center"  HorizontalOptions="FillAndExpand" HorizontalTextAlignment="Center" Grid.Column="2"/>
                                                        <Label Text="asd" FontSize="14" BackgroundColor="Blue" VerticalOptions="FillAndExpand" TextColor="red"  VerticalTextAlignment="Center"  HorizontalOptions="FillAndExpand" HorizontalTextAlignment="Center"  Grid.Column="3" IsVisible="{Binding BindingContext.WideScreen, Source={x:Reference Main}}" />
                                                        <Label Text="asd"  FontSize="14" BackgroundColor="Green" VerticalOptions="FillAndExpand" TextColor="red" VerticalTextAlignment="Center"  HorizontalOptions="FillAndExpand" HorizontalTextAlignment="Center"  Grid.Column="4" IsVisible="{Binding BindingContext.WideScreen, Source={x:Reference Main}}" />

                                                    </Grid>

                                            </ViewCell>
                                        </DataTemplate>
                                    </ListView.ItemTemplate>

                                </ListView>
                                </StackLayout>
                            </ViewCell>
                        </DataTemplate>
                    </cards:CardViewExtended.ItemTemplate>
                </cards:CardViewExtended>

            </StackLayout>`

Here's a few screenshots of the issue with and without safe space enabled:

image

image

image

Any insight into what might be causing this? Again it works exactly as you would expect on all other platforms.

Xamarin Forms: 4.1.0.778454 CardsView 2.5.1

AndreiMisiukevich commented 4 years ago

Can you build a simple sample? And can you show the expected screenshot? it's difficult to understand what's wrong. Also, I see you use cards:CardViewExtended

AndreiMisiukevich commented 4 years ago

image

Works as expected

AndreiMisiukevich commented 4 years ago

I've just tried to put simple cell inside listview WITHOUT carousel

Content = new ListView
{
    BackgroundColor = Color.Green,
    ItemsSource = new int[] { 1, 2, 3, 4, 5 },
    ItemTemplate = new DataTemplate(() => new ViewCell { View = new ContentView { BackgroundColor = Color.Red } })
};

So, it's Xamarin.Forms issue

image