-
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 6 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
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/xpeho/xpeapp/data/dateConverter/DateTimeTypeAdapter.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,18 @@ | ||
| package com.xpeho.xpeapp.data.dateConverter | ||
|
|
||
| import com.google.gson.* | ||
| import java.lang.reflect.Type | ||
| import java.time.LocalTime | ||
| import java.time.format.DateTimeFormatter | ||
|
|
||
| class DateTimeTypeAdapter : JsonSerializer<LocalTime?>, JsonDeserializer<LocalTime?> { | ||
| private val formatter = DateTimeFormatter.ofPattern("HH:mm:ss") | ||
|
|
||
| override fun serialize(src: LocalTime?, typeOfSrc: Type?, context: JsonSerializationContext?): JsonElement { | ||
| return if (src == null) JsonNull.INSTANCE else JsonPrimitive(src.format(formatter)) | ||
| } | ||
|
|
||
| override fun deserialize(json: JsonElement?, typeOfT: Type?, context: JsonDeserializationContext?): LocalTime? { | ||
| return if (json == null || json.isJsonNull) null else LocalTime.parse(json.asString, formatter) | ||
| } | ||
| } |
37 changes: 37 additions & 0 deletions
37
app/src/main/java/com/xpeho/xpeapp/data/dateConverter/DateTypeAdapter.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,37 @@ | ||
| package com.xpeho.xpeapp.data.dateConverter | ||
|
|
||
| import com.google.gson.* | ||
| import java.lang.reflect.Type | ||
| import java.text.ParseException | ||
| import java.text.SimpleDateFormat | ||
| import java.util.Date | ||
| import java.util.Locale | ||
|
|
||
| class DateTypeAdapter : JsonSerializer<Date>, JsonDeserializer<Date> { | ||
| // Format for input dates | ||
| private val inputFormats = listOf( | ||
| SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.FRENCH), | ||
| SimpleDateFormat("yyyy-MM-dd", Locale.FRENCH) | ||
| ) | ||
| // Format for output dates | ||
| private val outputFormat = SimpleDateFormat("dd/MM/yyyy", Locale.FRENCH) | ||
|
|
||
| override fun serialize(src: Date?, typeOfSrc: Type?, context: JsonSerializationContext?): JsonElement { | ||
| return JsonPrimitive(src?.let { outputFormat.format(it) }) | ||
| } | ||
|
|
||
| override fun deserialize(json: JsonElement?, typeOfT: Type?, context: JsonDeserializationContext?): Date? { | ||
| val dateStr = json?.asString | ||
| if (dateStr != null) { | ||
| for (format in inputFormats) { | ||
| try { | ||
| return format.parse(dateStr) | ||
| } catch (e: ParseException) { | ||
| // Ignore and try the next format | ||
| println(e.message) | ||
| } | ||
| } | ||
| } | ||
| throw JsonParseException("Unparseable date in dateTypeAdapter: \"$dateStr\"") | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
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,11 @@ | ||
| package com.xpeho.xpeapp.data.model.agenda | ||
|
|
||
| import com.google.gson.annotations.SerializedName | ||
| import java.util.Date | ||
|
|
||
| data class AgendaBirthday( | ||
| val id: Int, | ||
| @SerializedName("first_name") val firstName: String, | ||
| val birthdate: Date, | ||
| val email: String, | ||
| ) |
16 changes: 16 additions & 0 deletions
16
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,16 @@ | ||
| package com.xpeho.xpeapp.data.model.agenda | ||
|
|
||
| import com.google.gson.annotations.SerializedName | ||
| import java.time.LocalTime | ||
| import java.util.Date | ||
|
|
||
| data class AgendaEvent( | ||
| val id: Int, | ||
| val date: Date, | ||
| @SerializedName("start_time") val startTime: LocalTime?, | ||
| @SerializedName("end_time") val endTime: LocalTime?, | ||
| 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: Int, | ||
| 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
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/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,55 @@ | ||
| 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.res.painterResource | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.compose.ui.unit.sp | ||
| import com.xpeho.xpeho_ui_android.CollapsableCard | ||
| import com.xpeho.xpeho_ui_android.TagPill | ||
| import com.xpeho.xpeapp.R | ||
| import com.xpeho.xpeapp.data.model.agenda.AgendaBirthday | ||
| import java.text.SimpleDateFormat | ||
| import java.util.Locale | ||
|
|
||
| @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 dateFormat = SimpleDateFormat("dd/MM/yyyy", Locale.FRENCH) | ||
|
|
||
| return { | ||
| TagPill( | ||
| label = dateFormat.format(birthday.birthdate), | ||
| backgroundColor = color, | ||
| size = 9.sp | ||
| ) | ||
| } | ||
| } | ||
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.