+++ /dev/null
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using Fitness.Services;
-using Fitness.ViewModels;
-using Tizen.NUI;
-using Tizen.NUI.BaseComponents;
-using Tizen.NUI.Binding;
-using Tizen.NUI.Components;
-
-namespace Fitness.Controls
-{
- public class BindableRecyclerView : RecyclerView
- {
- /// <summary>
- /// ItemsSource property
- /// </summary>
- public static readonly BindableProperty ItemsSourceProperty =
- BindableProperty.Create(nameof(ItemsSource), typeof(IEnumerable), typeof(BindableRecyclerView), null, propertyChanged: OnItemsSourceChanged);
-
- /// <summary>
- /// SelectedItem property
- /// </summary>
- public static readonly BindableProperty SelectedItemProperty =
- BindableProperty.Create(nameof(SelectedItem), typeof(object), typeof(BindableRecyclerView), null, propertyChanged: OnSelectionChanged);
-
- /// <summary>
- /// SelectionMode property
- /// </summary>
- public static readonly BindableProperty SelectionModeProperty =
- BindableProperty.Create(nameof(SelectionMode), typeof(RecyclerViewSelectionMode), typeof(BindableRecyclerView), RecyclerViewSelectionMode.None, propertyChanged: OnSelectionChanged);
-
- private TapGestureDetector detector;
-
- public BindableRecyclerView()
- : base()
- {
- SelectionMode = RecyclerViewSelectionMode.None;
-
- ContentContainer.ChildAdded += ChildAddedCallback;
- ContentContainer.ChildRemoved += ChildRemovedCallback;
-
- detector = new TapGestureDetector();
- detector.Detected += SelectedItemChanged;
- }
-
- /// <summary>
- /// Triggered when List item has been selected.
- /// </summary>
- public event EventHandler ItemSelected;
-
- /// <summary>
- /// Selection mode.
- /// </summary>
- public enum RecyclerViewSelectionMode
- {
- /// <summary>
- /// None of RecyclerView items elements is selectable.
- /// </summary>
- None,
-
- /// <summary>
- /// Only a single RecyclerView item element is selectable.
- /// </summary>
- Single,
- }
-
- public IEnumerable ItemsSource
- {
- get => (IEnumerable)GetValue(ItemsSourceProperty);
- set
- {
- SetValue(ItemsSourceProperty, value);
- }
- }
-
- public object SelectedItem
- {
- get => (object)GetValue(SelectedItemProperty);
- set
- {
- SetValue(SelectedItemProperty, value);
- }
- }
-
- public RecyclerViewSelectionMode SelectionMode
- {
- get => (RecyclerViewSelectionMode)GetValue(SelectionModeProperty);
- set
- {
- SetValue(SelectionModeProperty, value);
- }
- }
-
- public static void OnItemsSourceChanged(BindableObject bindable, object oldValue, object newValue)
- {
- var recycler = bindable as BindableRecyclerView;
- if (recycler != null && recycler.Adapter != null)
- {
- var list = (newValue as IEnumerable<object>)?.ToList();
- recycler.Adapter.Data = list;
- recycler.SelectedItem = null;
- }
- }
-
- public static void OnSelectionChanged(BindableObject bindable, object oldValue, object newValue)
- {
- if (bindable is BindableRecyclerView recycler)
- {
- recycler.EvaluateSelection();
- }
- }
-
- protected override void Dispose(DisposeTypes type)
- {
- if (disposed)
- {
- return;
- }
-
- if (type == DisposeTypes.Explicit)
- {
- detector.Dispose();
- }
-
- base.Dispose(type);
- }
-
- private void EvaluateSelection()
- {
- var selectedItem = SelectedItem;
- var selectionMode = SelectionMode;
-
- foreach (View item in ContentContainer.Children)
- {
- if (item is ISelectionController selectableItem)
- {
- selectableItem.IsSelected = selectionMode == RecyclerViewSelectionMode.None ? false : item.BindingContext == selectedItem;
- }
- }
- }
-
- private void SelectedItemChanged(object sender, TapGestureDetector.DetectedEventArgs args)
- {
- if (SelectionMode == RecyclerViewSelectionMode.Single)
- {
- ItemSelected?.Invoke(sender, null);
- SelectedItem = args.View?.BindingContext;
- }
- }
-
- private void ChildAddedCallback(object sender, ChildAddedEventArgs args)
- {
- detector.Attach(args.Added);
- }
-
- private void ChildRemovedCallback(object sender, ChildRemovedEventArgs args)
- {
- detector.Detach(args.Removed);
- }
- }
-}
<PropertyGroup>
<OutputType>Exe</OutputType>
- <TargetFramework>tizen80</TargetFramework>
+ <TargetFramework>tizen90</TargetFramework>
<TargetFrameworkIdentifier>Tizen</TargetFrameworkIdentifier>
<CodeAnalysisRuleSet>Settings.StyleCop</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Tizen.NET.Sdk" Version="1.1.2" />
- <PackageReference Include="Tizen.NET" Version="8.0.0.15595" />
+ <PackageReference Include="Tizen.NET" Version="9.0.0.16042" />
<PackageReference Include="Tizen.NUI.XamlBuild" Version="1.0.11" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+++ /dev/null
-using Fitness.Controls;
-using Fitness.Services;
-using Tizen.NUI;
-using Tizen.NUI.BaseComponents;
-using Tizen.NUI.Components;
-
-namespace Fitness.Views
-{
- public partial class FitnessItemView : RecycleItem, ISelectionController
- {
- private const float SelectedOpacity = 1.0f;
- private const float NotSelectedOpacity = 0.9f;
- private bool isSelected;
-
- public FitnessItemView()
- {
- InitializeComponent();
- IsSelected = false;
- }
-
- public bool IsSelected
- {
- get => isSelected;
- set
- {
- if (value)
- {
- Opacity = SelectedOpacity;
- }
- else
- {
- Opacity = NotSelectedOpacity;
- }
-
- isSelected = value;
- }
- }
- }
-}
+++ /dev/null
-using System.Collections.Generic;
-using Fitness.Controls;
-using Fitness.Services;
-using Tizen.NUI;
-using Tizen.NUI.Components;
-
-namespace Fitness.Views
-{
- public class FitnessItemViewRecycleAdapter : RecycleAdapter
- {
- public FitnessItemViewRecycleAdapter()
- {
- }
-
- public override RecycleItem CreateRecycleItem()
- {
- return new FitnessItemView();
- }
-
- public override void BindData(RecycleItem item)
- {
- item.BindingContext = Data[item.DataIndex];
-
- // rewrite binding context for item child views as
- // currently iheriting binding context in NUI do now work properly.
- if (item is FitnessItemView fitnessItem)
- {
- fitnessItem.image.BindingContext = item.BindingContext;
- fitnessItem.label.BindingContext = item.BindingContext;
- fitnessItem.favourite.BindingContext = item.BindingContext;
- }
- }
- }
-}
InitializeComponent();
- this.scroller.SelectionMode = BindableRecyclerView.RecyclerViewSelectionMode.Single;
+ // TODO : Change RecyclerView to Collection View
+ // this.scroller.SelectionMode = BindableRecyclerView.RecyclerViewSelectionMode.Single;
- this.scroller.LayoutManager = new LinearRecycleLayoutManager()
- {
- LayoutOrientation = RecycleLayoutManager.Orientation.Horizontal,
- };
- this.scroller.ScrollingDirection = ScrollableBase.Direction.Horizontal;
+ // this.scroller.LayoutManager = new LinearRecycleLayoutManager()
+ // {
+ // LayoutOrientation = RecycleLayoutManager.Orientation.Horizontal,
+ // };
+ // this.scroller.ScrollingDirection = ScrollableBase.Direction.Horizontal;
}
private void CheckPrivilege()
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<nui:RecycleItem x:Class="Fitness.Views.FitnessItemView"
- xmlns="http://tizen.org/Tizen.NUI/2018/XAML"
- xmlns:nui="clr-namespace:Tizen.NUI.Components"
- xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
- xmlns:views="clr-namespace:Fitness.Views"
- xmlns:converters="clr-namespace:Fitness.Views.Converters"
- xmlns:ctrl="clr-namespace:Fitness.Controls"
- Size="{views:SizeInUnits Width=82,Height=44}">
- <View Size="{views:SizeInUnits Width=78,Height=44}" >
- <ImageView x:Name="image" HeightResizePolicy="FillToParent" WidthResizePolicy="FillToParent" ResourceUrl="{Binding ThumbnailUrl}"/>
- <TextLabel x:Name="label" PositionUsesPivotPoint="true" PivotPoint="0.0,1.0" ParentOrigin="0.0,1.0" PixelSize="24" Text="{Binding Title}"/>
- <ImageView x:Name="favourite" Size="30,30" PositionUsesPivotPoint="true" PivotPoint="1.0,0.0" ParentOrigin="1.0,0.0" ResourceUrl="{Binding Favourite, Converter={Static converters:FavouriteToIconConverter.Converter}}"/>
- </View>
-</nui:RecycleItem>
<ImageView PositionUsesPivotPoint="true" PivotPoint="1.0,0.0" ParentOrigin="1.0, 0.0" Size="30,30" BindingContext="{Binding Source={x:Reference context}, Path=SelectedWorkout}" ResourceUrl="{Binding Favourite, Converter={Static converters:FavouriteToIconConverter.Converter}}"/>
</View>
</View>
- <ctrl:BindableRecyclerView Size="{views:SizeInUnits Height=44}" Margin="{views:ExtentsInUnits Top=10, Bottom=10}" WidthResizePolicy="FillToParent" ItemsSource="{Binding Workouts}" x:Name="scroller" Padding="{views:ExtentsInUnits Start=16, End=16}" SelectedItem="{Binding Path=SelectedWorkout, Mode=TwoWay}">
- <ctrl:BindableRecyclerView.Adapter>
- <views:FitnessItemViewRecycleAdapter/>
- </ctrl:BindableRecyclerView.Adapter>
- </ctrl:BindableRecyclerView>
+ <nui:CollectionView Size="{views:SizeInUnits Height=44}" Margin="{views:ExtentsInUnits Top=10, Bottom=10}" WidthResizePolicy="FillToParent" ItemsSource="{Binding Workouts}" x:Name="scroller" Padding="{views:ExtentsInUnits Start=16, End=16}">
+ </nui:CollectionView>
</ctrl:Page>