Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
[CommonUI] Added the ShadowFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
rookiejava committed Mar 11, 2021
1 parent 44a84e1 commit 16de770
Show file tree
Hide file tree
Showing 7 changed files with 642 additions and 7 deletions.
16 changes: 10 additions & 6 deletions sample/Sample.Tizen/Sample.Tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,19 @@ static void Main(string[] args)
var option = new InitializationOptions(app)
{
//Using DP without device scaling mode
DisplayResolutionUnit = DisplayResolutionUnit.DP()
DisplayResolutionUnit = DisplayResolutionUnit.DP(),
UseSkiaSharp = true
};
Forms.Init(option);

// UIControls.Init() should be called after Forms.Init()
UIControls.Init(new InitOptions(app));
CommonUI.Init(app);
if (Device.Idiom != TargetIdiom.TV)
if (Device.Idiom == TargetIdiom.TV)
{
// UIControls.Init() should be called after Forms.Init()
UIControls.Init(new InitOptions(app));
CommonUI.Init(app);
}
else
{
CommonUI.Init(app);
CommonUI.AddCommonThemeOverlay();
}
app.Run(args);
Expand Down
5 changes: 5 additions & 0 deletions sample/Sample/MainPageModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public MainPageModel()
{
TestCategories = new List<TestCategory>
{
new TestCategory
{
Name = "Shadow Frame Test",
PageType = typeof(ShadowFrame.ShadowFrameTest),
},
new TestCategory
{
Name = "Page Transition Test",
Expand Down
5 changes: 4 additions & 1 deletion sample/Sample/Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<!-- Include Nuget Package for Xamarin building -->
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="5.0.0.1829-pre6" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2012" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Tizen.Theme.Common\Tizen.Theme.Common.csproj" />
Expand Down Expand Up @@ -40,6 +40,9 @@
<Compile Update="RemoteControl\TestFlyoutPage.xaml.cs">
<DependentUpon>TestFlyoutPage.xaml</DependentUpon>
</Compile>
<Compile Update="ShadowFrame\ShadowFrameTest.xaml.cs">
<DependentUpon>ShadowFrameTest.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="ContentButton\ContentButtonTest.xaml">
Expand Down
100 changes: 100 additions & 0 deletions sample/Sample/ShadowFrame/ShadowFrameTest.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?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:cui="clr-namespace:Tizen.Theme.Common;assembly=Tizen.Theme.Common"
Title="ShadowFrame Test"
x:Class="Sample.ShadowFrame.ShadowFrameTest">
<StackLayout Spacing="40">
<cui:ShadowFrame x:Name="Frame1"
WidthRequest="100"
HeightRequest="100"
BackgroundColor="White"
BorderColor="#fcd071"
BorderWidth="8"
CornerRadius="20,20,20,20"
ShadowOffsetX ="{Binding Value, Source={x:Reference offsetXSlider}}"
ShadowOffsetY ="{Binding Value, Source={x:Reference offsetYSlider}}"
ShadowBlurRadius="{Binding Value, Source={x:Reference blurSlider}}"
ShadowOpacity ="{Binding Value, Source={x:Reference opacitySlider}}"
HorizontalOptions="Center" VerticalOptions="CenterAndExpand"/>
<ScrollView>
<StackLayout>
<Label Text="CornerRadius" FontSize="Large" TextColor="Coral"/>
<StackLayout Orientation="Horizontal">
<Label Text="Top L: " TextColor ="Black"/>
<Slider x:Name="tlSlider" Value="20" Minimum="0" Maximum="50" HorizontalOptions="FillAndExpand" ValueChanged="radius_ValueChanged"/>
<Label Text="Top R: " TextColor ="Black" />
<Slider x:Name="trSlider" Value="20" Minimum="0" Maximum="50" HorizontalOptions="FillAndExpand" ValueChanged="radius_ValueChanged"/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Bot L: " TextColor ="Black"/>
<Slider x:Name="blSlider" Value="20" Minimum="0" Maximum="50" HorizontalOptions="FillAndExpand" ValueChanged="radius_ValueChanged"/>
<Label Text="Bot R: " TextColor ="Black"/>
<Slider x:Name="brSlider" Value="20" Minimum="0" Maximum="50" HorizontalOptions="FillAndExpand" ValueChanged="radius_ValueChanged"/>
</StackLayout>

<Label Text="ShadowOffset" FontSize="Large" TextColor="Coral"/>
<StackLayout Orientation="Horizontal">
<Label Text="Off X: " TextColor ="Black"/>
<Slider x:Name="offsetXSlider" Minimum="-50" Maximum="50" HorizontalOptions="FillAndExpand" ValueChanged="shadowOffset_ValueChanged"/>
<Label Text="Off Y: " TextColor ="Black"/>
<Slider x:Name="offsetYSlider" Minimum="-50" Maximum="50" HorizontalOptions="FillAndExpand" ValueChanged="shadowOffset_ValueChanged"/>
</StackLayout>

<Label Text="ShadowOpacity/BlurRadius" FontSize="Large" TextColor="Coral"/>
<StackLayout Orientation="Horizontal">
<Label Text="Opacity" TextColor ="Black"/>
<Slider x:Name="opacitySlider" Value=".24" HorizontalOptions="FillAndExpand" ValueChanged="blurOpacity_ValueChanged"/>
<Label Text="Blur R " TextColor ="Black"/>
<Slider x:Name="blurSlider" Minimum="0" Maximum="20" HorizontalOptions="FillAndExpand" ValueChanged="blurRadius_ValueChanged"/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Toggle HasShadow: " TextColor ="Black"/>
<Button x:Name="hasShadow" HeightRequest="20" Clicked="hasShadow_Clicked" Text="{Binding HasShadow, Source={x:Reference Frame1}}"/>
</StackLayout>

<Label Text="ShadowColor" FontSize="Large" TextColor="Coral"/>
<StackLayout Orientation="Horizontal">
<Label Text="R: " TextColor ="Red"/>
<Slider x:Name="RedColorS" HorizontalOptions="FillAndExpand" ValueChanged="shadowColor_ValueChanged"/>
<Label Text="G: " TextColor ="Green"/>
<Slider x:Name="GreenColorS" HorizontalOptions="FillAndExpand" ValueChanged="shadowColor_ValueChanged"/>
<Label Text="B: " TextColor ="Blue"/>
<Slider x:Name="BlueColorS" HorizontalOptions="FillAndExpand" ValueChanged="shadowColor_ValueChanged"/>
</StackLayout>

<Label Text="BorderWidth/Color" FontSize="Large" TextColor="Coral"/>
<StackLayout Orientation="Horizontal">
<Label Text="Width: " TextColor ="Black"/>
<Slider x:Name="borderWidthSlider" Value="8" Minimum="0" Maximum="20" HorizontalOptions="FillAndExpand" ValueChanged="borderWidth_ValueChanged"/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="R: " TextColor ="Red"/>
<Slider x:Name="RedColor" Value=".99" HorizontalOptions="FillAndExpand" ValueChanged="borderColor_ValueChanged"/>
<Label Text="G: " TextColor ="Green"/>
<Slider x:Name="GreenColor" Value=".82" HorizontalOptions="FillAndExpand" ValueChanged="borderColor_ValueChanged"/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="B: " TextColor ="Blue"/>
<Slider x:Name="BlueColor" Value=".44" HorizontalOptions="FillAndExpand" ValueChanged="borderColor_ValueChanged"/>
<Label Text="A: " TextColor ="Black"/>
<Slider x:Name="AlphaColor" Value="1" HorizontalOptions="FillAndExpand" ValueChanged="borderColor_ValueChanged"/>
</StackLayout>

<Label Text="BackgroundColor" FontSize="Large" TextColor="Coral"/>
<StackLayout Orientation="Horizontal">
<Label Text="R: " TextColor ="Red"/>
<Slider x:Name="RedColorBG" Value="1" HorizontalOptions="FillAndExpand" ValueChanged="bgColor_ValueChanged"/>
<Label Text="G: " TextColor ="Green"/>
<Slider x:Name="GreenColorBG" Value="1" HorizontalOptions="FillAndExpand" ValueChanged="bgColor_ValueChanged"/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="B: " TextColor ="Blue"/>
<Slider x:Name="BlueColorBG" Value="1" HorizontalOptions="FillAndExpand" ValueChanged="bgColor_ValueChanged"/>
<Label Text="A: " TextColor ="Black"/>
<Slider x:Name="AlphaColorBG" Value="1" HorizontalOptions="FillAndExpand" ValueChanged="bgColor_ValueChanged"/>
</StackLayout>
</StackLayout>
</ScrollView>
</StackLayout>
</ContentPage>
68 changes: 68 additions & 0 deletions sample/Sample/ShadowFrame/ShadowFrameTest.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;

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

namespace Sample.ShadowFrame
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ShadowFrameTest : ContentPage
{
public ShadowFrameTest()
{
InitializeComponent();
tlSlider.Value = 20;
trSlider.Value = 20;
blSlider.Value = 20;
brSlider.Value = 20;
blurSlider.Value = 10;
offsetXSlider.Value = 0;
offsetYSlider.Value = 0;
}

void radius_ValueChanged(object sender, ValueChangedEventArgs e)
{
Frame1.CornerRadius = new CornerRadius(tlSlider.Value, trSlider.Value, blSlider.Value, brSlider.Value);
}

void borderColor_ValueChanged(object sender, ValueChangedEventArgs e)
{
Frame1.BorderColor = Color.FromRgba(RedColor.Value, GreenColor.Value, BlueColor.Value, AlphaColor.Value);
}

void shadowColor_ValueChanged(object sender, ValueChangedEventArgs e)
{
Frame1.ShadowColor = Color.FromRgb(RedColorS.Value, GreenColorS.Value, BlueColorS.Value);
}

void borderWidth_ValueChanged(object sender, ValueChangedEventArgs e)
{
Frame1.BorderWidth = borderWidthSlider.Value;
}

void bgColor_ValueChanged(object sender, ValueChangedEventArgs e)
{
Frame1.BackgroundColor = Color.FromRgba(RedColorBG.Value, GreenColorBG.Value, BlueColorBG.Value, AlphaColorBG.Value);
}

void blurOpacity_ValueChanged(object sender, ValueChangedEventArgs e)
{
Console.WriteLine("[ShadowOpacity] : " + Frame1.ShadowOpacity);
}

void blurRadius_ValueChanged(object sender, ValueChangedEventArgs e)
{
Console.WriteLine("[ShadowBlurRadius] : " + Frame1.ShadowBlurRadius);
}

void shadowOffset_ValueChanged(object sender, ValueChangedEventArgs e)
{
Console.WriteLine("[ShadowOffset] (X : " + Frame1.ShadowOffsetX + ", Y: " + Frame1.ShadowOffsetY+")");
}

private void hasShadow_Clicked(object sender, EventArgs e)
{
Frame1.HasShadow = !Frame1.HasShadow;
}
}
}
Loading

0 comments on commit 16de770

Please sign in to comment.