Skip to content

Commit 27eb556

Browse files
committed
winui: extract common DialogWindow to shared project
Extract the GitHubDialogWindow into a shared control that can be used by multiple consumers. Also simplify the IGui interface and optimise creating a DialogWindow window with a control.
1 parent 3588523 commit 27eb556

17 files changed

+223
-228
lines changed

src/windows/GitHub.UI.Windows/AuthenticationPrompts.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
3-
using GitHub.UI.Dialog;
3+
44
using GitHub.UI.Login;
55
using Microsoft.Git.CredentialManager.UI;
6+
using Microsoft.Git.CredentialManager.UI.Controls;
67

78
namespace GitHub.UI
89
{
@@ -25,7 +26,7 @@ public CredentialPromptResult ShowCredentialPrompt(string enterpriseUrl, bool sh
2526
GitHubEnterpriseUrl = enterpriseUrl
2627
};
2728

28-
bool valid = _gui.ShowDialogWindow(() => new GitHubDialogWindow(viewModel, new LoginCredentialsView()));
29+
bool valid = _gui.ShowDialogWindow(viewModel, () => new LoginCredentialsView());
2930

3031
if (viewModel.UseBrowserLogin)
3132
{
@@ -46,7 +47,7 @@ public bool ShowAuthenticationCodePrompt(bool isSms, out string authenticationCo
4647
{
4748
var viewModel = new Login2FaViewModel(isSms ? TwoFactorType.Sms : TwoFactorType.AuthenticatorApp);
4849

49-
bool valid = _gui.ShowViewModel(viewModel, () => new GitHubDialogWindow(viewModel, new Login2FaView()));
50+
bool valid = _gui.ShowDialogWindow(viewModel, () => new Login2FaView());
5051

5152
authenticationCode = valid ? viewModel.AuthenticationCode : null;
5253

src/windows/GitHub.UI.Windows/Colors.xaml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,7 @@
4545
<Color x:Key="TextBoxTextDisabled">yellow</Color>
4646
<Color x:Key="TextBoxBorderDisabled">black</Color>
4747

48-
<Color x:Key="WindowPanel">#FBFBFB</Color>
49-
<Color x:Key="WindowPanelText">#1E1E1E</Color>
50-
<Color x:Key="WindowBorder">#CCCEDB</Color>
5148

52-
<Color x:Key="WindowButton">#FBFBFB</Color>
53-
<Color x:Key="WindowButtonGlyph">#332C21</Color>
54-
55-
<Color x:Key="WindowButtonHover">#FCD8A2</Color>
56-
<Color x:Key="WindowButtonHoverGlyph">#332C21</Color>
57-
<Color x:Key="WindowButtonHoverBorder">#FFFFFF</Color>
58-
59-
<Color x:Key="WindowButtonDown">#FCD8A2</Color>
60-
<Color x:Key="WindowButtonDownGlyph">#332C21</Color>
61-
<Color x:Key="WindowButtonDownBorder">#FFFFFF</Color>
6249

6350
<Color x:Key="ToolWindowBackground">#F1F1F1</Color>
6451
<Color x:Key="ToolWindowText">#F1F1F1</Color>
@@ -106,18 +93,5 @@
10693
<SolidColorBrush x:Key="TextBoxTextDisabledBrush" Color="{DynamicResource TextBoxTextDisabled}" />
10794
<SolidColorBrush x:Key="TextBoxBorderDisabledBrush" Color="{DynamicResource TextBoxBorderDisabled}" />
10895

109-
<SolidColorBrush x:Key="WindowPanelBrush" Color="{DynamicResource WindowPanel}" />
110-
<SolidColorBrush x:Key="WindowPanelTextBrush" Color="{DynamicResource WindowPanelText}" />
111-
<SolidColorBrush x:Key="WindowBorderBrush" Color="{DynamicResource WindowBorder}" />
112-
113-
<SolidColorBrush x:Key="WindowButtonBrush" Color="{DynamicResource WindowButton}" />
114-
<SolidColorBrush x:Key="WindowButtonGlyphBrush" Color="{DynamicResource WindowButtonGlyph}" />
115-
116-
<SolidColorBrush x:Key="WindowButtonHoverBrush" Color="{DynamicResource WindowButtonHover}" />
117-
<SolidColorBrush x:Key="WindowButtonHoverGlyphBrush" Color="{DynamicResource WindowButtonHoverGlyph}" />
118-
<SolidColorBrush x:Key="WindowButtonHoverBorderBrush" Color="{DynamicResource WindowButtonHoverBorder}" />
11996

120-
<SolidColorBrush x:Key="WindowButtonDownBrush" Color="{DynamicResource WindowButtonDown}" />
121-
<SolidColorBrush x:Key="WindowButtonDownGlyphBrush" Color="{DynamicResource WindowButtonDownGlyph}" />
122-
<SolidColorBrush x:Key="WindowButtonDownBorderBrush" Color="{DynamicResource WindowButtonDownBorder}" />
12397
</ResourceDictionary>

src/windows/GitHub.UI.Windows/Dialog/GitHubDialogWindow.xaml

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/windows/GitHub.UI.Windows/Dialog/GitHubDialogWindow.xaml.cs

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/windows/GitHub.UI.Windows/Login/Login2FaView.xaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:controls="clr-namespace:GitHub.UI.Controls"
55
xmlns:octicons="clr-namespace:GitHub.UI.Octicons"
6-
Style="{DynamicResource DialogUserControl}"
7-
Background="{DynamicResource WindowPanelBrush}"
8-
Foreground="{DynamicResource WindowPanelTextBrush}">
6+
Style="{DynamicResource DialogUserControl}">
97

108
<Control.Resources>
119
<ResourceDictionary>
@@ -18,10 +16,10 @@
1816
<StackPanel Style="{DynamicResource DialogContainerStackPanel}">
1917
<octicons:OcticonImage Icon="logo_github" Style="{DynamicResource GitHubLogo}" />
2018
<WrapPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="0,0,0,12">
21-
<TextBlock Text="Two-factor authentication"
22-
Padding="0"
19+
<TextBlock Text="Two-factor authentication"
20+
Padding="0"
2321
Margin="0,0,12,0"
24-
Style="{DynamicResource GitHubH1TextBlock}"
22+
Style="{DynamicResource GitHubH1TextBlock}"
2523
x:Uid="titleBlock"/>
2624
</WrapPanel>
2725

src/windows/GitHub.UI.Windows/Login/Login2FaViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Windows.Input;
22
using Microsoft.Git.CredentialManager;
33
using Microsoft.Git.CredentialManager.UI;
4+
using Microsoft.Git.CredentialManager.UI.ViewModels;
45

56
namespace GitHub.UI.Login
67
{

src/windows/GitHub.UI.Windows/Login/LoginCredentialsView.xaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
xmlns:sharedControls="clr-namespace:Microsoft.Git.CredentialManager.UI.Controls;assembly=Microsoft.Git.CredentialManager.UI"
88
xmlns:sharedConverters="clr-namespace:Microsoft.Git.CredentialManager.UI.Converters;assembly=Microsoft.Git.CredentialManager.UI"
99
xmlns:octicons="clr-namespace:GitHub.UI.Octicons"
10-
Background="{DynamicResource WindowPanelBrush}"
11-
Foreground="{DynamicResource WindowPanelTextBrush}"
1210
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
1311
mc:Ignorable="d"
1412
d:DesignWidth="414"

src/windows/GitHub.UI.Windows/Login/LoginCredentialsViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.ComponentModel;
22
using System.Security;
33
using Microsoft.Git.CredentialManager.UI;
4+
using Microsoft.Git.CredentialManager.UI.ViewModels;
45

56
namespace GitHub.UI.Login
67
{

src/windows/GitHub.UI.Windows/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static void Main(string[] args)
1919
// Show test UI when given no arguments
2020
if (args.Length == 0)
2121
{
22-
gui.ShowDialogWindow(() => new Tester());
22+
gui.ShowWindow(() => new Tester());
2323
}
2424
else
2525
{

src/windows/GitHub.UI.Windows/Styles.xaml

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -179,44 +179,6 @@
179179
</Style.Triggers>
180180
</Style>
181181

182-
<Style x:Key="WindowCloseButton" TargetType="{x:Type Button}">
183-
<Setter x:Uid="Setter_1" Property="FocusVisualStyle" Value="{x:Null}"/>
184-
<Setter x:Uid="Setter_2" Property="Background" Value="{DynamicResource WindowButtonBrush}"/>
185-
<Setter x:Uid="Setter_3" Property="Foreground" Value="{DynamicResource WindowButtonGlyphBrush}"/>
186-
<Setter x:Uid="Setter_4" Property="BorderBrush" Value="Transparent"/>
187-
<Setter x:Uid="Setter_5" Property="BorderThickness" Value="0"/>
188-
<Setter x:Uid="Setter_6" Property="HorizontalContentAlignment" Value="Center"/>
189-
<Setter x:Uid="Setter_7" Property="VerticalContentAlignment" Value="Center"/>
190-
<Setter x:Uid="Setter_8" Property="Width" Value="46" />
191-
<Setter x:Uid="Setter_9" Property="Height" Value="33" />
192-
<Style.Triggers>
193-
<Trigger x:Uid="Trigger_3" Property="IsDefaulted" Value="true">
194-
<Setter x:Uid="Setter_18" Property="Background" Value="{DynamicResource WindowButtonBrush}"/>
195-
<Setter x:Uid="Setter_19" Property="Foreground" Value="{DynamicResource WindowButtonGlyphBrush}"/>
196-
</Trigger>
197-
<Trigger x:Uid="Trigger_1" Property="IsKeyboardFocused" Value="true">
198-
<Setter x:Uid="Setter_12" Property="Background" Value="{DynamicResource WindowButtonHoverBrush}"/>
199-
<Setter x:Uid="Setter_13" Property="Foreground" Value="{DynamicResource WindowButtonHoverGlyphBrush}"/>
200-
<Setter x:Uid="Setter_14" Property="BorderBrush" Value="{DynamicResource WindowButtonHoverBorderBrush}"/>
201-
</Trigger>
202-
<Trigger x:Uid="Trigger_2" Property="IsMouseOver" Value="true">
203-
<Setter x:Uid="Setter_15" Property="Background" Value="{DynamicResource WindowButtonHoverBrush}"/>
204-
<Setter x:Uid="Setter_16" Property="Foreground" Value="{DynamicResource WindowButtonHoverGlyphBrush}"/>
205-
<Setter x:Uid="Setter_17" Property="BorderBrush" Value="{DynamicResource WindowButtonHoverBorderBrush}"/>
206-
</Trigger>
207-
<Trigger x:Uid="Trigger_4" Property="IsPressed" Value="true">
208-
<Setter x:Uid="Setter_21" Property="Background" Value="{DynamicResource WindowButtonDownBrush}"/>
209-
<Setter x:Uid="Setter_22" Property="Foreground" Value="{DynamicResource WindowButtonDownGlyphBrush}"/>
210-
<Setter x:Uid="Setter_23" Property="BorderBrush" Value="{DynamicResource WindowButtonDownBorderBrush}"/>
211-
</Trigger>
212-
<Trigger x:Uid="Trigger_5" Property="IsFocused" Value="true">
213-
<Setter x:Uid="Setter_10" Property="Background" Value="{DynamicResource WindowButtonHoverBrush}"/>
214-
<Setter x:Uid="Setter_11" Property="Foreground" Value="{DynamicResource WindowButtonHoverGlyphBrush}"/>
215-
<Setter x:Uid="Setter_12" Property="BorderBrush" Value="{DynamicResource WindowButtonHoverBorderBrush}"/>
216-
</Trigger>
217-
</Style.Triggers>
218-
</Style>
219-
220182
<Style TargetType="{x:Type sharedControls:PromptTextBox}" BasedOn="{StaticResource GitHubVsPromptTextBox}" />
221183
<Style TargetType="{x:Type sharedControls:SecurePasswordBox}" BasedOn="{StaticResource GitHubVsPromptTextBox}" />
222184
<Style TargetType="{x:Type TextBlock}" x:Key="GitHubDescriptionTextBlock">
@@ -228,7 +190,4 @@
228190
<Setter Property="FontWeight" Value="Thin" />
229191
</Style>
230192
<Style TargetType="{x:Type Label}" />
231-
<Style TargetType="UserControl" x:Key="DialogUserControl">
232-
<Setter Property="Margin" Value="30,30,30,0" />
233-
</Style>
234193
</ResourceDictionary>

0 commit comments

Comments
 (0)