Skip to content

Commit 0d26504

Browse files
committed
Added UWP HeaderedTextBlock control. Updated csproj to work accordingly with UWP, Android and iOS. Updated the samples apps to show off the headered text block.
1 parent a5aa9d0 commit 0d26504

22 files changed

Lines changed: 6383 additions & 2356 deletions

File tree

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,3 +289,13 @@ __pycache__/
289289

290290
# Additionals
291291
*.bak
292+
*.yml
293+
.manifest
294+
**/DROP/
295+
**/TEMP/
296+
**/packages/
297+
**/bin/
298+
**/obj/
299+
**/_site
300+
**/log.txt
301+
**/docfx.json

MADE.App.Design/MADE.App.Design.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@
5252
</ItemGroup>
5353

5454
<ItemGroup>
55-
<PackageReference Include="docfx.console" Version="2.36.0" PrivateAssets="All" />
55+
<PackageReference Include="docfx.console" Version="2.36.2" PrivateAssets="All" />
5656
<PackageReference Include="MSBuild.Sdk.Extras" Version="1.5.4" PrivateAssets="All" />
5757
</ItemGroup>
5858

5959
<ItemGroup Condition=" '$(TargetFramework)' == 'uap10.0.16299' ">
60-
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.1.4" />
60+
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.1.5" />
6161
</ItemGroup>
6262

6363
<Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />

MADE.App.Mvvm/MADE.App.Mvvm.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
</ItemGroup>
4848

4949
<ItemGroup>
50-
<PackageReference Include="docfx.console" Version="2.36.0" PrivateAssets="All" />
50+
<PackageReference Include="docfx.console" Version="2.36.2" PrivateAssets="All" />
5151
</ItemGroup>
5252

5353
</Project>

MADE.App.Mvvm/log.txt

Lines changed: 357 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
#if WINDOWS_UWP
2+
namespace MADE.App.Views
3+
{
4+
using Windows.UI.Xaml;
5+
using Windows.UI.Xaml.Controls;
6+
7+
using MADE.App.Views.Extensions;
8+
9+
using Control = MADE.App.Views.Controls.Control;
10+
using Orientation = MADE.App.Views.Layout.Orientation;
11+
12+
[TemplatePart(Name = "HeaderContent", Type = typeof(TextBlock))]
13+
[TemplatePart(Name = "TextContent", Type = typeof(TextBlock))]
14+
[TemplateVisualState(GroupName = "OrientationStates", Name = "Vertical")]
15+
[TemplateVisualState(GroupName = "OrientationStates", Name = "Horizontal")]
16+
public class HeaderedTextBlock : Control, IHeaderedTextBlock
17+
{
18+
/// <summary>
19+
/// Defines the dependency property for the <see cref="Header"/> value.
20+
/// </summary>
21+
public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(
22+
nameof(Header),
23+
typeof(string),
24+
typeof(HeaderedTextBlock),
25+
new PropertyMetadata(null, (d, e) => ((HeaderedTextBlock)d).UpdateVisibility()));
26+
27+
/// <summary>
28+
/// Defines the dependency property for the <see cref="HeaderStyle"/> value.
29+
/// </summary>
30+
public static readonly DependencyProperty HeaderStyleProperty = DependencyProperty.Register(
31+
nameof(HeaderStyle),
32+
typeof(Style),
33+
typeof(HeaderedTextBlock),
34+
new PropertyMetadata(default(Style)));
35+
36+
/// <summary>
37+
/// Defines the dependency property for the <see cref="Orientation"/> value.
38+
/// </summary>
39+
public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register(
40+
nameof(Orientation),
41+
typeof(Orientation),
42+
typeof(HeaderedTextBlock),
43+
new PropertyMetadata(Orientation.Vertical, (d, e) => ((HeaderedTextBlock)d).UpdateOrientation()));
44+
45+
/// <summary>
46+
/// Defines the dependency property for the <see cref="Text"/> value.
47+
/// </summary>
48+
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
49+
nameof(Text),
50+
typeof(string),
51+
typeof(HeaderedTextBlock),
52+
new PropertyMetadata(null, (d, e) => ((HeaderedTextBlock)d).UpdateVisibility()));
53+
54+
/// <summary>
55+
/// Defines the dependency property for the <see cref="TextStyle"/> value.
56+
/// </summary>
57+
public static readonly DependencyProperty TextStyleProperty = DependencyProperty.Register(
58+
nameof(TextStyle),
59+
typeof(Style),
60+
typeof(HeaderedTextBlock),
61+
new PropertyMetadata(default(Style)));
62+
63+
/// <summary>
64+
/// Defines the dependency property for the <see cref="HideIfNullOrWhiteSpace"/> value.
65+
/// </summary>
66+
public static readonly DependencyProperty HideIfNullOrWhiteSpaceProperty = DependencyProperty.Register(
67+
nameof(HideIfNullOrWhiteSpace),
68+
typeof(bool),
69+
typeof(HeaderedTextBlock),
70+
new PropertyMetadata(false, (d, e) => ((HeaderedTextBlock)d).UpdateVisibility()));
71+
72+
/// <summary>
73+
/// Initializes a new instance of the <see cref="HeaderedTextBlock"/> class.
74+
/// </summary>
75+
public HeaderedTextBlock()
76+
{
77+
this.DefaultStyleKey = typeof(HeaderedTextBlock);
78+
}
79+
80+
public TextBlock HeaderTextBlock { get; private set; }
81+
82+
public TextBlock ContentTextBlock { get; private set; }
83+
84+
/// <summary>
85+
/// Gets or sets a value indicating whether to hide the control if the <see cref="IHeaderedTextBlock.Text"/> is null or whitespace.
86+
/// </summary>
87+
public bool HideIfNullOrWhiteSpace
88+
{
89+
get => (bool)this.GetValue(HideIfNullOrWhiteSpaceProperty);
90+
set => this.SetValue(HideIfNullOrWhiteSpaceProperty, value);
91+
}
92+
93+
/// <summary>
94+
/// Gets or sets the string associated with the text.
95+
/// </summary>
96+
public string Text
97+
{
98+
get => (string)this.GetValue(TextProperty);
99+
set => this.SetValue(TextProperty, value);
100+
}
101+
102+
/// <summary>
103+
/// Gets or sets the orientation the header and text should layout as.
104+
/// </summary>
105+
public Orientation Orientation
106+
{
107+
get => (Orientation)this.GetValue(OrientationProperty);
108+
set => this.SetValue(OrientationProperty, value);
109+
}
110+
111+
/// <summary>
112+
/// Gets or sets the string associated with the header.
113+
/// </summary>
114+
public string Header
115+
{
116+
get => (string)this.GetValue(HeaderProperty);
117+
set => this.SetValue(HeaderProperty, value);
118+
}
119+
120+
/// <summary>
121+
/// Gets or sets the style associated with the header content.
122+
/// </summary>
123+
public Style HeaderStyle
124+
{
125+
get => (Style)this.GetValue(HeaderStyleProperty);
126+
set => this.SetValue(HeaderStyleProperty, value);
127+
}
128+
129+
/// <summary>
130+
/// Gets or sets the style associated with the text content.
131+
/// </summary>
132+
public Style TextStyle
133+
{
134+
get => (Style)this.GetValue(TextStyleProperty);
135+
set => this.SetValue(TextStyleProperty, value);
136+
}
137+
138+
/// <summary>
139+
/// Updates the layout for the control based on the current <see cref="IHeaderedTextBlock.Orientation"/> value.
140+
/// </summary>
141+
public void UpdateOrientation()
142+
{
143+
switch (this.Orientation)
144+
{
145+
case Orientation.Vertical:
146+
VisualStateManager.GoToState(this, "Vertical", true);
147+
break;
148+
case Orientation.Horizontal:
149+
VisualStateManager.GoToState(this, "Horizontal", true);
150+
break;
151+
}
152+
}
153+
154+
/// <summary>
155+
/// Updates the visibility of the control based on the values of the <see cref="IHeaderedTextBlock.Header"/> and <see cref="IHeaderedTextBlock.Text"/> properties.
156+
/// </summary>
157+
public void UpdateVisibility()
158+
{
159+
if (!this.HideIfNullOrWhiteSpace || !string.IsNullOrWhiteSpace(this.Text))
160+
{
161+
this.IsVisible = true;
162+
this.HeaderTextBlock?.SetVisible(!string.IsNullOrWhiteSpace(this.Header));
163+
this.ContentTextBlock?.SetVisible(!string.IsNullOrWhiteSpace(this.Text));
164+
}
165+
else
166+
{
167+
this.IsVisible = false;
168+
this.HeaderTextBlock?.SetVisible(false);
169+
this.ContentTextBlock?.SetVisible(false);
170+
}
171+
}
172+
173+
/// <summary>
174+
/// Loads the relevant control template so that it's parts can be referenced.
175+
/// </summary>
176+
protected override void OnApplyTemplate()
177+
{
178+
base.OnApplyTemplate();
179+
180+
this.HeaderTextBlock = this.GetChildView<TextBlock>("HeaderContent");
181+
this.ContentTextBlock = this.GetChildView<TextBlock>("TextContent");
182+
183+
this.UpdateVisibility();
184+
this.UpdateOrientation();
185+
}
186+
}
187+
}
188+
#endif

MADE.App.Views.Controls.HeaderedTextBlock/MADE.App.Views.Controls.HeaderedTextBlock.csproj

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515
<ItemGroup>
1616
<Compile Remove="api\**" />
1717
<Compile Remove="articles\**" />
18+
<Compile Remove="obj\**" />
1819
<Compile Remove="_site\**" />
1920
<EmbeddedResource Remove="api\**" />
2021
<EmbeddedResource Remove="articles\**" />
22+
<EmbeddedResource Remove="obj\**" />
2123
<EmbeddedResource Remove="_site\**" />
2224
<None Remove="api\**" />
2325
<None Remove="articles\**" />
26+
<None Remove="obj\**" />
2427
<None Remove="_site\**" />
2528
</ItemGroup>
2629

@@ -54,12 +57,13 @@
5457

5558
<ItemGroup>
5659
<Compile Remove="**\*.designer.cs" />
57-
<None Include="Resources\**\*.*;*.xib" />
60+
<None Include="Resources\**\*.*;**\*.xib;**\*.designer.cs" />
61+
<Page Remove="Themes\*.xaml" />
5862
</ItemGroup>
5963

6064
<ItemGroup Condition=" '$(TargetFramework)' == 'xamarin.ios10' ">
61-
<Compile Include="**\*.designer.cs" />
62-
<InterfaceDefinition Include="HeaderedTextBlock.xib">
65+
<Compile Include="HeaderedTextBlock.designer.cs" />
66+
<InterfaceDefinition Include="*.xib">
6367
<SubType>Designer</SubType>
6468
</InterfaceDefinition>
6569
</ItemGroup>
@@ -70,20 +74,32 @@
7074
<AndroidResource Include="Resources\**\*.xml" />
7175
</ItemGroup>
7276

77+
<PropertyGroup Condition=" '$(TargetFramework)' == 'uap10.0.16299' ">
78+
<GenerateLibraryLayout>true</GenerateLibraryLayout>
79+
</PropertyGroup>
80+
81+
<ItemGroup Condition=" '$(TargetFramework)' == 'uap10.0.16299' ">
82+
<Page Include="Themes\*.xaml">
83+
<SubType>Designer</SubType>
84+
<Generator>MSBuild:Compile</Generator>
85+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
86+
</Page>
87+
</ItemGroup>
88+
7389
<ItemGroup>
74-
<PackageReference Include="docfx.console" Version="2.36.0" PrivateAssets="All" />
90+
<PackageReference Include="docfx.console" Version="2.36.2" PrivateAssets="All" />
7591
<PackageReference Include="MSBuild.Sdk.Extras" Version="1.5.4" PrivateAssets="All" />
7692
</ItemGroup>
7793

7894
<ItemGroup Condition=" '$(TargetFramework)' == 'monoandroid81' ">
79-
<PackageReference Include="Xamarin.Android.Support.Fragment" Version="27.0.2" />
80-
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="27.0.2" />
81-
<PackageReference Include="Xamarin.Android.Support.Design" Version="27.0.2" />
82-
<PackageReference Include="Xamarin.Android.Support.v4" Version="27.0.2" />
95+
<PackageReference Include="Xamarin.Android.Support.Fragment" Version="27.0.2.1" />
96+
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="27.0.2.1" />
97+
<PackageReference Include="Xamarin.Android.Support.Design" Version="27.0.2.1" />
98+
<PackageReference Include="Xamarin.Android.Support.v4" Version="27.0.2.1" />
8399
</ItemGroup>
84100

85101
<ItemGroup Condition=" '$(TargetFramework)' == 'uap10.0.16299' ">
86-
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.1.4" />
102+
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.1.5" />
87103
</ItemGroup>
88104

89105
<ItemGroup>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<ResourceDictionary
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:controls="using:MADE.App.Views">
5+
6+
<Style x:Key="HeaderedTextBlockTextStyle" TargetType="TextBlock">
7+
<Setter Property="Foreground" Value="{ThemeResource ApplicationForegroundThemeBrush}" />
8+
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
9+
<Setter Property="SelectionHighlightColor" Value="{ThemeResource TextSelectionHighlightColorThemeBrush}" />
10+
<Setter Property="TextTrimming" Value="CharacterEllipsis" />
11+
<Setter Property="TextWrapping" Value="Wrap" />
12+
<Setter Property="TextLineBounds" Value="TrimToBaseline" />
13+
<Setter Property="OpticalMarginAlignment" Value="TrimSideBearings" />
14+
<Setter Property="FontSize" Value="18" />
15+
<Setter Property="FontWeight" Value="Light" />
16+
<Setter Property="LineHeight" Value="28" />
17+
</Style>
18+
19+
<Style
20+
x:Key="HeaderedTextBlockHeaderStyle"
21+
BasedOn="{StaticResource HeaderedTextBlockTextStyle}"
22+
TargetType="TextBlock">
23+
<Setter Property="Foreground" Value="{ThemeResource SystemControlBackgroundAccentBrush}" />
24+
<Setter Property="FontWeight" Value="Normal" />
25+
</Style>
26+
27+
<Style TargetType="controls:HeaderedTextBlock">
28+
<Setter Property="HorizontalAlignment" Value="Left" />
29+
<Setter Property="HeaderStyle" Value="{ThemeResource HeaderedTextBlockHeaderStyle}" />
30+
<Setter Property="TextStyle" Value="{ThemeResource HeaderedTextBlockTextStyle}" />
31+
<Setter Property="Template">
32+
<Setter.Value>
33+
<ControlTemplate TargetType="controls:HeaderedTextBlock">
34+
<Grid>
35+
<StackPanel x:Name="Panel">
36+
<TextBlock
37+
x:Name="HeaderContent"
38+
Style="{TemplateBinding HeaderStyle}"
39+
Text="{TemplateBinding Header}" />
40+
<TextBlock
41+
x:Name="TextContent"
42+
Style="{TemplateBinding TextStyle}"
43+
Text="{TemplateBinding Text}" />
44+
</StackPanel>
45+
46+
<VisualStateManager.VisualStateGroups>
47+
<VisualStateGroup x:Name="OrientationStates">
48+
<VisualState x:Name="Vertical">
49+
<VisualState.Setters>
50+
<Setter Target="Panel.Orientation" Value="Vertical" />
51+
</VisualState.Setters>
52+
</VisualState>
53+
<VisualState x:Name="Horizontal">
54+
<VisualState.Setters>
55+
<Setter Target="Panel.Orientation" Value="Horizontal" />
56+
<Setter Target="TextContent.Margin" Value="10,0,0,0" />
57+
</VisualState.Setters>
58+
</VisualState>
59+
</VisualStateGroup>
60+
</VisualStateManager.VisualStateGroups>
61+
</Grid>
62+
</ControlTemplate>
63+
</Setter.Value>
64+
</Setter>
65+
</Style>
66+
</ResourceDictionary>

MADE.App.Views.Navigation.MvvmLight/MADE.App.Views.Navigation.MvvmLight.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,18 @@
5454

5555
<ItemGroup>
5656
<PackageReference Include="CommonServiceLocator" Version="2.0.3" />
57-
<PackageReference Include="docfx.console" Version="2.36.0" PrivateAssets="All" />
57+
<PackageReference Include="docfx.console" Version="2.36.2" PrivateAssets="All" />
5858
<PackageReference Include="MSBuild.Sdk.Extras" Version="1.5.4" PrivateAssets="All" />
5959
<PackageReference Include="MvvmLightLibs" Version="5.4.1" />
6060
</ItemGroup>
6161

6262
<ItemGroup Condition=" '$(TargetFramework)' == 'monoandroid81' ">
63-
<PackageReference Include="Xamarin.Android.Support.Fragment" Version="27.0.2" />
64-
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="27.0.2" />
63+
<PackageReference Include="Xamarin.Android.Support.Fragment" Version="27.0.2.1" />
64+
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="27.0.2.1" />
6565
</ItemGroup>
6666

6767
<ItemGroup Condition=" '$(TargetFramework)' == 'uap10.0.16299' ">
68-
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.1.4" />
68+
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.1.5" />
6969
</ItemGroup>
7070

7171
<ItemGroup>

0 commit comments

Comments
 (0)