Skip to content

Commit

Permalink
[NUI] Fix a crash when applying ViewStyle.
Browse files Browse the repository at this point in the history
  • Loading branch information
huayongxu authored and dongsug-song committed Feb 17, 2025
1 parent b0c6bf3 commit 0bf87b6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 20 deletions.
42 changes: 38 additions & 4 deletions src/Tizen.NUI.Components/Controls/RecyclerView/CollectionView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,28 @@ public enum ItemScrollTo
/// <since_tizen> 9 </since_tizen>
public override IEnumerable ItemsSource
{
get => GetValue(RecyclerView.ItemsSourceProperty) as IEnumerable;
set => SetValue(RecyclerView.ItemsSourceProperty, value);
get
{
if (NUIApplication.IsUsingXaml)
{
return GetValue(RecyclerView.ItemsSourceProperty) as IEnumerable;
}
else
{
return GetInternalItemsSourceProperty(this) as IEnumerable;
}
}
set
{
if (NUIApplication.IsUsingXaml)
{
SetValue(RecyclerView.ItemsSourceProperty, value);
}
else
{
SetInternalItemsSourceProperty(this, null, value);
}
}
}

internal override IEnumerable InternalItemsSource
Expand Down Expand Up @@ -347,11 +367,25 @@ public override DataTemplate ItemTemplate
{
get
{
return GetValue(ItemTemplateProperty) as DataTemplate;
if (NUIApplication.IsUsingXaml)
{
return GetValue(ItemTemplateProperty) as DataTemplate;
}
else
{
return GetInternalItemTemplateProperty(this) as DataTemplate;
}
}
set
{
SetValue(ItemTemplateProperty, value);
if (NUIApplication.IsUsingXaml)
{
SetValue(ItemTemplateProperty, value);
}
else
{
SetInternalItemTemplateProperty(this, null, value);
}
NotifyPropertyChanged();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ public Extents Padding
}
else
{
return (Extents)GetInternalPaddingProperty(this);
return (Extents)GetInternalPaddingProperty(this) ?? (padding = new Extents());
}
}
set
Expand Down Expand Up @@ -1001,7 +1001,7 @@ public Extents Margin
}
else
{
return (Extents)GetInternalMarginProperty(this);
return (Extents)GetInternalMarginProperty(this) ?? (margin = new Extents());
}
}
set
Expand Down
18 changes: 4 additions & 14 deletions src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,11 @@ internal static object GetInternalKeyInputFocusProperty(BindableObject bindable)
internal static void SetInternalBackgroundColorProperty(BindableObject bindable, object oldValue, object newValue)
{
var view = (View)bindable;

if (NUIApplication.IsUsingXaml)
view.themeData?.selectorData?.ClearBackground(view);
if (newValue is Selector<Color> selector)
{
view.themeData?.selectorData?.ClearBackground(view);

if (newValue is Selector<Color> selector)
{
if (selector.HasAll()) view.SetBackgroundColor(selector.All);
else view.EnsureSelectorData().BackgroundColor = new TriggerableSelector<Color>(view, selector, view.SetBackgroundColor, true);
}
else
{
view.SetBackgroundColor((Color)newValue);
}

if (selector.HasAll()) view.SetBackgroundColor(selector.All);
else view.EnsureSelectorData().BackgroundColor = new TriggerableSelector<Color>(view, selector, view.SetBackgroundColor, true);
}
else
{
Expand Down

0 comments on commit 0bf87b6

Please sign in to comment.