public App () { ApplicationResources.SetApplicationResources (); if (App.WorkoutCreatorContext.StaffMember == null || App.WorkoutCreatorContext.StaffMember.GymID == 0) { Task.Run (async() => { App.WorkoutCreatorContext.StaffMember = await StaffMemberDAL.GetLoggedInUser (); }).Wait (); } if (App.WorkoutCreatorContext.StaffMember != null && App.WorkoutCreatorContext.StaffMember.GymID != 0) { NavigationPage navigationPage = new MyNavigationPage (new CoachMainPage ()); //navigationPage.BarTextColor = Color.White; this.MainPage = navigationPage; } else { this.MainPage = new LoginPage (); } }
private async void ExecuteLoginCommand () { if (IsProcessing) return; IsProcessing = true; if (string.IsNullOrEmpty (Username)) { DependencyService.Get<ICustomDialog> ().Display (StringConstants._UsernameRequiredPrompt, "OK"); } else { if (string.IsNullOrEmpty (Password)) { IsProcessing = false; DependencyService.Get<ICustomDialog> ().Display (StringConstants._PasswordRequiredPrompt, "OK"); } else { String loginResponse = await Login (Username, Password); if (!string.IsNullOrEmpty (loginResponse) || loginResponse == StringConstants._ConnectivityFailedValidationPrompt || loginResponse == StringConstants._AuthenticationFailedValidationPrompt) { if (loginResponse == StringConstants._ConnectivityFailedValidationPrompt) { DependencyService.Get<ICustomDialog> ().Display (StringConstants._ConnectivityFailedValidationPrompt, "OK"); } else { if (loginResponse == StringConstants._AuthenticationFailedValidationPrompt) { DependencyService.Get<ICustomDialog> ().Display (StringConstants._AuthenticationFailedValidationPrompt, "OK"); } else { DependencyService.Get<ICustomDialog> ().Display (StringConstants._AuthenticationFailedValidationPrompt, "OK"); } } } else { Username = ""; Password = ""; Task task = SetLogginInUserContext (); Action<Task> action = (actionResult) => Device.BeginInvokeOnMainThread (() => { if (App.WorkoutCreatorContext.StaffMember != null && App.WorkoutCreatorContext.StaffMember.GymID != 0) { Task backgroundSyncTask = DataSyncManager.Instance.RunInitialLoad (App.WorkoutCreatorContext.StaffMember.GymID); MyNavigationPage navigationPage = new MyNavigationPage (new CoachMainPage (backgroundSyncTask)); //navigationPage.BarTextColor = Color.Gray; Application.Current.MainPage = navigationPage; } }); await task.ContinueWith (action); } IsProcessing = false; } } IsProcessing = false; }
public PrimaryOptionsPage(Task taskResponder = null) { this.Title = "MobileFiT Coach"; _viewModel = new SimplePrimaryOptions (Manager.Instance.StaffMember, App.WorkoutCreatorContext); this.HasBackButton = false; ToolbarItem logoutItem = new ToolbarItem { Text = "Logout", Order = ToolbarItemOrder.Primary }; logoutItem.Clicked += async (sender, args) => { bool confirm = await this.DisplayAlert("Logout user", "Are you sure you want to logout?", "Yes", "No"); if (confirm) { //Call Methods to logout user await _viewModel.Logout(); MyNavigationPage navigationPage = new MyNavigationPage (new LoginPageXaml ()); navigationPage.BarBackgroundColor = Color.FromRgb (135, 206, 250); navigationPage.BarTextColor = Color.White; Application.Current.MainPage = navigationPage; } }; this.ToolbarItems.Add(logoutItem); Image logoImage = new Image { Source = ImageSource.FromResource("WorkoutCreator.Images.mainpagelogo.png"), HeightRequest = 167, WidthRequest = 225 }; ActivityIndicator activityIndicator = new ActivityIndicator { Color = Color.Red, IsRunning = false }; Button createTemplateButton = new Button { Text = "Create Template", FontSize = 40, WidthRequest = 400, HeightRequest = 55 }; Button assignTemplateButton = new Button { Text = "Assign Template", FontSize = 40, WidthRequest = 400, HeightRequest = 55, }; Button viewMemberTemplateButton = new Button { Text = "Member Templates", FontSize = 40, WidthRequest = 400, HeightRequest = 55, }; if (taskResponder != null) { createTemplateButton.IsEnabled = false; assignTemplateButton.IsEnabled = false; viewMemberTemplateButton.IsEnabled = false; activityIndicator.IsRunning = true; Action<Task> action = (str) => Device.BeginInvokeOnMainThread ( () => { createTemplateButton.IsEnabled = true; assignTemplateButton.IsEnabled = true; viewMemberTemplateButton.IsEnabled = true; activityIndicator.IsRunning = false; }); taskResponder.ContinueWith(action); } createTemplateButton.Clicked += async (sender2, args2) => await Navigation.PushAsync (new ExerciseContainerPage ()); assignTemplateButton.Clicked += async (sender2, args2) => await Navigation.PushAsync (new TemplateListPage ()); viewMemberTemplateButton.Clicked += async (sender2, args2) => await Navigation.PushAsync (new MemberTemplateListPage ()); StackLayout buttonStack = new StackLayout { Children = { activityIndicator, createTemplateButton, assignTemplateButton, viewMemberTemplateButton }, Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, Spacing = 50, Padding = new Thickness(20) }; StackLayout modalStack = new StackLayout { Children = { logoImage, buttonStack }, Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, Spacing = 50 }; this.BackgroundColor = Color.FromRgb(135, 206, 250); this.Content = modalStack; }