Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
capdiem committed Jun 17, 2024
1 parent cb106df commit 4a997ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
29 changes: 17 additions & 12 deletions src/Masa.Blazor/Components/Window/MWindow.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ public MWindow() : base(GroupType.Window)

public bool IsActive => TransitionCount > 0;

public int InternalIndex => GetComputedValue<int>();
public int InternalIndex { get; private set; }

private int _prevInternalIndex = 0;
private void UpdateInternalIndex()
{
InternalIndex = Items.FindIndex(item => item.Value == InternalValue);
IsReverse = UpdateReverse(InternalIndex, _prevInternalIndex);
_prevInternalIndex = InternalIndex;
}

public bool HasActiveItems => Items.Any(item => !item.Disabled);

Expand All @@ -69,15 +77,17 @@ public string ComputedTransition
private bool IndependentTheme =>
(IsDirtyParameter(nameof(Dark)) && Dark) || (IsDirtyParameter(nameof(Light)) && Light);

private StringNumber _prevInternalValue;

protected override void OnParametersSet()
{
base.OnParametersSet();

#if NET8_0_OR_GREATER
if (MasaBlazor.IsSsr && !IndependentTheme)
{
CascadingIsDark = MasaBlazor.Theme.Dark;
}
if (MasaBlazor.IsSsr && !IndependentTheme)
{
CascadingIsDark = MasaBlazor.Theme.Dark;
}
#endif
ActiveClass = "m-window-item--active";
PrevIcon ??= "$prev";
Expand All @@ -103,12 +113,7 @@ protected override void RegisterWatchers(PropertyWatcher watcher)
{
base.RegisterWatchers(watcher);

watcher.Watch(nameof(InternalIndex),
(newVal, oldVal) => IsReverse = UpdateReverse(newVal, oldVal),
() => Items.FindIndex(item => item.Value == InternalValue),
new[] { nameof(InternalValues) },
false,
true);
watcher.Watch<List<StringNumber?>>(nameof(InternalValues), UpdateInternalIndex);
}

internal override void Register(IGroupable item)
Expand Down Expand Up @@ -136,7 +141,7 @@ protected void Next()
protected void Prev()
{
if (!HasActiveItems || !HasPrev) return;

var prevIndex = GetPrevIndex(InternalIndex);
var prevItem = Items[prevIndex];

Expand Down
11 changes: 0 additions & 11 deletions src/Masa.Blazor/Core/MasaComponentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,17 +305,6 @@ protected virtual void RegisterWatchers(PropertyWatcher watcher)
return _watcher.GetValue(@default, name);
}

protected TValue? GetComputedValue<TValue>([CallerMemberName] string name = "")
{
return _watcher.GetComputedValue<TValue>(name);
}

protected TValue? GetComputedValue<TValue>(Expression<Func<TValue>> valueExpression,
[CallerMemberName] string name = "")
{
return _watcher.GetComputedValue(valueExpression, name);
}

protected TValue? GetComputedValue<TValue>(Func<TValue> valueFactory, string[] dependencyProperties,
[CallerMemberName] string name = "")
{
Expand Down

0 comments on commit 4a997ed

Please sign in to comment.