repositories {
mavenCentral()
}
dependencies {
implementation("me.adkhambek.gsa:gsa-core:${latest_version}")
}
dependencies {
ksp("me.adkhambek.gsa:ciceron-compiler:${latest_version}")
}
abstract class Home private constructor()
@Screen(
installIn = Home::class,
)
class MainFragment : Fragment()
@Screen(
installIn = Home::class,
args = [
Arg(
name = "user_name",
type = String::class,
),
Arg(
name = "user_id",
type = Long::class,
)
]
)
class ProfileFragment : Fragment() {
// 1 option
private val arg: ProfileScreenArgs by navArgs()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// 2 option
val args = ProfileScreenArgs.fromBundle(requireArguments())
}
}
// Arg holders
data class ProfileScreenArgs(
val userName: String,
val userId: Long
) {
fun toBundle(): Bundle = TODO()
companion object {
fun fromBundle(bundle: Bundle): ProfileScreenArgs = TODO()
}
}
// Cicerone Screen factories
@Suppress("FunctionName")
object HomeScreens {
@JvmStatic
fun MainScreen(): FragmentScreen {
return FragmentScreen {
MainFragment()
}
}
@JvmStatic
fun ProfileScreen(userName: String,userId: Long): FragmentScreen {
val bundle : Bundle = TODO()
return FragmentScreen {
MainFragment().apply { arguments = bundle}
}
}
}