2 * Copyright(c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.ComponentModel;
19 using System.Collections.Generic;
21 using Tizen.NUI.BaseComponents;
22 using Tizen.NUI.Components;
23 using Tizen.NUI.Binding;
25 namespace Tizen.NUI.StyleGuide
27 // IExample inehrited class will be automatically added in the main examples list.
28 internal class ScrollableBaseExample : ContentPage, IExample
30 private Window window;
31 private List<DirectionOption> directionMenu;
32 public void Activate()
34 Log.Info(this.GetType().Name, $"@@@ this.GetType().Name={this.GetType().Name}, Activate()\n");
36 public void Deactivate()
38 Log.Info(this.GetType().Name, $"@@@ this.GetType().Name={this.GetType().Name}, Deactivate()\n");
43 /// Modify this method for adding other examples.
44 public ScrollableBaseExample() : base()
46 Log.Info(this.GetType().Name, $"{this.GetType().Name} is contructed\n");
48 // Navigator bar title is added here.
51 Title = "ScrollableBase Default Style",
54 directionMenu = new List<DirectionOption>();
55 directionMenu.Add(new DirectionOption("Vertical"));
56 directionMenu.Add(new DirectionOption("Horizontal"));
58 // Example root content view.
59 // you can decorate, add children on this view.
60 // ScrollableBase need two different style guide.
61 // so here we adding new CollectionView for 2-depth option.
62 var directionListView = new CollectionView()
64 WidthSpecification = LayoutParamPolicies.MatchParent,
65 HeightSpecification = LayoutParamPolicies.MatchParent,
66 ItemsSource = directionMenu,
67 ItemsLayouter = new LinearLayouter(),
68 ItemTemplate = new DataTemplate(() =>
70 DefaultLinearItem item = new DefaultLinearItem()
72 WidthSpecification = LayoutParamPolicies.MatchParent,
74 item.Label.SetBinding(TextLabel.TextProperty, "Direction");
75 item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
78 ScrollingDirection = ScrollableBase.Direction.Vertical,
79 SelectionMode = ItemSelectionMode.SingleAlways,
81 directionListView.SelectionChanged += (object colView, SelectionChangedEventArgs ev) =>
83 if (ev.CurrentSelection.Count == 0) return;
84 if (ev.CurrentSelection[0] is DirectionOption directionItem)
86 Log.Info(this.GetType().Name, $"{directionItem.Direction} will be activated!\n");
87 Page scrollDirPage = new ScrollableBaseDirectionExample(directionItem.Direction);
88 window = NUIApplication.GetDefaultWindow();
89 window.GetDefaultNavigator().Push(scrollDirPage);
91 directionListView.SelectedItem = null;
94 Content = directionListView;
98 internal class DirectionOption
100 private string direction;
101 public string Direction { get => direction; }
103 public DirectionOption(string dir)