-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NUITizenGallery] ScrollViewTest8 sample
- Loading branch information
Patryk Kaczmarek
committed
Aug 4, 2021
1 parent
d0b77cc
commit 16edc4e
Showing
4 changed files
with
174 additions
and
1 deletion.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
NUITizenGallery/Examples/ScrollViewTest8/ScrollViewTest8.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
97
NUITizenGallery/Examples/ScrollViewTest8/ScrollViewTest8.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|