-
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 1 commit
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
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, | ||
| 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 | ||
| ) |
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
115 changes: 115 additions & 0 deletions
115
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,115 @@ | ||
| 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.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.xpeho_ui_android.CollapsableCard | ||
| import com.xpeho.xpeho_ui_android.TagPill | ||
| import com.xpeho.xpeho_ui_android.R.drawable as XpehoRes | ||
| import com.xpeho.xpeho_ui_android.foundations.Colors as XpehoColors | ||
|
|
||
| @Composable | ||
| fun AgendaCard( | ||
| event: AgendaEvent, | ||
| collapsable: Boolean = true, | ||
| defaultOpen: Boolean = false | ||
| ) { | ||
| CollapsableCard( | ||
| label = event.title, | ||
| tags = getTagsList(event = event), | ||
| icon = { | ||
| Icon( | ||
| painter = painterResource(id = XpehoRes.qvst), | ||
| contentDescription = "event", | ||
| tint = XpehoColors.XPEHO_COLOR, | ||
| modifier = Modifier | ||
| .size(22.dp) | ||
| ) | ||
| }, | ||
| size = 16.sp, | ||
| collapsable = collapsable, | ||
| defaultOpen = defaultOpen | ||
| ) | ||
| } | ||
|
|
||
| // Get the tag pills for a campaign | ||
| private fun getTagsList(event: AgendaEvent): @Composable() (() -> Unit) { | ||
|
|
||
| // Init the tagsList depending the data that we got | ||
| val tagPillTheme: @Composable() () -> Unit = { | ||
| TagPill( | ||
| label = event.topic, | ||
| backgroundColor = XpehoColors.GREEN_DARK_COLOR, | ||
| size = 9.sp | ||
| ) | ||
| } | ||
|
|
||
| var tagPillDeadline: @Composable() () -> Unit | ||
|
|
||
| // If the campaign is open we indicate the days remaining | ||
| // If it end in less or equal than 3 days and it hasn't been completed -> the color is red | ||
| // Else we indicate the end date | ||
| // if (event.status == "OPEN") { | ||
| // tagPillDeadline = { | ||
| // TagPill( | ||
| // label = | ||
| // when (campaign.remainingDays) { | ||
| // 0 -> "Dernier jour" | ||
| // 1 -> "${campaign.remainingDays} jour restant" | ||
| // else -> "${campaign.remainingDays} jours restants" | ||
| // }, | ||
| // backgroundColor = | ||
| // if (campaign.completed || (campaign.remainingDays > 3)) | ||
| // XpehoColors.GREEN_DARK_COLOR | ||
| // else | ||
| // XpehoColors.RED_INFO_COLOR, | ||
| // size = 9.sp | ||
| // ) | ||
| // } | ||
| // } else { | ||
| // val formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy") | ||
| // // val endDate = LocalDate.parse(campaign.endDate, DateTimeFormatter.ISO_DATE) | ||
| // tagPillDeadline = { | ||
| // TagPill( | ||
| // label = "endDate", | ||
| // backgroundColor = XpehoColors.GREEN_DARK_COLOR, | ||
| // size = 9.sp | ||
| // ) | ||
| // } | ||
| // } | ||
|
|
||
| val tagPillCompletion: @Composable() () -> Unit | ||
|
||
|
|
||
| // If campaign is completed we indicate that it has been complete | ||
| // Else if it is always open we indicate it can always be completed | ||
| // if (campaign.completed) { | ||
| // tagPillCompletion = { | ||
| // TagPill( | ||
| // label = "Complétée", | ||
| // backgroundColor = XpehoColors.XPEHO_COLOR, | ||
| // size = 9.sp | ||
| // ) | ||
| // } | ||
| // } else if (campaign.status == "OPEN") { | ||
| // tagPillCompletion = { | ||
| // TagPill( | ||
| // label = "À compléter", | ||
| // backgroundColor = XpehoColors.GREEN_DARK_COLOR, | ||
| // size = 9.sp | ||
| // ) | ||
| // } | ||
| // } else { | ||
| // tagPillCompletion = {} | ||
| // } | ||
|
|
||
| return { | ||
| tagPillTheme.invoke() | ||
| //tagPillDeadline.invoke() | ||
| //tagPillCompletion.invoke() | ||
| } | ||
| } | ||
33 changes: 33 additions & 0 deletions
33
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,33 @@ | ||
| 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.AgendaEvent | ||
| import com.xpeho.xpeapp.ui.components.layout.NoContentPlaceHolder | ||
|
|
||
| @Composable | ||
| fun AgendaCardList( | ||
| events: List<AgendaEvent>, | ||
| collapsable: Boolean = true | ||
| ) { | ||
| if (events.isEmpty()) { | ||
| // Display a placeholder if there is no events | ||
| NoContentPlaceHolder() | ||
| } else { | ||
| // Display the list of events | ||
| Column { | ||
| for (event in events) { | ||
| AgendaCard( | ||
| event = event, | ||
| collapsable = collapsable, | ||
| defaultOpen = true | ||
| ) | ||
| Spacer(modifier = Modifier.height(10.dp)) | ||
| } | ||
| } | ||
| } | ||
| } |
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
55 changes: 55 additions & 0 deletions
55
app/src/main/java/com/xpeho/xpeapp/ui/viewModel/agenda/AgendaViewModel.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,55 @@ | ||
| package com.xpeho.xpeapp.ui.viewModel.agenda | ||
|
|
||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.mutableStateOf | ||
| import androidx.compose.runtime.setValue | ||
| import androidx.lifecycle.ViewModel | ||
| import androidx.lifecycle.viewModelScope | ||
| import com.xpeho.xpeapp.XpeApp | ||
| import com.xpeho.xpeapp.data.model.agenda.AgendaEvent | ||
|
|
||
| import kotlinx.coroutines.launch | ||
|
|
||
| class AgendaViewModel : ViewModel() { | ||
|
|
||
| var state: AgendaViewModelState by mutableStateOf(AgendaViewModelState.EMPTY) | ||
|
|
||
| private fun getAllEvents() { | ||
| viewModelScope.launch { | ||
| // Get All Events | ||
| val result = XpeApp.appModule.wordpressRepository.getAllAgendaEvents() | ||
|
|
||
| // Update state | ||
| state = if (result != null) { | ||
| if (result.isEmpty()) { | ||
| AgendaViewModelState.EMPTY | ||
| } else { | ||
| AgendaViewModelState.SUCCESS( | ||
| agendaEvent = result | ||
| ) | ||
| } | ||
| } else { | ||
| AgendaViewModelState.ERROR("Erreur de chargement de tout les événements") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun resetState() { | ||
| state = AgendaViewModelState.EMPTY | ||
| } | ||
|
|
||
| fun updateState() { | ||
| resetState() | ||
| getAllEvents() | ||
| } | ||
|
|
||
| } | ||
|
|
||
| interface AgendaViewModelState { | ||
| object EMPTY : AgendaViewModelState | ||
| object LOADING : AgendaViewModelState | ||
| data class ERROR(val error: String) : AgendaViewModelState | ||
| data class SUCCESS( | ||
| val agendaEvent: List<AgendaEvent>, | ||
| ) : AgendaViewModelState | ||
| } |
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.