Skip to content

Commit

Permalink
Display branch name
Browse files Browse the repository at this point in the history
  • Loading branch information
yaira2 committed May 11, 2023
1 parent 76e895f commit 611ed5f
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 36 deletions.
12 changes: 6 additions & 6 deletions src/Files.App/Helpers/DynamicDialogFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,16 @@ public static DynamicDialog GetFor_CredentialEntryDialog(string path)
return dialog;
}

public static DynamicDialog GetFor_GitCheckoutConflicts()
public static DynamicDialog GetFor_GitCheckoutConflicts(string checkoutBranchName, string headBranchName)
{
DynamicDialog dialog = null!;

var optionsListView = new ListView()
{
ItemsSource = new string[]
{
"BringChanges".GetLocalizedResource(),
"StashChanges".GetLocalizedResource(),
string.Format("BringChanges".GetLocalizedResource(), checkoutBranchName),
string.Format("StashChanges".GetLocalizedResource(), headBranchName),
"DiscardChanges".GetLocalizedResource()
},
SelectionMode = ListViewSelectionMode.Single
Expand All @@ -240,10 +240,10 @@ public static DynamicDialog GetFor_GitCheckoutConflicts()

dialog = new DynamicDialog(new DynamicDialogViewModel()
{
TitleText = "UncommitedChanges".GetLocalizedResource(),
PrimaryButtonText = "OK".GetLocalizedResource(),
TitleText = "SwitchBranch".GetLocalizedResource(),
PrimaryButtonText = "Switch".GetLocalizedResource(),
CloseButtonText = "Cancel".GetLocalizedResource(),
SubtitleText = "UncommitedChangesMessage".GetLocalizedResource(),
SubtitleText = "UncommittedChanges".GetLocalizedResource(),
DisplayControl = new Grid()
{
MinWidth = 250d,
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Helpers/GitHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static async Task Checkout(string? repositoryPath, string? branch)

if (repository.RetrieveStatus().IsDirty)
{
var dialog = DynamicDialogFactory.GetFor_GitCheckoutConflicts();
var dialog = DynamicDialogFactory.GetFor_GitCheckoutConflicts(checkoutBranch.FriendlyName, repository.Head.FriendlyName);
await dialog.ShowAsync();

var resolveConflictOption = (GitCheckoutOptions)dialog.ViewModel.AdditionalData;
Expand Down
22 changes: 14 additions & 8 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -3263,21 +3263,27 @@
<value>Unable to display permissions.</value>
</data>
<data name="StashChanges" xml:space="preserve">
<value>Stash changes</value>
<value>Leave my changes on '{0}'</value>
</data>
<data name="DiscardChanges" xml:space="preserve">
<value>Discard changes</value>
<value>Discard my changes</value>
</data>
<data name="BringChanges" xml:space="preserve">
<value>Bring changes</value>
<value>Bring my changes to '{0}'</value>
</data>
<data name="UncommitedChanges" xml:space="preserve">
<value>There are uncommited changes on the local branch</value>
<data name="UncommittedChanges" xml:space="preserve">
<value>You have uncommitted changes on this branch. What would you like to do with them?</value>
</data>
<data name="UncommitedChangesMessage" xml:space="preserve">
<value>What do you want to do with them?</value>
<data name="SwitchBranch" xml:space="preserve">
<value>Switch Branch</value>
</data>
<data name="Branches" xml:space="preserve">
<value>Branches:</value>
<value>Branches</value>
</data>
<data name="Switch" xml:space="preserve">
<value>Switch</value>
</data>
<data name="NewBranch" xml:space="preserve">
<value>New branch</value>
</data>
</root>
55 changes: 39 additions & 16 deletions src/Files.App/UserControls/StatusBarControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,49 @@
Content="{x:Bind DirectoryPropertiesViewModel.GitBranchDisplayName, Mode=OneWay}">
<Button.Flyout>
<Flyout Opening="Flyout_Opening">
<Flyout.FlyoutPresenterStyle>
<Style TargetType="FlyoutPresenter">
<Setter Property="Padding" Value="8" />
<Setter Property="CornerRadius" Value="{StaticResource OverlayCornerRadius}" />
</Style>
</Flyout.FlyoutPresenterStyle>
<StackPanel
Width="200"
Height="200"
LostFocus="StackPanel_LostFocus"
Spacing="8">
<TextBlock
Margin="16,0,0,0"
FontWeight="Bold"
Text="{helpers:ResourceString Name=Branches}" />
<Grid
Width="300"
Height="340"
Margin="-16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<!-- Header -->
<Grid
Grid.Row="0"
Padding="12"
Background="{ThemeResource AcrylicBackgroundFillColorDefaultBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="0,0,0,1">
<!-- Title -->
<TextBlock
VerticalAlignment="Center"
FontSize="14"
Text="{helpers:ResourceString Name=Branches}" />

<!-- New Branch Button -->
<Button
x:Name="NewBranchButton"
Height="24"
Padding="8,0"
HorizontalAlignment="Right"
x:Load="False"
Content="{helpers:ResourceString Name=NewBranch}"
FontSize="12"
ToolTipService.ToolTip="{helpers:ResourceString Name=NewBranch}" />
</Grid>

<!-- Branches List -->
<ListView
Grid.Row="1"
Padding="4"
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
ItemsSource="{x:Bind DirectoryPropertiesViewModel.BranchesNames, Mode=OneWay}"
SelectedIndex="{x:Bind DirectoryPropertiesViewModel.SelectedBranchIndex, Mode=TwoWay}"
SelectionMode="Single" />
</StackPanel>
</Grid>
</Flyout>
</Button.Flyout>
</Button>
Expand Down
5 changes: 0 additions & 5 deletions src/Files.App/UserControls/StatusBarControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,5 @@ private void Flyout_Opening(object sender, object e)
{
DirectoryPropertiesViewModel.SelectedBranchIndex = DirectoryPropertiesViewModel.ActiveBranchIndex;
}

private void StackPanel_LostFocus(object sender, RoutedEventArgs e)
{
((Popup)((FlyoutPresenter)((StackPanel)sender).Parent).Parent).IsOpen = false;
}
}
}

0 comments on commit 611ed5f

Please sign in to comment.