Beispiel #1
0
 private async void DownloadDataButton_Clicked(object sender, EventArgs e)
 {
     UserDialogs.Instance.ShowLoading("Downloading Data...");
     await Task.Run(async() =>
     {
         bool success = await Kucha.RefreshLocalData();
         Device.BeginInvokeOnMainThread(() =>
         {
             UserDialogs.Instance.HideLoading();
             if (success)
             {
                 UserDialogs.Instance.Toast("Data successfully downloaded!");
                 downloadDataButton.IsEnabled = false;
                 downloadStatusLabel.Text     = "Data from " + Kucha.GetDataTimeStamp().ToShortDateString();
                 if (!loginButton.IsEnabled)
                 {
                     continueButton.IsEnabled = true;
                 }
             }
             else
             {
                 UserDialogs.Instance.Toast("Data download failed. Please check your connectivity.");
             }
         });
     });
 }
Beispiel #2
0
 private async void UpdateLocalDatabaseButton_Clicked(object sender, EventArgs e)
 {
     UserDialogs.Instance.ShowLoading("Downloading Data...");
     await Task.Run(async() =>
     {
         bool success = await Kucha.RefreshLocalData();
         Device.BeginInvokeOnMainThread(() =>
         {
             UserDialogs.Instance.HideLoading();
             if (success)
             {
                 UserDialogs.Instance.Toast("Download successful!");
                 downloadStatusLabel.Text = "Data from " + Kucha.GetDataTimeStamp().ToShortDateString();
             }
             else
             {
                 UserDialogs.Instance.Toast("Download failed. Please check connectivity.");
             }
         });
     });
 }
Beispiel #3
0
        public SettingsUI()
        {
            Title = "Settings";
            StackLayout contentStack = new StackLayout
            {
                Padding = 16
            };

            Grid  previewPicGrid  = new Grid();
            Label previewPicLabel = new Label
            {
                Text = "Enable Preview Images in Painted Representations"
            };
            Switch previewPicSwitch = new Switch
            {
                IsToggled = Settings.ShowPreviewPicturesSetting
            };

            previewPicSwitch.Toggled += PreviewPicSwitch_Toggled;
            previewPicGrid.Children.Add(previewPicLabel, 0, 0);
            previewPicGrid.Children.Add(previewPicSwitch, 1, 0);
            previewPicGrid.HorizontalOptions = LayoutOptions.CenterAndExpand;
            contentStack.Children.Add(previewPicGrid);

            if (Connection.IsInOfflineMode())
            {
                Button showLoginScreenButton = new Button
                {
                    Text = "Go to Login Screen"
                };
                showLoginScreenButton.Clicked += ShowLoginScreenButton_Clicked;
                contentStack.Children.Add(showLoginScreenButton);
            }

            downloadStatusLabel = new Label
            {
                Text = "Data from " + Kucha.GetDataTimeStamp().ToShortDateString()
            };
            contentStack.Children.Add(downloadStatusLabel);

            Button updateLocalDatabaseButton = new Button
            {
                Text = "Update Database"
            };

            updateLocalDatabaseButton.Clicked += UpdateLocalDatabaseButton_Clicked;
            contentStack.Children.Add(updateLocalDatabaseButton);

            Button clearAllNotesButton = new Button
            {
                Text = "Clear private notes"
            };

            clearAllNotesButton.Clicked += ClearAllNotesButton_Clicked;
            contentStack.Children.Add(clearAllNotesButton);

            Button deleteLocalFilesButton = new Button
            {
                Text = "Delete all local files"
            };

            deleteLocalFilesButton.Clicked += DeleteLocalFilesButton_Clicked;
            contentStack.Children.Add(deleteLocalFilesButton);

            Label licenseLabel = new Label
            {
                TextColor = Color.LightGray,
                Text      = "Icon licenses\n\ncave by Alexander Skowalsky from the Noun Project\nImage by Viktor Vorobyev from the Noun Project\ncog by Vicons Design from the Noun Project\n\nAll icons issued under Creative Commons license.",
                Margin    = new Thickness(0, 50, 0, 0)
            };

            contentStack.Children.Add(licenseLabel);
            Content = contentStack;
        }
Beispiel #4
0
        public LoginPage()
        {
            StackLayout contentStack = new StackLayout
            {
                Padding = 16
            };
            Image huLogo = new Image
            {
                Source        = "SAW_logo.png",
                HeightRequest = 100,
                Aspect        = Aspect.AspectFit
            };

            contentStack.Children.Add(huLogo);
            nameEntry = new Entry
            {
                Placeholder = "Username"
            };
            if (Connection.HasLegitSessionID())
            {
                nameEntry.IsEnabled = false;
            }
            contentStack.Children.Add(nameEntry);

            passwordEntry = new Entry
            {
                Placeholder = "Password",
                IsPassword  = true
            };
            if (Connection.HasLegitSessionID())
            {
                passwordEntry.IsEnabled = false;
            }
            contentStack.Children.Add(passwordEntry);

            loginstatusLabel = new Label
            {
                Margin = new Thickness(0, 10, 0, 0)
            };
            loginstatusLabel.TranslationY += 10;
            if (Connection.HasLegitSessionID())
            {
                loginstatusLabel.Text = "Logged in with valid session";
            }
            else
            {
                loginstatusLabel.Text = "Please log in";
            }
            contentStack.Children.Add(loginstatusLabel);

            loginButton          = new Button();
            loginButton.Clicked += LoginButton_Clicked;

            if (Connection.HasLegitSessionID())
            {
                loginButton.IsEnabled = false;
            }
            loginButton.Text = "Login";
            contentStack.Children.Add(loginButton);

            downloadStatusLabel = new Label
            {
                Margin = new Thickness(0, 10, 0, 0)
            };
            downloadStatusLabel.TranslationY += 10;
            if (!Kucha.KuchaContainerIsValid())
            {
                downloadStatusLabel.Text = "Please download initial data";
            }
            else
            {
                downloadStatusLabel.Text = "Data from " + Kucha.GetDataTimeStamp().ToShortDateString();
            }
            contentStack.Children.Add(downloadStatusLabel);

            downloadDataButton          = new Button();
            downloadDataButton.Clicked += DownloadDataButton_Clicked;
            downloadDataButton.Text     = "Download Data";
            if (!Connection.HasLegitSessionID())
            {
                downloadDataButton.IsEnabled = false;
            }
            contentStack.Children.Add(downloadDataButton);

            continueButton = new Button
            {
                Margin          = new Thickness(0, 10, 0, 0),
                Text            = "Continue",
                BackgroundColor = Color.Accent,
                TextColor       = Color.White
            };
            continueButton.Clicked += ContinueButton_Clicked;
            if (!Connection.HasLegitSessionID() || !Kucha.KuchaContainerIsValid())
            {
                continueButton.IsEnabled = false;
            }
            contentStack.Children.Add(continueButton);

            Content = new ScrollView {
                Content = contentStack
            };
        }