refactor: move BoxedValue to util
This commit is contained in:
parent
64e6ccf08b
commit
1fa2a9bc10
5 changed files with 15 additions and 12 deletions
|
|
@ -43,7 +43,7 @@ import com.google.maps.android.compose.rememberMarkerState
|
|||
import kotlinx.coroutines.flow.Flow
|
||||
import moe.lava.banksia.R
|
||||
import moe.lava.banksia.native.BanksiaTheme
|
||||
import moe.lava.banksia.ui.BoxedValue
|
||||
import moe.lava.banksia.util.BoxedValue
|
||||
import com.google.android.gms.maps.model.CameraPosition as GoogleCameraPosition
|
||||
|
||||
fun Point.toLatLng(): LatLng = LatLng(this.lat, this.lng)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import moe.lava.banksia.ui.BoxedValue
|
||||
import moe.lava.banksia.util.BoxedValue
|
||||
|
||||
enum class MarkerType {
|
||||
GENERIC_STOP,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ import moe.lava.banksia.native.maps.Marker
|
|||
import moe.lava.banksia.native.maps.MarkerType
|
||||
import moe.lava.banksia.native.maps.Point
|
||||
import moe.lava.banksia.native.maps.Polyline
|
||||
import moe.lava.banksia.ui.BoxedValue.Companion.box
|
||||
import moe.lava.banksia.util.BoxedValue
|
||||
import moe.lava.banksia.util.BoxedValue.Companion.box
|
||||
|
||||
data class RouteState(
|
||||
val route: PtvRoute,
|
||||
|
|
@ -50,14 +51,6 @@ data class BanksiaViewState(
|
|||
val polylines: List<Polyline> = listOf(),
|
||||
)
|
||||
|
||||
class BoxedValue<T>(val value: T) {
|
||||
operator fun component1() = value
|
||||
|
||||
companion object {
|
||||
fun <T> T.box() = BoxedValue(this)
|
||||
}
|
||||
}
|
||||
|
||||
class BanksiaViewModel : ViewModel() {
|
||||
private val iState = MutableStateFlow(BanksiaViewState())
|
||||
val state: StateFlow<BanksiaViewState> = iState.asStateFlow()
|
||||
|
|
@ -113,6 +106,7 @@ class BanksiaViewModel : ViewModel() {
|
|||
iState.update {
|
||||
it.copy(
|
||||
routeState = routeState,
|
||||
stopState = null,
|
||||
markers = listOf(),
|
||||
polylines = listOf(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package moe.lava.banksia.util
|
||||
|
||||
class BoxedValue<T>(val value: T) {
|
||||
operator fun component1() = value
|
||||
|
||||
companion object {
|
||||
fun <T> T.box() = BoxedValue(this)
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ import androidx.compose.ui.ExperimentalComposeUiApi
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalWindowInfo
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import moe.lava.banksia.ui.BoxedValue
|
||||
import moe.lava.banksia.util.BoxedValue
|
||||
|
||||
@OptIn(ExperimentalComposeUiApi::class)
|
||||
@Composable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue