Skip to content

Commit 2b6b0fc

Browse files
committed
Merged across components for building custom views for Windows, Android, iOS and Xamarin.Forms
1 parent 603b57b commit 2b6b0fc

27 files changed

Lines changed: 1675 additions & 81 deletions

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767

6868
<ItemGroup>
6969
<ProjectReference Include="..\MADE.App.Views\MADE.App.Views.csproj" />
70+
<ProjectReference Include="..\MADE.App\MADE.App.csproj" />
7071
</ItemGroup>
7172

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

MADE.App.Views.Navigation/Pages/Page.Windows.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
namespace MADE.App.Views.Navigation.Pages
33
{
44
using Windows.ApplicationModel;
5+
using Windows.UI.Xaml.Media;
56

7+
using MADE.App.Design.Color;
68
using MADE.App.Views.Extensions;
79

810
/// <summary>
@@ -27,6 +29,15 @@ public Page()
2729
};
2830
}
2931

32+
/// <summary>
33+
/// Gets or sets a color that provides the background of the view.
34+
/// </summary>
35+
public Color BackgroundColor
36+
{
37+
get => this.Background as SolidColorBrush;
38+
set => this.Background = value;
39+
}
40+
3041
/// <summary>
3142
/// Occurs when the view has loaded.
3243
/// </summary>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="OrientationExtensions.cs" company="MADE Apps">
3+
// Copyright (c) MADE Apps.
4+
// </copyright>
5+
// <summary>
6+
// Defines a collection of extensions for Xamarin.Forms orientation supported controls.
7+
// </summary>
8+
// --------------------------------------------------------------------------------------------------------------------
9+
10+
namespace MADE.App.Views.Extensions
11+
{
12+
using MADE.App.Views.Layout;
13+
14+
using Xamarin.Forms;
15+
16+
/// <summary>
17+
/// Defines a collection of extensions for Xamarin.Forms orientation supported controls.
18+
/// </summary>
19+
public static class OrientationExtensions
20+
{
21+
/// <summary>
22+
/// Sets the current orientation of the given <see cref="StackLayout"/> layout control by the given orientation value.
23+
/// </summary>
24+
/// <param name="layout">
25+
/// The <see cref="StackLayout"/> to update the orientation.
26+
/// </param>
27+
/// <param name="orientation">
28+
/// The orientation to update with.
29+
/// </param>
30+
public static void SetOrientation(this StackLayout layout, Orientation orientation)
31+
{
32+
if (layout == null)
33+
{
34+
return;
35+
}
36+
37+
layout.Orientation = orientation == Orientation.Vertical
38+
? StackOrientation.Vertical
39+
: StackOrientation.Horizontal;
40+
}
41+
}
42+
}

MADE.App.Views/Extensions/ViewExtensions.cs renamed to MADE.App.Views.Xamarin.Forms/Extensions/ViewExtensions.cs

Lines changed: 30 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@
33
// Copyright (c) MADE Apps.
44
// </copyright>
55
// <summary>
6-
// Defines a collection of extensions for application views.
6+
// Defines a collection of extensions for Xamarin.Forms views.
77
// </summary>
88
// --------------------------------------------------------------------------------------------------------------------
99

1010
namespace MADE.App.Views.Extensions
1111
{
12+
using System;
13+
14+
using Xamarin.Forms;
15+
1216
/// <summary>
13-
/// Defines a collection of extensions for application views.
17+
/// Defines a collection of extensions for Xamarin.Forms views.
1418
/// </summary>
1519
public static class ViewExtensions
1620
{
17-
#if __ANDROID__
1821
/// <summary>
1922
/// Sets the visibility of the given control by the given visible boolean value.
2023
/// </summary>
@@ -24,72 +27,36 @@ public static class ViewExtensions
2427
/// <param name="isVisible">
2528
/// A value indicating whether the control is visible.
2629
/// </param>
27-
public static void SetVisible(this Android.Views.View view, bool isVisible)
30+
public static void SetVisible(this View view, bool isVisible)
2831
{
29-
SetVisible(view, isVisible, false);
30-
}
31-
32-
/// <summary>
33-
/// Sets the visibility of the given control by the given visible boolean value.
34-
/// If the control can contain child control, these will also be updated if the given parameter is set to true.
35-
/// </summary>
36-
/// <param name="view">
37-
/// The control to update visibility.
38-
/// </param>
39-
/// <param name="isVisible">
40-
/// A value indicating whether the control is visible.
41-
/// </param>
42-
/// <param name="updateChildViews">
43-
/// A value indicating whether to update the control's child visibility states.
44-
/// </param>
45-
public static void SetVisible(this Android.Views.View view, bool isVisible, bool updateChildViews)
46-
{
47-
if (view == null)
48-
{
49-
return;
50-
}
51-
52-
view.Visibility = isVisible ? Android.Views.ViewStates.Visible : Android.Views.ViewStates.Gone;
53-
54-
if (!updateChildViews || !(view is Android.Views.ViewGroup viewGroup))
55-
{
56-
return;
57-
}
58-
59-
for (int i = 0; i < viewGroup.ChildCount; i++)
60-
{
61-
try
62-
{
63-
Android.Views.View child = viewGroup.GetChildAt(i);
64-
child?.SetVisible(isVisible, true);
65-
}
66-
catch (System.Exception)
67-
{
68-
// Ignored
69-
}
70-
}
32+
SetVisible<View>(view, isVisible, false);
7133
}
72-
#endif
7334

74-
#if WINDOWS_UWP
7535
/// <summary>
7636
/// Sets the visibility of the given control by the given visible boolean value.
7737
/// </summary>
38+
/// <typeparam name="T">
39+
/// The type of views that are potentially children of the given view.
40+
/// </typeparam>
7841
/// <param name="view">
7942
/// The control to update visibility.
8043
/// </param>
8144
/// <param name="isVisible">
8245
/// A value indicating whether the control is visible.
8346
/// </param>
84-
public static void SetVisible(this Windows.UI.Xaml.UIElement view, bool isVisible)
47+
public static void SetVisible<T>(this View view, bool isVisible)
48+
where T : View
8549
{
86-
SetVisible(view, isVisible, false);
50+
SetVisible<T>(view, isVisible, false);
8751
}
8852

8953
/// <summary>
9054
/// Sets the visibility of the given control by the given visible boolean value.
9155
/// If the control can contain child control, these will also be updated if the given parameter is set to true.
9256
/// </summary>
57+
/// <typeparam name="T">
58+
/// The type of views that are potentially children of the given view.
59+
/// </typeparam>
9360
/// <param name="view">
9461
/// The control to update visibility.
9562
/// </param>
@@ -99,25 +66,32 @@ public static void SetVisible(this Windows.UI.Xaml.UIElement view, bool isVisibl
9966
/// <param name="updateChildViews">
10067
/// A value indicating whether to update the control's child visibility states.
10168
/// </param>
102-
public static void SetVisible(this Windows.UI.Xaml.UIElement view, bool isVisible, bool updateChildViews)
69+
public static void SetVisible<T>(this View view, bool isVisible, bool updateChildViews)
70+
where T : View
10371
{
10472
if (view == null)
10573
{
10674
return;
10775
}
10876

109-
view.Visibility = isVisible ? Windows.UI.Xaml.Visibility.Visible : Windows.UI.Xaml.Visibility.Collapsed;
77+
view.IsVisible = isVisible;
11078

111-
if (!updateChildViews || !(view is Windows.UI.Xaml.Controls.Panel viewGroup))
79+
if (!updateChildViews || !(view is Layout<T> panel))
11280
{
11381
return;
11482
}
11583

116-
foreach (Windows.UI.Xaml.UIElement child in viewGroup.Children)
84+
foreach (T child in panel.Children)
11785
{
118-
child?.SetVisible(isVisible, true);
86+
try
87+
{
88+
child?.SetVisible<T>(isVisible, true);
89+
}
90+
catch (Exception)
91+
{
92+
// Ignored
93+
}
11994
}
12095
}
121-
#endif
12296
}
12397
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Xamarin.Forms" Version="3.0.0.482510" />
9+
</ItemGroup>
10+
11+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
12+
<DocumentationFile>bin\Debug\netstandard2.0\MADE.App.Views.Xamarin.Forms.xml</DocumentationFile>
13+
</PropertyGroup>
14+
15+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
16+
<DocumentationFile>bin\Release\netstandard2.0\MADE.App.Views.Xamarin.Forms.xml</DocumentationFile>
17+
</PropertyGroup>
18+
19+
<ItemGroup>
20+
<Compile Remove="api\**" />
21+
<Compile Remove="articles\**" />
22+
<Compile Remove="_site\**" />
23+
<EmbeddedResource Remove="api\**" />
24+
<EmbeddedResource Remove="articles\**" />
25+
<EmbeddedResource Remove="_site\**" />
26+
<None Remove="api\**" />
27+
<None Remove="articles\**" />
28+
<None Remove="_site\**" />
29+
</ItemGroup>
30+
31+
<PropertyGroup>
32+
<LogFile>Docfx-$(TargetFramework).log</LogFile>
33+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
34+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
35+
<Version>1.0.0.0</Version>
36+
<Authors>MADE Apps</Authors>
37+
<Company>MADE Apps</Company>
38+
<Product>MADE App Xamarin.Forms Views Library</Product>
39+
<Description>Making App Development Easier with a collection of easy to use components for working with and build views for Xamarin.Forms projects.</Description>
40+
<Copyright>Copyright (C) MADE Apps. All rights reserved.</Copyright>
41+
<PackageLicenseUrl>https://github.com/MADE-Apps/MADE-App-Components/blob/master/LICENSE</PackageLicenseUrl>
42+
<PackageProjectUrl>https://github.com/MADE-Apps/MADE-App-Components</PackageProjectUrl>
43+
<RepositoryUrl>https://github.com/MADE-Apps/MADE-App-Components</RepositoryUrl>
44+
<RepositoryType>git</RepositoryType>
45+
<PackageIconUrl>https://pbs.twimg.com/profile_images/927154020422160385/6HSRU36P_400x400.jpg</PackageIconUrl>
46+
<PackageTags>MADE App Development Xamarin.Forms View Custom Controls Windows Android iOS Xamarin</PackageTags>
47+
<RootNamespace>MADE.App.Views</RootNamespace>
48+
</PropertyGroup>
49+
50+
<ItemGroup>
51+
<None Remove=".gitignore" />
52+
<None Remove="docfx.json" />
53+
<None Remove="index.md" />
54+
<None Remove="log.txt" />
55+
<None Remove="toc.yml" />
56+
<None Remove="Docfx-*.log" />
57+
</ItemGroup>
58+
59+
<ItemGroup>
60+
<PackageReference Include="docfx.console" Version="2.36.0" PrivateAssets="All" />
61+
</ItemGroup>
62+
63+
<ItemGroup>
64+
<ProjectReference Include="..\MADE.App.Views\MADE.App.Views.csproj" />
65+
</ItemGroup>
66+
67+
</Project>

0 commit comments

Comments
 (0)