Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
- expander flag
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWeen committed Apr 3, 2020
1 parent 00c3c8a commit 1878c2a
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Xamarin.Forms.Controls/CoreGallery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Xamarin.Forms.Controls.GalleryPages.PlatformTestsGallery;
using Xamarin.Forms.Controls.GalleryPages.TwoPaneViewGalleries;
using Xamarin.Forms.Controls.GalleryPages.AppThemeGalleries;
using Xamarin.Forms.Controls.GalleryPages.ExpanderGalleries;

namespace Xamarin.Forms.Controls
{
Expand Down Expand Up @@ -297,7 +298,7 @@ public override string ToString()
new GalleryPageFactory(() => new RadioButtonGroupGalleryPage(), "RadioButton group Gallery - Legacy"),
new GalleryPageFactory(() => new RadioButtonCoreGalleryPage(), "RadioButton Gallery"),
new GalleryPageFactory(() => new FontImageSourceGallery(), "Font ImageSource"),
new GalleryPageFactory(() => new ExpanderGallery(), "Expander Gallery"),
new GalleryPageFactory(() => new ExpanderGalleries(), "Expander Gallery"),
new GalleryPageFactory(() => new IndicatorsSample(), "Indicator Gallery"),
new GalleryPageFactory(() => new CarouselViewGallery(), "CarouselView Gallery"),
new GalleryPageFactory(() => new CarouselViewCoreGalleryPage(), "CarouselView Core Gallery"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
namespace Xamarin.Forms.Controls.GalleryPages.ExpanderGalleries
{
public class ExpanderGalleries : ContentPage
{
public ExpanderGalleries()
{
var descriptionLabel =
new Label { Text = "Expander Galleries", Margin = new Thickness(2, 2, 2, 2) };

Title = "Expander Galleries";

var button = new Button
{
Text = "Enable Expander",
AutomationId = "EnableExpander"
};
button.Clicked += ButtonClicked;

Content = new ScrollView
{
Content = new StackLayout
{
Children =
{
descriptionLabel,
button,
GalleryBuilder.NavButton("Expander Gallery", () =>
new ExpanderGallery(), Navigation)
}
}
};
}

void ButtonClicked(object sender, System.EventArgs e)
{
var button = sender as Button;

button.Text = "Expander Enabled!";
button.TextColor = Color.Black;
button.IsEnabled = false;

Device.SetFlags(new[] { ExperimentalFlags.ExpanderExperimental });
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Xamarin.Forms.Controls.ExpanderGallery"
x:Class="Xamarin.Forms.Controls.GalleryPages.ExpanderGalleries.ExpanderGallery"
x:Name="page">
<ScrollView Padding="30, 20">
<StackLayout BindableLayout.ItemsSource="{Binding Path=Items, Source={x:Reference page}}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Windows.Input;
using Xamarin.Forms;

namespace Xamarin.Forms.Controls
namespace Xamarin.Forms.Controls.GalleryPages.ExpanderGalleries
{
public partial class ExpanderGallery : ContentPage
{
Expand Down
18 changes: 18 additions & 0 deletions Xamarin.Forms.Core/Expander.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using static System.Math;

Expand Down Expand Up @@ -51,6 +52,7 @@ public class Expander : TemplatedView
double _endHeight;
bool _shouldIgnoreContentSetting;
bool _shouldIgnoreAnimation;
static bool isExperimentalFlagSet = false;

public Expander()
{
Expand All @@ -59,6 +61,22 @@ public Expander()
InternalChildren.Add(ExpanderLayout);
}

internal static void VerifyExperimental([CallerMemberName] string memberName = "", string constructorHint = null)
{
if (isExperimentalFlagSet)
return;

ExperimentalFlags.VerifyFlagEnabled(nameof(Markup), ExperimentalFlags.ExpanderExperimental, constructorHint, memberName);

isExperimentalFlagSet = true;
}

protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint)
{
VerifyExperimental();
return base.OnMeasure(widthConstraint, heightConstraint);
}

StackLayout ExpanderLayout { get; }

public double Spacing
Expand Down
1 change: 1 addition & 0 deletions Xamarin.Forms.Core/ExperimentalFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal static class ExperimentalFlags
internal const string MediaElementExperimental = "MediaElement_Experimental";
internal const string MarkupExperimental = "Markup_Experimental";
internal const string AppThemeExperimental = "AppTheme_Experimental";
internal const string ExpanderExperimental = "Expander_Experimental";

[EditorBrowsable(EditorBrowsableState.Never)]
public static void VerifyFlagEnabled(
Expand Down

0 comments on commit 1878c2a

Please sign in to comment.