Commit 27d95db0 authored by Abdulrahman Mohammed's avatar Abdulrahman Mohammed

Done with update profile message and scroll to owner rank

parent f2151e2d
...@@ -236,9 +236,13 @@ public class AppRouter : MonoBehaviour ...@@ -236,9 +236,13 @@ public class AppRouter : MonoBehaviour
UserService.Instance.StartListening(); UserService.Instance.StartListening();
} }
public static async void Logout() public static async void Logout(UnityEngine.UIElements.Button logoutButton = null)
{ {
logoutButton.SetEnabled(false);
CleanupSingletons(); CleanupSingletons();
await SupabaseAuthentication.Instance.LogOut(); await SupabaseAuthentication.Instance.LogOut();
GoToLogin(); GoToLogin();
} }
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using Cysharp.Threading.Tasks; using Cysharp.Threading.Tasks;
...@@ -14,15 +14,33 @@ public class LeaderboardController : MonoBehaviour, IDisposable ...@@ -14,15 +14,33 @@ public class LeaderboardController : MonoBehaviour, IDisposable
private CancellationTokenSource _loadCts; private CancellationTokenSource _loadCts;
public int CurrentPlayerSlotIndex { get; private set; } = -1; CustomLeaderboardSlot currentPlayerSlot;
ScrollView leaderBoardScrollView;
void Start() void Start()
{ {
root = leaderboardDocument.rootVisualElement; root = leaderboardDocument.rootVisualElement;
allPlayersContainer = root.Q<VisualElement>("AllPlayerContainer"); allPlayersContainer = root.Q<VisualElement>("AllPlayerContainer");
leaderBoardScrollView = root.Q<ScrollView>("Leaderboard");
UserService.Instance.OnUserChanged += OnUserChanged; UserService.Instance.OnUserChanged += OnUserChanged;
LoadLeaderboard().Forget(); LoadLeaderboard().Forget();
Button myRankButton = root.Q<Button>("MyRankButton");
myRankButton.clicked += () =>
{
if(currentPlayerSlot == null)
{
ShowUIMessage.Instance.ShowMessage("حسابك ليس من ضمن افضل 100 لاعب");
}
else
{
leaderBoardScrollView.experimental.animation.Start(leaderBoardScrollView.scrollOffset.y, currentPlayerSlot.layout.y, 300, (v, t) => {
leaderBoardScrollView.scrollOffset = new Vector2(leaderBoardScrollView.scrollOffset.x, t);
});
}
};
} }
private void OnUserChanged(object user) private void OnUserChanged(object user)
...@@ -59,7 +77,7 @@ public class LeaderboardController : MonoBehaviour, IDisposable ...@@ -59,7 +77,7 @@ public class LeaderboardController : MonoBehaviour, IDisposable
result.Switch( result.Switch(
(List<LeaderboardPlayerModel> players) => (List<LeaderboardPlayerModel> players) =>
{ {
CurrentPlayerSlotIndex = -1; currentPlayerSlot = null;
for (int i = 0; i < players.Count; i++) for (int i = 0; i < players.Count; i++)
{ {
...@@ -69,8 +87,7 @@ public class LeaderboardController : MonoBehaviour, IDisposable ...@@ -69,8 +87,7 @@ public class LeaderboardController : MonoBehaviour, IDisposable
var player = players[i]; var player = players[i];
var isOwner = player.Id == UserService.Instance.CurrentUser?.Id; var isOwner = player.Id == UserService.Instance.CurrentUser?.Id;
if (isOwner)
CurrentPlayerSlotIndex = i;
var entry = new CustomLeaderboardSlot var entry = new CustomLeaderboardSlot
{ {
...@@ -81,6 +98,9 @@ public class LeaderboardController : MonoBehaviour, IDisposable ...@@ -81,6 +98,9 @@ public class LeaderboardController : MonoBehaviour, IDisposable
IsOwner = isOwner IsOwner = isOwner
}; };
if (isOwner)
currentPlayerSlot = entry;
allPlayersContainer.Add(entry); allPlayersContainer.Add(entry);
} }
}, },
......
using UnityEngine; using UnityEngine;
using UnityEngine.UIElements; using UnityEngine.UIElements;
public class ProfileController : MonoBehaviour public class ProfileController : MonoBehaviour
...@@ -24,10 +24,16 @@ public class ProfileController : MonoBehaviour ...@@ -24,10 +24,16 @@ public class ProfileController : MonoBehaviour
var root = profileDocument.rootVisualElement.Q("Settings"); var root = profileDocument.rootVisualElement.Q("Settings");
name = root.Q<Label>("Username"); name = root.Q<Label>("Username");
logoutButton = root.Q<Button>("LogoutButton"); logoutButton = root.Q<Button>("LogoutButton");
logoutButton.clicked += AppRouter.Logout; logoutButton.clicked += () =>
{
AppRouter.Logout(logoutButton);
};
updateProfileButton = root.Q<Button>("UpdateProfile"); updateProfileButton = root.Q<Button>("UpdateProfile");
updateProfileButton.clicked += UpdateProfile; updateProfileButton.clicked += () =>
{
UpdateProfile();
};
UsernameLabel = root.Q<TextField>("Name"); UsernameLabel = root.Q<TextField>("Name");
Grade = root.Q<DropdownField>("Grade"); Grade = root.Q<DropdownField>("Grade");
...@@ -63,6 +69,8 @@ public class ProfileController : MonoBehaviour ...@@ -63,6 +69,8 @@ public class ProfileController : MonoBehaviour
private async void UpdateProfile() private async void UpdateProfile()
{ {
updateProfileButton.SetEnabled(false);
int gradeId = EducationManager.GetGradeId(Grade.value); int gradeId = EducationManager.GetGradeId(Grade.value);
int termId = EducationManager.GetTermId(Term.value); int termId = EducationManager.GetTermId(Term.value);
int curriculumId = EducationManager.GetCurriculumId(Curriculum.value); int curriculumId = EducationManager.GetCurriculumId(Curriculum.value);
...@@ -72,6 +80,8 @@ public class ProfileController : MonoBehaviour ...@@ -72,6 +80,8 @@ public class ProfileController : MonoBehaviour
if (gradeId < 0 || termId < 0 || curriculumId < 0) if (gradeId < 0 || termId < 0 || curriculumId < 0)
{ {
updateProfileButton.SetEnabled(true);
Debug.LogWarning("[Profile] Invalid grade or term selection"); Debug.LogWarning("[Profile] Invalid grade or term selection");
return; return;
} }
...@@ -81,7 +91,10 @@ public class ProfileController : MonoBehaviour ...@@ -81,7 +91,10 @@ public class ProfileController : MonoBehaviour
grade: gradeId, grade: gradeId,
term: termId, term: termId,
curriculum: curriculumId curriculum: curriculumId
); );
updateProfileButton.SetEnabled(true);
ShowUIMessage.Instance.ShowMessage("تم تحديث البيانات بنجاح", false);
} }
private async void DeleteAccount() private async void DeleteAccount()
...@@ -92,7 +105,7 @@ public class ProfileController : MonoBehaviour ...@@ -92,7 +105,7 @@ public class ProfileController : MonoBehaviour
private void OnDestroy() private void OnDestroy()
{ {
UserService.Instance.OnUserChanged -= OnUserChange; UserService.Instance.OnUserChanged -= OnUserChange;
logoutButton.clicked -= AppRouter.Logout; logoutButton.clicked -= () => { AppRouter.Logout(logoutButton); };
updateProfileButton.clicked -= UpdateProfile; updateProfileButton.clicked -= UpdateProfile;
} }
......
<ui:UXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False"> <ui:UXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Assets/AppUI/NewAppUI/USS/NewStyle.uss?fileID=7433441132597879392&amp;guid=c81297485ce529246b88d7955e887342&amp;type=3"/> <Style src="project://database/Assets/AppUI/NewAppUI/USS/NewStyle.uss?fileID=7433441132597879392&amp;guid=c81297485ce529246b88d7955e887342&amp;type=3#NewStyle"/>
<ui:VisualElement name="Parent" style="flex-grow: 1;"> <ui:VisualElement name="Parent" style="flex-grow: 1;">
<ui:VisualElement name="Root" style="flex-grow: 1; background-color: rgb(238, 240, 248); display: flex;"> <ui:VisualElement name="Root" style="flex-grow: 1; background-color: rgb(238, 240, 248); display: flex;">
<ui:VisualElement name="Body" style="flex-grow: 0; width: 300%; flex-direction: row; translate: -33.333% 0; height: 90%; transition-duration: 0.15s; transition-timing-function: ease;"> <ui:VisualElement name="Body" style="flex-grow: 0; width: 300%; flex-direction: row; translate: -33.333% 0; height: 90%; transition-duration: 0.15s; transition-timing-function: ease;">
...@@ -352,6 +352,9 @@ ...@@ -352,6 +352,9 @@
</ui:VisualElement> </ui:VisualElement>
</ui:ScrollView> </ui:ScrollView>
<ui:VisualElement name="Fade" style="flex-grow: 0; background-image: url(&quot;project://database/Assets/AppUI/Image/Transp4.png?fileID=2800000&amp;guid=9046ff72a71cb9f42bd69f32d5cc9a45&amp;type=3#Transp4&quot;); position: absolute; bottom: auto; width: 98%; height: 150px; -unity-background-image-tint-color: rgb(238, 240, 248); rotate: 180deg; top: 30%; border-bottom-right-radius: 100px; border-bottom-left-radius: 100px; align-self: center;"/> <ui:VisualElement name="Fade" style="flex-grow: 0; background-image: url(&quot;project://database/Assets/AppUI/Image/Transp4.png?fileID=2800000&amp;guid=9046ff72a71cb9f42bd69f32d5cc9a45&amp;type=3#Transp4&quot;); position: absolute; bottom: auto; width: 98%; height: 150px; -unity-background-image-tint-color: rgb(238, 240, 248); rotate: 180deg; top: 30%; border-bottom-right-radius: 100px; border-bottom-left-radius: 100px; align-self: center;"/>
<ui:Button text="" name="MyRankButton" class="edit-photo" style="width: 120px; height: 120px; display: flex; right: auto; bottom: auto; top: 30%; align-self: center; translate: 0% -50%; background-color: rgb(245, 3, 45);">
<ui:Label text="➜" class="emoji" style="font-size: 63px; translate: 0% 0; background-image: none; height: 50px; width: auto; aspect-ratio: 1; -unity-background-image-tint-color: rgb(255, 255, 255); color: rgb(255, 255, 255); rotate: 90deg;"/>
</ui:Button>
<ui:VisualElement name="Fade" style="flex-grow: 0; background-image: url(&quot;project://database/Assets/AppUI/Image/Transp4.png?fileID=2800000&amp;guid=9046ff72a71cb9f42bd69f32d5cc9a45&amp;type=3#Transp4&quot;); position: absolute; bottom: 0; width: 100%; height: 100px; -unity-background-image-tint-color: rgb(238, 240, 248);"/> <ui:VisualElement name="Fade" style="flex-grow: 0; background-image: url(&quot;project://database/Assets/AppUI/Image/Transp4.png?fileID=2800000&amp;guid=9046ff72a71cb9f42bd69f32d5cc9a45&amp;type=3#Transp4&quot;); position: absolute; bottom: 0; width: 100%; height: 100px; -unity-background-image-tint-color: rgb(238, 240, 248);"/>
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
...@@ -438,4 +441,22 @@ ...@@ -438,4 +441,22 @@
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="MessagePanel" style="flex-grow: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.75); position: absolute; display: none; opacity: 0; align-items: center; justify-content: center;">
<ui:VisualElement name="Menu" class="padding" style="flex-grow: 0; background-color: rgb(255, 255, 255); height: auto; flex-shrink: 10; border-top-width: 0; border-right-width: 0; border-bottom-width: 7px; border-left-width: 0; border-top-left-radius: 50px; border-top-right-radius: 50px; border-bottom-right-radius: 50px; border-bottom-left-radius: 50px; padding-top: 50px; padding-right: 50px; padding-bottom: 50px; padding-left: 50px; justify-content: space-between; border-left-color: rgba(0, 0, 0, 0.25); border-right-color: rgba(0, 0, 0, 0.25); border-top-color: rgba(0, 0, 0, 0.25); border-bottom-color: rgba(0, 0, 0, 0.25); display: flex; width: 80%;">
<ui:Label text="يرجي التسجيل" name="MessageLabel" class="text-bold-black" style="color: rgb(66, 66, 66); align-self: center; font-size: 49px; white-space: pre-wrap; -unity-text-align: middle-center;"/>
<ui:VisualElement name="Line" style="flex-grow: 0; width: 100%; background-color: rgba(0, 0, 0, 0.1); height: 2px; margin-top: 25px; margin-bottom: 25px;"/>
<ui:VisualElement style="flex-grow: 1; flex-direction: row-reverse;">
<ui:VisualElement name="BackToHome" style="flex-grow: 1; flex-direction: row-reverse; justify-content: space-around; display: none;">
<ui:VisualElement name="Parent" style="width: 250px; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; justify-content: center; display: flex;">
<ui:Button text="تسجيل" name="BackToHomeButton" language-direction="RTL" class="action-btn" style="background-color: rgb(0, 137, 107); color: rgb(255, 255, 255); -unity-font-definition: url(&quot;project://database/Assets/ALArcade/Hakwaty%20Font/TSHakwaty-ExtraBold.otf?fileID=12800000&amp;guid=9edc60294a97d7f4e87aee01d4e4d689&amp;type=3#TSHakwaty-ExtraBold&quot;); font-size: 55px; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; height: 140px; -unity-text-generator: advanced; display: flex;"/>
</ui:VisualElement>
</ui:VisualElement>
<ui:VisualElement name="Buttons" style="flex-grow: 1; flex-direction: row-reverse; justify-content: space-around;">
<ui:VisualElement name="Button" style="width: 250px; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; justify-content: center;">
<ui:Button text="الغاء" name="CloseMessagePanelButton" language-direction="RTL" class="action-btn" style="background-color: rgb(245, 3, 45); color: rgb(255, 255, 255); -unity-font-definition: url(&quot;project://database/Assets/ALArcade/Hakwaty%20Font/TSHakwaty-ExtraBold.otf?fileID=12800000&amp;guid=9edc60294a97d7f4e87aee01d4e4d689&amp;type=3#TSHakwaty-ExtraBold&quot;); font-size: 55px; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; height: 140px; -unity-text-generator: advanced;"/>
</ui:VisualElement>
</ui:VisualElement>
</ui:VisualElement>
</ui:VisualElement>
</ui:VisualElement>
</ui:UXML> </ui:UXML>
...@@ -534,6 +534,7 @@ Transform: ...@@ -534,6 +534,7 @@ Transform:
- {fileID: 1154832527} - {fileID: 1154832527}
- {fileID: 373486799} - {fileID: 373486799}
- {fileID: 1008654135} - {fileID: 1008654135}
- {fileID: 757936571}
m_Father: {fileID: 2035341440} m_Father: {fileID: 2035341440}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &659928730 --- !u!1 &659928730
...@@ -569,6 +570,51 @@ Transform: ...@@ -569,6 +570,51 @@ Transform:
- {fileID: 1455761155} - {fileID: 1455761155}
m_Father: {fileID: 2035341440} m_Father: {fileID: 2035341440}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &757936570
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 757936571}
- component: {fileID: 757936572}
m_Layer: 0
m_Name: _showUIMessage
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &757936571
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 757936570}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 652396694}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &757936572
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 757936570}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 42d332574029f664b90d64379d0bea9b, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::ShowUIMessage
UIDocument: {fileID: 1455761156}
--- !u!1 &803660554 --- !u!1 &803660554
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment