Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit b3c3ec5

Browse files
committed
Use setters instead of virtual properties
1 parent ade0bae commit b3c3ec5

File tree

4 files changed

+21
-39
lines changed

4 files changed

+21
-39
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationView.cs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ namespace GitHub.Unity
77
[Serializable]
88
class AuthenticationView : Subview
99
{
10-
private static readonly Vector2 PublishViewSize = new Vector2(290, 290);
11-
12-
const string WindowTitle = "Authenticate";
13-
const string UsernameLabel = "Username";
14-
const string PasswordLabel = "Password";
15-
const string TwofaLabel = "2FA Code";
16-
const string LoginButton = "Sign in";
17-
const string BackButton = "Back";
18-
const string AuthTitle = "Sign in to GitHub";
19-
const string TwofaTitle = "Two-Factor Authentication";
20-
const string TwofaDescription = "Open the two-factor authentication app on your device to view your 2FA code and verify your identity.";
21-
const string TwofaButton = "Verify";
10+
private static readonly Vector2 viewSize = new Vector2(290, 290);
11+
12+
private const string WindowTitle = "Authenticate";
13+
private const string UsernameLabel = "Username";
14+
private const string PasswordLabel = "Password";
15+
private const string TwofaLabel = "2FA Code";
16+
private const string LoginButton = "Sign in";
17+
private const string BackButton = "Back";
18+
private const string AuthTitle = "Sign in to GitHub";
19+
private const string TwofaTitle = "Two-Factor Authentication";
20+
private const string TwofaDescription = "Open the two-factor authentication app on your device to view your 2FA code and verify your identity.";
21+
private const string TwofaButton = "Verify";
2222

2323
[SerializeField] private Vector2 scroll;
2424
[SerializeField] private string username = "";
@@ -62,6 +62,8 @@ public override void InitializeView(IView parent)
6262
{
6363
base.InitializeView(parent);
6464
need2fa = busy = false;
65+
Title = WindowTitle;
66+
Size = viewSize;
6567
}
6668

6769
public override void OnEnable()
@@ -246,15 +248,5 @@ private void ShowErrorMessage()
246248
GUILayout.Label(errorMessage, Styles.ErrorLabel);
247249
}
248250
}
249-
250-
public override string Title
251-
{
252-
get { return WindowTitle; }
253-
}
254-
255-
public override Vector2 Size
256-
{
257-
get { return PublishViewSize; }
258-
}
259251
}
260252
}

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BaseWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public virtual void OnDestroy()
124124
public virtual void OnSelectionChange()
125125
{}
126126

127-
public virtual Rect Position { get { return position; } }
127+
public Rect Position { get { return position; } }
128128
public IApplicationManager Manager { get; private set; }
129129
public IRepository Repository { get { return inLayout ? cachedRepository : Environment.Repository; } }
130130
public bool HasRepository { get { return Environment.RepositoryPath != null; } }

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace GitHub.Unity
88
{
99
class PublishView : Subview
1010
{
11-
private static readonly Vector2 PublishViewSize = new Vector2(300, 250);
11+
private static readonly Vector2 viewSize = new Vector2(300, 250);
1212

1313
private const string WindowTitle = "Publish";
1414
private const string Header = "Publish this repository to GitHub";
@@ -54,6 +54,8 @@ public IApiClient Client
5454
public override void InitializeView(IView parent)
5555
{
5656
base.InitializeView(parent);
57+
Title = WindowTitle;
58+
Size = viewSize;
5759
PopulateView();
5860
}
5961

@@ -236,15 +238,5 @@ public override void OnGUI()
236238
GUILayout.EndHorizontal();
237239
GUILayout.Space(10);
238240
}
239-
240-
public override string Title
241-
{
242-
get { return WindowTitle; }
243-
}
244-
245-
public override Vector2 Size
246-
{
247-
get { return PublishViewSize; }
248-
}
249241
}
250242
}

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/Subview.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ public virtual void Finish(bool result)
5353
public virtual void OnRepositoryChanged(IRepository oldRepository)
5454
{}
5555

56-
public virtual string Title { get { return null; } }
57-
58-
public virtual Vector2 Size { get { return Vector2.zero; } }
59-
6056
protected IView Parent { get; private set; }
6157
public IApplicationManager Manager { get { return Parent.Manager; } }
6258
public IRepository Repository { get { return Parent.Repository; } }
@@ -66,7 +62,9 @@ public virtual void OnRepositoryChanged(IRepository oldRepository)
6662
protected IGitClient GitClient { get { return Manager.GitClient; } }
6763
protected IEnvironment Environment { get { return Manager.Environment; } }
6864
protected IPlatform Platform { get { return Manager.Platform; } }
69-
public virtual Rect Position { get { return Parent.Position; } }
65+
public Rect Position { get { return Parent.Position; } }
66+
public string Title { get; protected set; }
67+
public Vector2 Size { get; protected set; }
7068

7169
private ILogging logger;
7270
protected ILogging Logger

0 commit comments

Comments
 (0)