Repository navigation
Reactive UI 2.0 - #216
Reactive UI 2.0#216
Conversation
| } | ||
| } | ||
|
|
||
| private static Sprite GetFirstFrame(CachedImage image) { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Might potentially be problematic because setting false and rechecking immediately won't return false
There was a problem hiding this comment.
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 }; |
There was a problem hiding this comment.
Can be defined directly on the Layout instance returned by Construct
| size: new() { x = _avatarSize }, | ||
| position: new() { left = CalculateIndent(index) } | ||
| ); | ||
| wrapper.FlexItem.AspectRatio = 1f; |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
Can be done using bindings gen
| HandleVisibilityButtonClicked(); | ||
| global::Reactive.BeatSaber.GameResources.ButtonClickSignal.Raise(); | ||
| } | ||
| ).On( |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Might be an unintended change?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Doesn't have to be attached to a component
f4406d6 to
e08ca9f
Compare
| } | ||
| ) | ||
| .AsFlexItem(margin: new() { left = 1f, right = 1f }) | ||
| .On(_context, (_, ctx) => UpdateBottomText(ctx.Item), lazy: true) |
7e0b609 to
06ce727
Compare
No description provided.