Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: enabled sign out and animated window resize#109

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ibetitsmike merged 9 commits intomainfrommike/enable-sign-out-animation-expander
May 28, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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
51 changes: 26 additions & 25 deletionsApp/Controls/ExpandContent.xaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,42 +9,43 @@
xmlns:toolkit="using:CommunityToolkit.WinUI"
mc:Ignorable="d">

<Grid x:Name="CollapsiblePanel" Opacity="0" Visibility="Collapsed" toolkit:UIElementExtensions.ClipToBounds="True">
<Grid x:Name="CollapsiblePanel" Opacity="0" Visibility="Collapsed"MaxHeight="0"toolkit:UIElementExtensions.ClipToBounds="True">
<Grid.RenderTransform>
<TranslateTransform x:Name="SlideTransform" Y="-10"/>
<TranslateTransform x:Name="SlideTransform" Y="-16"/>
</Grid.RenderTransform>

<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="ExpandedState">
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="CollapsiblePanel"
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0:0:0.2" />
<DoubleAnimation
Storyboard.TargetName="SlideTransform"
Storyboard.TargetProperty="Y"
To="0"
Duration="0:0:0.2"/>
<Storyboard x:Name="ExpandSb">
<DoubleAnimation Storyboard.TargetName="CollapsiblePanel"
Storyboard.TargetProperty="MaxHeight"
To="10000" Duration="0:0:0.16" BeginTime="0:0:0.16"
EnableDependentAnimation="True"/>
<DoubleAnimation Storyboard.TargetName="CollapsiblePanel"
Storyboard.TargetProperty="Opacity" BeginTime="0:0:0.16"
To="1" Duration="0:0:0.16"/>
<DoubleAnimationStoryboard.TargetName="SlideTransform"
Storyboard.TargetProperty="Y" BeginTime="0:0:0.16"
To="0"Duration="0:0:0.16"/>
</Storyboard>
</VisualState>

<VisualState x:Name="CollapsedState">
<Storyboard Completed="{x:Bind CollapseAnimation_Completed}">
<DoubleAnimation
Storyboard.TargetName="CollapsiblePanel"
Storyboard.TargetProperty="Opacity"
To="0"
Duration="0:0:0.2" />
<DoubleAnimation
Storyboard.TargetName="SlideTransform"
Storyboard.TargetProperty="Y"
To="-10"
Duration="0:0:0.2" />
<Storyboard x:Name="CollapseSb"
Completed="{x:Bind CollapseStoryboard_Completed}">
<DoubleAnimation Storyboard.TargetName="CollapsiblePanel"
Storyboard.TargetProperty="MaxHeight"
To="0" Duration="0:0:0.16"
EnableDependentAnimation="True"/>
<DoubleAnimation Storyboard.TargetName="CollapsiblePanel"
Storyboard.TargetProperty="Opacity"
To="0" Duration="0:0:0.16"/>
<DoubleAnimation Storyboard.TargetName="SlideTransform"
Storyboard.TargetProperty="Y"
To="-16" Duration="0:0:0.16"/>
</Storyboard>
</VisualState>

</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
Expand Down
46 changes: 34 additions & 12 deletionsApp/Controls/ExpandContent.xaml.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,38 +2,60 @@
usingMicrosoft.UI.Xaml;
usingMicrosoft.UI.Xaml.Controls;
usingMicrosoft.UI.Xaml.Markup;
usingSystem;
usingSystem.Threading.Tasks;

namespaceCoder.Desktop.App.Controls;


[ContentProperty(Name=nameof(Children))]
[DependencyProperty<bool>("IsOpen",DefaultValue=false)]
publicsealedpartialclassExpandContent:UserControl
{
publicUIElementCollectionChildren=>CollapsiblePanel.Children;

privatereadonlystring_expandedState="ExpandedState";
privatereadonlystring_collapsedState="CollapsedState";

publicExpandContent()
{
InitializeComponent();
}
Loaded+=(_,__)=>
{
// When we load the control for the first time (after panel swapping)
// we need to set the initial state based on IsOpen.
VisualStateManager.GoToState(
this,
IsOpen?_expandedState:_collapsedState,
useTransitions:false);// NO animation yet

publicvoidCollapseAnimation_Completed(object?sender,objectargs)
{
// Hide the panel completely when the collapse animation is done. This
// cannot be done with keyframes for some reason.
//
// Without this, the space will still be reserved for the panel.
CollapsiblePanel.Visibility=Visibility.Collapsed;
// If IsOpen was already true we must also show the panel
if(IsOpen)
{
CollapsiblePanel.Visibility=Visibility.Visible;
// This makes the panel expand to its full height
CollapsiblePanel.ClearValue(FrameworkElement.MaxHeightProperty);
}
};
}

partialvoidOnIsOpenChanged(boololdValue,boolnewValue)
{
varnewState=newValue?"ExpandedState":"CollapsedState";

// The animation can't set visibility when starting or ending the
// animation.
varnewState=newValue?_expandedState:_collapsedState;
if(newValue)
{
CollapsiblePanel.Visibility=Visibility.Visible;
// We use BeginTime to ensure other panels are collapsed first.
// If the user clicks the expand button quickly, we want to avoid
// the panel expanding to its full height before the collapse animation completes.
CollapseSb.SkipToFill();
}

VisualStateManager.GoToState(this,newState,true);
}

privatevoidCollapseStoryboard_Completed(objectsender,objecte)
{
CollapsiblePanel.Visibility=Visibility.Collapsed;
}
}
2 changes: 2 additions & 0 deletionsApp/Services/RpcController.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -234,6 +234,8 @@ public async Task StopVpn(CancellationToken ct = default)
MutateState(state => { state.VpnLifecycle = VpnLifecycle.Unknown; });
throw new VpnLifecycleException($"Failed to stop VPN. Service reported failure: {reply.Stop.ErrorMessage}");
}

MutateState(state => { state.VpnLifecycle = VpnLifecycle.Stopped; });
}

public async ValueTask DisposeAsync()
Expand Down
12 changes: 10 additions & 2 deletionsApp/ViewModels/AgentViewModel.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -237,12 +237,20 @@ public AgentViewModel(ILogger<AgentViewModel> logger, ICoderApiClientFactory cod

Id = id;

PropertyChanged += (_, args) =>
PropertyChanging += (x, args) =>
{
if (args.PropertyName == nameof(IsExpanded))
{
_expanderHost.HandleAgentExpanded(Id, IsExpanded);
var value = !IsExpanded;
if (value)
_expanderHost.HandleAgentExpanded(Id, value);
}
};

PropertyChanged += (x, args) =>
{
if (args.PropertyName == nameof(IsExpanded))
{
// Every time the drawer is expanded, re-fetch all apps.
if (IsExpanded && !FetchingApps)
FetchApps();
Expand Down
7 changes: 7 additions & 0 deletionsApp/ViewModels/TrayWindowLoginRequiredViewModel.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@
using Coder.Desktop.App.Views;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.UI.Xaml;

namespace Coder.Desktop.App.ViewModels;

Expand DownExpand Up@@ -31,4 +32,10 @@ public void Login()
_signInWindow.Closed += (_, _) => _signInWindow = null;
_signInWindow.Activate();
}

[RelayCommand]
public void Exit()
{
_ = ((App)Application.Current).ExitApplication();
}
}
9 changes: 4 additions & 5 deletionsApp/ViewModels/TrayWindowViewModel.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -126,7 +126,7 @@ public void HandleAgentExpanded(Uuid id, bool expanded)
if (!expanded) return;
_hasExpandedAgent = true;
// Collapse every other agent.
foreach (var otherAgent in Agents.Where(a => a.Id != id))
foreach (var otherAgent in Agents.Where(a => a.Id != id && a.IsExpanded == true))
otherAgent.SetExpanded(false);
}

Expand DownExpand Up@@ -360,11 +360,10 @@ private void ShowFileSyncListWindow()
}

[RelayCommand]
privatevoid SignOut()
privateasync Task SignOut()
{
if (VpnLifecycle is not VpnLifecycle.Stopped)
return;
_credentialManager.ClearCredentials();
await _rpcController.StopVpn();
await _credentialManager.ClearCredentials();
}

[RelayCommand]
Expand Down
9 changes: 9 additions & 0 deletionsApp/Views/Pages/TrayWindowLoginRequiredPage.xaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,5 +34,14 @@

<TextBlock Text="Sign in" Foreground="{ThemeResource DefaultTextForegroundThemeBrush}" />
</HyperlinkButton>

<HyperlinkButton
Command="{x:Bind ViewModel.ExitCommand, Mode=OneWay}"
Margin="-12,-8,-12,-5"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left">

<TextBlock Text="Exit" Foreground="{ThemeResource DefaultTextForegroundThemeBrush}" />
</HyperlinkButton>
</StackPanel>
</Page>
1 change: 0 additions & 1 deletionApp/Views/Pages/TrayWindowMainPage.xaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -333,7 +333,6 @@

<HyperlinkButton
Command="{x:Bind ViewModel.SignOutCommand, Mode=OneWay}"
IsEnabled="{x:Bind ViewModel.VpnLifecycle, Converter={StaticResource StoppedBoolConverter}, Mode=OneWay}"
Margin="-12,0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left">
Expand Down
7 changes: 7 additions & 0 deletionsApp/Views/TrayWindow.xaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,5 +20,12 @@

<!-- This is where the current Page is displayed -->
<controls:SizedFrame x:Name="RootFrame" />

<!-- proxy for animating resize -->
<Border x:Name="SizeProxy"
Width="0"
Height="0"
IsHitTestVisible="False"
Opacity="0" />
</Grid>
</Window>
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp