Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Max height of dialog - perhaps more a question? #15

Open
john-dalsgaard opened this issue Jun 9, 2020 · 4 comments
Open

Max height of dialog - perhaps more a question? #15

john-dalsgaard opened this issue Jun 9, 2020 · 4 comments

Comments

@john-dalsgaard
Copy link

Description

I have a dialog defined by this XAML:

<extra:DialogView
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:extra="clr-namespace:AiForms.Dialogs.Abstractions;assembly=AiForms.Dialogs.Abstractions"
    xmlns:resource="clr-namespace:Angler.Resources"
    UseCurrentPageLocation="False"
    OverlayColor="#80000000"
    ProportionalWidth="0.9"
    HorizontalLayoutAlignment="Center"
    VerticalLayoutAlignment="Center"
    x:Name="Dialog" 
    x:Class="Angler.Views.CustomControls.NotifyDialog">
    <ContentView BindingContext="{x:Reference Dialog}">
        <StackLayout BackgroundColor="White" Padding="10">
            <Label Text="{Binding Title}"
                   Padding="0,10"
                   Style="{StaticResource ConfirmDialogHeading}"></Label>
            <ScrollView BackgroundColor="Transparent">
                <Label Text="{Binding Message}"
                       Style="{StaticResource ConfirmDialogText}"></Label>
            </ScrollView>
            <Button Text="{Binding OkButton}"
                    Clicked="OkButtonClicked"
                    Padding="1"/>
        </StackLayout>
    </ContentView>
</extra:DialogView>

The contents of the scroll view is edited by an administrator (in several languages) so it can take up a lot of space on devices with a small screen.

So if I set the ProportionalHeight the dialog will not auto size to fit the contents (and potentially look way too large/high). However, if there is a lot of content without ProportionalHeight the dialog will get bigger than the screen - and the user cannot read the entire message or press the button to close the dialog....

Steps to Reproduce

  1. Just create a dialog with the above XAML and call it with a long text (e.g. with several new lines)

Expected Behavior

That the dialog would not flow outside the actual screen

Actual Behavior

Dialog grows bigger than visual screen - and user can't close it

Platforms

  • [x ] Android
  • [ x] iOS

Basic Information

  • AiForms.SettingsView 1.0.3 (and earlier)
  • Xamarin.Forms 4.6.0.847
  • Affected Devices: All phones

Any suggestions I may have overlooked would be much appreciated :-)

@john-dalsgaard
Copy link
Author

I had a look at the methods I could override - and tried a simple test in the code-behind of the dialog:

protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint)
{
    var h = Dialog.Height;
    if (heightConstraint > 500)
    {
        heightConstraint = 500;
    }
    return base.OnMeasure(widthConstraint, heightConstraint);
}

... but that doesn't make any difference ;-)

Perhaps a different implementation of the above "thought" could do the trick - but apparently with some other code.

@john-dalsgaard
Copy link
Author

I can see that I could set the ProportionalHeight in the Setup method - but at this time I can't find out the calculated height of the contents.... :-(

@jmkyarrow
Copy link

If it were me I'd set proportional height to 1 with transparent overlay colour, have my contents vertically centered within a parent absolute layout, adding a tap gesture recogniser to the absolute layout and call DialogNotifier.Cancel when the tapped event fires, but I suppose you're looking for a more built-in way.

Are you supposed to put 'h' in the if statement instead? Not sure why you've defined it if it wasn't for that...

@john-dalsgaard
Copy link
Author

Ahh... the 'h' was just a test to be able to see what was going on in the debugger.

I appreciate the way you suggest to do it. However, I feel it should be possible to do way simpler - if just I could get my hands on the height of the dialog and screen - and if the dialog is higher then 90% of the screen then set the proportional height to 0.9... - but I couldn't figure out where to make that happen. Once I had the heights then changing the proportional height didn't have any effect.... :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants