-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* UIColor supportes token * Token table is managed by internal TokenManager Signed-off-by: Jiyun Yang <[email protected]>
- Loading branch information
Showing
10 changed files
with
568 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright(c) 2025 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.ComponentModel; | ||
using Tizen.NUI; | ||
using Tizen.NUI.BaseComponents; | ||
|
||
namespace Tizen.NUI.Extension | ||
{ | ||
internal static class ViewPropertySetters | ||
{ | ||
public static readonly PropertySetter<View, UIColor> BackgroundColor = new ("_background", (view, value) => view.SetBackgroundColor(value)); | ||
|
||
public static readonly PropertySetter<View, UIColor> BorderlineColor = new (nameof(View.BorderlineColor), (view, value) => | ||
{ | ||
//FIXME: we need to set UI value type directly without converting reference value. | ||
view.BorderlineColor = value.ToReferenceType(); | ||
}); | ||
|
||
public static readonly PropertySetter<View, UIColor> Color = new (nameof(View.Color), (view, value) => | ||
{ | ||
//FIXME: we need to set UI value type directly without converting reference value. | ||
view.Color = value.ToReferenceType(); | ||
}); | ||
} | ||
} |
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,37 @@ | ||
/* | ||
* Copyright(c) 2025 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.ComponentModel; | ||
|
||
namespace Tizen.NUI | ||
{ | ||
/// <summary> | ||
/// The interface for property setter. | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public interface IPropertySetter<TValue> | ||
{ | ||
/// <summary> | ||
/// The name of the property. | ||
/// </summary> | ||
string Name { get; } | ||
|
||
/// <summary> | ||
/// Invokes property setter. | ||
/// </summary> | ||
void Invoke(object target, TValue value); | ||
} | ||
} |
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,43 @@ | ||
/* | ||
* Copyright(c) 2025 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.ComponentModel; | ||
using Tizen.NUI.BaseComponents; | ||
|
||
namespace Tizen.NUI | ||
{ | ||
/// <summary> | ||
/// Interface for token. Token is a key-value pair that can be applied to the target. It has an id and value. The value type is generic. | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public interface IToken<T> | ||
{ | ||
/// <summary> | ||
/// The unique identifier of the token. | ||
/// </summary> | ||
string Id { get; } | ||
|
||
/// <summary> | ||
/// The value of the token. | ||
/// </summary> | ||
T Value { get; } | ||
|
||
/// <summary> | ||
/// Apply the token to target. | ||
/// </summary> | ||
void Apply<TView>(TView view, IPropertySetter<T> propertySetter) where TView : View; | ||
} | ||
} |
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,51 @@ | ||
/* | ||
* Copyright(c) 2025 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 System.Collections.Generic; | ||
using System.ComponentModel; | ||
using Tizen.NUI.BaseComponents; | ||
|
||
namespace Tizen.NUI | ||
{ | ||
/// <summary> | ||
/// The interface for a token table. | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public interface ITokenTable<T> | ||
{ | ||
/// <summary> | ||
/// The event which is invoked when the resource table is updated. | ||
/// </summary> | ||
event EventHandler Updated; | ||
|
||
/// <summary> | ||
/// The method to get the value from the resource table. | ||
/// </summary> | ||
bool TryGetValue(string id, out T result); | ||
|
||
/// <summary> | ||
/// The method to update the resource table. | ||
/// </summary> | ||
void Update(IDictionary<string, T> table); | ||
|
||
/// <summary> | ||
/// The method to bind target with token. | ||
/// When table is updated, binded view will be updated. | ||
/// </summary> | ||
void Bind(View target, IPropertySetter<T> setter, IToken<T> token); | ||
} | ||
} |
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,51 @@ | ||
/* | ||
* Copyright(c) 2025 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 System.ComponentModel; | ||
|
||
namespace Tizen.NUI | ||
{ | ||
/// <summary> | ||
/// Describes a property setter. | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public class PropertySetter<TView, TValue> : IPropertySetter<TValue> | ||
{ | ||
private Action<TView, TValue> _setter; | ||
|
||
/// <summary> | ||
/// Creates an instance of the PropertySetter class. | ||
/// </summary> | ||
/// <param name="name">The name of the property.</param> | ||
/// <param name="setter">The action to set the property.</param> | ||
public PropertySetter(string name, Action<TView, TValue> setter) | ||
{ | ||
Name = name; | ||
_setter = setter; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public string Name { get; } | ||
|
||
/// <inheritdoc/> | ||
public virtual void Invoke(object target, TValue value) | ||
{ | ||
if (target is TView typedTarget) | ||
_setter(typedTarget, value); | ||
} | ||
} | ||
} |
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,39 @@ | ||
/* | ||
* Copyright(c) 2025 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.ComponentModel; | ||
|
||
namespace Tizen.NUI | ||
{ | ||
/// <summary> | ||
/// The type of token. | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public enum TokenType | ||
{ | ||
/// <summary> The color token.</summary> | ||
Color, | ||
|
||
/// <summary> The shadow token.</summary> | ||
Shadow, | ||
|
||
/// <summary> The font family token.</summary> | ||
FontFamily, | ||
|
||
/// <summary> The font weight token.</summary> | ||
FontSize | ||
} | ||
} |
Oops, something went wrong.