Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/2.1.0 #20

Merged
merged 8 commits into from
Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changelog

* [2.1.0](#210-2023-04-24)
* [2.0.1](#201-2023-02-26)
* [2.0.0](#200-2022-12-20)
* [1.6.0](#160-2022-11-20)
Expand All @@ -10,6 +11,28 @@
* [1.1.0](#110-2022-03-20)
* [1.0.0](#100-2022-03-08)

## [2.1.0](https://github.com/alexandrehtrb/Pororoca/tree/2.1.0) (2023-04-24)

### Features

* Great improvement on UI/UX for headers, URL encoded and form data params, and websocket subprotocols. Their grids now support drag-and-drop and the item removal actions now have a button on each row.
* Adds MIME types `application/dns-json`, `application/dns-message` and `application/problem+xml` (issue [#19](https://github.com/alexandrehtrb/Pororoca/issues/19)).
* Protects against rare scenario that response body is text, but not in UTF-8 encoding.

### Bug Fixes

* On Linux, requests with client certificate authentication will have independent SSL sessions of others to the same destination host.

### Refactoring

* Now using `[Reactive]` from ReactiveUI.Fody attributes on ViewModel properties.
* Reformatted XML views.
* Reformatted C# code.

### Others

* Raised .NET SDK to 7.0.203.

## [2.0.1](https://github.com/alexandrehtrb/Pororoca/tree/2.0.1) (2023-02-26)

### Minor features
Expand Down
6 changes: 5 additions & 1 deletion src/Icons_licences.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ HTTP icon:
WebSocket icon:
Source: https://freebiesupply.com/logos/websocket-logo/
Licence: Unknown, but free
Changes: Colour changed to white.
Changes: Colour changed to white.
Remove icon:
Source: https://pixabay.com/vectors/abort-delete-no-cancel-locked-146096/
Licence: Creative Commons.
Changes: Changed to white and brown.
57 changes: 56 additions & 1 deletion src/Pororoca.Desktop/App.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Pororoca.Desktop" x:Class="Pororoca.Desktop.App">
xmlns:local="using:Pororoca.Desktop" x:Class="Pororoca.Desktop.App"
xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
xmlns:idd="clr-namespace:Avalonia.Xaml.Interactions.DragAndDrop;assembly=Avalonia.Xaml.Interactions"
xmlns:iac="clr-namespace:Avalonia.Xaml.Interactions.Custom;assembly=Avalonia.Xaml.Interactions">
<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>
Expand Down Expand Up @@ -73,12 +76,64 @@
<Setter Property="BorderBrush" Value = "#E3A068" />
</Style>

<Style Selector="Button.Trash">
<Setter Property="Background">
<ImageBrush Source="/Assets/Images/icon_white_remove.png" />
</Setter>
</Style>

<Style Selector="Button.Trash:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background">
<ImageBrush Source="/Assets/Images/icon_brown_remove.png" />
</Setter>
</Style>

<Style Selector="ListBoxItem:selected:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="#183e67" />
</Style>

<Style Selector="ListBoxItem:selected /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="#0F263F" />
</Style>

<Style Selector="DataGrid.dragging-up DataGridRow.dragging">
<Setter Property="AdornerLayer.Adorner">
<Template>
<Border BorderThickness="0 2 0 0" BorderBrush="White" />
</Template>
</Setter>
</Style>

<Style Selector="DataGrid.dragging-down DataGridRow.dragging">
<Setter Property="AdornerLayer.Adorner">
<Template>
<Border BorderThickness="0 0 0 2" BorderBrush="White" />
</Template>
</Setter>
</Style>

<Style Selector="DataGrid.draggable DataGridRow">
<Setter Property="DragDrop.AllowDrop" Value="True" />
<Setter Property="(i:Interaction.Behaviors)">
<i:BehaviorCollectionTemplate>
<i:BehaviorCollection>
<idd:ContextDragBehavior />
<iac:RoutedEventTriggerBehavior RoutedEvent="{x:Static DragDrop.DragEnterEvent}"
RoutingStrategies="Bubble">
<iac:AddClassAction ClassName="dragging" RemoveIfExists="True" />
</iac:RoutedEventTriggerBehavior>
<iac:RoutedEventTriggerBehavior RoutedEvent="{x:Static DragDrop.DragLeaveEvent}"
RoutingStrategies="Bubble">
<iac:RemoveClassAction ClassName="dragging" />
</iac:RoutedEventTriggerBehavior>
<iac:RoutedEventTriggerBehavior RoutedEvent="{x:Static DragDrop.DropEvent}"
RoutingStrategies="Bubble">
<iac:RemoveClassAction ClassName="dragging" />
</iac:RoutedEventTriggerBehavior>
</i:BehaviorCollection>
</i:BehaviorCollectionTemplate>
</Setter>
</Style>

</Application.Styles>
</Application>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/Pororoca.Desktop/Assets/MacOSX/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<key>CFBundleDisplayName</key>
<string>Pororoca</string>
<key>CFBundleVersion</key>
<string>2.0.1</string>
<string>2.1.0</string>
<key>CFBundleShortVersionString</key>
<string>2.0.1</string>
<string>2.1.0</string>
<key>LSMinimumSystemVersion</key>
<string>10.12</string>
<key>CFBundleExecutable</key>
Expand Down
1 change: 1 addition & 0 deletions src/Pororoca.Desktop/Assets/i18n/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
"HttpRequest/SendRequest": "Send",
"HttpRequest/UrlWatermark": "(request url here)",
"HttpResponse/Body": "Body",
"HttpResponse/BodyCouldNotReadAsUTF8": "(could not read body as UTF-8 text, {0} bytes)",
"HttpResponse/BodyContentBinaryNotShown": "(binary content not shown, {0} bytes)",
"HttpResponse/BodyContentTypeWatermark": "(response content-type here)",
"HttpResponse/BodyContentWatermark": "(response body here)",
Expand Down
1 change: 1 addition & 0 deletions src/Pororoca.Desktop/Assets/i18n/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
"HttpRequest/SendRequest": "Enviar",
"HttpRequest/UrlWatermark": "(url da requisição aqui)",
"HttpResponse/Body": "Corpo",
"HttpResponse/BodyCouldNotReadAsUTF8": "(não foi possível ler o corpo como texto UTF-8, {0} bytes)",
"HttpResponse/BodyContentBinaryNotShown": "(conteúdo binário não-exibido, {0} bytes)",
"HttpResponse/BodyContentTypeWatermark": "(content-type da resposta aqui)",
"HttpResponse/BodyContentWatermark": "(corpo da resposta aqui)",
Expand Down
157 changes: 157 additions & 0 deletions src/Pororoca.Desktop/Behaviors/DataGridDragAndDropBehavior.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
using System.Diagnostics;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.VisualTree;
using Avalonia.Xaml.Interactions.DragAndDrop;

namespace Pororoca.Desktop.Behaviors;

public class DataGridDragAndDropBehavior<T> : DropHandlerBase where T : class
{
private enum DragDirection
{
Up,
Down
}

private struct DndData
{
public DndData() { }
public DataGrid? SrcDataGrid = null;
public DataGrid DestDataGrid = null!;
public IList<T> SrcList = null!;
public IList<T> DestList = null!;
public int SrcIndex = -1;

public int DestIndex = -1;
public DragDirection Direction;
}

private const string DraggingUpClassName = "dragging-up";
private const string DraggingDownClassName = "dragging-down";

private DndData dnd = new();

private bool Validate(object? sender, DragEventArgs e, object? sourceContext)
{
if (this.dnd.SrcDataGrid is not { } srcDg ||
sender is not DataGrid destDg ||
sourceContext is not T src ||
srcDg.Items is not IList<T> srcList ||
destDg.Items is not IList<T> destList ||
destDg.GetVisualAt(e.GetPosition(destDg),
v => v.FindDescendantOfType<DataGridCell>() is not null) is not Control
{
DataContext: T dest
} visual)
{
return false;
}

var cell = visual.FindDescendantOfType<DataGridCell>()!;
var pos = e.GetPosition(cell);

this.dnd.SrcDataGrid = srcDg;
this.dnd.DestDataGrid = destDg;
this.dnd.SrcList = srcList;
this.dnd.DestList = destList;
this.dnd.Direction = cell.DesiredSize.Height / 2 > pos.Y ? DragDirection.Up : DragDirection.Down;
this.dnd.SrcIndex = srcList.IndexOf(src);
this.dnd.DestIndex = destList.IndexOf(dest);

return true;
}

public override bool Validate(object? sender, DragEventArgs e, object? sourceContext,
object? targetContext, object? state) => Validate(sender, e, sourceContext);

public override bool Execute(object? sender, DragEventArgs e, object? sourceContext,
object? targetContext, object? state)
{
if (!Validate(sender, e, sourceContext))
return false;

if (this.dnd.SrcDataGrid != this.dnd.DestDataGrid && this.dnd.Direction == DragDirection.Down)
this.dnd.DestIndex++;
else if (this.dnd.SrcIndex > this.dnd.DestIndex && this.dnd.Direction == DragDirection.Down)
this.dnd.DestIndex++;
else if (this.dnd.SrcIndex < this.dnd.DestIndex && this.dnd.Direction == DragDirection.Up)
this.dnd.DestIndex--;

MoveItem(this.dnd.SrcList, this.dnd.DestList, this.dnd.SrcIndex, this.dnd.DestIndex);
this.dnd.DestDataGrid.SelectedIndex = this.dnd.DestIndex;
this.dnd.DestDataGrid.ScrollIntoView(this.dnd.DestList[this.dnd.DestIndex], null);
this.dnd.SrcDataGrid = null;
return true;
}

public override void Enter(object? sender, DragEventArgs e, object? sourceContext,
object? targetContext)
{
this.dnd.SrcDataGrid ??= sender as DataGrid;
if (!Validate(sender, e, sourceContext))
{
e.DragEffects = DragDropEffects.None;
e.Handled = true;
return;
}

string className = this.dnd.Direction switch
{
DragDirection.Down => DraggingDownClassName,
DragDirection.Up => DraggingUpClassName,
_ => throw new UnreachableException($"Invalid drag direction: {this.dnd.Direction}")
};
this.dnd.DestDataGrid.Classes.Add(className);

e.DragEffects |= DragDropEffects.Copy | DragDropEffects.Move | DragDropEffects.Link;
e.Handled = true;
}

public override void Over(object? sender, DragEventArgs e, object? sourceContext,
object? targetContext)
{
if (!Validate(sender, e, sourceContext))
{
e.DragEffects = DragDropEffects.None;
e.Handled = true;
return;
}

e.DragEffects |= DragDropEffects.Copy | DragDropEffects.Move | DragDropEffects.Link;
e.Handled = true;

(string toAdd, string toRemove) = this.dnd.Direction switch
{
DragDirection.Down => (DraggingDownClassName, DraggingUpClassName),
DragDirection.Up => (DraggingUpClassName, DraggingDownClassName),
_ => throw new UnreachableException($"Invalid drag direction: {this.dnd.Direction}")
};
if (this.dnd.DestDataGrid.Classes.Contains(toAdd))
return;

this.dnd.DestDataGrid.Classes.Remove(toRemove);
this.dnd.DestDataGrid.Classes.Add(toAdd);
}

public override void Leave(object? sender, RoutedEventArgs e)
{
base.Leave(sender, e);
RemoveDraggingClass(sender as DataGrid);
}

public override void Drop(object? sender, DragEventArgs e, object? sourceContext,
object? targetContext)
{
RemoveDraggingClass(sender as DataGrid);
base.Drop(sender, e, sourceContext, targetContext);
this.dnd.SrcDataGrid = null;
}

private static void RemoveDraggingClass(DataGrid? dg)
{
if (dg is not null && !dg.Classes.Remove(DraggingUpClassName))
dg.Classes.Remove(DraggingDownClassName);
}
}
36 changes: 26 additions & 10 deletions src/Pororoca.Desktop/Controls/IconButton.axaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
<ContentControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="Pororoca.Desktop.Controls.IconButton"
xmlns:controls="clr-namespace:Pororoca.Desktop.Controls">
<ContentControl
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="Pororoca.Desktop.Controls.IconButton"
xmlns:controls="clr-namespace:Pororoca.Desktop.Controls">
<ContentControl.Styles>
<Style Selector="controls|IconButton">
<Setter Property="Template">
<ControlTemplate>
<Button Classes="Primary" Command="{TemplateBinding Command}">
<Button
Classes="Primary"
Command="{TemplateBinding Command}">
<Button.Content>
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Orientation="Horizontal" Background="Transparent" Height="16" Width="180">
<Image Source="{TemplateBinding Icon}" Width="16" Height="16" Margin="4 0 8 0" />
<TextBlock Text="{TemplateBinding Text}" Margin="4 0 8 0" FontSize="14"/>
<StackPanel
VerticalAlignment="Center"
HorizontalAlignment="Center"
Orientation="Horizontal"
Background="Transparent"
Height="16"
Width="180">
<Image
Source="{TemplateBinding Icon}"
Width="16"
Height="16"
Margin="4 0 8 0" />
<TextBlock
Text="{TemplateBinding Text}"
Margin="4 0 8 0"
FontSize="14" />
</StackPanel>
</Button.Content>
</Button>
Expand Down
Loading