Пример #1
0
        protected async Task <bool> ShowDialog(Layout <View> parent)
        {
            if (Settings == null)
            {
                Settings = new DialogSettings(); // Use default values
            }
            Parent = null;                       // Parent byl nastaven, kvůli hledání rootu, ale před přidáním Layoutu do něčeho musí být Parent null
            this.MinimumWidthRequest = parent.Width;

            // V gridu přes všechny řádky a sloupce
            if (parent is Grid)
            {
                if (((Grid)parent).RowDefinitions.Count > 1)
                {
                    Grid.SetRowSpan(this, ((Grid)parent).RowDefinitions.Count);
                }
                if (((Grid)parent).ColumnDefinitions.Count > 1)
                {
                    Grid.SetColumnSpan(this, ((Grid)parent).ColumnDefinitions.Count);
                }
            }

            // Animace zobrazení
            uint animLength = 400;

            if (Settings.DialogAnimation)
            {
                this.Opacity    = 0;
                MainFrame.Scale = 0.75;
                parent.Children.Add(this);
                this.FadeTo(1, animLength, Easing.SinOut);
                await MainFrame.ScaleTo(1, animLength, Easing.SinOut);
            }
            else
            {
                parent.Children.Add(this);
            }
            // Čekání na odkliknutí
            string result = await this.WaitForClick();

            // Animace zmizení
            if (Settings.DialogAnimation)
            {
                this.FadeTo(0, animLength, Easing.SinIn);
                await MainFrame.ScaleTo(0.75, animLength, Easing.SinIn);
            }
            parent.Children.Remove(this);
            // Vrácení výsledku
            return(result == btnOk?.Text);
        }
Пример #2
0
        protected async Task <bool> ShowDialog(Layout <View> parent)
        {
            if (Settings == null)
            {
                Settings = new DialogSettings(); // Use default values
            }
            Parent = null;                       // Parent byl nastaven, kvůli hledání rootu, ale před přidáním Layoutu do něčeho musí být Parent null
            MinimumWidthRequest = parent.Width;

            // V gridu přes všechny řádky a sloupce
            if (parent is Grid grid)
            {
                if (grid.RowDefinitions.Count > 1)
                {
                    SetRowSpan(this, grid.RowDefinitions.Count);
                }
                if (grid.ColumnDefinitions.Count > 1)
                {
                    SetColumnSpan(this, grid.ColumnDefinitions.Count);
                }
            }

            var  page      = Settings.HideNavigationBar ? ColorPickerUtils.GetRootParent <ContentPage>(parent) : null;
            bool hasNavBar = page == null ? false : NavigationPage.GetHasNavigationBar(page);

            if (hasNavBar)
            {
                NavigationPage.SetHasNavigationBar(page, false);
            }

            // Display animation
            uint animLength = 400;

            if (Settings.DialogAnimation)
            {
                Opacity         = 0;
                MainFrame.Scale = 0.75;
                parent.Children.Add(this);
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                this.FadeTo(1, animLength, Easing.SinOut);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                await MainFrame.ScaleTo(1, animLength, Easing.SinOut);
            }
            else
            {
                parent.Children.Add(this);
            }
            // Waiting for click
            string result = await WaitForClick();

            // The disappearance animation
            if (Settings.DialogAnimation)
            {
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                this.FadeTo(0, animLength, Easing.SinIn);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                await MainFrame.ScaleTo(0.75, animLength, Easing.SinIn);
            }
            parent.Children.Remove(this);

            if (hasNavBar)
            {
                NavigationPage.SetHasNavigationBar(page, true);
            }

            // Returning the result
            return(result == btnOk?.Text);
        }