|
1 | 1 | package com.revolgenx.anilib.staff.ui.model |
2 | 2 |
|
3 | | -import android.text.Spanned |
| 3 | +import android.content.Context |
4 | 4 | import androidx.compose.runtime.MutableState |
5 | 5 | import androidx.compose.runtime.mutableStateOf |
6 | 6 | import com.revolgenx.anilib.StaffQuery |
7 | 7 | import com.revolgenx.anilib.character.ui.model.CharacterConnectionModel |
8 | | -import com.revolgenx.anilib.common.ext.anilify |
9 | | -import com.revolgenx.anilib.common.ext.markdown |
10 | 8 | import com.revolgenx.anilib.common.ext.naText |
11 | 9 | import com.revolgenx.anilib.common.ui.model.BaseModel |
12 | 10 | import com.revolgenx.anilib.common.ui.model.FuzzyDateModel |
@@ -48,44 +46,42 @@ data class StaffModel( |
48 | 46 | // Media where the staff member has a production role |
49 | 47 | val staffMedia: MediaConnectionModel? = null, |
50 | 48 | val yearsActive: List<Int>? = null, |
51 | | - |
52 | | - var spannedDescription: Spanned? = null, |
53 | 49 | ) : BaseModel { |
54 | | - fun generalDescription(): String { |
| 50 | + fun generalDescription(context: Context): String { |
55 | 51 | var generalInfo = "" |
56 | 52 | dateOfBirth?.let { |
57 | 53 | val month = it.month?.let { m -> |
58 | 54 | Month.of(m).getDisplayName(TextStyle.SHORT, Locale.getDefault()) |
59 | 55 | } ?: "" |
60 | 56 | val day = it.day ?: "" |
61 | 57 | val year = it.year ?: "" |
62 | | - generalInfo += "<b>Birth:</b> $month $day, $year \n" |
| 58 | + generalInfo += "<b>${context.getString(anilib.i18n.R.string.birth)}:</b> $month $day, $year \n" |
63 | 59 | } |
64 | 60 | dateOfDeath?.let { |
65 | 61 | val month = it.month?.let { m -> |
66 | 62 | Month.of(m).getDisplayName(TextStyle.SHORT, Locale.getDefault()) |
67 | 63 | } ?: "" |
68 | 64 | val day = it.day ?: "" |
69 | 65 | val year = it.year ?: "" |
70 | | - generalInfo += "<b>Death:</b> $month $day, $year \n" |
| 66 | + generalInfo += "<b>${context.getString(anilib.i18n.R.string.death)}:</b> $month $day, $year \n" |
71 | 67 | } |
72 | 68 | age?.let { |
73 | | - generalInfo += "<b>Age:</b> $it \n" |
| 69 | + generalInfo += "<b>${context.getString(anilib.i18n.R.string.age)}:</b> $it \n" |
74 | 70 | } |
75 | 71 | gender?.let { |
76 | | - generalInfo += "<b>Gender:</b> $it \n" |
| 72 | + generalInfo += "<b>${context.getString(anilib.i18n.R.string.gender)}:</b> $it \n" |
77 | 73 | } |
78 | 74 | bloodType?.let { |
79 | | - generalInfo += "<b>Blood Type:</b> $it \n" |
| 75 | + generalInfo += "<b>${context.getString(anilib.i18n.R.string.blood_type)}:</b> $it \n" |
80 | 76 | } |
81 | 77 | yearsActive?.takeIf { it.isNotEmpty() }?.let { |
82 | 78 | val firstDate = it.getOrNull(0).naText() |
83 | | - val lastDate = it.getOrNull(1) ?: "Present" |
84 | | - generalInfo += "<b>Years active:</b> $firstDate-$lastDate \n" |
| 79 | + val lastDate = it.getOrNull(1) ?: context.getString(anilib.i18n.R.string.present) |
| 80 | + generalInfo += "<b>${context.getString(anilib.i18n.R.string.years_active)}:</b> $firstDate-$lastDate \n" |
85 | 81 | } |
86 | 82 |
|
87 | 83 | homeTown?.let { |
88 | | - generalInfo += "<b>Hometown:</b> $it \n" |
| 84 | + generalInfo += "<b>${context.getString(anilib.i18n.R.string.hometown)}:</b> $it \n" |
89 | 85 | } |
90 | 86 |
|
91 | 87 | if (generalInfo.isNotBlank()) { |
@@ -118,8 +114,6 @@ fun StaffQuery.Staff.toModel(): StaffModel { |
118 | 114 | yearsActive = yearsActive?.filterNotNull() |
119 | 115 | ) |
120 | 116 |
|
121 | | - model.spannedDescription = |
122 | | - markdown.toMarkdown(model.generalDescription() + anilify(model.description)) |
123 | 117 | return model |
124 | 118 | } |
125 | 119 |
|
|
0 commit comments