Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process: com.example.schoolsandinstruction, PID: 11787 kotlinx.serialization.SerializationException: Serializer for class 'Companion' is not found. Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied. #264

Open
Boanerges-Legacy opened this issue Jul 14, 2024 · 0 comments

Comments

@Boanerges-Legacy
Copy link

Boanerges-Legacy commented Jul 14, 2024

I have implemented type-safe navigation. My issue is I have a rapper #class with these: val screensInSetup = listOf(
AppScreens.Setup.RegionSetup,
AppScreens.Setup.DistrictSetup,
AppScreens.Setup.SchoolSetup,
AppScreens.Setup.CircuitSetup,
AppScreens.Setup.ManagementUnit,
AppScreens.Setup.AcademicYear
) which has been annotated @serializable. I set up the UI component with it.
GenAdminScreenSh.
This is how the navigation route is set:

LazyVerticalGrid(
columns = GridCells.Fixed(2), modifier = Modifier
.wrapContentSize()
.padding(
smallPadding
)
) {
items(screensInSetup) { screen ->
SetupActionCard(
title = screen.sTitle,
icon = screen.sIcon,
navController = navController,
modifier = Modifier.padding(8.dp),
//onClick = onNavigate
onClick = {
navController.navigate(AppScreens.Setup)
}
)
}
}

This is the card design:
@composable
fun SetupActionCard(
title: String,
@DrawableRes icon: Int,
modifier: Modifier = Modifier,
navController: NavHostController = rememberNavController(),
onClick: () -> Unit = {}
) {
Column(
modifier = modifier
.wrapContentHeight()
.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Card(
onClick = onClick,
modifier = Modifier
.fillMaxWidth()
.height(68.dp),
elevation = CardDefaults.cardElevation(4.dp),
colors = CardDefaults.cardColors(MaterialTheme.colorScheme.onPrimary)
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center,
modifier = Modifier
.fillMaxSize()
.padding(smallPadding) // Ensure full size and centered content
) {
Icon(
painter = painterResource(id = icon),
contentDescription = title,
modifier = Modifier
.size(32.dp)
.padding(end = iconSize), // Set a smaller size for the icon
//tint = MaterialTheme.colorScheme.primary
tint = colorResource(id = R.color.gold)
)
LabelTextComponent1(value = title, color = MaterialTheme.colorScheme.secondary)
}
}
}
}

This is the navGraph

@RequiresApi(Build.VERSION_CODES.O)
@composable
fun AppNavigationGraph(
modifier: Modifier = Modifier,
navController: NavHostController = rememberNavController(),
) {
val dialogOpen = rememberSaveable { mutableStateOf(true) }
NavHost(navController = navController, startDestination = GeneralAdmin) {
composable {
GenAdminScreen(navController = navController)
}

    composable <AppScreens.Setup.SchoolSetup> {
        SchoolSignUpForm()
    }

    composable <AppScreens.Setup.CircuitSetup> {
        CircuitCreatingScreen()
    }

    composable <AppScreens.Setup.ManagementUnit> {
        ManagementUnitScreen()
    }

    composable <AppScreens.Setup.AcademicYear>{
        //AcademicYearScreen()
    }

    composable <AppScreens.Setup.DistrictSetup> {
        DistrictCreatingScreen {}
    }

    composable<AppScreens.Setup.RegionSetup> {
        // RegionProfileCreatScreen()
    }

}

onClick = {
navController.navigate(AppScreens.Setup)
}
How should I handle this error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant