From 5a6d87ff660813d6576f4ac86bc3db493d564ec8 Mon Sep 17 00:00:00 2001 From: egray Date: Wed, 24 Apr 2024 22:08:33 -0500 Subject: [PATCH 01/16] [WIP] Updating labels on profile page OnAppearing --- .../Views/Social/ProfilePage.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/FocusApp.Client/Views/Social/ProfilePage.cs b/src/FocusApp.Client/Views/Social/ProfilePage.cs index db487b6..b01de1c 100644 --- a/src/FocusApp.Client/Views/Social/ProfilePage.cs +++ b/src/FocusApp.Client/Views/Social/ProfilePage.cs @@ -416,6 +416,24 @@ private void CreateUserDataElements() private void CreateSelectedItemElements() { + // Selected item labels + _selectedPetLabel = new Label + { + Text = $"{(_authenticationService.CurrentUser?.SelectedPet?.Name == null + ? "Select a pet!" + : _authenticationService.CurrentUser?.SelectedPet?.Name)}", + FontSize = 15 + }; + + _selectedIslandLabel = new Label + { + Text = $"{(_authenticationService.CurrentUser?.SelectedIsland?.Name == null + ? "Select an island!" + : _authenticationService.CurrentUser?.SelectedIsland?.Name)}", + FontSize = 15 + }; + + // Selected item image buttons _selectedPet = new ImageButton { HeightRequest = 110, From 003d2449815b5cecaf1536dc5573b9d705747220 Mon Sep 17 00:00:00 2001 From: egray Date: Wed, 24 Apr 2024 22:25:35 -0500 Subject: [PATCH 02/16] Update user selected item label OnAppearing --- .../Views/Social/ProfilePage.cs | 74 +++++++++++-------- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/src/FocusApp.Client/Views/Social/ProfilePage.cs b/src/FocusApp.Client/Views/Social/ProfilePage.cs index b01de1c..43a3226 100644 --- a/src/FocusApp.Client/Views/Social/ProfilePage.cs +++ b/src/FocusApp.Client/Views/Social/ProfilePage.cs @@ -38,6 +38,10 @@ enum SelectedItemRow { Top, Bottom } Label _email { get; set; } // Selected user item references + Label _selectedPetLabel { get; set; } + Label _selectedIslandLabel { get; set; } + Label _selectedDecorLabel { get; set; } + Label _selectedBadgeLabel { get; set; } ImageButton _selectedPet { get; set; } ImageButton _selectedIsland { get; set; } ImageButton _selectedDecor { get; set; } @@ -139,14 +143,7 @@ public ProfilePage(IAPIClient client, IAuthenticationService authenticationServi .Column(PageColumn.Left) .Center(), - new Label - { - Text = $"{ - (_authenticationService.CurrentUser?.SelectedPet?.Name == null - ? "Select a pet!" - : _authenticationService.CurrentUser?.SelectedPet?.Name)}", - FontSize = 15 - } + _selectedPetLabel .Row(SelectedItemRow.Top) .Column(PageColumn.Left) .Top() @@ -172,14 +169,7 @@ public ProfilePage(IAPIClient client, IAuthenticationService authenticationServi .Column(PageColumn.Right) .Center(), - new Label - { - Text = $"{ - (_authenticationService.CurrentUser?.SelectedIsland?.Name == null - ? "Select an island!" - : _authenticationService.CurrentUser?.SelectedIsland?.Name)}", - FontSize = 15 - } + _selectedIslandLabel .Row(SelectedItemRow.Top) .Column(PageColumn.Right) .Top() @@ -205,14 +195,7 @@ public ProfilePage(IAPIClient client, IAuthenticationService authenticationServi .Column(PageColumn.Left) .Center(), - new Label - { - Text = $"{ - (_authenticationService.CurrentUser?.SelectedDecor?.Name == null - ? "Select decor!" - : _authenticationService.CurrentUser?.SelectedDecor?.Name)}", - FontSize = 15 - } + _selectedDecorLabel .Row(SelectedItemRow.Bottom) .Column(PageColumn.Left) .Top() @@ -237,14 +220,7 @@ public ProfilePage(IAPIClient client, IAuthenticationService authenticationServi .Column(PageColumn.Right) .Center(), - new Label - { - Text = $"{ - (_authenticationService.CurrentUser?.SelectedBadge?.Name == null - ? "Select a badge!" - : _authenticationService.CurrentUser?.SelectedBadge?.Name)}", - FontSize = 15 - } + _selectedBadgeLabel .Row(SelectedItemRow.Bottom) .Column(PageColumn.Right) .Top() @@ -371,13 +347,31 @@ protected override async void OnAppearing() // Set user selected items bindings _selectedPet.Source = byteArrayConverter.ConvertFrom(_authenticationService.SelectedPet?.Image); + _selectedPetLabel.Text = $"{(_authenticationService.SelectedPet?.Name == null + ? "Select a pet!" + : _authenticationService.SelectedPet?.Name)}"; + _selectedIsland.Source = byteArrayConverter.ConvertFrom(_authenticationService.SelectedIsland?.Image); + _selectedIslandLabel.Text = $"{(_authenticationService.SelectedIsland?.Name == null + ? "Select an island!" + : _authenticationService.SelectedIsland?.Name)}"; if (_authenticationService.SelectedDecor != null) + { _selectedDecor.Source = byteArrayConverter.ConvertFrom(_authenticationService.SelectedDecor?.Image); + _selectedDecorLabel.Text = $"{(_authenticationService.SelectedDecor?.Name == null + ? "Select decor!" + : _authenticationService.SelectedDecor?.Name)}"; + } + if (_authenticationService.SelectedBadge != null) + { _selectedBadge.Source = byteArrayConverter.ConvertFrom(_authenticationService.SelectedBadge?.Image); + _selectedBadgeLabel.Text = $"{(_authenticationService.SelectedBadge?.Name == null + ? "Select a badge!" + : _authenticationService.SelectedBadge?.Name)}"; + } } @@ -433,6 +427,22 @@ private void CreateSelectedItemElements() FontSize = 15 }; + _selectedDecorLabel = new Label + { + Text = $"{(_authenticationService.CurrentUser?.SelectedDecor?.Name == null + ? "Select decor!" + : _authenticationService.CurrentUser?.SelectedDecor?.Name)}", + FontSize = 15 + }; + + _selectedBadgeLabel = new Label + { + Text = $"{(_authenticationService.CurrentUser?.SelectedBadge?.Name == null + ? "Select a badge!" + : _authenticationService.CurrentUser?.SelectedBadge?.Name)}", + FontSize = 15 + }; + // Selected item image buttons _selectedPet = new ImageButton { From a0fe488eba61e1d9437f4928be41b856474b3e0c Mon Sep 17 00:00:00 2001 From: egray Date: Wed, 24 Apr 2024 23:00:13 -0500 Subject: [PATCH 03/16] adjust styling, link selected buttons to correct page (excluding islands) --- src/FocusApp.Client/Views/Social/ProfilePage.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/FocusApp.Client/Views/Social/ProfilePage.cs b/src/FocusApp.Client/Views/Social/ProfilePage.cs index 43a3226..f6d6054 100644 --- a/src/FocusApp.Client/Views/Social/ProfilePage.cs +++ b/src/FocusApp.Client/Views/Social/ProfilePage.cs @@ -21,7 +21,7 @@ internal class ProfilePage : BasePage FocusAppContext _localContext; // Row / Column structure for entire page - enum PageRow { UserProfilePictureHeader, SelectedItems, UserDataFooter, MembershipDate, TabBarSpace } + enum PageRow { UserProfilePictureHeader, SelectedItems, UserDataFooter, MembershipDate } enum PageColumn { Left, Right } // Row / Column structure for user data header @@ -60,11 +60,10 @@ public ProfilePage(IAPIClient client, IAuthenticationService authenticationServi Content = new Grid { RowDefinitions = Rows.Define( - (PageRow.UserProfilePictureHeader, Stars(0.75)), + (PageRow.UserProfilePictureHeader, Stars(0.8)), (PageRow.SelectedItems, Stars(2)), (PageRow.UserDataFooter, Stars(0.75)), - (PageRow.MembershipDate, Stars(0.35)), - (PageRow.TabBarSpace, Stars(0.5)) + (PageRow.MembershipDate, Stars(0.35)) ), ColumnDefinitions = Columns.Define( (PageColumn.Left, Stars(1)), @@ -510,13 +509,13 @@ private async void SelectedIslandClicked(object sender, EventArgs eventArgs) private async void SelectedDecorClicked(object sender, EventArgs eventArgs) { Shell.Current.SetTransition(Transitions.RightToLeftPlatformTransition); - await Shell.Current.GoToAsync($"///{nameof(SocialPage)}/{nameof(PetsPage)}"); + await Shell.Current.GoToAsync($"///{nameof(SocialPage)}/{nameof(DecorPage)}"); } private async void SelectedBadgeClicked(object sender, EventArgs eventArgs) { Shell.Current.SetTransition(Transitions.RightToLeftPlatformTransition); - await Shell.Current.GoToAsync($"///{nameof(SocialPage)}/{nameof(PetsPage)}"); + await Shell.Current.GoToAsync($"///{nameof(SocialPage)}/{nameof(BadgesPage)}"); } private async void BackButtonClicked(object sender, EventArgs e) From d13ddfee3f92e22a3df8a6e7b594fc6e11d8896c Mon Sep 17 00:00:00 2001 From: egray Date: Wed, 24 Apr 2024 23:03:20 -0500 Subject: [PATCH 04/16] Tweak display size for badge image on profile page --- src/FocusApp.Client/Views/Social/ProfilePage.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FocusApp.Client/Views/Social/ProfilePage.cs b/src/FocusApp.Client/Views/Social/ProfilePage.cs index f6d6054..e61f748 100644 --- a/src/FocusApp.Client/Views/Social/ProfilePage.cs +++ b/src/FocusApp.Client/Views/Social/ProfilePage.cs @@ -472,8 +472,8 @@ private void CreateSelectedItemElements() _selectedBadge = new ImageButton { - HeightRequest = 110, - WidthRequest = 110 + HeightRequest = 100, + WidthRequest = 100 } .Bind(ImageButton.SourceProperty, "Image", converter: new ByteArrayToImageSourceConverter()) .Invoke(button => button.Released += (sender, eventArgs) => From 83523ed29a4b7002a7ff38a842c3d0d53e388949 Mon Sep 17 00:00:00 2001 From: egray Date: Mon, 29 Apr 2024 21:31:53 -0500 Subject: [PATCH 05/16] Link islands page to selected island button --- src/FocusApp.Client/Views/Social/ProfilePage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FocusApp.Client/Views/Social/ProfilePage.cs b/src/FocusApp.Client/Views/Social/ProfilePage.cs index e61f748..4b5fc5b 100644 --- a/src/FocusApp.Client/Views/Social/ProfilePage.cs +++ b/src/FocusApp.Client/Views/Social/ProfilePage.cs @@ -503,7 +503,7 @@ private async void SelectedPetClicked(object sender, EventArgs eventArgs) private async void SelectedIslandClicked(object sender, EventArgs eventArgs) { Shell.Current.SetTransition(Transitions.RightToLeftPlatformTransition); - await Shell.Current.GoToAsync($"///{nameof(SocialPage)}/{nameof(PetsPage)}"); + await Shell.Current.GoToAsync($"///{nameof(SocialPage)}/{nameof(IslandsPage)}"); } private async void SelectedDecorClicked(object sender, EventArgs eventArgs) From 5d4066b6d2e3d288d4f2a94d0c2fb9ad48fc9460 Mon Sep 17 00:00:00 2001 From: egray Date: Mon, 29 Apr 2024 22:13:40 -0500 Subject: [PATCH 06/16] Adjust sizing on leaderboards page --- src/FocusApp.Client/Views/Social/LeaderboardsPage.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/FocusApp.Client/Views/Social/LeaderboardsPage.cs b/src/FocusApp.Client/Views/Social/LeaderboardsPage.cs index 2c1bc4d..8e240be 100644 --- a/src/FocusApp.Client/Views/Social/LeaderboardsPage.cs +++ b/src/FocusApp.Client/Views/Social/LeaderboardsPage.cs @@ -88,9 +88,9 @@ public LeaderboardsPage(IAPIClient client, IAuthenticationService authentication { RowDefinitions = GridRowsColumns.Rows.Define( (PageRow.PageHeader, GridRowsColumns.Stars(1)), - (PageRow.LeaderboardSelectors, GridRowsColumns.Stars(1)), + (PageRow.LeaderboardSelectors, GridRowsColumns.Stars(1.15)), (PageRow.TopThreeFriendsDisplay, GridRowsColumns.Stars(4.5)), - (PageRow.RemainingFriendsDisplay, GridRowsColumns.Stars(3.5)), + (PageRow.RemainingFriendsDisplay, GridRowsColumns.Stars(2)), (PageRow.TabBarSpacer, Consts.TabBarHeight) ), ColumnDefinitions = GridRowsColumns.Columns.Define( @@ -261,7 +261,7 @@ ScrollView GetRemainingFriendsScrollView() Label friendName = new Label { - FontSize = 24, + FontSize = 20, VerticalOptions = LayoutOptions.Center, } .Column(RemainingFriendsColumn.Name); From 6889426ce81dff04cb1b7d8f850cf817d775fd13 Mon Sep 17 00:00:00 2001 From: egray Date: Tue, 30 Apr 2024 19:47:38 -0500 Subject: [PATCH 07/16] Update pronoun field validation, tweak text size on leaderboards page, further restrict username length --- src/FocusApp.Client/Views/Social/LeaderboardsPage.cs | 9 ++++++--- src/FocusApp.Client/Views/Social/ProfilePageEdit.cs | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/FocusApp.Client/Views/Social/LeaderboardsPage.cs b/src/FocusApp.Client/Views/Social/LeaderboardsPage.cs index 8e240be..eaae16e 100644 --- a/src/FocusApp.Client/Views/Social/LeaderboardsPage.cs +++ b/src/FocusApp.Client/Views/Social/LeaderboardsPage.cs @@ -340,7 +340,8 @@ void SetTopThreeDynamicElements() _thirdPlaceUsername = new Label { - Text = "Username" + Text = "Username", + FontSize = 12 } .CenterHorizontal(); @@ -369,7 +370,8 @@ void SetTopThreeDynamicElements() _secondPlaceUsername = new Label { Text = "Username", - TextColor = Colors.Black + TextColor = Colors.Black, + FontSize = 12 } .CenterHorizontal(); @@ -398,7 +400,8 @@ void SetTopThreeDynamicElements() _firstPlaceUsername = new Label { Text = "Username", - TextColor = Colors.Black + TextColor = Colors.Black, + FontSize = 12 } .CenterHorizontal(); diff --git a/src/FocusApp.Client/Views/Social/ProfilePageEdit.cs b/src/FocusApp.Client/Views/Social/ProfilePageEdit.cs index e895ee7..50eb482 100644 --- a/src/FocusApp.Client/Views/Social/ProfilePageEdit.cs +++ b/src/FocusApp.Client/Views/Social/ProfilePageEdit.cs @@ -235,7 +235,7 @@ private void CreateFormValidationBehaviors() { _userNameValidationBehavior = new TextValidationBehavior { - MaximumLength = 20, + MaximumLength = 14, MinimumLength = 3, Flags = ValidationFlags.ValidateOnValueChanged, InvalidStyle = new Style(Entry.TextColorProperty, Colors.Red), @@ -357,11 +357,15 @@ private async void SaveChangesButtonClicked(object sender, EventArgs e) if (_pronounsField.Text != _authenticationService.CurrentUser?.Pronouns) command.Pronouns = _pronounsField.Text; + else if (string.IsNullOrEmpty(_pronounsField.Text) && _pronounsField.Text != _authenticationService.CurrentUser?.Pronouns) + command.Pronouns = _pronounsField.Text; if (_newPhoto != _authenticationService.CurrentUser?.ProfilePicture) command.ProfilePicture = _newPhoto; - if (!string.IsNullOrEmpty(command.Pronouns) || !string.IsNullOrEmpty(command.UserName) || command.ProfilePicture != null) + if (command.Pronouns is not null || + !string.IsNullOrEmpty(command.UserName) || + command.ProfilePicture != null) { // Call method to update the user data when the user fields have changed MediatrResult result = await _mediator.Send(command, default); From 560e0bff5f6e61127159bb2e76c0ffb178e681f6 Mon Sep 17 00:00:00 2001 From: Chris Perry Date: Tue, 30 Apr 2024 22:13:02 -0500 Subject: [PATCH 08/16] Added async overloads to the popup services --- src/FocusApp.Client/Helpers/PopupService.cs | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/FocusApp.Client/Helpers/PopupService.cs b/src/FocusApp.Client/Helpers/PopupService.cs index 7931dfa..95f7260 100644 --- a/src/FocusApp.Client/Helpers/PopupService.cs +++ b/src/FocusApp.Client/Helpers/PopupService.cs @@ -37,6 +37,19 @@ public void ShowPopup() where T : Popup _popups.Push(popup); } + /// + /// Show popup. + /// + /// Popup + /// + public async Task ShowPopupAsync() where T : Popup + { + var mainPage = App.Current?.MainPage ?? throw new MissingMethodException("Main page is null"); + var popup = _services.GetRequiredService(); + await MainThread.InvokeOnMainThreadAsync(() => mainPage.ShowPopup(popup)); + _popups.Push(popup); + } + /// /// Show popup and return the object for populating with shop data /// @@ -73,6 +86,20 @@ public void HidePopup(bool wasDismissedByTappingOutsideOfPopup = false) } } + public async Task HidePopupAsync(bool wasDismissedByTappingOutsideOfPopup = false) + { + if (_popups.Count > 0) + { + // Quick patch for popups closed via tapping outside of the popup + if (wasDismissedByTappingOutsideOfPopup) + // Remove the popup from the stack, but do not close it, as it has already + // been closed/disposed via tapping outside of popup + _popups.Pop(); + else + await MainThread.InvokeOnMainThreadAsync(() => _popups.Pop().Close()); + } + } + public void HideAllPopups() { while (_popups.Count > 0) From 49adca73d988260b1f89c0415ac847f10803d0b2 Mon Sep 17 00:00:00 2001 From: Chris Perry Date: Tue, 30 Apr 2024 22:14:18 -0500 Subject: [PATCH 09/16] Fix login bug --- src/FocusApp.Client/Methods/User/GetUserLogin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FocusApp.Client/Methods/User/GetUserLogin.cs b/src/FocusApp.Client/Methods/User/GetUserLogin.cs index 453e313..6b95c8e 100644 --- a/src/FocusApp.Client/Methods/User/GetUserLogin.cs +++ b/src/FocusApp.Client/Methods/User/GetUserLogin.cs @@ -250,7 +250,7 @@ await GetSelectedDecorQuery(user.SelectedDecorId.Value) .FirstOrDefaultAsync(cancellationToken); bool userExistsLocally = await _localContext.Users - .AnyAsync(u => u.Auth0Id == getUserResponse.User.Auth0Id, cancellationToken); + .AnyAsync(u => u.Auth0Id == getUserResponse.User.Auth0Id || getUserResponse.User.Id == u.Id, cancellationToken); // Add user to the local database if the user doesn't exist locally if (!userExistsLocally) From 1f9af77273786c17dde200eb452c32da5e57b3c0 Mon Sep 17 00:00:00 2001 From: Chris Perry Date: Tue, 30 Apr 2024 22:18:04 -0500 Subject: [PATCH 10/16] Leaderboards page refactoring and modification to show loading spinner --- .../Views/Social/LeaderboardsPage.cs | 84 +++++++++---------- 1 file changed, 38 insertions(+), 46 deletions(-) diff --git a/src/FocusApp.Client/Views/Social/LeaderboardsPage.cs b/src/FocusApp.Client/Views/Social/LeaderboardsPage.cs index eaae16e..5c644bb 100644 --- a/src/FocusApp.Client/Views/Social/LeaderboardsPage.cs +++ b/src/FocusApp.Client/Views/Social/LeaderboardsPage.cs @@ -16,6 +16,12 @@ namespace FocusApp.Client.Views.Social { internal class LeaderboardsPage : BasePage { + + public enum LeaderboardType + { + Daily, + Weekly + } // Row / Column structure for entire page enum PageRow { PageHeader, LeaderboardSelectors, TopThreeFriendsDisplay, RemainingFriendsDisplay, TabBarSpacer } enum PageColumn { DailyLeadboardButton, WeeklyLeaderboardButton } @@ -69,8 +75,8 @@ public LeaderboardsPage(IAPIClient client, IAuthenticationService authentication } .Row(PageRow.LeaderboardSelectors) .Column(PageColumn.DailyLeadboardButton) - .Invoke(button => button.Released += (sender, eventArgs) => - GetDailyLeaderboards(sender, eventArgs)); + .Invoke(button => button.Released += (_, _) => + _ = FetchAndDisplayLeaderboards(LeaderboardType.Daily)); // Weekly Leaderboard Button _weeklyLeaderboardButton = new Button @@ -81,8 +87,8 @@ public LeaderboardsPage(IAPIClient client, IAuthenticationService authentication } .Row(PageRow.LeaderboardSelectors) .Column(PageColumn.WeeklyLeaderboardButton) - .Invoke(button => button.Released += (sender, eventArgs) => - GetWeeklyLeaderboards(sender, eventArgs)); + .Invoke(button => button.Released += (_, _) => + _ = FetchAndDisplayLeaderboards(LeaderboardType.Weekly)); Content = new Grid { @@ -410,44 +416,6 @@ void SetTopThreeDynamicElements() _firstPlaceUsername.Bind(Label.TextProperty, "UserName"); } - async void GetDailyLeaderboards(object sender, EventArgs e) - { - try - { - _popupService.ShowPopup(); - LeaderboardResponse leaderboardResponse = await _client.GetDailyLeaderboard(new GetDailyLeaderboardQuery { UserId = _authenticationService.CurrentUser.Id }, default); - PopulateLeaderboard(leaderboardResponse.LeaderboardRecords); - - // Disable the daily leaderboards button, and enable the weekly leaderboards button - _dailyLeaderboardButton.IsEnabled = false; - _weeklyLeaderboardButton.IsEnabled = true; - } - catch (Exception ex) - { - _logger.Log(LogLevel.Error, "Error retreiving daily leaderboards. Message: " + ex.Message); - } - _popupService.HidePopup(); - } - - async void GetWeeklyLeaderboards(object sender, EventArgs e) - { - try - { - _popupService.ShowPopup(); - LeaderboardResponse leaderboardResponse = await _client.GetWeeklyLeaderboard(new GetWeeklyLeaderboardQuery { UserId = _authenticationService.CurrentUser.Id }, default); - PopulateLeaderboard(leaderboardResponse.LeaderboardRecords); - - // Disable the weekly leaderboards button, and enable the daily leaderboards button - _weeklyLeaderboardButton.IsEnabled = false; - _dailyLeaderboardButton.IsEnabled = true; - } - catch (Exception ex) - { - _logger.Log(LogLevel.Error, "Error retreiving weekly leaderboards. Message: " + ex.Message); - } - _popupService.HidePopup(); - } - void PopulateLeaderboard(List leaderboard) { ClearLeaderboard(); @@ -513,15 +481,39 @@ protected override async void OnAppearing() { base.OnAppearing(); - // On page load, fetch daily leaderboards + await Task.Run(() => FetchAndDisplayLeaderboards(LeaderboardType.Daily)); + } + + /// + /// Show loading popup, retrieve leaderboards from API, then populate the UI with leaderboard data + /// + private async Task FetchAndDisplayLeaderboards(LeaderboardType leaderboardType) + { try { - LeaderboardResponse leaderboardResponse = await _client.GetDailyLeaderboard(new GetDailyLeaderboardQuery { UserId = _authenticationService.CurrentUser.Id }, default); - PopulateLeaderboard(leaderboardResponse.LeaderboardRecords); + await _popupService.ShowPopupAsync(); + LeaderboardResponse leaderboardResponse = null; + if (leaderboardType == LeaderboardType.Daily) + { + leaderboardResponse = await _client.GetDailyLeaderboard(new GetDailyLeaderboardQuery { UserId = _authenticationService.CurrentUser.Id }, default); + } + else + { + leaderboardResponse = await _client.GetWeeklyLeaderboard(new GetWeeklyLeaderboardQuery { UserId = _authenticationService.CurrentUser.Id }, default); + } + + await MainThread.InvokeOnMainThreadAsync(() => + { + PopulateLeaderboard(leaderboardResponse.LeaderboardRecords); + _dailyLeaderboardButton.IsEnabled = leaderboardType != LeaderboardType.Daily; + _weeklyLeaderboardButton.IsEnabled = leaderboardType != LeaderboardType.Weekly; + }); + + await _popupService.HidePopupAsync(); } catch (Exception ex) { - _logger.Log(LogLevel.Error, "Error retreiving daily leaderboards on page load. Message: " + ex.Message); + _logger.LogError(ex, "Error retrieving {leaderboardType} leaderboards.", leaderboardType); } } From 0d1b481cafca46a1816dc421c6599045415894ce Mon Sep 17 00:00:00 2001 From: egray Date: Tue, 30 Apr 2024 22:32:32 -0500 Subject: [PATCH 11/16] Remove login check on badges page (this is handled on social page) --- src/FocusApp.Client/Views/Social/BadgesPage.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/FocusApp.Client/Views/Social/BadgesPage.cs b/src/FocusApp.Client/Views/Social/BadgesPage.cs index bcfb227..8560246 100644 --- a/src/FocusApp.Client/Views/Social/BadgesPage.cs +++ b/src/FocusApp.Client/Views/Social/BadgesPage.cs @@ -113,14 +113,6 @@ protected override async void OnAppearing() { base.OnAppearing(); - // Check if the user is logged in - if (string.IsNullOrEmpty(_authenticationService.AuthToken)) - { - var loginPopup = (EnsureLoginPopupInterface)_popupService.ShowAndGetPopup(); - loginPopup.OriginPage = nameof(ShopPage); - return; - } - // Fetch badges from the local database and display them var localBadges = await FetchBadgesFromLocalDb(); var userBadges = await FetchUserBadgesFromLocalDb(); From 1f1180e0de4b6364546429f5291545c621b2ffbc Mon Sep 17 00:00:00 2001 From: Chris Perry Date: Tue, 30 Apr 2024 22:42:12 -0500 Subject: [PATCH 12/16] Remove decor given when continue without login --- src/FocusApp.Client/Views/LoginPage.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/FocusApp.Client/Views/LoginPage.cs b/src/FocusApp.Client/Views/LoginPage.cs index 47e5f3f..1cac247 100644 --- a/src/FocusApp.Client/Views/LoginPage.cs +++ b/src/FocusApp.Client/Views/LoginPage.cs @@ -183,7 +183,6 @@ private async Task InitializeEmptyUser() _authenticationService.SelectedIsland ??= result.Island; _authenticationService.SelectedPet ??= result.Pet; - _authenticationService.SelectedDecor ??= result.Decor; } } From 36c0981df04a5a0628e717203a2b42169320d3e3 Mon Sep 17 00:00:00 2001 From: Chris Perry Date: Tue, 30 Apr 2024 22:42:54 -0500 Subject: [PATCH 13/16] Add generic synchronous and async overloads for hide popup --- src/FocusApp.Client/Helpers/PopupService.cs | 34 +++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/FocusApp.Client/Helpers/PopupService.cs b/src/FocusApp.Client/Helpers/PopupService.cs index 95f7260..fe7e227 100644 --- a/src/FocusApp.Client/Helpers/PopupService.cs +++ b/src/FocusApp.Client/Helpers/PopupService.cs @@ -86,6 +86,23 @@ public void HidePopup(bool wasDismissedByTappingOutsideOfPopup = false) } } + public void HidePopup(bool wasDismissedByTappingOutsideOfPopup = false) where T : BasePopup + { + if (_popups.Count > 0) + { + if (typeof(T) == _popups.Peek().GetType()) + { + // Quick patch for popups closed via tapping outside of the popup + if (wasDismissedByTappingOutsideOfPopup) + // Remove the popup from the stack, but do not close it, as it has already + // been closed/disposed via tapping outside of popup + _popups.Pop(); + else + MainThread.BeginInvokeOnMainThread(() => _popups.Pop().Close()); + } + } + } + public async Task HidePopupAsync(bool wasDismissedByTappingOutsideOfPopup = false) { if (_popups.Count > 0) @@ -100,6 +117,23 @@ public async Task HidePopupAsync(bool wasDismissedByTappingOutsideOfPopup = fals } } + public async Task HidePopupAsync(bool wasDismissedByTappingOutsideOfPopup = false) where T : BasePopup + { + if (_popups.Count > 0) + { + if (typeof(T) == _popups.Peek().GetType()) + { + // Quick patch for popups closed via tapping outside of the popup + if (wasDismissedByTappingOutsideOfPopup) + // Remove the popup from the stack, but do not close it, as it has already + // been closed/disposed via tapping outside of popup + _popups.Pop(); + else + await MainThread.InvokeOnMainThreadAsync(() => _popups.Pop().Close()); + } + } + } + public void HideAllPopups() { while (_popups.Count > 0) From 1bc3f74f7e739d8615fde152996e155a02218f22 Mon Sep 17 00:00:00 2001 From: Chris Perry Date: Tue, 30 Apr 2024 22:43:14 -0500 Subject: [PATCH 14/16] Fix issue with profile popup interface closing popups on other pages --- src/FocusApp.Client/Views/Social/ProfilePopupInterface.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FocusApp.Client/Views/Social/ProfilePopupInterface.cs b/src/FocusApp.Client/Views/Social/ProfilePopupInterface.cs index 716ead5..f06ca13 100644 --- a/src/FocusApp.Client/Views/Social/ProfilePopupInterface.cs +++ b/src/FocusApp.Client/Views/Social/ProfilePopupInterface.cs @@ -289,8 +289,8 @@ private async void PageButtonClicked(object sender, EventArgs e) Shell.Current.SetTransition(Transitions.RightToLeftPlatformTransition); // Navigate to page within social (this allows back navigation to work properly) + await _popupService.HidePopupAsync(); await Shell.Current.GoToAsync($"///{nameof(SocialPage)}/{pageName}"); - _popupService.HidePopup(); } } } From 8822b899ba43739a86ccc9acde30cfa244f22a05 Mon Sep 17 00:00:00 2001 From: Chris Perry Date: Tue, 30 Apr 2024 22:45:34 -0500 Subject: [PATCH 15/16] Fixed screen orientation to lock onto portrait mode --- src/FocusApp.Client/Platforms/Android/MainActivity.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/FocusApp.Client/Platforms/Android/MainActivity.cs b/src/FocusApp.Client/Platforms/Android/MainActivity.cs index cacd200..1d289bf 100644 --- a/src/FocusApp.Client/Platforms/Android/MainActivity.cs +++ b/src/FocusApp.Client/Platforms/Android/MainActivity.cs @@ -4,7 +4,11 @@ namespace FocusApp.Client { - [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] + [Activity( + Theme = "@style/Maui.SplashTheme", + MainLauncher = true, + ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density, + ScreenOrientation = ScreenOrientation.Portrait)] public class MainActivity : MauiAppCompatActivity { } From 99f9b530eba2637907b7e43ed6a7b359bcb04898 Mon Sep 17 00:00:00 2001 From: Chris Perry Date: Thu, 2 May 2024 22:14:42 -0500 Subject: [PATCH 16/16] minor fix --- src/FocusApp.Client/Methods/User/GetUserLogin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FocusApp.Client/Methods/User/GetUserLogin.cs b/src/FocusApp.Client/Methods/User/GetUserLogin.cs index 6b95c8e..6a370e9 100644 --- a/src/FocusApp.Client/Methods/User/GetUserLogin.cs +++ b/src/FocusApp.Client/Methods/User/GetUserLogin.cs @@ -145,7 +145,7 @@ public async Task Handle( user = await GatherUserDataForCreatedUser(createUserResponse, auth0UserId, userEmail, userName, cancellationToken); bool userExistsLocally = await _localContext.Users - .AnyAsync(u => u.Auth0Id == auth0UserId, cancellationToken); + .AnyAsync(u => u.Auth0Id == auth0UserId || u.Id == user.Id, cancellationToken); // Add user to the local database if the user doesn't exist locally if (!userExistsLocally)