using AutoCat.Utils; using AutoCat.ViewModel; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; using Windows.Foundation.Collections; using Windows.UI.Popups; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 namespace AutoCat.Pages { /// /// An empty page that can be used on its own or navigated to within a Frame. /// public sealed partial class AuthPage : Page { public AuthViewModel viewModel = new AuthViewModel(new DialogService()); public AuthPage() { this.InitializeComponent(); } private async void Login_Click(object sender, RoutedEventArgs e) { try { Progress.Visibility = Visibility.Visible; Progress.IsActive = true; Login.IsEnabled = false; await viewModel.Login(Email.Text, Password.Password); Frame.Navigate(typeof(MainPage)); Frame.BackStack.Clear(); } finally { Progress.Visibility = Visibility.Collapsed; Progress.IsActive = false; Login.IsEnabled = true; } } private void Page_Loaded(object sender, RoutedEventArgs e) { if(viewModel.isLoggedIn) { Frame.Navigate(typeof(MainPage)); Frame.BackStack.Clear(); } } } }