Skip to content

Commit 8c6c381

Browse files
committed
Move endpoints to HTTPS and make design little adaptive
1 parent 5366a87 commit 8c6c381

File tree

6 files changed

+337
-360
lines changed

6 files changed

+337
-360
lines changed

app/src/main/java/com/nekodev/hackathonapp/di/NetworkModule.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import com.nekodev.hackathonapp.network.api.DroneApi
55
import com.nekodev.hackathonapp.network.api.OrderApi
66
import com.nekodev.hackathonapp.network.datasource.NetworkDataSource
77
import com.nekodev.hackathonapp.network.datasource.OrdersDataSource
8-
import kotlinx.coroutines.time.withTimeout
9-
import kotlinx.coroutines.withTimeout
108
import kotlinx.serialization.ExperimentalSerializationApi
119
import kotlinx.serialization.json.Json
1210
import kotlinx.serialization.json.JsonNamingStrategy
@@ -27,10 +25,10 @@ val networkModule = module {
2725
}
2826
}
2927
single(named("droneEndpoint")) {
30-
Endpoint("http://91.107.125.237:8001/")
28+
Endpoint("https://dronepost.m41den.com/api/")
3129
}
3230
single(named("orderEndpoint")) {
33-
Endpoint("http://91.107.125.237:8002/api/v1/")
31+
Endpoint("https://dronepost.m41den.com/market/api/v1/")
3432
}
3533
single<Json> {
3634
Json {

app/src/main/java/com/nekodev/hackathonapp/navigation/root/DefaultRootComponent.kt

Lines changed: 4 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,19 @@ import com.arkivanov.decompose.ComponentContext
44
import com.arkivanov.decompose.router.stack.ChildStack
55
import com.arkivanov.decompose.router.stack.StackNavigation
66
import com.arkivanov.decompose.router.stack.childStack
7-
import com.arkivanov.decompose.router.stack.push
87
import com.arkivanov.decompose.router.stack.replaceAll
9-
import com.arkivanov.decompose.router.stack.replaceCurrent
108
import com.arkivanov.essenty.lifecycle.doOnCreate
11-
import com.arkivanov.essenty.lifecycle.doOnResume
12-
import com.nekodev.hackathonapp.data.OrderRepository
13-
import com.nekodev.hackathonapp.model.OrderState
14-
import com.nekodev.hackathonapp.navigation.root.RootComponent.Child.*
9+
import com.nekodev.hackathonapp.navigation.root.RootComponent.Child.DetailsScreenChild
10+
import com.nekodev.hackathonapp.navigation.root.RootComponent.Child.MainScreenChild
11+
import com.nekodev.hackathonapp.navigation.root.RootComponent.Child.SplashScreenChild
1512
import com.nekodev.hackathonapp.screens.details.RealDetailsScreenComponent
1613
import com.nekodev.hackathonapp.screens.main.RealMainScreenComponent
1714
import com.nekodev.hackathonapp.screens.splash.RealSplashScreenComponent
1815
import com.nekodev.hackathonapp.util.BaseComponent
1916
import com.nekodev.hackathonapp.util.toStateFlow
20-
import kotlinx.coroutines.Dispatchers
2117
import kotlinx.coroutines.delay
22-
import kotlinx.coroutines.flow.MutableStateFlow
2318
import kotlinx.coroutines.flow.StateFlow
24-
import kotlinx.coroutines.flow.update
2519
import kotlinx.coroutines.launch
26-
import kotlinx.coroutines.withContext
27-
import org.koin.core.component.inject
2820

2921
class DefaultRootComponent(
3022
componentContext: ComponentContext
@@ -42,16 +34,11 @@ class DefaultRootComponent(
4234

4335
override val stack: StateFlow<ChildStack<*, RootComponent.Child>> = _stack
4436

45-
private val _states: MutableStateFlow<List<OrderState>> = MutableStateFlow(emptyList())
46-
47-
private val repo: OrderRepository by inject()
48-
4937
private fun child(config: RootConfig, componentContext: ComponentContext): RootComponent.Child {
5038
return when(config){
5139
is RootConfig.MainScreen -> MainScreenChild(
5240
RealMainScreenComponent(
5341
componentContext = componentContext,
54-
_states = _states,
5542
navigateToDetails = {
5643
mainScope.launch {
5744
navigation.replaceAll(RootConfig.MainScreen, RootConfig.DetailsScreen(it))
@@ -69,48 +56,8 @@ class DefaultRootComponent(
6956
RealDetailsScreenComponent(
7057
componentContext = componentContext,
7158
orderId = config.orderId,
72-
updateOrders = { state ->
73-
_states.update {
74-
if (
75-
it.indexOfFirst { state ->
76-
when (state) {
77-
is OrderState.OnlyOrder -> {
78-
state.orderId == config.orderId
79-
}
80-
81-
is OrderState.OrderAndState -> {
82-
state.orderId == config.orderId
83-
}
84-
}
85-
} == -1
86-
) {
87-
val newList: MutableList<OrderState> = it.toMutableList()
88-
newList += state
89-
return@update newList
90-
} else {
91-
val newList = it.toMutableList()
92-
val lol = newList.indexOfFirst {
93-
when (state) {
94-
is OrderState.OnlyOrder -> {
95-
state.orderId == config.orderId
96-
}
97-
98-
is OrderState.OrderAndState -> {
99-
state.orderId == config.orderId
100-
}
101-
}
102-
}
103-
if (lol == -1) return@update newList
104-
newList.removeAt(lol)
105-
newList += state
106-
return@update newList
107-
}
108-
}
109-
},
11059
navigateToMain = {
11160
mainScope.launch {
112-
val result = withContext(Dispatchers.IO){ repo.getAllStates() }
113-
_states.value = result
11461
navigation.replaceAll(RootConfig.MainScreen)
11562
}
11663
}
@@ -122,21 +69,8 @@ class DefaultRootComponent(
12269
init {
12370
lifecycle.doOnCreate {
12471
mainScope.launch {
125-
val result = withContext(Dispatchers.IO){ repo.getAllStates() }
126-
_states.value = result
12772
delay(1_000L)
128-
navigation.replaceCurrent(RootConfig.MainScreen)
129-
}
130-
}
131-
lifecycle.doOnResume(isOneTime = false) {
132-
mainScope.launch {
133-
if (
134-
stack.value.active.configuration is RootConfig.MainScreen ||
135-
stack.value.active.configuration is RootConfig.DetailsScreen
136-
) {
137-
val result = withContext(Dispatchers.IO){ repo.getAllStates() }
138-
_states.value = result
139-
}
73+
navigation.replaceAll(RootConfig.MainScreen)
14074
}
14175
}
14276
}

0 commit comments

Comments
 (0)