Skip to content

Commit

Permalink
Merge pull request #6098 from unoplatform/feature/calendar
Browse files Browse the repository at this point in the history
Add CalendarView and CalendarDatePicker
  • Loading branch information
dr1rrb authored Jun 3, 2021
2 parents 543f580 + c571040 commit 6757684
Show file tree
Hide file tree
Showing 244 changed files with 31,610 additions and 1,551 deletions.
4 changes: 3 additions & 1 deletion .codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ exclude_paths:
- 'src/SamplesApp/**'
- '**/tsBindings/*.ts'
- 'doc/**'
- 'src/Uno.UI/Microsoft/UI/Xaml/Controls/Repeater/**'
- 'src/Uno.UI/Microsoft/UI/Xaml/Controls/Repeater/**'
- 'src/Uno.UI/UI/Xaml/Controls/CalendarView/**'
- 'src/Uno.UI/DirectUI/**'
52 changes: 51 additions & 1 deletion build/PackageDiffIgnore.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3681,15 +3681,65 @@
<Member
fullName="System.Void Windows.ApplicationModel.LeavingBackgroundEventArgs..ctor()"
reason="Not part of the UWP API" />
<Member
fullName="System.Void Windows.UI.Xaml.Controls.CalendarViewDayItemChangingEventArgs..ctor()"
reason="Not part of the UWP API" />
<Member
fullName="System.Void Windows.UI.Xaml.Controls.CalendarViewSelectedDatesChangedEventArgs..ctor()"
reason="Not part of the UWP API" />
<Member
fullName="System.Void Windows.UI.Xaml.Automation.Provider.IRawElementProviderSimple..ctor()"
reason="Not part of the UWP API" />
<Member
fullName="System.Void Windows.UI.Xaml.FrameworkElement.OnIsEnabledChanged(System.Boolean oldValue, System.Boolean newValue)"
reason="Internal method which is not part of the UWP API" />
<Member
fullName="System.Void Windows.UI.Xaml.Controls.Picker.OnIsEnabledChanged(System.Boolean oldValue, System.Boolean newValue)"
reason="Internal method which is not part of the UWP API" />
<Member
fullName="System.Void Windows.UI.Xaml.Controls.NativeListViewBase.OnIsEnabledChanged(System.Boolean oldValue, System.Boolean newValue)"
reason="Internal method which is not part of the UWP API" />
<Member
fullName="System.Void Windows.UI.Xaml.Controls.NativePagedView.OnIsEnabledChanged(System.Boolean oldValue, System.Boolean newValue)"
reason="Internal method which is not part of the UWP API" />
<Member
fullName="System.Void Windows.UI.Xaml.Controls.MultilineTextBoxView.OnIsEnabledChanged(System.Boolean oldValue, System.Boolean newValue)"
reason="Internal method which is not part of the UWP API" />
<Member
fullName="System.Void Windows.UI.Xaml.Controls.SinglelineTextBoxView.OnIsEnabledChanged(System.Boolean oldValue, System.Boolean newValue)"
reason="Internal method which is not part of the UWP API" />
<Member
fullName="System.Void Windows.UI.Xaml.Controls.SecureTextBoxView.OnIsEnabledChanged(System.Boolean oldValue, System.Boolean newValue)"
reason="Internal method which is not part of the UWP API" />
<Member
fullName="System.Void Uno.UI.Controls.Legacy.ListViewBase.OnIsEnabledChanged(System.Boolean oldValue, System.Boolean newValue)"
reason="Internal method which is not part of the UWP API" />
<Member
fullName="System.Void Uno.UI.Controls.Legacy.ListView.OnIsEnabledChanged(System.Boolean oldValue, System.Boolean newValue)"
reason="Internal method which is not part of the UWP API" />
<Member
fullName="System.Void Uno.UI.Controls.Legacy.GridView.OnIsEnabledChanged(System.Boolean oldValue, System.Boolean newValue)"
reason="Internal method which is not part of the UWP API" />
<Member
fullName="System.Void Uno.UI.Controls.Legacy.HorizontalListView.OnIsEnabledChanged(System.Boolean oldValue, System.Boolean newValue)"
reason="Internal method which is not part of the UWP API" />
<Member
fullName="System.Void Uno.UI.Controls.Legacy.HorizontalGridView.OnIsEnabledChanged(System.Boolean oldValue, System.Boolean newValue)"
reason="Internal method which is not part of the UWP API" />
</Methods>
<Fields>
<Member
fullName="Windows.UI.Xaml.DependencyProperty Microsoft.UI.Xaml.Controls.XamlControlsResources::UseCompactResourcesProperty"
reason="This should be a property, not a field" />
<Member
fullName="System.Int32 Windows.UI.Xaml.Automation.Peers.PatternInterface::value__"
reason="This enum is an uint in UWP, not an int" />
</Fields>
<Properties>
</Properties>
</IgnoreSet> <!--
</IgnoreSet>

<!--
Supported nodes (please keep at the bottom of this file):
<Types>
</Types>
Expand Down
6 changes: 6 additions & 0 deletions src/SamplesApp/SamplesApp.Shared/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,13 @@ private async Task<bool> TryNavigateToLaunchSampleAsync(LaunchActivatedEventArgs
const string samplePrefix = "sample=";
try
{
if (launchActivatedEventArgs.Arguments == null)
{
return false;
}

var args = Uri.UnescapeDataString(launchActivatedEventArgs.Arguments);

if (string.IsNullOrEmpty(args) || !args.StartsWith(samplePrefix))
{
return false;
Expand Down
42 changes: 42 additions & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,26 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\CalendarView\CalendarDatePicker_Features.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\CalendarView\CalendarView_Basics.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\CalendarView\CalendarView_Features.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\CalendarView\CalendarView_ScrollingRegion.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\CalendarView\CalendarView_SmallRange.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\Canvas\Canvas_With_Outer_Clip.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -1525,6 +1545,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ScrollViewerTests\ScrollViewer_Nested.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ScrollViewerTests\ScrollViewer_Padding.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -4791,6 +4815,21 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\Button\Buttons_Native.xaml.cs">
<DependentUpon>Buttons_Native.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\CalendarView\CalendarDatePicker_Features.xaml.cs">
<DependentUpon>CalendarDatePicker_Features.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\CalendarView\CalendarView_Basics.xaml.cs">
<DependentUpon>CalendarView_Basics.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\CalendarView\CalendarView_Features.xaml.cs">
<DependentUpon>CalendarView_Features.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\CalendarView\CalendarView_ScrollingRegion.xaml.cs">
<DependentUpon>CalendarView_ScrollingRegion.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\CalendarView\CalendarView_SmallRange.xaml.cs">
<DependentUpon>CalendarView_SmallRange.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\Canvas\Canvas_With_Outer_Clip.xaml.cs">
<DependentUpon>Canvas_With_Outer_Clip.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -5158,6 +5197,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ScrollViewerTests\ScrollViewer_Margin.xaml.cs">
<DependentUpon>ScrollViewer_Margin.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ScrollViewerTests\ScrollViewer_Nested.xaml.cs">
<DependentUpon>ScrollViewer_Nested.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ScrollViewerTests\ScrollViewer_Padding.xaml.cs">
<DependentUpon>ScrollViewer_Padding.xaml</DependentUpon>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<Page
x:Class="UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarDatePicker_Features"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<StackPanel Spacing="12">
<StackPanel Orientation="Horizontal" Spacing="10" Background="LightBlue" Padding="3">
<ComboBox x:Name="dow" Header="FirstDayOfWeek">
<ComboBoxItem IsSelected="True">Sunday</ComboBoxItem>
<ComboBoxItem>Monday</ComboBoxItem>
<ComboBoxItem>Tuesday</ComboBoxItem>
<ComboBoxItem>Wednesday</ComboBoxItem>
<ComboBoxItem>Thursday</ComboBoxItem>
<ComboBoxItem>Friday</ComboBoxItem>
<ComboBoxItem>Saturday</ComboBoxItem>
</ComboBox>
<ComboBox x:Name="dowf" Header="DOW Format">
<!-- https://docs.microsoft.com/en-us/uwp/api/windows.globalization.datetimeformatting.datetimeformatter -->
<ComboBoxItem Content="{}{dayofweek.full}"></ComboBoxItem>
<ComboBoxItem Content="{}{dayofweek.abbreviated}" IsSelected="True"></ComboBoxItem>
<ComboBoxItem Content="{}{dayofweek.abbreviated(2)}"></ComboBoxItem>
<ComboBoxItem Content="{}{dayofweek.abbreviated(3)}"></ComboBoxItem>
<ComboBoxItem Content="{}{dayofweek.solo.full}"></ComboBoxItem>
<ComboBoxItem Content="{}{dayofweek.solo.abbreviated}"></ComboBoxItem>
<ComboBoxItem Content="{}{dayofweek.solo.abbreviated(2)}"></ComboBoxItem>
<ComboBoxItem Content="{}{dayofweek.solo.abbreviated(3)}"></ComboBoxItem>
</ComboBox>
<ComboBox x:Name="cid" Header="Calendar">
<ComboBoxItem>ChineseLunarCalendar</ComboBoxItem>
<ComboBoxItem IsSelected="True">GregorianCalendar</ComboBoxItem>
<ComboBoxItem>HebrewCalendar</ComboBoxItem>
<ComboBoxItem>HijriCalendar</ComboBoxItem>
<ComboBoxItem>JapaneseCalendar</ComboBoxItem>
<ComboBoxItem>JapaneseLunarCalendar</ComboBoxItem>
<ComboBoxItem>JulianCalendar</ComboBoxItem>
<ComboBoxItem>KoreanCalendar</ComboBoxItem>
<ComboBoxItem>KoreanLunarCalendar</ComboBoxItem>
<ComboBoxItem>PersianCalendar</ComboBoxItem>
<ComboBoxItem>TaiwanCalendar</ComboBoxItem>
<ComboBoxItem>TaiwanLunarCalendar</ComboBoxItem>
<ComboBoxItem>ThaiCalendar</ComboBoxItem>
<ComboBoxItem>UmAlQuraCalendar</ComboBoxItem>
<ComboBoxItem>VietnameseLunarCalendar</ComboBoxItem>
</ComboBox>
<ToggleButton x:Name="today" IsChecked="True">IsTodayHighlighted</ToggleButton>
</StackPanel>
<StackPanel Orientation="Horizontal" Spacing="10" Background="Bisque" Padding="3">
<CalendarDatePicker
x:Name="cdp1"
Header="Stock CalendarDatePicker"
CalendarIdentifier="{Binding SelectedItem.Content, ElementName=cid, FallbackValue=GregorianCalendar}"
FirstDayOfWeek="{Binding SelectedItem.Content, ElementName=dow, FallbackValue=Sunday}"
DayOfWeekFormat="{Binding SelectedItem.Content, ElementName=dowf}"
IsTodayHighlighted="{Binding IsChecked, ElementName=today}"/>
<ToggleButton IsChecked="{Binding IsEnabled, ElementName=cdp1, Mode=TwoWay}">
IsEnabled
</ToggleButton>
<ToggleButton IsChecked="{Binding IsCalendarOpen, ElementName=cdp1, Mode=TwoWay}">
IsCalendarOpen
</ToggleButton>
<TextBox Header="Header" Text="{Binding Header, ElementName=cdp1, Mode=TwoWay}" />
<TextBlock>Date: <Run Text="{Binding Date, ElementName=cdp1}" /></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" Spacing="10" Background="Bisque" Padding="3">
<CalendarDatePicker
x:Name="cdp2"
CalendarIdentifier="{Binding SelectedItem.Content, ElementName=cid, FallbackValue=GregorianCalendar}"
Header="IsCalendarOpen=True"
IsCalendarOpen="True"
IsEnabled="False"
FirstDayOfWeek="{Binding SelectedItem.Content, ElementName=dow}"
DayOfWeekFormat="{Binding SelectedItem.Content, ElementName=dowf}"
IsTodayHighlighted="{Binding IsChecked, ElementName=today}" />
<ToggleButton IsChecked="{Binding IsEnabled, ElementName=cdp2, Mode=TwoWay}">
IsEnabled
</ToggleButton>
<ToggleButton IsChecked="{Binding IsCalendarOpen, ElementName=cdp2, Mode=TwoWay}">
IsCalendarOpen
</ToggleButton>
<TextBox Header="Header" Text="{Binding Header, ElementName=cdp2, Mode=TwoWay}" />

<TextBlock>Date: <Run Text="{Binding Date, ElementName=cdp2}" /></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" Spacing="10" Background="Bisque" Padding="3">
<CalendarDatePicker
x:Name="cdp3"
CalendarIdentifier="{Binding SelectedItem.Content, ElementName=cid, FallbackValue=GregorianCalendar}"
Header="IsGroupLabelVisible=False"
PlaceholderText="--PLACEHOLDER--"
IsGroupLabelVisible="False"
DayOfWeekFormat="{Binding SelectedItem.Content, ElementName=dowf}"
FirstDayOfWeek="{Binding SelectedItem.Content, ElementName=dow}"
IsTodayHighlighted="{Binding IsChecked, ElementName=today}" />
<ToggleButton IsChecked="{Binding IsEnabled, ElementName=cdp3, Mode=TwoWay}">
IsEnabled
</ToggleButton>
<ToggleButton IsChecked="{Binding IsCalendarOpen, ElementName=cdp3, Mode=TwoWay}">
IsCalendarOpen
</ToggleButton>

<TextBlock>Date: <Run Text="{Binding Date, ElementName=cdp3}" /></TextBlock>
</StackPanel>
</StackPanel>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Windows.UI.Xaml.Controls;
using Uno.UI.Samples.Controls;

namespace UITests.Windows_UI_Xaml_Controls.CalendarView
{
[Sample("Date Picking")]
public sealed partial class CalendarDatePicker_Features : Page
{
public CalendarDatePicker_Features()
{
this.InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Page
x:Class="UITests.Windows_UI_Xaml_Controls.CalendarViewTests.CalendarView_Basics"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UITests.Windows_UI_Xaml_Controls.CalendarViewTests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
<TextBlock VerticalAlignment="Top">This is a vanilla CalendarView...</TextBlock>
<CalendarView x:Name="sut" />
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Uno.UI.Samples.Controls;

namespace UITests.Windows_UI_Xaml_Controls.CalendarViewTests
{
[Sample("Date Picking")]
public sealed partial class CalendarView_Basics : Page
{
public CalendarView_Basics()
{
this.InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<Page
x:Class="UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Features"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />

</Grid.ColumnDefinitions>

<CalendarView x:Name="sut"
FirstDayOfWeek="{Binding SelectedItem.Content, ElementName=dow, Mode=TwoWay}"
SelectionMode="{Binding SelectedItem.Content, ElementName=selection, Mode=TwoWay}"
DisplayMode="{Binding SelectedItem.Content, ElementName=mode, FallbackValue=Month, Mode=TwoWay}" />

<StackPanel Grid.Column="1" Background="#20000000" Margin="5" Spacing="5">
<StackPanel Orientation="Horizontal" Spacing="5">
<ComboBox x:Name="mode" Header="DisplayMode">
<ComboBoxItem IsSelected="True">Month</ComboBoxItem>
<ComboBoxItem>Decade</ComboBoxItem>
<ComboBoxItem>Year</ComboBoxItem>
</ComboBox>
<ComboBox x:Name="selection" Header="SelectionMode">
<ComboBoxItem IsSelected="True">Single</ComboBoxItem>
<ComboBoxItem>Multiple</ComboBoxItem>
<ComboBoxItem>None</ComboBoxItem>
</ComboBox>
<ComboBox x:Name="dow" Header="FirstDayOfWeek">
<ComboBoxItem IsSelected="True">Sunday</ComboBoxItem>
<ComboBoxItem>Monday</ComboBoxItem>
<ComboBoxItem>Tuesday</ComboBoxItem>
<ComboBoxItem>Wednesday</ComboBoxItem>
<ComboBoxItem>Thursday</ComboBoxItem>
<ComboBoxItem>Friday</ComboBoxItem>
<ComboBoxItem>Saturday</ComboBoxItem>
</ComboBox>
<ToggleButton x:Name="today" IsChecked="{Binding IsTodayHighlighted, ElementName=sut, Mode=TwoWay}">IsTodayHighlighted</ToggleButton>
</StackPanel>
<StackPanel Orientation="Horizontal" Spacing="5">
<DatePicker x:Name="min" Header="MinDate" Date="{Binding MinDate, ElementName=sut, Mode=TwoWay}" />
<DatePicker x:Name="max" Header="MaxDate" Date="{Binding MaxDate, ElementName=sut, Mode=TwoWay}" />
</StackPanel>

<StackPanel Orientation="Horizontal" Spacing="5">
<DatePicker x:Name="setDisplayDate" Header="SetDisplayDate" />
<Button Click="SetDisplayDate">Set</Button>
</StackPanel>

<TextBlock>Selected Date(s):</TextBlock>
<ItemsControl x:Name="selected" />
</StackPanel>
</Grid></Page>
Loading

0 comments on commit 6757684

Please sign in to comment.