private async void ClickRegistrar() { if (BlockRegister) { return; } BlockRegister = true; Application.Current.MainPage.Unfocus(); var userService = new Services.UserService(); var toastService = new Services.ToastService(); var result = await userService.RegisterUser(Username.Trim(), Email.Trim(), Password.Trim()); if (result != UsuarioResultEnum.Ok) { BlockRegister = false; toastService.SendToast(result.GetText()); } else { toastService.SendToast(Resx.AppResources.RegisterOkMsg); await Task.Delay(2000); var navigationService = new Services.NavigationService(); navigationService.GoBack(); } }
private async void DoLogin() { if (BlockLogin) { return; } BlockLogin = true; Application.Current.MainPage.Unfocus(); var userService = new Services.UserService(); var toastService = new Services.ToastService(); var result = await userService.TryLogin(Username.Trim(), Password.Trim()); if (result.Item1 != UsuarioResultEnum.Ok) { toastService.SendToast(result.Item1.GetText()); } else { var resultStore = await userService.SaveUserLoginDataAsync(Username.Trim(), Password.Trim()); if (!resultStore) { toastService.SendToast(Resx.AppResources.NoAutologinSupport); } userService.SaveActiveUserId(result.Item2.Id); var navigationService = new Services.NavigationService(); navigationService.GoToHome(); } BlockLogin = false; }
public LoginViewModel(IFirebaseAuthenticator firebaseAuthenticator, Services.NavigationService navigationService) { this.firebaseAuthenticator = firebaseAuthenticator; this.navigationService = navigationService; LoginCmd = new Command(async() => await Login()); }
public GameInfoViewModel() { FavIcon = "fav_status_off.png"; Initialized = false; QRCommand = new Command(execute: () => { var navigationService = new Services.NavigationService(); navigationService.GoToQR(Juego); }); ToggleFavoriteCommand = new Command(execute: () => { if (!Initialized) { return; } var userService = new Services.UserService(); if (FavIcon == "fav_status_on.png") { FavIcon = "fav_status_off.png"; userService.RemoveFavorite(JuegoId); } else { FavIcon = "fav_status_on.png"; userService.AddFavorite(Juego); } }); }
public PlatformInfoViewModel() { GoPlatformCommand = new Command(execute: () => { var navigationService = new Services.NavigationService(); navigationService.GoToPlatformGames(Platform); }); }
private INavigationService CreateNavigationService() { var navigationService = new Services.NavigationService(); navigationService.Configure(NavigationKeys.Home, typeof(MainPage)); navigationService.Configure(NavigationKeys.Discover, typeof(DiscoverPage)); return navigationService; }
public LoginPageViewModel() { LoginCommand = new Command(execute: DoLogin, canExecute: UpdateRegisterButton); RegisterCommand = new Command(execute: () => { var navigationService = new Services.NavigationService(); navigationService.GoToRegister(); }); }
private async void NavegationNotification(string param) { string[] paramPush = param.Split(';'); Preferences.Set("pushParam", string.Empty); try { if (paramPush.Length > 2) { string valorNav = paramPush.GetValue(1).ToString(); object val = paramPush.GetValue(2).ToString(); Services.NavigationService nav = new Services.NavigationService(); switch (valorNav) { case "B": var gamesDay = new List <GameDay>(); var gameDay = new GameDay(); Services.GameDayService gameDayService = new Services.GameDayService(); gamesDay = await gameDayService.GetGameDay(null); foreach (var game in gamesDay) { if (int.Parse(val.ToString()) == game.IDCalendario) { gameDay = game as Models.GameDay; } } if (gameDay.IDCalendario > 0) { nav.Navegate("GameDetailsPage", gameDay); } break; case "N": nav.Navegate("NewsPage"); break; case "E": nav.Navegate("LeadersPage"); break; case "C": nav.Navegate("SchedulePage"); break; default: break; } } } catch { } }
private static INavigationService CreateNavigationService() { var navigationService = new Services.NavigationService(); navigationService.Configure(MasterViewKey, typeof(MasterView)); navigationService.Configure(DetailViewKey, typeof(DetailView)); navigationService.Configure(AboutViewKey, typeof(AboutView)); navigationService.Configure(CommentViewKey, typeof(CommentView)); navigationService.Configure(NoDetailViewKey, typeof(NoDetailView)); return(navigationService); }
public void GoToGame() { if (SelectedGame == null) { return; } var navigationService = new Services.NavigationService(); navigationService.GoToGame(SelectedGame.Id); SelectedGame = null; }
void ItemSelected() { if (SelectedItem == null) { return; } var navigationService = new Services.NavigationService(); navigationService.GoToPlatform(SelectedItem.Id); SelectedItem = null; }
private void Initialize() { // Page navigation var navigationService = new Services.NavigationService(); navigationService.Configure(Pages.MainPage.ToString(), typeof(MainActivity)); this.Locator = new ViewModelLocator(); Locator.Initialize(navigationService); // MVVM Light's DispatcherHelper for cross-thread handling. DispatcherHelper.Initialize(); }
public FavoritePageViewModel() { SelectionChangedCommand = new Command <CollectionView>(execute: (CollectionView collectionView) => { if (collectionView.SelectedItem == null) { return; } var navigationService = new Services.NavigationService(); navigationService.GoToGame(((Models.JuegoFav)collectionView.SelectedItem).Id); collectionView.SelectedItem = null; }); }
public SecondPage() { this.InitializeComponent(); navigationService = ((ApiInformationDemo.App)App.Current).NavigationService; if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) { Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed; } else { backButton.Click += BackButton_Click; } }
public SecondPage() { this.InitializeComponent(); navigationService = ((ApiInformationDemo.App)App.Current).NavigationService; if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) { Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed; } else { backButton.Click += BackButton_Click; } }
public ViewModelLocator() { ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); SimpleIoc.Default.Register<IDialogService, DialogService>(); _navigationService = new Services.NavigationService(); InitNavigation(); SimpleIoc.Default.Register<INavigationService>(() => _navigationService); SimpleIoc.Default.Register<SettingsService>(); SimpleIoc.Default.Register<NotificationsService>(); SimpleIoc.Default.Register<HangoutsService>(); SimpleIoc.Default.Register<MainViewModel>(); SimpleIoc.Default.Register<LoginViewModel>(); }
private async void TryAutoLogin() { var navService = new Services.NavigationService(); var userService = new Services.UserService(); var autoLoginOk = await userService.TryAutoLogin(); if (autoLoginOk) { await Task.Delay(1000); navService.GoToHome(); return; } await Task.Delay(1000); navService.GoToLogin(); }
public SettingsPageViewModel() { LogoutCommand = new Command(execute: async() => { var confirm = await Application.Current.MainPage.DisplayAlert(Resx.AppResources.Logout, Resx.AppResources.LogoutConfirm, Resx.AppResources.Yes, Resx.AppResources.Cancel); if (confirm) { var userService = new Services.UserService(); var navigationService = new Services.NavigationService(); userService.DoLogout(); navigationService.GoToLogin(); } }); ChangePasswordCommand = new Command(execute: () => { var navigationService = new Services.NavigationService(); navigationService.GoToChangePasswordPage(); }); LoadUserData(); }
public async void ChangePassword() { var confirm = await Application.Current.MainPage.DisplayAlert(Resx.AppResources.ChangePasswordTitle, Resx.AppResources.ChangePasswordWarning, Resx.AppResources.Yes, Resx.AppResources.Cancel); if (confirm) { var userService = new Services.UserService(); var result = await userService.ChangePassword(OldPassword.Trim(), NewPassword.Trim()); if (result != UsuarioResultEnum.Ok) { var toastService = new Services.ToastService(); toastService.SendToast(result.GetText()); } else { var navigationService = new Services.NavigationService(); userService.DoLogout(); navigationService.GoToLogin(); } } }
public StartPageViewModel() { BarScannerVisible = false; PickerData = Enum.GetValues(typeof(JuegoOrderEnum)) .Cast <JuegoOrderEnum>().Select(v => v.GetStringValue()).ToList(); SelectionChangedCommand = new Command <CollectionView>(execute: (CollectionView collectionView) => { if (collectionView.SelectedItem == null) { return; } var navigationService = new Services.NavigationService(); navigationService.GoToGame(((Models.Juego)collectionView.SelectedItem).Id); collectionView.SelectedItem = null; }); RefreshCommand = new Command(execute: async() => { IsRefreshing = true; await LoadData(false); IsRefreshing = false; }); ThresholdReachedCommand = new Command(execute: async() => { if (LoadedElementCount >= MaxLoadedElements || IsLoadingMoreData) { return; } IsLoadingMoreData = true; await LoadData(true); IsLoadingMoreData = false; }); QRCommand = new Command(execute: () => { BarScannerVisible = !BarScannerVisible; }); ScanResultCommand = new Command <ZXing.Result>(execute: (ZXing.Result result) => { if (result.Text == null || !BarScannerVisible) { return; } var qrMode = JsonConvert.DeserializeObject <Models.QR>(result.Text); if (qrMode == null) { return; } BarScannerVisible = false; Device.InvokeOnMainThreadAsync(() => { var navigationService = new Services.NavigationService(); navigationService.GoToGame(qrMode.Id); }); }); }