Skip to content

Commit

Permalink
changes in mechanism: one click - scan & upload
Browse files Browse the repository at this point in the history
  • Loading branch information
lswiderski committed May 9, 2022
1 parent c7d9901 commit 38da031
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/MiScaleExporter/ViewModels/FormViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ private bool ValidateSave()
&& !String.IsNullOrWhiteSpace(_password);
}

public void CheckPreferences()
public void AutoUpload()
{
if ( Preferences.Get(PreferencesKeys.OneClickScanAndUpload, false)
&& !string.IsNullOrWhiteSpace(Email)
if (!string.IsNullOrWhiteSpace(Email)
&& !string.IsNullOrWhiteSpace(Password))
{
OnUpload();
Expand All @@ -87,7 +86,7 @@ private async void OnUpload()
await Application.Current.MainPage.DisplayAlert ("Response", message, "OK");
this.IsBusy = false;
// This will pop the current page off the navigation stack
await Shell.Current.GoToAsync("..");
await Shell.Current.GoToAsync("..?autoUpload=false");
}

private BodyComposition PrepareRequest()
Expand Down
2 changes: 1 addition & 1 deletion src/MiScaleExporter/ViewModels/IFormViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ public interface IFormViewModel
{
void LoadBodyComposition();

void CheckPreferences();
void AutoUpload();
}
}
2 changes: 1 addition & 1 deletion src/MiScaleExporter/ViewModels/ScaleViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ await Application.Current.MainPage.DisplayAlert("Problem", msg,
else
{
App.BodyComposition = bc;
await Shell.Current.GoToAsync("///FormPage");
await Shell.Current.GoToAsync($"///FormPage?autoUpload={Preferences.Get(PreferencesKeys.OneClickScanAndUpload, false)}");
}
}

Expand Down
14 changes: 12 additions & 2 deletions src/MiScaleExporter/Views/FormPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace MiScaleExporter.Views
{
[QueryProperty(nameof(AutoUpload), "autoUpload")]
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class FormPage : ContentPage
{
Expand All @@ -27,9 +28,18 @@ public FormPage()
protected override async void OnAppearing()
{
base.OnAppearing();

vm.LoadBodyComposition();
vm.CheckPreferences();
}

public bool AutoUpload
{
set
{
if (value)
{
vm.AutoUpload();
}
}
}

}
Expand Down

0 comments on commit 38da031

Please sign in to comment.