Skip to content

Reactive UI 2.0 - #216

Merged
Hermanest merged 6 commits into
masterfrom
nsgolova/reactive2
Nov 19, 2026
Merged

Hermanest merged 6 commits into
masterfrom
nsgolova/reactive2

Conversation

@NSGolova

@NSGolova NSGolova commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@Hermanest
Hermanest self-requested a review November 3, 2026 21:04
}
}

private static Sprite GetFirstFrame(CachedImage image) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move to an extension or util as its duplicated in multiple places

public void Hide() {
_animator.Pull();
public bool IsPresent {
get => _alpha.TargetValue > 0f;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might potentially be problematic because setting false and rechecking immediately won't return false

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TargetValue is assigned synchronously, so the getter did return false right after setting false. Nothing read it though, so I removed it.


protected override void OnInitialize() {
this.AsFlexItem(size: new() { x = 50f, y = 10f });
this.FlexItem.Size = new() { x = 50f, y = 10f };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be defined directly on the Layout instance returned by Construct

size: new() { x = _avatarSize },
position: new() { left = CalculateIndent(index) }
);
wrapper.FlexItem.AspectRatio = 1f;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In places where we set multiple properties it makes sense to either cache FlexItem or use the legacy AsFlexItem version

base.OnInitialize();
SelectionMode = global::Reactive.Components.Basic.SelectionMode.None;
private void RefreshItems() {
_table.Items = _replays.Select(static x => new Opponent(x, x.ReplayRank)).ToArray();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recreating the entire array on each mutation is inefficient

.WithAlpha(_spinnerAlpha, invert: true)
.Animate(_event, (x, y) => x.Accent = y.eventDescription.MainColor() ?? x.Accent)
.Animate(_event, (x, y) => x.Text = y.eventDescription.name),
.On(_event, (x, y) => x.Accent = y.eventDescription.MainColor() ?? x.Accent, lazy: true),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be done using bindings gen

HandleVisibilityButtonClicked();
global::Reactive.BeatSaber.GameResources.ButtonClickSignal.Raise();
}
).On(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't have to be attached to a component. Use plain AddCallback

destination = _layoutGrid.OnResize(component, destination);
destination = ApplyBorders(destination, component.LayoutData.size);
return destination;
return Vector2.Min(destination, AreaSize);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be an unintended change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentional. ApplyBorders clamps a position, but this passes a size, which capped resizing at about a third of the area and made it oscillate. It's an old bug that I fixed during the port; I can split it into its own PR if you prefer.

case Justify.FlexStart:
_railsLayoutModifier.FlexGrow = 1;
_railsLayoutModifier.Size = new() { x = YogaValue.Undefined };
_rails.FlexItem.FlexGrow = 1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't really make any sense to use this instead of storing modifiers directly. Nothing sets a new instance anyway

onLeave: _ => state.IsHovered = false,
onDown: _ => _selectedView.Value = key
)
.On(_selectedView, (_, y) => state.IsActive = y == key);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't have to be attached to a component

}
)
.AsFlexItem(margin: new() { left = 1f, right = 1f })
.On(_context, (_, ctx) => UpdateBottomText(ctx.Item), lazy: true)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use AddCallback instead

@Hermanest
Hermanest merged commit 388073e into master Nov 19, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants