Capitalize first letters of name
This commit is contained in:
		
							
								
								
									
										11
									
								
								app/src/main/java/com/ti/mobpo/Helpers.kt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								app/src/main/java/com/ti/mobpo/Helpers.kt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
				
			|||||||
 | 
					package com.ti.mobpo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Locale
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fun capitalizeFirstLetterAfterHyphens(name: String): String {
 | 
				
			||||||
 | 
					    return name.replace("-", " ").split(" ").joinToString(" ") { it.replaceFirstChar {
 | 
				
			||||||
 | 
					        if (it.isLowerCase()) it.titlecase(
 | 
				
			||||||
 | 
					            Locale.getDefault()
 | 
				
			||||||
 | 
					        ) else it.toString()
 | 
				
			||||||
 | 
					    } }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -34,7 +34,9 @@ import androidx.lifecycle.viewmodel.compose.viewModel
 | 
				
			|||||||
import com.ti.mobpo.model.PokemonDetails
 | 
					import com.ti.mobpo.model.PokemonDetails
 | 
				
			||||||
import coil.compose.AsyncImage
 | 
					import coil.compose.AsyncImage
 | 
				
			||||||
import coil.request.ImageRequest
 | 
					import coil.request.ImageRequest
 | 
				
			||||||
 | 
					import com.ti.mobpo.capitalizeFirstLetterAfterHyphens
 | 
				
			||||||
import com.ti.mobpo.ui.theme.MobileSecurityTheme
 | 
					import com.ti.mobpo.ui.theme.MobileSecurityTheme
 | 
				
			||||||
 | 
					import java.util.Locale
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Composable
 | 
					@Composable
 | 
				
			||||||
fun PokeSearchScreen(pokeSearchViewModel: PokeSearchViewModel) {
 | 
					fun PokeSearchScreen(pokeSearchViewModel: PokeSearchViewModel) {
 | 
				
			||||||
@@ -101,7 +103,7 @@ fun PokemonCard(pokemon: PokemonDetails) {
 | 
				
			|||||||
                    .weight(1f)
 | 
					                    .weight(1f)
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
            Text(
 | 
					            Text(
 | 
				
			||||||
                text = pokemon.name.replace("-", " "),
 | 
					                text = capitalizeFirstLetterAfterHyphens(pokemon.name),
 | 
				
			||||||
                style = MaterialTheme.typography.bodySmall,
 | 
					                style = MaterialTheme.typography.bodySmall,
 | 
				
			||||||
                modifier = Modifier
 | 
					                modifier = Modifier
 | 
				
			||||||
                    .fillMaxWidth()
 | 
					                    .fillMaxWidth()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user