Skip to content

Commit

Permalink
feat(hrui): Improve types output + open overlay by default
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Jul 5, 2024
1 parent 6a4f340 commit 7935c03
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,41 @@ internal HotReloadClientOperation(HotReloadSource source, Type[] types, Action o

public Type[] Types { get; }

internal string[] CuratedTypes => _curatedTypes ??= Types
.Select(t =>
internal string[] CuratedTypes => _curatedTypes ??= GetCuratedTypes();

private string[] GetCuratedTypes()
{
return Types
.Select(GetFriendlyName)
.Where(name => name is { Length: > 0 })
.Distinct()
.ToArray()!;

string? GetFriendlyName(Type type)
{
var name = t.Name;
var versionIndex = t.Name.IndexOf('#');
return versionIndex < 0
? default!
: name[..versionIndex];
})
.Where(t => t is not null)
.ToArray();
var name = type.FullName ?? type.Name;

var versionIndex = name.IndexOf('#');
if (versionIndex >= 0)
{
name = name[..versionIndex];
}

var nestingIndex = name.IndexOf('+');
if (nestingIndex >= 0)
{
name = name[..nestingIndex];
}

var endOfNamespaceIndex = name.LastIndexOf('.');
if (endOfNamespaceIndex >= 0)
{
name = name[(endOfNamespaceIndex + 1)..];
}

return name;
}
}

public DateTimeOffset? EndTime { get; private set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ internal void Update(HotReloadClientOperation localOp)
HotReloadClientResult.Failed => "An error occured",
_ => null
};
Description = Join("type", localOp.CuratedTypes, localOp.Types.Length);
Description = Join("type", localOp.CuratedTypes);
Duration = localOp.EndTime is not null ? localOp.EndTime - localOp.StartTime : null;

RaiseChanged();
Expand Down
4 changes: 2 additions & 2 deletions src/Uno.UI.RemoteControl/HotReload/HotReloadStatusView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@

<Setter Property="SuccessNotification">
<Setter.Value>
<diag:DiagnosticViewNotification Duration="0:0:10" Options="EvenIfExpended">
<diag:DiagnosticViewNotification Duration="0:0:5" Options="EvenIfExpended">
<diag:DiagnosticViewNotification.ContentTemplate>
<DataTemplate>
<StackPanel
Expand Down Expand Up @@ -179,7 +179,7 @@

<Setter Property="FailureNotification">
<Setter.Value>
<diag:DiagnosticViewNotification Duration="0:0:10" Options="EvenIfExpended">
<diag:DiagnosticViewNotification Duration="0:0:5" Options="EvenIfExpended">
<diag:DiagnosticViewNotification.ContentTemplate>
<DataTemplate>
<StackPanel
Expand Down
20 changes: 10 additions & 10 deletions src/Uno.UI.Toolkit/Diagnostics/DiagnosticsOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static DiagnosticsOverlay Get(XamlRoot root)
private ViewContext? _context;
private Popup? _overlayHost;
private bool _isVisible;
private bool _isExpanded;
private bool _isExpanded = true;
private int _updateEnqueued;
private Panel? _elementsPanel;
private UIElement? _anchor;
Expand Down Expand Up @@ -108,7 +108,7 @@ private DiagnosticsOverlay(XamlRoot root)
/// Make the overlay visible.
/// </summary>
/// <remarks>This can be invoked from any thread.</remarks>>
public void Show(bool? isExpanded = false)
public void Show(bool? isExpanded = null)
{
_isVisible = true;
if (isExpanded is not null)
Expand Down Expand Up @@ -196,7 +196,7 @@ protected override void OnApplyTemplate()
{
if (_anchor is not null)
{
_anchor.Tapped -= OnAnchorTapped;
//_anchor.Tapped -= OnAnchorTapped;
_anchor.ManipulationDelta -= OnAnchorManipulated;
}
if (_notificationPresenter is not null)
Expand All @@ -212,7 +212,7 @@ protected override void OnApplyTemplate()

if (_anchor is not null)
{
_anchor.Tapped += OnAnchorTapped;
//_anchor.Tapped += OnAnchorTapped;
_anchor.ManipulationDelta += OnAnchorManipulated;
_anchor.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY | ManipulationModes.TranslateInertia;
RenderTransform = new TranslateTransform { X = 15, Y = 15 };
Expand All @@ -227,12 +227,12 @@ protected override void OnApplyTemplate()
EnqueueUpdate();
}

private void OnAnchorTapped(object sender, TappedRoutedEventArgs args)
{
_isExpanded = !_isExpanded;
VisualStateManager.GoToState(this, _isExpanded ? DisplayModeExpandedStateName : DisplayModeCompactStateName, true);
args.Handled = true;
}
//private void OnAnchorTapped(object sender, TappedRoutedEventArgs args)
//{
// _isExpanded = !_isExpanded;
// VisualStateManager.GoToState(this, _isExpanded ? DisplayModeExpandedStateName : DisplayModeCompactStateName, true);
// args.Handled = true;
//}

private void OnAnchorManipulated(object sender, ManipulationDeltaRoutedEventArgs e)
{
Expand Down

0 comments on commit 7935c03

Please sign in to comment.