Skip to content

Commit

Permalink
Rework ControlGallery (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamescaper authored Jul 22, 2022
1 parent 7b65b9f commit ca5acc6
Show file tree
Hide file tree
Showing 33 changed files with 211 additions and 166 deletions.
109 changes: 46 additions & 63 deletions samples/ControlGallery/AppShell.razor
Original file line number Diff line number Diff line change
@@ -1,66 +1,49 @@
@using ControlGallery.Views
@using ControlGallery.Views.Collections
@using ControlGallery.Views.Collections.CollectionView
@using ControlGallery.Views.Controls
@using ControlGallery.Views.EditText
@using ControlGallery.Views.InitiateCommands
@using ControlGallery.Views.Layouts
@using ControlGallery.Views.PresentData
@using ControlGallery.Views.SetValues
@using ControlGallery.Views.Shell

<Shell>
<FlyoutItem Title="Main">
<Tab Title="Gallery">
<ShellContent>
<PlaygroundList />
</ShellContent>
</Tab>
<Tab Title="Shell Properties">
<ShellPropertiesPlayground />
</Tab>
<Tab Title="Add/Remove">
<ContentPage Title="Adder">
<StackLayout Spacing="12">
<Button OnClick="AddTab">Add Tab</Button>
<Button IsEnabled="(tabCount > 1)" OnClick="RemoveTab">Remove tab</Button>
<Button OnClick="AddMenuItem">Add MenuItem</Button>
<Button IsEnabled="(menuItemCount > 0)" OnClick="RemoveMenuItem">Remove MenuItem</Button>
</StackLayout>
</ContentPage>
</Tab>

@for (int i = 0; i < tabCount; i++)
{
var currentIndex = i;
<ShellTab Title="@($"Tab #{currentIndex + 1}")" />
}
</FlyoutItem>

@for (int i = 0; i < menuItemCount; i++)
{
<MenuItem Text="@($"MenuItem #{i + 1}")" />
}
</Shell>

@code {
int tabCount = 1;
int menuItemCount = 2;

void AddTab()
{
tabCount++;
}

void RemoveTab()
{
if (tabCount > 1)
{
tabCount--;
}
}

void AddMenuItem()
{
menuItemCount++;
}

void RemoveMenuItem()
{
if (menuItemCount > 0)
{
menuItemCount--;
}
}
}
@*Present data*@
<BoxViewPage />
<LabelPage />

@*Initiate commands*@
<ButtonPage />
<RefreshViewPage />

@*Set values*@
<SliderPage />
<CheckboxPage />
<RadioButtonPage />

@*Edit text*@
<EntryPage />
<EditorPage />

@*Display collections*@
<CarouselViewPage />
<ShellSection Title="CollectionView">
<AddRemovePage />
<GridLayoutPage />
<SelectionPage />
<InfiniteScrollPage />
</ShellSection>

@*Layouts*@
<AbsoluteLayoutPage />
<GridPage />
<FlexLayoutPage />

@*Shell*@
<ShellNavigationPage />
<ShellPropertiesPage />
<ShellItemsPage />

</Shell>
18 changes: 0 additions & 18 deletions samples/ControlGallery/Views/CollectionViewPlayground.razor

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@page "/carouselviewplayground"

<ContentPage>
<ContentPage Title="CarouselView">
<Grid RowDefinitions="*,Auto">

<CarouselView Grid.Row="0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

@page "/pickerplayground"

<ContentPage>
<ContentPage Title="Pickers">
<ScrollView>
<StackLayout Padding="10">
<Label Text="Picker Playground" FontSize="30">
Expand Down
31 changes: 0 additions & 31 deletions samples/ControlGallery/Views/CommonControls.razor

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@page "/editorplayground"
@page "/edit-text/editors"

<ContentPage>
<ContentPage Title="Editor">
<StackLayout Margin="20">
<Editor @bind-Text="_text" OnCompleted="OnCompleted" AutoSize="EditorAutoSizeOption.TextChanges" />
<Label Text=@($"Edits count: {_editsNumber}. Text entered: {_text}")/>
Expand Down
31 changes: 31 additions & 0 deletions samples/ControlGallery/Views/EditText/EntryPage.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@page "/edit-text/editor"

@{
RenderFragment Separator = @<BoxView Color="Colors.LightGray" HeightRequest="1" />;
}

<ContentPage Title="Entry">
<StackLayout Margin="20">
<Entry @bind-Text="_text" OnCompleted="OnCompleted" />
<Label Text=@($"Edits count: {_editsNumber}. Text entered: {_text}") />

@Separator

<Label>Email entry: @_email</Label>
<Entry @bind-Text="_email" Keyboard="Keyboard.Email" />

@Separator



</StackLayout>
</ContentPage>

@code
{
string _text;
string _email;
int _editsNumber;

void OnCompleted() => _editsNumber++;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@page "/gestureplayground"

<ContentPage>
<ContentPage Title="Gestures">
<StackLayout Margin="new Thickness(20)">

<Label Text="Tap me or pan me"
Expand Down
23 changes: 23 additions & 0 deletions samples/ControlGallery/Views/InitiateCommands/ButtonPage.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<ContentPage Title="Buttons">
<VerticalStackLayout Margin="20">

<HorizontalStackLayout>
<Button Text="Favorite?" OnClick="ToggleFavorite" />

<Image Source="@(isFavorite ? _favorite : _nonFavorite)" />
</HorizontalStackLayout>

</VerticalStackLayout>
</ContentPage>

@code {
ImageSource _favorite = ImageSource.FromFile("favorite.png");
ImageSource _nonFavorite = ImageSource.FromFile("not_favorite.png");

bool isFavorite;

void ToggleFavorite()
{
isFavorite = !isFavorite;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@using Microsoft.Maui.Layouts

<ContentPage>
<ContentPage Title="FlexLayouts">
<ScrollView>
<VerticalStackLayout Padding="10" Spacing="10">

Expand Down
24 changes: 0 additions & 24 deletions samples/ControlGallery/Views/PlaygroundList.razor

This file was deleted.

21 changes: 21 additions & 0 deletions samples/ControlGallery/Views/PresentData/BoxViewPage.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<ContentPage Title="BoxViews">
<VerticalStackLayout Spacing="8">
<BoxView HeightRequest="30"
WidthRequest="30"
Color="Colors.OrangeRed"
CornerRadius="8" />

<BoxView HeightRequest="1"
Color="Colors.LightGray" />

<BoxView HeightRequest="30">
<Background>
<LinearGradientBrush EndPoint="new(1,0)">
<GradientStop Offset="0" Color="Colors.Red" />
<GradientStop Offset="1" Color="Colors.Green" />
</LinearGradientBrush>
</Background>
</BoxView>

</VerticalStackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@page "/controls/labels"

<ContentPage>
<ContentPage Title="Labels">
<ScrollView>
<VerticalStackLayout Padding="10" Spacing="20">

Expand Down
16 changes: 16 additions & 0 deletions samples/ControlGallery/Views/SetValues/CheckboxPage.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<ContentPage Title="Checkboxes">
<VerticalStackLayout Margin="20">

<HorizontalStackLayout>
<CheckBox @bind-IsChecked="_isChecked" />
<Label>Checkbox Title</Label>
</HorizontalStackLayout>

<Label>Checkbox is @(_isChecked ? "checked" : "unchecked")!</Label>
</VerticalStackLayout>
</ContentPage>

@code
{
private bool _isChecked;
}
11 changes: 11 additions & 0 deletions samples/ControlGallery/Views/SetValues/SliderPage.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<ContentPage Title="Sliders">
<VerticalStackLayout Margin="20">
<Slider Minimum="0" Maximum="20" @bind-Value="_sliderValue" />
<Label>Slider is @_sliderValue</Label>
</VerticalStackLayout>
</ContentPage>

@code
{
private double _sliderValue;
}
File renamed without changes.
Loading

0 comments on commit ca5acc6

Please sign in to comment.