UI/accounts: adds a loading screen during account loading
- adds faded loading pages with a spinner animation
- starts and stops the load page during account creation and loading
- resizes the loading graphics when window is resized
- adds an event handler for DPI and scale factor changes
- removes stretching from welcome page image
- clears account creation alias box after account creation clicked
Change-Id: I5046e0bc820e91c8b2f91ca223534d93ddf916f1
Tuleap: #1010
diff --git a/MainPage.xaml.cpp b/MainPage.xaml.cpp
index d6b4bb9..5e30336 100644
--- a/MainPage.xaml.cpp
+++ b/MainPage.xaml.cpp
@@ -51,6 +51,8 @@
{
InitializeComponent();
+ Window::Current->SizeChanged += ref new WindowSizeChangedEventHandler(this, &MainPage::OnResize);
+
_welcomeFrame_->Navigate(TypeName(RingClientUWP::Views::WelcomePage::typeid));
_smartPanel_->Navigate(TypeName(RingClientUWP::Views::SmartPanel::typeid));
_consolePanel_->Navigate(TypeName(RingClientUWP::Views::RingConsolePanel::typeid));
@@ -64,6 +66,10 @@
ContactsViewModel::instance->noContactSelected += ref new NoContactSelected([&]() {
showFrame(_welcomeFrame_);
});
+
+ DisplayInformation^ displayInformation = DisplayInformation::GetForCurrentView();
+ dpiChangedtoken = (displayInformation->DpiChanged += ref new TypedEventHandler<DisplayInformation^,
+ Platform::Object^>(this, &MainPage::DisplayProperties_DpiChanged));
}
void
@@ -109,4 +115,91 @@
RingClientUWP::MainPage::OnNavigatedTo(NavigationEventArgs ^ e)
{
RingD::instance->startDaemon();
+ showLoadingOverlay(true, false);
+}
+
+void
+RingClientUWP::MainPage::showLoadingOverlay(bool load, bool modal)
+{
+ if (!isLoading && load) {
+ isLoading = true;
+ _loadingOverlay_->Visibility = Windows::UI::Xaml::Visibility::Visible;
+ if (modal) {
+ _fadeInModalStoryboard_->Begin();
+ auto blackBrush = ref new Windows::UI::Xaml::Media::SolidColorBrush(Windows::UI::Colors::Black);
+ _loadingOverlayRect_->Fill = blackBrush;
+ }
+ else {
+ auto whiteBrush = ref new Windows::UI::Xaml::Media::SolidColorBrush(Windows::UI::Colors::White);
+ _loadingOverlayRect_->Fill = whiteBrush;
+ _loadingOverlayRect_->Opacity = 1.0;
+ }
+ OnResize(nullptr, nullptr);
+ }
+ else if (!load) {
+ isLoading = false;
+ _fadeOutStoryboard_->Begin();
+ }
+}
+
+void
+RingClientUWP::MainPage::PositionImage()
+{
+ bounds = ApplicationView::GetForCurrentView()->VisibleBounds;
+
+ auto img = ref new Image();
+ auto bitmapImage = ref new Windows::UI::Xaml::Media::Imaging::BitmapImage();
+ Windows::Foundation::Uri^ uri;
+
+ if (bounds.Width < 1200)
+ uri = ref new Windows::Foundation::Uri("ms-appx:///Assets/TESTS/logo-ring.scale-200.png");
+ else
+ uri = ref new Windows::Foundation::Uri("ms-appx:///Assets/TESTS/logo-ring.scale-150.png");
+
+ bitmapImage->UriSource = uri;
+ img->Source = bitmapImage;
+ _loadingImage_->Source = img->Source;
+
+ _loadingImage_->SetValue(Canvas::LeftProperty, bounds.Width * 0.5 - _loadingImage_->Width * 0.5);
+ _loadingImage_->SetValue(Canvas::TopProperty, bounds.Height * 0.5 - _loadingImage_->Height * 0.5);
+}
+
+void
+RingClientUWP::MainPage::PositionRing()
+{
+ double left;
+ double top;
+ if (bounds.Width < 1200) {
+ _splashProgressRing_->Width = 118;
+ _splashProgressRing_->Height = 118;
+ left = bounds.Width * 0.5 - _loadingImage_->Width * 0.5 - 145;
+ top = bounds.Height * 0.5 - _loadingImage_->Height * 0.5 - 60;
+ }
+ else {
+ _splashProgressRing_->Width = 162;
+ _splashProgressRing_->Height = 162;
+ left = bounds.Width * 0.5 - _loadingImage_->Width * 0.5 - 195;
+ top = bounds.Height * 0.5 - _loadingImage_->Height * 0.5 - 84;
+ }
+ _splashProgressRing_->SetValue(Canvas::LeftProperty, left + _loadingImage_->Width * 0.5);
+ _splashProgressRing_->SetValue(Canvas::TopProperty, top + _loadingImage_->Height * 0.5);
+}
+
+void
+RingClientUWP::MainPage::OnResize(Platform::Object^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ e)
+{
+ PositionImage();
+ PositionRing();
+}
+
+void
+RingClientUWP::MainPage::DisplayProperties_DpiChanged(DisplayInformation^ sender, Platform::Object^ args)
+{
+ OnResize(nullptr, nullptr);
+}
+
+void
+RingClientUWP::MainPage::hideLoadingOverlay()
+{
+ _loadingOverlay_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
}
\ No newline at end of file