Skip to content

Commit

Permalink
[NUITizenGallery] ScrollViewTest8 sample
Browse files Browse the repository at this point in the history
  • Loading branch information
Patryk Kaczmarek committed Aug 4, 2021
1 parent d0b77cc commit 16edc4e
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 1 deletion.
40 changes: 40 additions & 0 deletions NUITizenGallery/Examples/ScrollViewTest8/ScrollViewTest8.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright(c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

using System;
using Tizen.NUI;
using Tizen.NUI.Components;

namespace NUITizenGallery
{
internal class ScrollViewTest8 : IExample
{
private Window window;
private ScrollViewTest8Page page;
public void Activate()
{
window = NUIApplication.GetDefaultWindow();
page = new ScrollViewTest8Page();
window.GetDefaultNavigator().Push(page);
}
public void Deactivate()
{
window.GetDefaultNavigator().Pop();
page = null; ;
}
}
}
97 changes: 97 additions & 0 deletions NUITizenGallery/Examples/ScrollViewTest8/ScrollViewTest8.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright(c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using Tizen.NUI;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Components;

namespace NUITizenGallery
{
public partial class ScrollViewTest8Page : ContentPage
{
public ScrollViewTest8Page()
{
InitializeComponent();

for (int i = 0; i <= 200; ++i)
{
var t = new TextLabel
{
Text = String.Format("I am label #{0}", i),
HeightSpecification = 70,
WidthSpecification = LayoutParamPolicies.MatchParent,
};
Scroller.Add(t);
}

btn1.Clicked += (o, e) =>
{
//ScrollStep +100
};

btn2.Clicked += (o, e) =>
{
//ScrollStep -100
};
}
protected override void Dispose(DisposeTypes type)
{
if (Disposed)
{
return;
}

if (type == DisposeTypes.Explicit)
{
RemoveAllChildren(true);
}

base.Dispose(type);
}

private void RemoveAllChildren(bool dispose = false)
{
RecursiveRemoveChildren(this, dispose);
}

private void RecursiveRemoveChildren(View parent, bool dispose)
{
if (parent == null)
{
return;
}

int maxChild = (int)parent.ChildCount;
for (int i = maxChild - 1; i >= 0; --i)
{
View child = parent.GetChildAt((uint)i);
if (child == null)
{
continue;
}

RecursiveRemoveChildren(child, dispose);
parent.Remove(child);
if (dispose)
{
child.Dispose();
}
}
}
}
}

5 changes: 4 additions & 1 deletion NUITizenGallery/NUITizenGallery.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@
<EmbeddedResource Include="res\layout\ScrollViewTest7Page.xaml">
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
<EmbeddedResource Include="res\layout\ScrollViewTest8Page.xaml">
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
<EmbeddedResource Include="res\layout\SetColorTestPage.xaml">
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
Expand Down Expand Up @@ -436,7 +439,7 @@
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
<EmbeddedResource Include="res\layout\TimePickerTestPage.xaml">
<Generator>MSBuild:Compile</Generator>
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
<EmbeddedResource Include="res\layout\TimerTest1Page.xaml">
<Generator>MSBuild:Compile</Generator>
Expand Down
33 changes: 33 additions & 0 deletions NUITizenGallery/res/layout/ScrollViewTest8Page.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" ?>
<comp:ContentPage x:Class="NUITizenGallery.ScrollViewTest8Page"
xmlns="http://tizen.org/Tizen.NUI/2018/XAML"
xmlns:base="clr-namespace:Tizen.NUI.BaseComponents;assembly=Tizen.NUI"
xmlns:comp="clr-namespace:Tizen.NUI.Components;assembly=Tizen.NUI.Components"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
WidthSpecification="{Static LayoutParamPolicies.MatchParent}"
HeightSpecification="{Static LayoutParamPolicies.MatchParent}"
BackgroundColor="White"
PositionUsesPivotPoint="True"
ParentOrigin="Center"
PivotPoint="Center">

<comp:ContentPage.AppBar>
<comp:AppBar x:Name="appBar" Title="ScrollViewTest8"/>
</comp:ContentPage.AppBar>

<comp:ContentPage.Content>
<base:View x:Name="rootView" WidthSpecification="{Static LayoutParamPolicies.MatchParent}" HeightSpecification="{Static LayoutParamPolicies.MatchParent}">
<base:View.Layout>
<LinearLayout LinearOrientation="Vertical" LinearAlignment="Begin" CellPadding="10, 10"/>
</base:View.Layout>
<comp:Button x:Name="btn1" Text="+100 Vertical Scroll Step" WidthSpecification="{Static LayoutParamPolicies.MatchParent}" HeightSpecification="100" CellHorizontalAlignment="Center"/>
<comp:Button x:Name="btn2" Text="-100 Vertical Scroll Step" WidthSpecification="{Static LayoutParamPolicies.MatchParent}" HeightSpecification="100" CellHorizontalAlignment="Center"/>
<comp:ScrollableBase x:Name="Scroller" ScrollingDirection="Vertical" HideScrollbar="false" WidthSpecification="{Static LayoutParamPolicies.MatchParent}" HeightSpecification="{Static LayoutParamPolicies.MatchParent}" >
<comp:ScrollableBase.Layout>
<LinearLayout LinearOrientation="Vertical" CellPadding="10, 10"/>
</comp:ScrollableBase.Layout>
</comp:ScrollableBase>
</base:View>
</comp:ContentPage.Content>
</comp:ContentPage>

0 comments on commit 16edc4e

Please sign in to comment.