-
Notifications
You must be signed in to change notification settings - Fork 0
feat(notToBeMissedPartOfAgenda): adding the part notBeMissed Events #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8e47d89
feat(notToBeMissedPartOfAgenda): adding the part notBeMissed Events
Theo-lbg dc7b82b
feat(eventsAndBirthday): adding all
Theo-lbg ffb1d73
feat(detekt): refine the error of detekt
Theo-lbg d87a252
feat(tests): correcting the tests
Theo-lbg 398f26c
feat(addTimeAndDateAdapter): adding converter to date and time
Theo-lbg ab6a23b
feat(tests): refine tests
Theo-lbg f73c6a8
feat(pull_request): adding pull request template
Theo-lbg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/xpeho/xpeapp/data/model/agenda/AgendaBirthday.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.xpeho.xpeapp.data.model.agenda | ||
|
|
||
| import com.google.gson.annotations.SerializedName | ||
|
|
||
| data class AgendaBirthday( | ||
| val id: String?, | ||
| @SerializedName("first_name") val firstName: String?, | ||
| val birthdate: String?, | ||
| val email: String, | ||
| ) | ||
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/xpeho/xpeapp/data/model/agenda/AgendaEvent.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.xpeho.xpeapp.data.model.agenda | ||
|
|
||
| import com.google.gson.annotations.SerializedName | ||
|
|
||
| data class AgendaEvent( | ||
| val id: String?, | ||
Theo-lbg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| val date: String, | ||
| @SerializedName("start_time") val startTime: String?, | ||
| @SerializedName("end_time") val endTime: String?, | ||
| val title: String, | ||
| val location: String?, | ||
| @SerializedName("type_id") val typeId: String, | ||
| val topic: String? | ||
| ) | ||
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/xpeho/xpeapp/data/model/agenda/AgendaEventType.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.xpeho.xpeapp.data.model.agenda | ||
|
|
||
| import com.google.gson.annotations.SerializedName | ||
|
|
||
| data class AgendaEventType( | ||
| val id: String?, | ||
Theo-lbg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| val label: String, | ||
| @SerializedName("color_code") val colorCode: String | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
app/src/main/java/com/xpeho/xpeapp/ui/components/agenda/AgendaBirthdayCard.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package com.xpeho.xpeapp.ui.components.agenda | ||
|
|
||
| import androidx.compose.foundation.layout.size | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.ui.graphics.compositeOver | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.compose.ui.unit.sp | ||
| import com.xpeho.xpeapp.data.model.agenda.AgendaEvent | ||
| import com.xpeho.xpeapp.data.model.agenda.AgendaEventType | ||
| import com.xpeho.xpeho_ui_android.CollapsableCard | ||
| import com.xpeho.xpeho_ui_android.TagPill | ||
| import com.xpeho.xpeho_ui_android.foundations.Colors as XpehoColors | ||
| import com.xpeho.xpeapp.R | ||
| import java.time.LocalDateTime | ||
| import java.time.format.DateTimeFormatter | ||
| import androidx.core.graphics.toColorInt | ||
| import com.xpeho.xpeapp.data.model.agenda.AgendaBirthday | ||
| import java.time.LocalDate | ||
| import java.time.LocalTime | ||
|
|
||
| @Composable | ||
| fun AgendaBirthdayCard( | ||
| birthday: AgendaBirthday, | ||
| collapsable: Boolean = true, | ||
| defaultOpen: Boolean = false | ||
| ) { | ||
| val tagColor = Color(0xFFFF7EEA) | ||
|
||
| val eventTypeIcon = R.drawable.birthday | ||
|
|
||
| CollapsableCard( | ||
| label = "Anniversaire de ${birthday.firstName}", | ||
| tags = getBirthdayTagsList(birthday, tagColor), | ||
| icon = { | ||
| Icon( | ||
| painter = painterResource(id = eventTypeIcon), | ||
| contentDescription = "birthday", | ||
| tint = tagColor, | ||
| modifier = Modifier.size(22.dp) | ||
| ) | ||
| }, | ||
| size = 16.sp, | ||
| collapsable = collapsable, | ||
| defaultOpen = defaultOpen | ||
| ) | ||
| } | ||
|
|
||
| @Composable | ||
| private fun getBirthdayTagsList(birthday: AgendaBirthday, color: Color): @Composable () -> Unit { | ||
| val formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy") | ||
|
|
||
| return { | ||
| birthday.birthdate?.takeIf { it.isNotEmpty() }?.let { | ||
| val formattedDate = LocalDate.parse(it, DateTimeFormatter.ofPattern("yyyy-MM-dd")).format(formatter) | ||
| TagPill( | ||
| label = formattedDate, | ||
| backgroundColor = color, | ||
| size = 9.sp | ||
| ) | ||
| } | ||
| } | ||
| } | ||
134 changes: 134 additions & 0 deletions
134
app/src/main/java/com/xpeho/xpeapp/ui/components/agenda/AgendaCard.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| package com.xpeho.xpeapp.ui.components.agenda | ||
|
|
||
| import androidx.compose.foundation.layout.size | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.ui.graphics.compositeOver | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.compose.ui.unit.sp | ||
| import com.xpeho.xpeapp.data.model.agenda.AgendaEvent | ||
| import com.xpeho.xpeapp.data.model.agenda.AgendaEventType | ||
| import com.xpeho.xpeho_ui_android.CollapsableCard | ||
| import com.xpeho.xpeho_ui_android.TagPill | ||
| import com.xpeho.xpeho_ui_android.foundations.Colors as XpehoColors | ||
| import com.xpeho.xpeapp.R | ||
| import java.time.LocalDateTime | ||
| import java.time.format.DateTimeFormatter | ||
| import androidx.core.graphics.toColorInt | ||
| import java.time.LocalTime | ||
|
|
||
| @Composable | ||
| fun AgendaCard( | ||
| event: AgendaEvent, | ||
| eventTypes: List<AgendaEventType>, | ||
| collapsable: Boolean = true, | ||
| defaultOpen: Boolean = false | ||
| ) { | ||
| val eventTypeColor = getEventTypeColor(event, eventTypes) | ||
| val tagColor = getTagColor(eventTypeColor) | ||
| val eventTypeIcon = getEventTypeIcon(event, eventTypes) | ||
|
|
||
| CollapsableCard( | ||
| label = event.title, | ||
| tags = getTagsList(event, eventTypes, tagColor), | ||
| icon = { | ||
| Icon( | ||
| painter = painterResource(id = eventTypeIcon), | ||
| contentDescription = "event", | ||
| tint = eventTypeColor, | ||
| modifier = Modifier.size(22.dp) | ||
| ) | ||
| }, | ||
| size = 16.sp, | ||
| collapsable = collapsable, | ||
| defaultOpen = defaultOpen | ||
| ) | ||
| } | ||
|
|
||
| @Composable | ||
| private fun getTagsList(event: AgendaEvent, eventType: List<AgendaEventType>, color: Color): @Composable () -> Unit { | ||
| val formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy") | ||
| val timeFormatter = DateTimeFormatter.ofPattern("HH-mm") | ||
| val timeOfData = DateTimeFormatter.ofPattern("HH:mm:ss") | ||
|
|
||
| return { | ||
| if (event.date.isNotEmpty()) { | ||
| val formattedDate = LocalDateTime.parse(event.date, | ||
| DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")).format(formatter) | ||
| TagPill( | ||
| label = formattedDate, | ||
| backgroundColor = color, | ||
| size = 9.sp | ||
| ) | ||
| } | ||
| event.startTime?.takeIf { it.isNotEmpty() }?.let { | ||
| val formattedTime = LocalTime.parse(it, timeOfData).format(timeFormatter) | ||
| TagPill( | ||
| label = formattedTime, | ||
| backgroundColor = color, | ||
| size = 9.sp | ||
| ) | ||
| } | ||
| event.endTime?.takeIf { it.isNotEmpty() }?.let { | ||
| val formattedTime = LocalTime.parse(it, timeOfData).format(timeFormatter) | ||
| TagPill( | ||
| label = formattedTime, | ||
| backgroundColor = color, | ||
| size = 9.sp | ||
| ) | ||
| } | ||
| eventType.firstOrNull { it.id == event.typeId }?.let { | ||
| TagPill( | ||
| label = it.label, | ||
| backgroundColor = color, | ||
| size = 9.sp | ||
| ) | ||
| } | ||
| event.location?.takeIf { it.isNotEmpty() }?.let { | ||
| TagPill( | ||
| label = it, | ||
| backgroundColor = color, | ||
| size = 9.sp | ||
| ) | ||
| } | ||
| event.topic?.takeIf { it.isNotEmpty() }?.let { | ||
| TagPill( | ||
| label = it, | ||
| backgroundColor = color, | ||
| size = 9.sp | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun getEventTypeColor(event: AgendaEvent, eventTypes: List<AgendaEventType>): Color { | ||
| val eventType = eventTypes.firstOrNull { it.id == event.typeId } | ||
| return if (eventType != null) { | ||
| Color(("#" + eventType.colorCode.trimStart('#')).toColorInt()) | ||
| } else { | ||
| XpehoColors.GREEN_DARK_COLOR | ||
| } | ||
| } | ||
|
|
||
| private const val BASE_COLOR_HEX = 0xFF7C4000 | ||
| private const val ALPHA_VALUE = 0.2f | ||
|
|
||
| private fun getTagColor(baseColor: Color): Color { | ||
| val overlayColor = Color(BASE_COLOR_HEX).copy(alpha = ALPHA_VALUE) | ||
| return overlayColor.compositeOver(baseColor) | ||
| } | ||
|
|
||
| private fun getEventTypeIcon(event: AgendaEvent, eventType: List<AgendaEventType>): Int { | ||
| return when (eventType.firstOrNull { it.id == event.typeId }?.label) { | ||
| "XpeUp" -> R.drawable.birthday | ||
| "Event interne" -> R.drawable.building | ||
| "Formation" -> R.drawable.study | ||
| "RSE" -> R.drawable.leaf | ||
| "Activité" -> R.drawable.gamepad | ||
| "Event externe" -> R.drawable.outside | ||
| else -> R.drawable.building | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
app/src/main/java/com/xpeho/xpeapp/ui/components/agenda/AgendaCardList.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package com.xpeho.xpeapp.ui.components.agenda | ||
|
|
||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.Spacer | ||
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.unit.dp | ||
| import com.xpeho.xpeapp.data.model.agenda.AgendaBirthday | ||
| import com.xpeho.xpeapp.data.model.agenda.AgendaEvent | ||
| import com.xpeho.xpeapp.data.model.agenda.AgendaEventType | ||
| @Composable | ||
| fun AgendaCardList( | ||
| events: List<AgendaEvent>, | ||
| birthdays: List<AgendaBirthday>, | ||
| eventsTypes: List<AgendaEventType>, | ||
| collapsable: Boolean = true | ||
| ) { | ||
| Column { | ||
| for (birthday in birthdays) { | ||
| AgendaBirthdayCard( | ||
| birthday = birthday, | ||
| collapsable = collapsable, | ||
| defaultOpen = true | ||
| ) | ||
| Spacer(modifier = Modifier.height(10.dp)) | ||
| } | ||
| for (event in events) { | ||
| AgendaCard( | ||
| event = event, | ||
| eventTypes = eventsTypes, | ||
| collapsable = collapsable, | ||
| defaultOpen = true | ||
| ) | ||
| Spacer(modifier = Modifier.height(10.dp)) | ||
| } | ||
|
|
||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.