Przeglądaj źródła

Make SpinnerView show/hide instead of stopping

Thomas 2 lat temu
rodzic
commit
30f830e22d
1 zmienionych plików z 15 dodań i 2 usunięć
  1. 15 2
      UICatalog/Scenarios/Progress.cs

+ 15 - 2
UICatalog/Scenarios/Progress.cs

@@ -79,7 +79,7 @@ namespace UICatalog.Scenarios {
 				ActivityProgressBar = new ProgressBar () {
 					X = Pos.Right (LeftFrame) + 1,
 					Y = Pos.Bottom (startButton) + 1,
-					Width = Dim.Fill (1),
+					Width = Dim.Fill (),
 					Height = 1,
 					Fraction = 0.25F,
 					ColorScheme = Colors.Error
@@ -88,7 +88,9 @@ namespace UICatalog.Scenarios {
 
 				Spinner = new SpinnerView {
 					X = Pos.Right (ActivityProgressBar),
-					Y = ActivityProgressBar.Y
+					Y = ActivityProgressBar.Y,
+					Visible = false,
+
 				};
 				Add (Spinner);
 
@@ -117,12 +119,23 @@ namespace UICatalog.Scenarios {
 			{
 				Started = true;
 				StartBtnClick?.Invoke ();
+				Application.MainLoop.Invoke(()=>{
+					Spinner.Visible = true;
+					ActivityProgressBar.Width = Dim.Fill(1);
+					this.LayoutSubviews();
+				});
 			}
 
 			internal void Stop ()
 			{
 				Started = false;
 				StopBtnClick?.Invoke ();
+
+				Application.MainLoop.Invoke(()=>{
+					Spinner.Visible = false;
+					ActivityProgressBar.Width = Dim.Fill();
+					this.LayoutSubviews();
+				});
 			}
 
 			internal void Pulse ()