Skip to content

Commit b06bae9

Browse files
rookiejavaJoonghyunCho
authored andcommitted
Updates the Samsung.Tizen.Templates (#297)
1 parent 1c44700 commit b06bae9

File tree

3 files changed

+66
-34
lines changed

3 files changed

+66
-34
lines changed

workload/src/Samsung.Tizen.Templates/tizen/Main.cs

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,33 @@
1-
using System;
2-
3-
using Tizen.NUI;
4-
using Tizen.NUI.BaseComponents;
1+
using Tizen.UI;
2+
using Tizen.UI.Components;
3+
using Tizen.UI.Components.Material;
54

65
namespace TizenApp1
76
{
8-
class Program : NUIApplication
7+
class Program : MaterialApplication
98
{
109
protected override void OnCreate()
1110
{
1211
base.OnCreate();
13-
Initialize();
14-
}
15-
16-
void Initialize()
17-
{
18-
Window.Default.KeyEvent += OnKeyEvent;
19-
20-
TextLabel text = new TextLabel("Hello Tizen") {
21-
HorizontalAlignment = HorizontalAlignment.Center,
22-
VerticalAlignment = VerticalAlignment.Center,
23-
TextColor = Color.Blue,
24-
PointSize = 12.0f,
25-
HeightResizePolicy = ResizePolicyType.FillToParent,
26-
WidthResizePolicy = ResizePolicyType.FillToParent
27-
};
28-
Window.Default.GetDefaultLayer().Add(text);
29-
30-
Animation animation = new Animation(2000);
31-
animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500);
32-
animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000);
33-
animation.Looping = true;
34-
animation.Play();
35-
}
36-
37-
public void OnKeyEvent(object sender, Window.KeyEventArgs e)
38-
{
39-
if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
12+
FocusManager.Instance.EnableDefaultFocusAlgorithm(true);
13+
Window.Default.AddAvailableOrientation(WindowOrientation.Portrait);
14+
Window.Default.AddAvailableOrientation(WindowOrientation.Landscape);
15+
Window.Default.AddAvailableOrientation(WindowOrientation.PortraitInverse);
16+
Window.Default.AddAvailableOrientation(WindowOrientation.LandscapeInverse);
17+
Window.Default.KeyEvent += (s, e) =>
4018
{
41-
Exit();
42-
}
19+
if (e.KeyEvent.State == KeyState.Up && (e.KeyEvent.KeyPressedName == "BackSpace" || e.KeyEvent.KeyPressedName == "XF86Back"))
20+
{
21+
if (!RootNavigateBack())
22+
{
23+
Window.Default.Dispose();
24+
Exit();
25+
}
26+
}
27+
};
28+
var navigator = new Navigator();
29+
Window.Default.DefaultLayer.Add(navigator);
30+
navigator.PushAsync(new MainView());
4331
}
4432

4533
static void Main(string[] args)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Tizen.UI;
2+
using Tizen.UI.Components.Material;
3+
using Tizen.UI.Layouts;
4+
5+
namespace TizenApp1
6+
{
7+
public class MainView : Scaffold
8+
{
9+
public MainView() : base()
10+
{
11+
int count = 0;
12+
13+
AppBar = new AppBar
14+
{
15+
BackgroundColor = MaterialColor.PrimaryContainer,
16+
Title = "TizenApp1",
17+
};
18+
19+
Content = new VStack
20+
{
21+
Children =
22+
{
23+
new Label
24+
{
25+
Text = $"Current Count: {count}",
26+
FontSize = 40f,
27+
}
28+
.Self(out var label)
29+
.Expand()
30+
.Center(),
31+
}
32+
};
33+
34+
FloatingActionButton = new IconButton(MaterialIcon.Add, IconButtonVariables.FAB)
35+
{
36+
ClickedCommand = (_, _) => label.Text = $"Current Count: {++count}"
37+
};
38+
}
39+
}
40+
}

workload/src/Samsung.Tizen.Templates/tizen/TizenApp1.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@
44
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">TizenApp1</RootNamespace>
55
<OutputType>Exe</OutputType>
66
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="Tizen.UI.Components.Material" Version="1.0.0-*" />
10+
</ItemGroup>
711
</Project>

0 commit comments

Comments
 (0)