This repository has been archived by the owner on Dec 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds SelectModeCell for CircleListView
- Loading branch information
1 parent
93cb4d7
commit d4ee5d4
Showing
21 changed files
with
620 additions
and
11 deletions.
There are no files selected for viewing
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
72 changes: 72 additions & 0 deletions
72
src/Tizen.Wearable.CircularUI.Forms.Renderer/SelectModeImageCellRenderer.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,72 @@ | ||
/* | ||
* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved | ||
* | ||
* Licensed under the Flora License, Version 1.1 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://floralicense.org/license/ | ||
* | ||
* 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.Collections.Generic; | ||
using Xamarin.Forms; | ||
using Xamarin.Forms.Platform.Tizen; | ||
using ElmSharp; | ||
using Tizen.Wearable.CircularUI.Forms; | ||
using Tizen.Wearable.CircularUI.Forms.Renderer; | ||
using ECheck = ElmSharp.Check; | ||
|
||
[assembly: ExportRenderer(typeof(SelectModeImageCell), typeof(SelectModeImageCellRenderer))] | ||
namespace Tizen.Wearable.CircularUI.Forms.Renderer | ||
{ | ||
public class SelectModeImageCellRenderer : ImageCellRenderer | ||
{ | ||
protected SelectModeImageCellRenderer(string style) : base(style) | ||
{ | ||
ImagePart = "elm.swallow.icon"; | ||
SelectionPart = "elm.swallow.center_check"; | ||
} | ||
|
||
public SelectModeImageCellRenderer() : this("1icon_2text") | ||
{ | ||
} | ||
|
||
protected string SelectionPart { get; set; } | ||
|
||
protected override EvasObject OnGetContent(Cell cell, string part) | ||
{ | ||
if (cell is ISelectModeCell selectCell && selectCell.IsSelectionModeEnabled && part == SelectionPart) | ||
{ | ||
var check = new CheckBox() | ||
{ | ||
BindingContext = cell, | ||
Parent = cell.Parent | ||
}; | ||
check.SetBinding(CheckBox.IsCheckedProperty, new Binding(SelectModeTextCell.IsSelectedProperty.PropertyName)); | ||
var nativeView = Platform.GetOrCreateRenderer(check).NativeView; | ||
if (nativeView is ECheck widget) | ||
widget.Style = "genlist/select_mode"; | ||
nativeView.PropagateEvents = false; | ||
nativeView.RepeatEvents = false; | ||
return nativeView; | ||
} | ||
return base.OnGetContent(cell, part); | ||
} | ||
|
||
protected override bool OnCellPropertyChanged(Cell cell, string property, Dictionary<string, EvasObject> realizedView) | ||
{ | ||
if (property == SelectModeCell.IsSelectedProperty.PropertyName || | ||
property == SelectModeCell.IsSelectionModeEnabledProperty.PropertyName) | ||
{ | ||
return true; | ||
} | ||
return base.OnCellPropertyChanged(cell, property, realizedView); | ||
} | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
src/Tizen.Wearable.CircularUI.Forms.Renderer/SelectModeTextCellRenderer.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,71 @@ | ||
/* | ||
* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved | ||
* | ||
* Licensed under the Flora License, Version 1.1 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://floralicense.org/license/ | ||
* | ||
* 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.Collections.Generic; | ||
using Xamarin.Forms; | ||
using Xamarin.Forms.Platform.Tizen; | ||
using ElmSharp; | ||
using Tizen.Wearable.CircularUI.Forms; | ||
using Tizen.Wearable.CircularUI.Forms.Renderer; | ||
using ECheck = ElmSharp.Check; | ||
|
||
[assembly: ExportRenderer(typeof(SelectModeTextCell), typeof(SelectModeTextCellRenderer))] | ||
namespace Tizen.Wearable.CircularUI.Forms.Renderer | ||
{ | ||
public class SelectModeTextCellRenderer : TextCellRenderer | ||
{ | ||
protected SelectModeTextCellRenderer(string style) : base(style) | ||
{ | ||
SelectionPart = "elm.swallow.center_check"; | ||
} | ||
|
||
public SelectModeTextCellRenderer() : this("1icon_2text") | ||
{ | ||
} | ||
|
||
protected string SelectionPart { get; set; } | ||
|
||
protected override EvasObject OnGetContent(Cell cell, string part) | ||
{ | ||
if (cell is ISelectModeCell selectCell && selectCell.IsSelectionModeEnabled && part == SelectionPart) | ||
{ | ||
var check = new CheckBox() | ||
{ | ||
BindingContext = cell, | ||
Parent = cell.Parent | ||
}; | ||
check.SetBinding(CheckBox.IsCheckedProperty, new Binding(SelectModeTextCell.IsSelectedProperty.PropertyName)); | ||
var nativeView = Platform.GetOrCreateRenderer(check).NativeView; | ||
if (nativeView is ECheck widget) | ||
widget.Style = "genlist/select_mode"; | ||
nativeView.PropagateEvents = false; | ||
nativeView.RepeatEvents = false; | ||
return nativeView; | ||
} | ||
return null; | ||
} | ||
|
||
protected override bool OnCellPropertyChanged(Cell cell, string property, Dictionary<string, EvasObject> realizedView) | ||
{ | ||
if (property == SelectModeCell.IsSelectedProperty.PropertyName || | ||
property == SelectModeCell.IsSelectionModeEnabledProperty.PropertyName) | ||
{ | ||
return true; | ||
} | ||
return base.OnCellPropertyChanged(cell, property, realizedView); | ||
} | ||
} | ||
} |
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
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,34 @@ | ||
/* | ||
* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved | ||
* | ||
* Licensed under the Flora License, Version 1.1 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://floralicense.org/license/ | ||
* | ||
* 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 System.ComponentModel; | ||
using System.Diagnostics; | ||
using Xamarin.Forms; | ||
|
||
namespace Tizen.Wearable.CircularUI.Forms | ||
{ | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
interface ISelectModeCell | ||
{ | ||
bool IsSelected { get; set; } | ||
bool IsSelectionModeEnabled { get; set; } | ||
|
||
void OnIsSelectedChanged(object sender, ToggledEventArgs e); | ||
|
||
event EventHandler<ToggledEventArgs> SelectionChanged; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/Tizen.Wearable.CircularUI.Forms/ItemLongPressedEventArgs.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) 2018 Samsung Electronics Co., Ltd All Rights Reserved | ||
* | ||
* Licensed under the Flora License, Version 1.1 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://floralicense.org/license/ | ||
* | ||
* 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; | ||
|
||
namespace Tizen.Wearable.CircularUI.Forms | ||
{ | ||
/// <summary> | ||
/// Event arguments for the ItemLongPressed event of CircleListView. | ||
/// </summary> | ||
public class ItemLongPressedEventArgs : EventArgs | ||
{ | ||
/// <summary> | ||
/// Creates a new ItemLongPressedEventArgs object. | ||
/// </summary> | ||
/// <param name="itemIndex">An index of new long pressed item.</param> | ||
public ItemLongPressedEventArgs(int itemIndex) | ||
{ | ||
ItemIndex = itemIndex; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the index of new long pressed item | ||
/// </summary> | ||
public int ItemIndex { get; private set; } | ||
} | ||
} |
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,31 @@ | ||
/* | ||
* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved | ||
* | ||
* Licensed under the Flora License, Version 1.1 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://floralicense.org/license/ | ||
* | ||
* 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 Xamarin.Forms; | ||
|
||
namespace Tizen.Wearable.CircularUI.Forms | ||
{ | ||
static class SelectModeCell | ||
{ | ||
public static readonly BindableProperty IsSelectedProperty = BindableProperty.Create(nameof(ISelectModeCell.IsSelected), typeof(bool), typeof(ISelectModeCell), false, propertyChanged: (obj, oldValue, newValue) => | ||
{ | ||
ISelectModeCell selectModetCell = (ISelectModeCell)obj; | ||
selectModetCell.OnIsSelectedChanged(obj, new ToggledEventArgs((bool)newValue)); | ||
}, defaultBindingMode: BindingMode.TwoWay); | ||
|
||
public static readonly BindableProperty IsSelectionModeEnabledProperty = BindableProperty.Create(nameof(ISelectModeCell.IsSelectionModeEnabled), typeof(bool), typeof(ISelectModeCell), default(bool)); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/Tizen.Wearable.CircularUI.Forms/SelectModeImageCell.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,65 @@ | ||
/* | ||
* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved | ||
* | ||
* Licensed under the Flora License, Version 1.1 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://floralicense.org/license/ | ||
* | ||
* 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 Xamarin.Forms; | ||
|
||
namespace Tizen.Wearable.CircularUI.Forms | ||
{ | ||
/// <summary> | ||
/// An ImageCell supports a selection mode. | ||
/// </summary> | ||
public class SelectModeImageCell : ImageCell, ISelectModeCell | ||
{ | ||
/// <summary> | ||
/// Identifies the On bindable property. | ||
/// </summary> | ||
public static readonly BindableProperty IsSelectedProperty = SelectModeCell.IsSelectedProperty; | ||
|
||
/// <summary> | ||
/// Identifies the Text bindable property. | ||
/// </summary> | ||
public static readonly BindableProperty IsSelectionModeEnabledProperty = SelectModeCell.IsSelectionModeEnabledProperty; | ||
|
||
/// <summary> | ||
/// Gets or sets the state of the selection. This is a bindable property. | ||
/// </summary> | ||
public bool IsSelected | ||
{ | ||
get { return (bool)GetValue(IsSelectedProperty); } | ||
set { SetValue(IsSelectedProperty, value); } | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets whether to enable the selection mode or not. This is a bindable property. | ||
/// </summary> | ||
public bool IsSelectionModeEnabled | ||
{ | ||
get { return (bool)GetValue(IsSelectionModeEnabledProperty); } | ||
set { SetValue(IsSelectionModeEnabledProperty, value); } | ||
} | ||
|
||
/// <summary> | ||
/// Triggered when IsSelected changed. | ||
/// </summary> | ||
public event EventHandler<ToggledEventArgs> SelectionChanged; | ||
|
||
void ISelectModeCell.OnIsSelectedChanged(object sender, ToggledEventArgs e) | ||
{ | ||
SelectionChanged?.Invoke(sender, e); | ||
} | ||
} | ||
} |
Oops, something went wrong.