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 (#332)
- Loading branch information
1 parent
f40fef2
commit b775010
Showing
21 changed files
with
632 additions
and
12 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; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
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,47 @@ | ||
/* | ||
* 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="item">An item data of new long pressed item.</param> | ||
/// <param name="itemIndex">An index of new long pressed item.</param> | ||
public ItemLongPressedEventArgs(object item, int itemIndex) | ||
{ | ||
Item = item; | ||
ItemIndex = itemIndex; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the data of new long pressed item | ||
/// </summary> | ||
public object Item { get; private set; } | ||
|
||
/// <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)); | ||
} | ||
} |
Oops, something went wrong.