From 3e35d94dcc89fd685e5b9f5541702fba13c02cfd Mon Sep 17 00:00:00 2001 From: Eli Payton <80854811+wesleypayton@users.noreply.github.com> Date: Fri, 3 May 2024 02:27:26 -0500 Subject: [PATCH] Added X button to add friend popup + reworked stack into a grid --- .../Views/Social/AddFriendPopupInterface.cs | 100 ++++++++++++++---- 1 file changed, 78 insertions(+), 22 deletions(-) diff --git a/src/FocusApp.Client/Views/Social/AddFriendPopupInterface.cs b/src/FocusApp.Client/Views/Social/AddFriendPopupInterface.cs index e3c13fe..7ed7c26 100644 --- a/src/FocusApp.Client/Views/Social/AddFriendPopupInterface.cs +++ b/src/FocusApp.Client/Views/Social/AddFriendPopupInterface.cs @@ -14,6 +14,7 @@ using Microsoft.Extensions.Logging; using static CommunityToolkit.Maui.Markup.GridRowsColumns; using CommunityToolkit.Maui.Core; +using FocusApp.Client.Resources.FontAwesomeIcons; namespace FocusApp.Client.Views.Social { @@ -48,6 +49,8 @@ public AddFriendPopupInterface( Color = Colors.Transparent; + CanBeDismissedByTappingOutsideOfPopup = false; + Entry emailEntry = new Entry { Placeholder = "Enter friend's email", @@ -74,8 +77,12 @@ public AddFriendPopupInterface( BackgroundColor = AppStyles.Palette.LightMauve, WidthRequest = 350, HeightRequest = 450, - Content = new VerticalStackLayout + Content = new Grid { + // Define rows and columns + RowDefinitions = Rows.Define(55, 60, Auto, Auto, Star), + ColumnDefinitions = Columns.Define(Star), + WidthRequest = 350, HeightRequest = 450, BackgroundColor = Colors.White, @@ -86,26 +93,61 @@ public AddFriendPopupInterface( WidthRequest = 360, HeightRequest = 55, BackgroundColor = AppStyles.Palette.DarkMauve, - Content = new Label() + Content = new Grid() { - Shadow = new Shadow - { - Brush = Brush.Black, - Radius = 5, - Opacity = 0.6f - }, - WidthRequest = 210, + WidthRequest = 360, HeightRequest = 55, - FontSize = 30, - TextColor = Colors.White, - HorizontalTextAlignment = TextAlignment.Center, - VerticalTextAlignment = TextAlignment.Center, - HorizontalOptions = LayoutOptions.Center, - VerticalOptions = LayoutOptions.Center, - - Text = "Add Friend" + + // Define rows and columns + RowDefinitions = Rows.Define(Star), + ColumnDefinitions = Columns.Define(Star, Star, Star), + + Children = + { + new Label() + { + Shadow = new Shadow + { + Brush = Brush.Black, + Radius = 5, + Opacity = 0.6f + }, + WidthRequest = 210, + HeightRequest = 55, + FontSize = 30, + TextColor = Colors.White, + HorizontalTextAlignment = TextAlignment.Center, + VerticalTextAlignment = TextAlignment.Center, + HorizontalOptions = LayoutOptions.Center, + VerticalOptions = LayoutOptions.Center, + + Text = "Add Friend" + } + .Row(0) + .Column(1), + + // Dismiss Popup Button + new Button + { + Text = SolidIcons.x, + TextColor = Colors.White, + FontFamily = nameof(SolidIcons), + FontSize = 20, + BackgroundColor = Colors.Transparent + } + .ZIndex(2) + //.Right() + //.CenterVertical() + //.Paddings(top: 10, bottom: 10, left: 15, right: 15) + .Column(2) + .Row(0) + // When clicked, close the popup + .Invoke(button => button.Released += OnDismissPopup), + } } - }, + } + .Column(0) + .Row(0), new Frame() { @@ -133,12 +175,16 @@ public AddFriendPopupInterface( } } .Margins(top: -15) - }, + } + .Column(0) + .Row(1), // Error label for friend request errors entryError .Top() - .Paddings(left: 15, bottom: 5), + .Paddings(left: 15, bottom: 5) + .Column(0) + .Row(2), // Horizontal Divider new BoxView @@ -147,7 +193,9 @@ public AddFriendPopupInterface( WidthRequest = 360, HeightRequest = 2 } - .Top(), + .Top() + .Column(0) + .Row(3), new Frame() { @@ -155,7 +203,9 @@ public AddFriendPopupInterface( HeightRequest = 350, BackgroundColor = Colors.Transparent, Content = _friendrequestView - }, + } + .Column(0) + .Row(4), } } .Top() @@ -403,5 +453,11 @@ private async void OnClickCancelFriendRequest(object sender, EventArgs e) PopulatePopup(); } + + // Navigate to page according to button + private async void OnDismissPopup(object? sender, EventArgs e) + { + _popupService.HidePopup(); + } } }