Skip to content

Commit 01b5557

Browse files
committed
feat(modif): add modifs
1 parent 36202a2 commit 01b5557

File tree

5 files changed

+97
-27
lines changed

5 files changed

+97
-27
lines changed

app/src/main/java/com/xpeho/xpeapp/ui/components/agenda/AgendaCard.kt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import com.xpeho.xpeho_ui_android.TagPill
1616
import com.xpeho.xpeho_ui_android.foundations.Colors as XpehoColors
1717
import com.xpeho.xpeapp.R
1818
import androidx.core.graphics.toColorInt
19+
import com.xpeho.xpeapp.ui.components.layout.TagPillCustom
1920
import java.text.SimpleDateFormat
2021
import java.util.Locale
2122

@@ -50,22 +51,20 @@ fun AgendaCard(
5051
@Composable
5152
private fun getTagsList(event: AgendaEvent, eventType: List<AgendaEventType>, color: Color): @Composable () -> Unit {
5253
val dateFormat = SimpleDateFormat("dd/MM", Locale.FRENCH)
54+
val timeInfo = listOfNotNull(
55+
event.startTime?.let { "De: $it" },
56+
event.endTime?.let { "à: $it" }
57+
).joinToString(separator = " ")
58+
5359
return {
5460
TagPill(
5561
label = dateFormat.format(event.date),
5662
backgroundColor = color,
5763
size = 9.sp
5864
)
59-
event.startTime?.let {
65+
if (timeInfo.isNotEmpty()) {
6066
TagPill(
61-
label = event.startTime.toString(),
62-
backgroundColor = color,
63-
size = 9.sp
64-
)
65-
}
66-
event.endTime?.let {
67-
TagPill(
68-
label = event.endTime.toString(),
67+
label = timeInfo,
6968
backgroundColor = color,
7069
size = 9.sp
7170
)
@@ -78,7 +77,8 @@ private fun getTagsList(event: AgendaEvent, eventType: List<AgendaEventType>, co
7877
)
7978
}
8079
event.location?.takeIf { it.isNotEmpty() }?.let {
81-
TagPill(
80+
TagPillCustom(
81+
iconResId = R.drawable.location,
8282
label = it,
8383
backgroundColor = color,
8484
size = 9.sp
@@ -112,13 +112,13 @@ private fun getTagColor(baseColor: Color): Color {
112112
}
113113

114114
private fun getEventTypeIcon(event: AgendaEvent, eventType: List<AgendaEventType>): Int {
115-
return when (eventType.firstOrNull { it.id == event.typeId.toInt() }?.label) {
116-
"XpeUp" -> R.drawable.birthday
117-
"Event interne" -> R.drawable.building
118-
"Formation" -> R.drawable.study
119-
"RSE" -> R.drawable.leaf
120-
"Activité" -> R.drawable.gamepad
121-
"Event externe" -> R.drawable.outside
122-
else -> R.drawable.building
115+
return when (eventType.firstOrNull { it.id == event.typeId.toInt() }?.label) {
116+
"XpeUp" -> R.drawable.birthday
117+
"Event interne" -> R.drawable.building
118+
"Formation" -> R.drawable.study
119+
"RSE" -> R.drawable.leaf
120+
"Activité" -> R.drawable.gamepad
121+
"Event externe" -> R.drawable.outside
122+
else -> R.drawable.building
123123
}
124124
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.xpeho.xpeapp.ui.components.layout
2+
3+
import androidx.compose.foundation.layout.Row
4+
import androidx.compose.foundation.layout.Spacer
5+
import androidx.compose.foundation.layout.padding
6+
import androidx.compose.foundation.layout.size
7+
import androidx.compose.foundation.layout.width
8+
import androidx.compose.foundation.shape.RoundedCornerShape
9+
import androidx.compose.material3.Card
10+
import androidx.compose.material3.CardDefaults
11+
import androidx.compose.material3.Icon
12+
import androidx.compose.material3.Text
13+
import androidx.compose.runtime.Composable
14+
import androidx.compose.ui.Alignment
15+
import androidx.compose.ui.Modifier
16+
import androidx.compose.ui.graphics.Color
17+
import androidx.compose.ui.res.painterResource
18+
import androidx.compose.ui.text.font.FontWeight
19+
import androidx.compose.ui.text.style.TextOverflow
20+
import androidx.compose.ui.unit.TextUnit
21+
import androidx.compose.ui.unit.dp
22+
import androidx.compose.ui.unit.sp
23+
import com.xpeho.xpeho_ui_android.foundations.Colors
24+
import com.xpeho.xpeho_ui_android.foundations.Fonts
25+
26+
@Composable
27+
fun TagPillCustom(
28+
label: String,
29+
size: TextUnit = 10.sp,
30+
backgroundColor: Color = Colors.GREEN_DARK_COLOR,
31+
labelColor: Color = Color.White,
32+
iconResId: Int? = null
33+
) {
34+
Card(
35+
shape = RoundedCornerShape(6.dp),
36+
colors = CardDefaults.cardColors(
37+
containerColor = backgroundColor,
38+
),
39+
) {
40+
Row(
41+
modifier = Modifier.padding(vertical = 1.dp, horizontal = 4.dp),
42+
verticalAlignment = Alignment.CenterVertically
43+
) {
44+
iconResId?.let {
45+
Icon(
46+
painter = painterResource(id = it),
47+
contentDescription = null,
48+
tint = labelColor,
49+
modifier = Modifier.size(12.dp)
50+
)
51+
Spacer(modifier = Modifier.width(4.dp))
52+
}
53+
Text(
54+
text = label.uppercase(),
55+
fontSize = size,
56+
fontFamily = Fonts.rubik,
57+
fontWeight = FontWeight.Medium,
58+
color = labelColor,
59+
softWrap = false,
60+
overflow = TextOverflow.Ellipsis,
61+
)
62+
}
63+
}
64+
}

app/src/main/java/com/xpeho/xpeapp/ui/page/AgendaPage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fun AgendaPage() {
5959
item {
6060
CustomDialog(
6161
title = stringResource(id = R.string.login_page_error_title),
62-
message = (agendaViewModel.state as QvstUiState.ERROR).error,
62+
message = (agendaViewModel.state as AgendaUiState.ERROR).error,
6363
) {
6464
agendaViewModel.resetState()
6565
}

app/src/main/java/com/xpeho/xpeapp/ui/page/HomePage.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ import com.xpeho.xpeapp.R
1818
import com.xpeho.xpeapp.XpeApp
1919
import com.xpeho.xpeapp.data.FeatureFlippingEnum
2020
import com.xpeho.xpeapp.data.entity.QvstCampaignEntity
21-
import com.xpeho.xpeapp.data.model.agenda.AgendaBirthday
22-
import com.xpeho.xpeapp.data.model.agenda.AgendaEvent
23-
import com.xpeho.xpeapp.data.model.agenda.AgendaEventType
2421
import com.xpeho.xpeapp.domain.FeatureFlippingState
2522
import com.xpeho.xpeapp.ui.components.CustomDialog
2623
import com.xpeho.xpeapp.ui.components.agenda.AgendaBirthdayItem
@@ -31,10 +28,10 @@ import com.xpeho.xpeapp.ui.components.layout.Title
3128
import com.xpeho.xpeapp.ui.components.newsletter.NewsletterPreview
3229
import com.xpeho.xpeapp.ui.components.qvst.QvstCardList
3330
import com.xpeho.xpeapp.ui.sendAnalyticsEvent
31+
import com.xpeho.xpeapp.ui.uiState.AgendaUiState
3432
import com.xpeho.xpeapp.ui.uiState.QvstActiveUiState
3533
import com.xpeho.xpeapp.ui.viewModel.FeatureFlippingViewModel
3634
import com.xpeho.xpeapp.ui.viewModel.agenda.AgendaViewModel
37-
import com.xpeho.xpeapp.ui.viewModel.agenda.AgendaViewModelState
3835
import com.xpeho.xpeapp.ui.viewModel.newsletter.NewsletterViewModel
3936
import com.xpeho.xpeapp.ui.viewModel.qvst.QvstActiveCampaignsViewModel
4037
import com.xpeho.xpeapp.ui.viewModel.viewModelFactory
@@ -163,9 +160,9 @@ fun HomePage(navigationController: NavController) {
163160
when (agendaViewModel.state) {
164161

165162
// If we successfully loaded the events
166-
is AgendaViewModelState.SUCCESS -> {
163+
is AgendaUiState.SUCCESS -> {
167164
item {
168-
val state = agendaViewModel.state as AgendaViewModelState.SUCCESS
165+
val state = agendaViewModel.state as AgendaUiState.SUCCESS
169166
val events = state.agendaEvent.map { AgendaEventItem(it) }
170167
val birthdays = state.agendaBirthday.map { AgendaBirthdayItem(it) }
171168
val items = (events + birthdays).sortedBy { it.date }
@@ -179,11 +176,11 @@ fun HomePage(navigationController: NavController) {
179176
}
180177

181178
// If there was an error loading the events
182-
is AgendaViewModelState.ERROR -> {
179+
is AgendaUiState.ERROR -> {
183180
item {
184181
CustomDialog(
185182
title = stringResource(id = R.string.login_page_error_title),
186-
message = (agendaViewModel.state as AgendaViewModelState.ERROR).error,
183+
message = (agendaViewModel.state as AgendaUiState.ERROR).error,
187184
) {
188185
agendaViewModel.resetState()
189186
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="384dp"
3+
android:height="512dp"
4+
android:viewportWidth="384"
5+
android:viewportHeight="512">
6+
<path
7+
android:fillColor="#FF000000"
8+
android:pathData="M215.7,499.2C267,435 384,279.4 384,192C384,86 298,0 192,0S0,86 0,192c0,87.4 117,243 168.3,307.2c12.3,15.3 35.1,15.3 47.4,0zM192,128a64,64 0,1 1,0 128,64 64,0 1,1 0,-128z"/>
9+
</vector>

0 commit comments

Comments
 (0)