Skip to content

Commit 3e079a8

Browse files
committed
Feature: Schedules - Add ScheduleDetail to add/edit them
1 parent 6e780db commit 3e079a8

35 files changed

+1476
-48
lines changed
371 Bytes
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.jarroyo.feature.schedules.api.destination
2+
3+
import androidx.lifecycle.SavedStateHandle
4+
import androidx.navigation.NamedNavArgument
5+
import androidx.navigation.NavType
6+
import androidx.navigation.navArgument
7+
import com.jarroyo.library.navigation.api.destination.NavigationDestination
8+
import kotlinx.serialization.Serializable
9+
10+
object ScheduleDetailDestination: NavigationDestination() {
11+
private const val ID_PARAM = "id"
12+
override val route: String = "scheduleDetail/{$ID_PARAM}"
13+
14+
override val arguments: List<NamedNavArgument> = listOf(
15+
navArgument(ID_PARAM) {
16+
type = NavType.StringType
17+
nullable = true
18+
defaultValue = null
19+
},
20+
)
21+
22+
fun get(id: String): String = route.replace("{$ID_PARAM}", id)
23+
24+
@Serializable
25+
data class Result(
26+
override val id: Long = uniqueId,
27+
val operationType: OperationType,
28+
) : NavigationDestination.Result() {
29+
enum class OperationType {
30+
CREATE,
31+
REMOVE,
32+
UPDATE,
33+
}
34+
}
35+
36+
object Arguments {
37+
fun getId(savedStateHandle: SavedStateHandle): String? = savedStateHandle[ID_PARAM]
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.jarroyo.feature.schedules.api.destination
2+
3+
import androidx.lifecycle.SavedStateHandle
4+
import androidx.navigation.NamedNavArgument
5+
import androidx.navigation.NavType
6+
import androidx.navigation.navArgument
7+
import com.jarroyo.feature.schedules.api.model.User
8+
import com.jarroyo.library.navigation.api.destination.NavigationDestination
9+
import kotlinx.serialization.Serializable
10+
11+
object UserSelectorDestination: NavigationDestination() {
12+
private const val USER_LIST_PARAM = "USER_LIST_PARAM"
13+
override val route: String = "userSelector/{$USER_LIST_PARAM}"
14+
15+
override val arguments: List<NamedNavArgument> = listOf(
16+
navArgument(USER_LIST_PARAM) {
17+
type = NavType.StringType
18+
nullable = true
19+
defaultValue = null
20+
},
21+
)
22+
23+
fun get(userList: String): String = route.replace("{$USER_LIST_PARAM}", userList)
24+
25+
@Serializable
26+
data class Result(
27+
override val id: Long = uniqueId,
28+
val userList: List<User>,
29+
) : NavigationDestination.Result()
30+
31+
object Arguments {
32+
fun getUserList(savedStateHandle: SavedStateHandle): String? = savedStateHandle[USER_LIST_PARAM]
33+
}
34+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.jarroyo.feature.schedules.api.ext
2+
3+
import com.jarroyo.feature.schedules.api.model.User
4+
5+
fun User.getFullName() = "$name $lastname"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.jarroyo.feature.schedules.api.interactor
2+
3+
import com.github.michaelbull.result.Result
4+
import com.jarroyo.feature.schedules.api.model.Schedule
5+
6+
interface AddScheduleInteractor {
7+
suspend operator fun invoke(
8+
schedule: Schedule,
9+
): Result<Boolean?, Exception>
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.jarroyo.feature.schedules.api.interactor
2+
3+
import com.github.michaelbull.result.Result
4+
import com.jarroyo.feature.schedules.api.model.Schedule
5+
6+
interface GetScheduleInteractor {
7+
suspend operator fun invoke(
8+
id: String,
9+
): Result<Schedule?, Exception>
10+
}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
package com.jarroyo.feature.schedules.api.interactor
22

33
import com.github.michaelbull.result.Result
4-
import kotlinx.serialization.Serializable
4+
import com.jarroyo.feature.schedules.api.model.Schedule
55

66
interface GetSchedulesInteractor {
77
suspend operator fun invoke(
88
): Result<List<Schedule>?, Exception>
99
}
10-
11-
@Serializable
12-
data class Schedule(
13-
val id: String,
14-
val name: String,
15-
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.jarroyo.feature.schedules.api.interactor
2+
3+
import com.github.michaelbull.result.Result
4+
import com.jarroyo.feature.schedules.api.model.User
5+
6+
interface GetUserInteractor {
7+
suspend operator fun invoke(
8+
id: String,
9+
): Result<User?, Exception>
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.jarroyo.feature.schedules.api.interactor
2+
3+
import com.github.michaelbull.result.Result
4+
import com.jarroyo.feature.schedules.api.model.User
5+
6+
interface GetUserListInteractor {
7+
suspend operator fun invoke(
8+
): Result<List<User>?, Exception>
9+
}

0 commit comments

Comments
 (0)