Skip to content

Commit

Permalink
fix details screen
Browse files Browse the repository at this point in the history
  • Loading branch information
mutukuian committed May 13, 2024
1 parent 44c1695 commit e653d77
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 49 deletions.
3 changes: 3 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@ package com.example.kocelainterview.domain.model
data class ShipDetail(
val active: Boolean,
val home_port: String,
//val image: String,
val ship_id: String,
//val ship_model: Any,
val ship_name: String,
val ship_type: String,
//val speed_kn: Int,
//val status: String,
//val successful_landings: Any,
val weight_kg: Int,
//val weight_lbs: Int,
val year_built: Int
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
Expand All @@ -24,11 +23,11 @@ import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel



@Composable
fun ShipDetailScreen(
viewModel: ShipDetailViewModel = hiltViewModel()
) {

val state = viewModel.state.value

Box (modifier = Modifier.fillMaxSize()){
Expand All @@ -37,46 +36,46 @@ fun ShipDetailScreen(
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(20.dp)
) {
item{
Row (
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween
){
Text(
text = "${shipDetail.ship_name}. ${shipDetail.weight_kg} (${shipDetail.year_built})",
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier.weight(8f)
)
Text(
text = if (shipDetail.active) "active" else "inactive",
color = if (shipDetail.active) Color.Green else Color.Red,
fontStyle = FontStyle.Italic,
textAlign = TextAlign.End,
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier
.align(Alignment.CenterVertically)
.weight(2f)
)
Spacer(modifier = Modifier.height(15.dp))
Text(
text = "More Details",
style = MaterialTheme.typography.bodyMedium
)
Spacer(modifier = Modifier.height(15.dp))
Text(
text = "$shipDetail.ship_type " ,
fontStyle = FontStyle.Italic,
style = MaterialTheme.typography.bodyMedium,
)
Spacer(modifier = Modifier.height(4.dp))
Text(
text = "$shipDetail.home_port",
fontStyle = FontStyle.Italic,
style = MaterialTheme.typography.bodyMedium
)
}
item{
Row (
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween
){
Text(
text = "$shipDetail.ship_name. $shipDetail.weight_kg ($shipDetail.year_built)",
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier.weight(8f)
)
Text(
text = if (shipDetail.active) "active" else "inactive",
color = if (shipDetail.active) Color.Green else Color.Red,
fontStyle = FontStyle.Italic,
textAlign = TextAlign.End,
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier
.align(Alignment.CenterVertically)
.weight(2f)
)
Spacer(modifier = Modifier.height(15.dp))
Text(
text = "More Details",
style = MaterialTheme.typography.bodyMedium
)
Spacer(modifier = Modifier.height(15.dp))
Text(
text = "$shipDetail.ship_type " ,
fontStyle = FontStyle.Italic,
style = MaterialTheme.typography.bodyMedium,
)
Spacer(modifier = Modifier.height(4.dp))
Text(
text = "$shipDetail.home_port",
fontStyle = FontStyle.Italic,
style = MaterialTheme.typography.bodyMedium
)
}

}
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import androidx.navigation.NavController
import coil.annotation.ExperimentalCoilApi
import coil.compose.rememberAsyncImagePainter
import com.example.kocelainterview.domain.model.Ship
import com.example.kocelainterview.presentation.navigation.Screen
import com.example.kocelainterview.presentation.search_controller.search_view_model.SearchViewModel


Expand Down Expand Up @@ -88,7 +89,9 @@ fun ShipListScreen(
}

items(state.ships) { ship ->
ShipImageCard(ships = ship)
ShipImageCard(ships = ship, onItemClick = {
navController.navigate(Screen.ShipDetailScreen.route)
})
}
}
if (state.error.isNotBlank()) {
Expand All @@ -107,7 +110,7 @@ fun ShipListScreen(

@OptIn(ExperimentalCoilApi::class)
@Composable
fun ShipImageCard(ships: Ship){
fun ShipImageCard(ships: Ship,onItemClick:(Ship)->Unit){
val imagePainter = rememberAsyncImagePainter(model = ships.image)
Card(
shape = MaterialTheme.shapes.medium,
Expand Down

0 comments on commit e653d77

Please sign in to comment.