microspaze / RGPopup.Maui

Popup controls for .NET MAUI migrated from Rg.Plugins.Popup for Xamarin with some fixes.
MIT License
42 stars 10 forks source link

Added property DisableScrollView #17

Closed REDECODE closed 5 months ago

REDECODE commented 5 months ago

Hello, i added the property DisableScrollView for disabling the automatic creation of the scrollview (in iOS) as a wrapper of the popuppage.

I know the scrollview is useful for automatic scroll content in case of large content in the poput, but in some case it can be useful to use the simple contentview, for example when I have a popup with inside a round border view, then a grid with a label on the top and a listview. With the scrollview, the listview are full expanded and all the border and the popup scroll on the bottom, but i want only the listview to scroll, so i put the DisableScrollView to True and put the grid with rowdefinition to "Auto,*" so the label stay on top and the listview have all the remaining height and scroll correctly.

See this code as just an example. Hope it can be helpful.

<?xml version="1.0" encoding="utf-8" ?>
<PopupPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="_4Grapes.Popup.ListaSelezioneSingola"           
             CloseWhenBackgroundIsClicked="True"  
             DisableScrollView="True"
                  >

    <Grid HorizontalOptions="FillAndExpand" VerticalOptions="Center" Margin="40,60,40,60" RowDefinitions="Auto,*">

        <ContentView x:Name="ViewTop"  Grid.Row="0">
            <Image 
                        Source="close_yellow.png"
                        WidthRequest="20"
                        HeightRequest="20"
                        HorizontalOptions="End"
                        Margin="0,0,0,6"
                        />
        </ContentView>

        <Border  Grid.Row="1"
            VerticalOptions="FillAndExpand"
            StrokeThickness="2"
            StrokeShape="RoundRectangle 20"
            Stroke="{StaticResource Yellow}"
            BackgroundColor="{StaticResource Gray}"
               >

            <Grid HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" RowDefinitions="Auto,*">

                <Label x:Name="LblTitolo" Grid.Row="0"                    
                   FontSize="16"
                    TextColor="{StaticResource White}"
                   HorizontalTextAlignment="Center"
                   Margin="10,0,10,0"
                   />             

                <ListView x:Name="Lista" Grid.Row="1">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>

                                <ContentView BackgroundColor="{Binding BackgroundColor}" VerticalOptions="FillAndExpand">

                                    <Label
                                            FontSize="16"
                                            TextColor="{Binding TextColor}"
                                            HorizontalTextAlignment="Center"
                                            VerticalOptions="Center"
                                            Text="{Binding Text}"                                            
                                        />

                                </ContentView>

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

            </Grid>
        </Border>      

    </Grid>

</PopupPage>
microspaze commented 5 months ago

PR has been merged in the latest version 1.1.2 https://www.nuget.org/packages/RGPopup.Maui/1.1.2

Thanks very much!