Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
TeamPrinterV2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aleksandr
TeamPrinterV2
Commits
be3bcf1e
Commit
be3bcf1e
authored
Jul 25, 2024
by
Aleksandr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drop current route when navigating with navigateSingleTopTo()
parent
b988457c
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
49 additions
and
11 deletions
+49
-11
app/src/main/java/com/isidroid/c23/domain/use_case/HomeUseCase.kt
+1
-0
app/src/main/java/com/isidroid/c23/ui/navigation/AppNavHost.kt
+10
-4
app/src/main/java/com/isidroid/c23/ui/navigation/Routes.kt
+7
-1
app/src/main/java/com/isidroid/c23/ui/navigation/destinations/HomeScreenDestination.kt
+1
-1
app/src/main/java/com/isidroid/c23/ui/navigation/destinations/MapScreenDestination.kt
+5
-0
app/src/main/java/com/isidroid/c23/ui/screen/home/HomeContract.kt
+1
-1
app/src/main/java/com/isidroid/c23/ui/screen/map/MapContract.kt
+2
-0
app/src/main/java/com/isidroid/c23/ui/screen/map/MapViewModel.kt
+18
-3
core/core/src/main/java/com/isidroid/core/ext/ExtNavigation.kt
+4
-1
No files found.
app/src/main/java/com/isidroid/c23/domain/use_case/HomeUseCase.kt
View file @
be3bcf1e
...
...
@@ -50,6 +50,7 @@ class HomeUseCase @Inject constructor(
// los gatos
lat
=
37.2451678
,
lng
=
-
121.9752617
,
uris
=
uris
)
uris
!=
null
->
HomeContract
.
Effect
.
Navigation
.
ToPreview
(
uris
)
...
...
app/src/main/java/com/isidroid/c23/ui/navigation/AppNavHost.kt
View file @
be3bcf1e
...
...
@@ -54,11 +54,17 @@ fun AppNavHost(
)
composable
(
route
=
routeMap
(
lat
=
"{${Argument.LATITUDE}}"
,
lng
=
"{${Argument.LONGITUDE}}"
,
spotCode
=
"{${Argument.SPOT_CODE}}"
),
route
=
routeMap
(
lat
=
"{${Argument.LATITUDE}}"
,
lng
=
"{${Argument.LONGITUDE}}"
,
spotCode
=
"{${Argument.SPOT_CODE}}"
,
uris
=
"{${Argument.URI}}"
),
arguments
=
listOf
(
makeNavArgument
(
Argument
.
LATITUDE
,
NavType
.
StringType
,
nullable
=
true
),
makeNavArgument
(
Argument
.
LONGITUDE
,
NavType
.
StringType
,
nullable
=
true
),
makeNavArgument
(
Argument
.
SPOT_CODE
,
NavType
.
StringType
,
nullable
=
true
),
makeNavArgument
(
Argument
.
LATITUDE
,
NavType
.
StringType
),
makeNavArgument
(
Argument
.
LONGITUDE
,
NavType
.
StringType
),
makeNavArgument
(
Argument
.
SPOT_CODE
,
NavType
.
StringType
),
makeNavArgument
(
Argument
.
URI
,
NavType
.
StringType
)
),
content
=
{
MapScreenDestination
(
navController
)
}
)
...
...
app/src/main/java/com/isidroid/c23/ui/navigation/Routes.kt
View file @
be3bcf1e
...
...
@@ -14,10 +14,16 @@ internal fun routeRenderPreview(uris: String = Argument.URI) = RenderPreview.rou
.
appendQueryParameter
(
Argument
.
URI
,
uris
)
.
toString
()
internal
fun
routeMap
(
lat
:
String
?
=
null
,
lng
:
String
?
=
null
,
spotCode
:
String
?
=
null
)
=
Map
.
route
.
toUri
().
buildUpon
()
internal
fun
routeMap
(
lat
:
String
?
=
null
,
lng
:
String
?
=
null
,
spotCode
:
String
?
=
null
,
uris
:
String
?
=
null
)
=
Map
.
route
.
toUri
().
buildUpon
()
.
appendQueryParameter
(
Argument
.
LATITUDE
,
lat
)
.
appendQueryParameter
(
Argument
.
LONGITUDE
,
lng
)
.
appendQueryParameter
(
Argument
.
SPOT_CODE
,
spotCode
)
.
appendQueryParameter
(
Argument
.
URI
,
uris
)
.
toString
()
internal
fun
routeJobDetails
(
id
:
String
=
Argument
.
ID
)
=
JobDetails
.
route
.
toUri
().
buildUpon
()
...
...
app/src/main/java/com/isidroid/c23/ui/navigation/destinations/HomeScreenDestination.kt
View file @
be3bcf1e
...
...
@@ -24,7 +24,7 @@ fun HomeScreenDestination(navController: NavHostController) {
val
route
=
when
(
effect
)
{
HomeContract
.
Effect
.
Navigation
.
ToLogin
->
TODO
(
"Session is not implemented"
)
HomeContract
.
Effect
.
Navigation
.
ToSelectContent
->
routeSelectContent
()
is
HomeContract
.
Effect
.
Navigation
.
ToSelectSpot
->
routeMap
(
lat
=
effect
.
lat
?.
toString
(),
lng
=
effect
.
lng
?.
toString
(),
spotCode
=
effect
.
spotCode
)
is
HomeContract
.
Effect
.
Navigation
.
ToSelectSpot
->
routeMap
(
lat
=
effect
.
lat
?.
toString
(),
lng
=
effect
.
lng
?.
toString
(),
spotCode
=
effect
.
spotCode
,
uris
=
effect
.
uris
)
is
HomeContract
.
Effect
.
Navigation
.
ToPreview
->
routeRenderPreview
(
uris
=
effect
.
uris
)
}
...
...
app/src/main/java/com/isidroid/c23/ui/navigation/destinations/MapScreenDestination.kt
View file @
be3bcf1e
...
...
@@ -3,6 +3,8 @@ package com.isidroid.c23.ui.navigation.destinations
import
androidx.compose.runtime.Composable
import
androidx.hilt.navigation.compose.hiltViewModel
import
androidx.navigation.NavHostController
import
com.isidroid.c23.ui.navigation.Home
import
com.isidroid.c23.ui.navigation.routeRenderPreview
import
com.isidroid.c23.ui.navigation.routeSelectContent
import
com.isidroid.c23.ui.screen.map.MapContract
import
com.isidroid.c23.ui.screen.map.MapScreen
...
...
@@ -23,6 +25,9 @@ fun MapScreenDestination(navController: NavHostController) {
when
(
effect
)
{
MapContract
.
Effect
.
Navigation
.
ToBack
->
navController
.
popBackStack
()
MapContract
.
Effect
.
Navigation
.
ToSelectContent
->
navController
.
navigateSingleTopTo
(
routeSelectContent
())
is
MapContract
.
Effect
.
Navigation
.
ToPreview
->
navController
.
navigateSingleTopTo
(
routeRenderPreview
(
uris
=
effect
.
uris
),
)
}
},
)
...
...
app/src/main/java/com/isidroid/c23/ui/screen/home/HomeContract.kt
View file @
be3bcf1e
...
...
@@ -17,7 +17,7 @@ class HomeContract {
sealed
interface
Navigation
:
Effect
{
data
object
ToLogin
:
Navigation
data
object
ToSelectContent
:
Navigation
data class
ToSelectSpot
(
val
lat
:
Double
?
=
null
,
val
lng
:
Double
?
=
null
,
val
spotCode
:
String
?
=
null
)
:
Navigation
data class
ToSelectSpot
(
val
lat
:
Double
?
=
null
,
val
lng
:
Double
?
=
null
,
val
spotCode
:
String
?
=
null
,
val
uris
:
String
?
)
:
Navigation
data class
ToPreview
(
val
uris
:
String
)
:
Navigation
}
}
...
...
app/src/main/java/com/isidroid/c23/ui/screen/map/MapContract.kt
View file @
be3bcf1e
package
com.isidroid.c23.ui.screen.map
import
com.isidroid.c23.ui.screen.home.HomeContract
import
com.isidroid.core.vm.ViewEvent
import
com.isidroid.core.vm.ViewSideEffect
import
com.isidroid.core.vm.ViewState
...
...
@@ -18,6 +19,7 @@ class MapContract {
sealed
interface
Navigation
:
Effect
{
data
object
ToBack
:
Navigation
data
object
ToSelectContent
:
Navigation
data class
ToPreview
(
val
uris
:
String
)
:
Navigation
}
}
...
...
app/src/main/java/com/isidroid/c23/ui/screen/map/MapViewModel.kt
View file @
be3bcf1e
...
...
@@ -32,6 +32,7 @@ class MapViewModel @Inject constructor(
private
var
_findSpotsJob
:
Job
?
=
null
private
val
_data
=
hashMapOf
<
String
,
RichSpot
>()
private
var
_markers
=
hashMapOf
<
String
,
List
<
RichSpot
>>()
private
var
_uris
:
String
?
=
null
private
val
_spotResultStateFlow
=
MutableStateFlow
<
List
<
MapMarker
>>(
emptyList
())
val
spotResultStateFlow
=
_spotResultStateFlow
.
asStateFlow
()
...
...
@@ -58,9 +59,15 @@ class MapViewModel @Inject constructor(
val
flowLat
=
savedStateHandle
.
getStateFlow
<
String
?>(
Argument
.
LATITUDE
,
null
)
val
flowLng
=
savedStateHandle
.
getStateFlow
<
String
?>(
Argument
.
LONGITUDE
,
null
)
val
flowSpotCode
=
savedStateHandle
.
getStateFlow
<
String
?>(
Argument
.
SPOT_CODE
,
null
)
val
flowUris
=
savedStateHandle
.
getStateFlow
<
String
?>(
Argument
.
URI
,
null
)
combine
(
flowLat
,
flowLng
,
flowSpotCode
)
{
lat
,
lng
,
spotCode
->
prepareData
(
lat
?.
toDoubleOrNull
(),
lng
?.
toDoubleOrNull
(),
spotCode
)
combine
(
flowLat
,
flowLng
,
flowSpotCode
,
flowUris
)
{
lat
,
lng
,
spotCode
,
uris
->
_uris
=
uris
prepareData
(
lat
=
lat
?.
toDoubleOrNull
(),
lng
=
lng
?.
toDoubleOrNull
(),
spotCode
=
spotCode
)
}.
collect
()
}
...
...
@@ -98,7 +105,7 @@ class MapViewModel @Inject constructor(
private
suspend
fun
selectSpot
(
id
:
String
)
{
useCase
.
selectSpot
(
_data
[
id
])
.
flowOn
(
Dispatchers
.
IO
)
.
collect
{
setEffect
{
MapContract
.
Effect
.
Navigation
.
ToSelectContent
}
}
.
collect
{
onSpotSelected
()
}
}
private
suspend
fun
moveToMyLocation
()
{
...
...
@@ -123,4 +130,11 @@ class MapViewModel @Inject constructor(
_spotResultStateFlow
.
emit
(
markers
)
}
private
fun
onSpotSelected
()
{
val
effect
=
_uris
?.
let
{
MapContract
.
Effect
.
Navigation
.
ToPreview
(
uris
=
it
)
}
?:
MapContract
.
Effect
.
Navigation
.
ToSelectContent
_uris
=
null
setEffect
{
effect
}
}
}
\ No newline at end of file
core/core/src/main/java/com/isidroid/core/ext/ExtNavigation.kt
View file @
be3bcf1e
...
...
@@ -9,6 +9,7 @@ import timber.log.Timber
fun
NavController
.
navigateSingleTopTo
(
route
:
String
,
dropCurrent
:
Boolean
=
true
,
isSaveState
:
Boolean
?
=
null
,
isLaunchSingleTop
:
Boolean
=
true
,
isRestoreState
:
Boolean
?
=
null
,
...
...
@@ -16,7 +17,9 @@ fun NavController.navigateSingleTopTo(
popupToRoute
:
String
?
=
null
)
{
navigate
(
route
)
{
val
node
=
popupToRoute
?.
let
{
graph
.
findNode
(
popupToRoute
)
}
?:
graph
.
findStartDestination
()
val
dropNode
=
if
(
dropCurrent
)
currentDestination
?.
route
else
popupToRoute
val
node
=
dropNode
?.
let
{
graph
.
findNode
(
popupToRoute
)
}
?:
graph
.
findStartDestination
()
popUpTo
(
node
.
id
)
{
inclusive
=
isInclusive
if
(
isSaveState
!=
null
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment