Skip to content

Commit

Permalink
details screen navigation and UI refinement
Browse files Browse the repository at this point in the history
  • Loading branch information
mutukuian committed May 14, 2024
1 parent d19045f commit 1b8c19b
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 114 deletions.
22 changes: 22 additions & 0 deletions .idea/androidTestResultsUserPreferences.xml

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

16 changes: 15 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ dependencies {
// implementation(libs.androidx.material3.android)
testImplementation(libs.junit)
testImplementation("junit:junit:4.12")
testImplementation("junit:junit:4.12")
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
Expand Down Expand Up @@ -121,8 +122,21 @@ dependencies {


testImplementation("junit:junit:4.13")
testImplementation("org.mockito:mockito-core:5.2.1")
testImplementation("org.mockito:mockito-core:5.7.0")
androidTestImplementation("org.mockito:mockito-core:5.7.0")
testImplementation("org.mockito.kotlin:mockito-kotlin:5.2.1")
androidTestImplementation("org.mockito.kotlin:mockito-kotlin:5.2.1")

// Use mockito-android for Android instrumentation tests
androidTestImplementation ("org.mockito:mockito-android:4.4.0")
androidTestImplementation ("androidx.arch.core:core-testing:2.2.0")

testImplementation("io.mockk:mockk:1.12.0")
androidTestImplementation("io.mockk:mockk-android:1.12.0")





//truth
testImplementation ("com.google.truth:truth:1.0.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ object RepositoryModule {
context.applicationContext,
ShipDatabase::class.java,
"ship_database"
).fallbackToDestructiveMigration().build()
).fallbackToDestructiveMigration()
.build()
}

@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data class ShipDetailDto(
val `class`: Int,
val course_deg: Any,
val home_port: String,
val image: String,
val image: String?,
val imo: Int,
val mmsi: Int,
val roles: List<String>,
Expand All @@ -27,5 +27,5 @@ data class ShipDetailDto(
)

fun ShipDetailDto.toShipDetail():ShipDetail{
return ShipDetail(active, home_port, ship_id, ship_name, ship_type,image, weight_kg, year_built)
return ShipDetail(active, image, home_port, ship_id, ship_name, ship_type, weight_kg, year_built)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,12 @@ import com.example.kocelainterview.domain.model.Ship


data class ShipDto(
// val abs: Int,

val active: Boolean,
// val attempted_landings: Any?,
// val `class`: Int,
// val course_deg: Any,
// val home_port: String,
val image: String?,
// val imo: Int,
// val mmsi: Int,
// val roles: List<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 url: String,
val weight_kg: Int,
// val weight_lbs: Int,
val year_built: Int
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.example.kocelainterview.domain.model


data class Ship(

val active: Boolean,
val image: String?,
val ship_id: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.example.kocelainterview.domain.model

data class ShipDetail(
val active: Boolean,
val image: String,
val image: String?,
val home_port: String,
val ship_id: String,
val ship_name: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.kocelainterview.presentation.ships_screen
package com.example.kocelainterview.presentation.search_controller.search_screen

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.MaterialTheme
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand All @@ -34,10 +34,10 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
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_screen.SearchBar
import com.example.kocelainterview.presentation.search_controller.search_view_model.SearchViewModel


Expand All @@ -48,9 +48,10 @@ fun ShipListScreen(

navController: NavController,
viewModel: ShipListViewModel = hiltViewModel(),
view:SearchViewModel = hiltViewModel()
searchViewModel:SearchViewModel = hiltViewModel()
) {
val state = viewModel.state.value
val searchState by searchViewModel.state.collectAsState()


var searchText by remember { mutableStateOf("") }
Expand All @@ -71,7 +72,7 @@ fun ShipListScreen(
searchQuery = searchText,
onSearchQueryChanged = { searchText = it }, // Update the search query
onSearchClicked = {
view.searchShip(searchText)
searchViewModel.searchShip(searchText)
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ShipListViewModel @Inject constructor(
getShips()
}

private fun getShips() {
fun getShips() {
viewModelScope.launch {
getShipsUseCase() // No search query parameter
.onEach { result ->
Expand Down

0 comments on commit 1b8c19b

Please sign in to comment.