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

Commit

Permalink
Merge branch '4.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWeen committed Feb 8, 2020
2 parents 058696b + dd3dba3 commit 038a8c6
Show file tree
Hide file tree
Showing 47 changed files with 1,763 additions and 44 deletions.
5 changes: 3 additions & 2 deletions Xamarin.Forms.ControlGallery.Android/MainApplication.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Plugin.CurrentActivity;
using Xamarin.Forms.DualScreen;

namespace Xamarin.Forms.ControlGallery.Android
{
Expand Down Expand Up @@ -36,7 +36,8 @@ public void OnActivityCreated(Activity activity, Bundle savedInstanceState)
{
CrossCurrentActivity.Current.Activity = activity;
ActivityContext = activity;
}
DualScreenService.Init(activity);
}

public void OnActivityDestroyed(Activity activity)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="Xamarin.Forms.Controls.GalleryPages.TwoPaneViewGalleries.GridUsingDualScreenInfo">
<ContentPage.Content>
<Grid x:Name="grid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding Column1Width}"></ColumnDefinition>
<ColumnDefinition Width="{Binding Column2Width}"></ColumnDefinition>
<ColumnDefinition Width="{Binding Column3Width}"></ColumnDefinition>
</Grid.ColumnDefinitions>

<Label Text="I should be one side of the hinge"></Label>
<Label Grid.Column="2" Text="I should be on the other side of the hinge"></Label>

</Grid>
</ContentPage.Content>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace Xamarin.Forms.Controls.GalleryPages.TwoPaneViewGalleries
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class GridUsingDualScreenInfo : ContentPage
{
public DualScreen.DualScreenInfo DualScreenInfo { get; }
public GridUsingDualScreenInfo()
{
InitializeComponent();
DualScreenInfo = new DualScreen.DualScreenInfo(grid);
BindingContext = this;
}

protected override void OnAppearing()
{
base.OnAppearing();
DualScreenInfo.PropertyChanged += DualScreenInfo_PropertyChanged;
}

protected override void OnDisappearing()
{
base.OnDisappearing();
DualScreenInfo.PropertyChanged -= DualScreenInfo_PropertyChanged;
}

void DualScreenInfo_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (DualScreenInfo.SpanningBounds.Length > 0)
{
Column1Width = DualScreenInfo.SpanningBounds[0].Width;
Column2Width = DualScreenInfo.HingeBounds.Width;
Column3Width = DualScreenInfo.SpanningBounds[1].Width;
}
else
{
Column1Width = 100;
Column2Width = 0;
Column3Width = 100;
}

OnPropertyChanged(nameof(Column1Width));
OnPropertyChanged(nameof(Column2Width));
OnPropertyChanged(nameof(Column3Width));
}

public double Column1Width { get; set; }
public double Column2Width { get; set; }
public double Column3Width { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="Xamarin.Forms.Controls.GalleryPages.TwoPaneViewGalleries.OpenCompactWindow">
<ContentPage.Content>
<StackLayout>
<Button Text="Open Compact Window"
Clicked="Button_Clicked"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace Xamarin.Forms.Controls.GalleryPages.TwoPaneViewGalleries
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class OpenCompactWindow : ContentPage
{
public OpenCompactWindow()
{
InitializeComponent();
}

async void Button_Clicked(object sender, EventArgs e)
{
ContentPage page = new ContentPage() { BackgroundColor = Color.Purple };
var button = new Button()
{
Text = "Close this Window"
};

var layout = new StackLayout()
{
Children =
{
new Label(){ Text = "rabbit"},new Label(){ Text = "rabbit"},new Label(){ Text = "rabbit"},new Label(){ Text = "rabbit"},new Label(){ Text = "rabbit"},new Label(){ Text = "rabbit"},new Label(){ Text = "rabbit"},new Label(){ Text = "rabbit"},new Label(){ Text = "rabbit"},new Label(){ Text = "rabbit"},new Label(){ Text = "rabbit"},new Label(){ Text = "rabbit"},new Label(){ Text = "rabbit"},new Label(){ Text = "rabbit"},new Label(){ Text = "rabbit"},
button
},
BackgroundColor = Color.Yellow,
HorizontalOptions = LayoutOptions.Fill,
VerticalOptions = LayoutOptions.Fill
};


layout.BatchCommitted += Layout_BatchCommitted;
page.Content = layout;

var args = await DualScreen.DualScreenHelper.OpenCompactMode(page);

button.Command = new Command(async () =>
{
await args.Close();
});
}

void Layout_BatchCommitted(object sender, Internals.EventArg<VisualElement> e)
{
if (sender is StackLayout layout)
System.Diagnostics.Debug.WriteLine($"{layout.Bounds}");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public TwoPaneViewGallery()
Children =
{
GalleryBuilder.NavButton("Nested TwoPaneView Split Across Hinge", () => new NestedTwoPaneViewSplitAcrossHinge(), Navigation),
GalleryBuilder.NavButton("Open Picture in Picture Window", () => new OpenCompactWindow(), Navigation),
GalleryBuilder.NavButton("DualScreenInfo with non TwoPaneView", () => new GridUsingDualScreenInfo(), Navigation),
}
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?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.GalleryPages.VisualStateManagerGalleries.CompareStateTriggerGallery"
Title="CompareStateTrigger">
<ContentPage.Resources>
<ResourceDictionary>

<Style x:Key="CompareStateTriggerGridStyle" TargetType="Grid">
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup>
<VisualState x:Name="Wide">
<VisualState.StateTriggers>
<CompareStateTrigger Property="{Binding IsChecked, Source={x:Reference CheckBox}}" Value="True" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Green" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Narrow">
<VisualState.StateTriggers>
<CompareStateTrigger Property="{Binding IsChecked, Source={x:Reference CheckBox}}" Value="False" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Red" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>

</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<Grid
Style="{StaticResource CompareStateTriggerGridStyle}">
<Frame
HorizontalOptions="Center"
VerticalOptions="Center"
BackgroundColor="White"
CornerRadius="12"
Margin="24">
<StackLayout
Orientation="Horizontal">
<CheckBox
x:Name="CheckBox"
VerticalOptions="Center"/>
<Label
Text="Checked/Uncheck the CheckBox to modify the Grid BackgroundColor"
VerticalOptions="Center"/>
</StackLayout>
</Frame>
</Grid>
</ContentPage.Content>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Xamarin.Forms.Controls.GalleryPages.VisualStateManagerGalleries
{
public partial class CompareStateTriggerGallery : ContentPage
{
public CompareStateTriggerGallery()
{
InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?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.GalleryPages.VisualStateManagerGalleries.DeviceStateTriggerGallery"
Title="DeviceStateTrigger">
<ContentPage.Resources>
<ResourceDictionary>

<Style x:Key="DeviceStateTriggerGridStyle" TargetType="Grid">
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup>
<VisualState
x:Name="Android">
<VisualState.StateTriggers>
<DeviceStateTrigger Device="Android" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Blue" />
</VisualState.Setters>
</VisualState>
<VisualState
x:Name="iOS">
<VisualState.StateTriggers>
<DeviceStateTrigger Device="iOS" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Red" />
</VisualState.Setters>
</VisualState>
<VisualState
x:Name="UWP">
<VisualState.StateTriggers>
<DeviceStateTrigger Device="UWP" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Green" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>

</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<Grid
Style="{StaticResource DeviceStateTriggerGridStyle}">
<Label
Text="This page changes the color based on the device where the App is running."
HorizontalOptions="Center"
VerticalOptions="Center"/>
</Grid>
</ContentPage.Content>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Xamarin.Forms.Controls.GalleryPages.VisualStateManagerGalleries
{
public partial class DeviceStateTriggerGallery : ContentPage
{
public DeviceStateTriggerGallery()
{
InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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.GalleryPages.VisualStateManagerGalleries.DualScreenStateTriggerGallery"
xmlns:dualScreen="clr-namespace:Xamarin.Forms.DualScreen;assembly=Xamarin.Forms.DualScreen"
Title="DualScreenStateTrigger Gallery">
<ContentPage.Content>
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="NotSpanned">
<VisualState.StateTriggers>
<dualScreen:SpanModeStateTrigger SpanMode="SinglePane"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Red" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Spanned">
<VisualState.StateTriggers>
<dualScreen:SpanModeStateTrigger SpanMode="Wide" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Green" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</ContentPage.Content>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Xamarin.Forms.Controls.GalleryPages.VisualStateManagerGalleries
{
public partial class DualScreenStateTriggerGallery : ContentPage
{
public DualScreenStateTriggerGallery()
{
InitializeComponent();
}
}
}
Loading

0 comments on commit 038a8c6

Please sign in to comment.