Skip to content

Commit 6da09af

Browse files
committed
feat(android_sidebar): adding the profil page and password edit
1 parent 25120d9 commit 6da09af

File tree

19 files changed

+386
-48
lines changed

19 files changed

+386
-48
lines changed

xpeapp_android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,5 @@ dependencies {
215215
implementation("com.google.accompanist:accompanist-permissions:0.31.1-alpha")
216216

217217
//XpehoUI
218-
implementation "com.xpeho.packages:xpeho_ui_android:1.5.0"
218+
implementation "com.xpeho.packages:xpeho_ui_android:1.6.0"
219219
}

xpeapp_android/app/src/main/java/com/xpeho/xpeapp/data/Constants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ enum class FeatureFlippingEnum(val value: String) {
1010
EXPENSE_REPORT("expenseReport"),
1111
COLLEAGUES("colleagues"),
1212
QVST("campaign"),
13+
PROFILE("profile")
1314
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.xpeho.xpeapp.data.entity.user
2+
3+
data class UserEditPassword(
4+
val initialPassword: String,
5+
val password: String,
6+
val passwordRepeat: String,
7+
)

xpeapp_android/app/src/main/java/com/xpeho/xpeapp/data/model/UserInfos.kt renamed to xpeapp_android/app/src/main/java/com/xpeho/xpeapp/data/model/user/UserInfos.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.xpeho.xpeapp.data.model
1+
package com.xpeho.xpeapp.data.model.user
22

33
data class UserInfos(
44
val id: String,

xpeapp_android/app/src/main/java/com/xpeho/xpeapp/data/service/WordpressRepository.kt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import androidx.annotation.VisibleForTesting
55
import com.xpeho.xpeapp.data.entity.AuthentificationBody
66
import com.xpeho.xpeapp.data.entity.QvstAnswerBody
77
import com.xpeho.xpeapp.data.entity.QvstCampaignEntity
8+
import com.xpeho.xpeapp.data.entity.user.UserEditPassword
89
import com.xpeho.xpeapp.data.model.AuthResult
9-
import com.xpeho.xpeapp.data.model.UserInfos
10+
import com.xpeho.xpeapp.data.model.user.UserInfos
1011
import com.xpeho.xpeapp.data.model.WordpressToken
1112
import com.xpeho.xpeapp.data.model.qvst.QvstCampaign
1213
import com.xpeho.xpeapp.data.model.qvst.QvstProgress
@@ -199,6 +200,20 @@ class WordpressRepository(
199200
)
200201
}
201202

203+
/*suspend fun updatePassword(
204+
editPassword: UserEditPassword
205+
): Boolean {
206+
handleServiceExceptions(
207+
tryBody = {
208+
return api.updatePassword(editPassword)
209+
},
210+
catchBody = { e ->
211+
Log.e("WordpressRepository: updatePassword", "Network error: ${e.message}")
212+
return false
213+
}
214+
)
215+
}*/
216+
202217
// Exceptions handling
203218

204219
@Suppress("ReturnCount")

xpeapp_android/app/src/main/java/com/xpeho/xpeapp/data/service/WordpressService.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ package com.xpeho.xpeapp.data.service
22

33
import com.xpeho.xpeapp.data.entity.AuthentificationBody
44
import com.xpeho.xpeapp.data.entity.QvstAnswerBody
5-
import com.xpeho.xpeapp.data.model.UserInfos
5+
import com.xpeho.xpeapp.data.entity.user.UserEditPassword
6+
import com.xpeho.xpeapp.data.model.user.UserInfos
67
import com.xpeho.xpeapp.data.model.WordpressToken
78
import com.xpeho.xpeapp.data.model.qvst.QvstCampaign
89
import com.xpeho.xpeapp.data.model.qvst.QvstProgress
@@ -61,8 +62,16 @@ interface WordpressService {
6162
@Body answers: List<QvstAnswerBody>,
6263
): Boolean
6364

65+
// Fetch the user infos
6466
@Headers("Content-Type: application/json")
6567
@GET("xpeho/v1/user-infos")
6668
suspend fun fetchUserInfos(): UserInfos
69+
70+
/*// Update the user infos
71+
@Headers("Content-Type: application/json")
72+
@POST("xpeho/v1/update-password")
73+
suspend fun updatePassword(
74+
@Body editPassword: UserEditPassword,
75+
): Boolean*/
6776
}
6877

xpeapp_android/app/src/main/java/com/xpeho/xpeapp/domain/AuthenticationManager.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.util.Log
44
import androidx.annotation.VisibleForTesting
55
import com.xpeho.xpeapp.data.DatastorePref
66
import com.xpeho.xpeapp.data.entity.AuthentificationBody
7+
import com.xpeho.xpeapp.data.entity.user.UserEditPassword
78
import com.xpeho.xpeapp.data.model.AuthResult
89
import com.xpeho.xpeapp.data.model.WordpressToken
910
import com.xpeho.xpeapp.data.service.FirebaseService
@@ -107,11 +108,6 @@ class AuthenticationManager(
107108
wordpressUid?.let { datastorePref.setUserId(it) }
108109
}
109110

110-
suspend fun fetchUserInfos() {
111-
val userInfos = wordpressRepo.fetchUserInfos()
112-
Log.d("AuthenticationManager: fetchUserInfos", userInfos.toString())
113-
}
114-
115111
suspend fun logout() {
116112
firebaseService.signOut()
117113
datastorePref.clearAuthData()

xpeapp_android/app/src/main/java/com/xpeho/xpeapp/enums/Screens.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ enum class Screens {
77
Vacation,
88
Colleague,
99
Qvst,
10+
Profile
1011
}

xpeapp_android/app/src/main/java/com/xpeho/xpeapp/ui/Navigation.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com.xpeho.xpeapp.ui.page.LoginPage
1313
import com.xpeho.xpeapp.ui.page.NewsletterPage
1414
import com.xpeho.xpeapp.ui.page.qvst.QvstCampaignDetailPage
1515
import com.xpeho.xpeapp.ui.page.qvst.QvstPage
16+
import com.xpeho.xpeapp.ui.page.user.ProfilePage
1617

1718
fun NavGraphBuilder.navigationBuilder(
1819
navigationController: NavHostController,
@@ -70,4 +71,13 @@ fun NavGraphBuilder.navigationBuilder(
7071
}
7172
}
7273
}
74+
composable(route = Screens.Profile.name) {
75+
Layout(navigationController) {
76+
if (ffManager.isFeatureEnabled(FeatureFlippingEnum.PROFILE)) {
77+
ProfilePage(navigationController = navigationController)
78+
} else {
79+
DisabledFeaturePlaceHolder()
80+
}
81+
}
82+
}
7383
}

xpeapp_android/app/src/main/java/com/xpeho/xpeapp/ui/components/layout/Sidebar.kt

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ fun Sidebar(
168168
modifier = Modifier
169169
.padding(bottom = 20.dp, start = 18.dp, end = 18.dp),
170170
) {
171-
SidebarLogoutButtonSection(navigationController)
172171
HorizontalDivider(
173172
color = Color.White,
174173
thickness = 1.dp,
@@ -186,33 +185,6 @@ fun Sidebar(
186185
}
187186
}
188187

189-
@Composable
190-
fun SidebarLogoutButtonSection(
191-
navigationController: NavController
192-
) {
193-
Row(
194-
modifier = Modifier
195-
.fillMaxWidth(),
196-
horizontalArrangement = Arrangement.Center
197-
) {
198-
ClickyButton(
199-
label = "Déconnexion",
200-
size = 16.sp,
201-
verticalPadding = 5.dp,
202-
horizontalPadding = 15.dp,
203-
backgroundColor = Color.White,
204-
labelColor = XpehoColors.CONTENT_COLOR
205-
) {
206-
CoroutineScope(Dispatchers.IO).launch {
207-
XpeApp.appModule.authenticationManager.logout()
208-
}
209-
// Return to login page and clear the backstack
210-
navigationController.navigate(route = Screens.Login.name) {
211-
popUpTo(Screens.Home.name) { inclusive = true }
212-
}
213-
}
214-
}
215-
}
216188

217189
@Composable
218190
fun SidebarInfoSection(

0 commit comments

Comments
 (0)