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

Commit 63b7c92

Browse files
committed
Add a loading view and make it so the PopupWindow always has an active view
1 parent db49ddd commit 63b7c92

File tree

3 files changed

+53
-48
lines changed

3 files changed

+53
-48
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/GitHub.Unity.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
<Compile Include="UI\ChangesView.cs" />
101101
<Compile Include="UI\HistoryView.cs" />
102102
<Compile Include="UI\IView.cs" />
103+
<Compile Include="UI\LoadingView.cs" />
103104
<Compile Include="UI\PublishView.cs" />
104105
<Compile Include="UI\SettingsView.cs" />
105106
<Compile Include="UI\Subview.cs" />
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Linq;
3+
using System.Threading.Tasks;
4+
using Octokit;
5+
using Rackspace.Threading;
6+
using UnityEditor;
7+
using UnityEngine;
8+
9+
namespace GitHub.Unity
10+
{
11+
class LoadingView : Subview
12+
{
13+
private static readonly Vector2 viewSize = new Vector2(300, 250);
14+
15+
private const string WindowTitle = "Loading...";
16+
private const string Header = "";
17+
18+
19+
public override void InitializeView(IView parent)
20+
{
21+
base.InitializeView(parent);
22+
Title = WindowTitle;
23+
Size = viewSize;
24+
}
25+
26+
public override void OnGUI()
27+
{}
28+
}
29+
}

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

Lines changed: 23 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ class PopupWindow : BaseWindow
99
{
1010
public enum PopupViewType
1111
{
12+
None,
1213
PublishView,
1314
AuthenticationView
1415
}
1516

16-
[NonSerialized] private Subview activeView;
17-
1817
[SerializeField] private PopupViewType activeViewType;
18+
1919
[SerializeField] private AuthenticationView authenticationView;
2020
[SerializeField] private PublishView publishView;
21+
[SerializeField] private LoadingView loadingView;
2122

2223
public event Action<bool> OnClose;
2324

@@ -53,50 +54,37 @@ public override void Initialize(IApplicationManager applicationManager)
5354

5455
publishView = publishView ?? new PublishView();
5556
authenticationView = authenticationView ?? new AuthenticationView();
57+
loadingView = loadingView ?? new LoadingView();
5658

5759
publishView.InitializeView(this);
5860
authenticationView.InitializeView(this);
61+
loadingView.InitializeView(this);
5962
}
6063

6164
public override void OnEnable()
6265
{
6366
base.OnEnable();
6467

65-
if (ActiveView != null)
66-
{
67-
minSize = maxSize = ActiveView.Size;
68-
ActiveView.OnEnable();
69-
}
68+
minSize = maxSize = ActiveView.Size;
69+
ActiveView.OnEnable();
7070
}
7171

7272
public override void OnDisable()
7373
{
7474
base.OnDisable();
75-
76-
if (ActiveView != null)
77-
{
78-
ActiveView.OnDisable();
79-
}
75+
ActiveView.OnDisable();
8076
}
8177

8278
public override void OnUI()
8379
{
8480
base.OnUI();
85-
86-
if (ActiveView != null)
87-
{
88-
ActiveView.OnGUI();
89-
}
81+
ActiveView.OnGUI();
9082
}
9183

9284
public override void Refresh()
9385
{
9486
base.Refresh();
95-
96-
if (ActiveView != null)
97-
{
98-
ActiveView.Refresh();
99-
}
87+
ActiveView.Refresh();
10088
}
10189

10290
public override void OnSelectionChange()
@@ -122,37 +110,24 @@ public override void OnDestroy()
122110

123111
private Subview ActiveView
124112
{
125-
get { return activeView; }
113+
get
114+
{
115+
switch (activeViewType)
116+
{
117+
case PopupViewType.PublishView:
118+
return publishView;
119+
case PopupViewType.AuthenticationView:
120+
return authenticationView;
121+
default:
122+
return loadingView;
123+
}
124+
}
126125
}
127126

128127
private PopupViewType ActiveViewType
129128
{
130129
get { return activeViewType; }
131-
set
132-
{
133-
var valueChanged = false;
134-
if (activeViewType != value)
135-
{
136-
valueChanged = true;
137-
activeViewType = value;
138-
}
139-
140-
if (activeView == null || valueChanged)
141-
{
142-
switch (activeViewType)
143-
{
144-
case PopupViewType.PublishView:
145-
activeView = publishView;
146-
break;
147-
148-
case PopupViewType.AuthenticationView:
149-
activeView = authenticationView;
150-
break;
151-
152-
default: throw new ArgumentOutOfRangeException("value", value, null);
153-
}
154-
}
155-
}
130+
set { activeViewType = value; }
156131
}
157132
}
158133
}

0 commit comments

Comments
 (0)