Код: Выделить всё
navController.navigate("HomeScreen")
Код: Выделить всё
Process: com.rendev.fooddelivery, PID: 23827
java.lang.VerifyError: Verifier rejected class com.rendev.fooddelivery.screens.RegisterScreenKt:
void com.rendev.fooddelivery.screens.RegisterScreenKt.RegisterScreen(androidx.compose.ui.Modifier,
androidx.navigation.NavController, androidx.compose.runtime.Composer, int, int) failed to verify:
void com.rendev.fooddelivery.screens.RegisterScreenKt.RegisterScreen(androidx.compose.ui.Modifier,
androidx.navigation.NavController, androidx.compose.runtime.Composer, int, int): [0x1072] copy1 v0 a n d r o i d x . c o m p o s e . u i . M o d i f i e r c a t = 1 < b r / > ( d e c l a r a t i o n o f ' c o m . r e n d e v . f o o d d e l i v e r y . s c r e e n s . R e g i s t e r S c r e e n K t ' a p p e a r s i n / d a t a / a p p / ~ ~ Z 0 U c u h n o p 6 J L n i k Z X 1 m H F w = = / c o m . r e n d e v . f o o d d e l i v e r y - T r y 7 B m z g N 6 7 _ E k B M t I O o f Q = = / b a s e . a p k ! c l a s s e s 3 . d e x ) < b r / > < b r / > a t c o m . r e n d e v . f o o d d e l i v e r y . C o m p o s a b l e S i n g l e t o n s $ M a i n A c t i v i t y K t $ l a m b d a - 1 $ 1 $ 1 $ 2 . i n v o k e ( M a i n A c t i v i t y . k t : 5 2 ) < b r / > < b r / > a t c o m . r e n d e v . f o o d d e l i v e r y . C o m p o s a b l e S i n g l e t o n s $ M a i n A c t i v i t y K t $ l a m b d a - 1 $ 1 $ 1 $ 2 . i n v o k e ( M a i n A c t i v i t y . k t : 5 1 ) < b r / > < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . i n t e r n a l . C o m p o s a b l e L a m b d a I m p l . i n v o k e ( C o m p o s a b l e L a m b d a . j v m . k t : 1 3 9 ) < b r / > < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . i n t e r n a l . C o m p o s a b l e L a m b d a I m p l . i n v o k e ( C o m p o s a b l e L a m b d a . j v m . k t : 3 5 ) < b r / > < b r / > a t a n d r o i d x . n a v i g a t i o n . c o m p o s e . N a v H o s t K t $ N a v H o s t $ 3 2 $ 1 . i n v o k e ( N a v H o s t . k t : 6 9 4 ) < b r / > < b r / > a t a n d r o i d x . n a v i g a t i o n . c o m p o s e . N a v H o s t K t $ N a v H o s t $ 3 2 $ 1 . i n v o k e ( N a v H o s t . k t : 6 9 3 ) < b r / > < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . i n t e r n a l . C o m p o s a b l e L a m b d a I m p l . i n v o k e ( C o m p o s a b l e L a m b d a . j v m . k t : 1 0 9 ) < b r / > < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . i n t e r n a l . C o m p o s a b l e L a m b d a I m p l . i n v o k e ( C o m p o s a b l e L a m b d a . j v m . k t : 3 5 ) < b r / > < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . C o m p o s i t i o n L o c a l K t . C o m p o s i t i o n L o c a l P r o v i d e r ( C o m p o s i t i o n L o c a l . k t : 4 0 1 ) < b r / > < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . s a v e a b l e . S a v e a b l e S t a t e H o l d e r I m p l . S a v e a b l e S t a t e Provider(SaveableStateHolder.kt:85)
at androidx.navigation.compose.NavBackStackEntryProviderKt.SaveableStateProvider(NavBackStackEntryProvider.kt:65)
at androidx.navigation.compose.NavBackStackEntryProviderKt.access$SaveableStateProvider(NavBackStackEntryProvider.kt:1)
at androidx.navigation.compose.NavBackStackEntryProviderKt$LocalOwnersProvider$1.invoke(NavBackStackEntryProvider.kt:52)
at androidx.navigation.compose.NavBackStackEntryProviderKt$LocalOwnersProvider$1.invoke(NavBackStackEntryProvider.kt:51)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:380)
at androidx.navigation.compose.NavBackStackEntryProviderKt.LocalOwnersProvider(NavBackStackEntryProvider.kt:47)
at androidx.navigation.compose.NavHostKt$NavHost$32.invoke(NavHost.kt:693)
at androidx.navigation.compose.NavHostKt$NavHost$32.invoke(NavHost.kt:674)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:139)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent$6$1$5.invoke(AnimatedContent.kt:803)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent$6$1$5.invoke(AnimatedContent.kt:792)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:118)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.animation.AnimatedVisibilityKt.AnimatedEnterExitImpl(AnimatedVisibility.kt:771)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent$6$1.invoke(AnimatedContent.kt:774)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent$6$1.invoke(AnimatedContent.kt:757)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.animation.AnimatedContentKt.AnimatedContent(AnimatedContent.kt:816)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:646)
OutlineButtonCode:
Код: Выделить всё
@Composable
fun OutlineButtonElement(
navController: NavController,
firstNameText: String,
lastNameText: String,
eMailText: String,
passText: String,
context: Context,
checkState: MutableState,
borderColor: Color,
tint: Color
) {
OutlinedButton(
enabled = true,
onClick = {
val passwordError = validatePassword(passText)
if (
firstNameText == ""
|| lastNameText == ""
|| eMailText == ""
|| passText == ""
) {
makeText(
context,
"Please fill in all the details",
Toast.LENGTH_SHORT
).show()
return@OutlinedButton
}
if (passwordError != null) {
makeText(
context,
passwordError,
Toast.LENGTH_SHORT
).show()
return@OutlinedButton
}
val namesPattern = Regex("\"/^((?:\\p{Ll}|\\p{Lu}){2,30}\\s?){2,4}\$/g\"")
if (
firstNameText.contains(namesPattern)
|| lastNameText.contains(namesPattern)
) {
makeText(
context,
"First or Last name contains digits/special symbols",
Toast.LENGTH_SHORT
).show()
return@OutlinedButton
}
if (!(android.util.Patterns.EMAIL_ADDRESS.matcher(eMailText.replace(" ", ""))
.matches())
) {
makeText(
context,
"E-mail is not valid",
Toast.LENGTH_SHORT
).show()
return@OutlinedButton
} else Log.d("E-mail", "Email is valid")
if (!checkState.value) {
makeText(
context,
"Please agree with the Privacy Policy & Terms Of Use",
Toast.LENGTH_SHORT
).show()
return@OutlinedButton
}
data class Person(
val firstName: String,
val lastName: String,
val email: String,
)
val database =
Firebase.database("")
val myRef = database.getReference("users")
auth = Firebase.auth
auth.createUserWithEmailAndPassword(eMailText, passText)
.addOnCompleteListener { task ->
if (task.isSuccessful) {
navController.navigate("HomeScreen")
val eMail = eMailText.replace(".", "_").replace("#", "_")
.replace("$", "_").replace("[", "_").replace("]", "_")
val person =
Person(firstNameText, lastNameText, eMailText)
myRef.child(eMail).setValue(person)
makeText(
context,
"Registered",
Toast.LENGTH_SHORT
).show()
} else {
makeText(
context,
"Registration failed",
Toast.LENGTH_SHORT
).show()
}
}
},
border = BorderStroke(1.dp, color = borderColor),
colors = ButtonDefaults.outlinedButtonColors(
containerColor = Color.Transparent
),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 10.dp, vertical = 10.dp)
.height(45.dp),
) {
Icon(
painter = painterResource(id = R.drawable.registered),
modifier = Modifier
.size(30.dp)
.padding(horizontal = 5.dp),
contentDescription = null,
tint = tint
)
val textColorMain = if (isSystemInDarkTheme()) Color.White else Color.Black
Text(
text = "Register",
color = textColorMain,
fontSize = 20.sp,
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(horizontal = 5.dp)
)
}
}
Код: Выделить всё
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
FoodDeliveryTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
val navController = rememberNavController()
Background()
NavHost(navController = navController, startDestination = "RegisterScreen",
) {
composable(
route = "RegisterScreen",
enterTransition = {
fadeIn(
animationSpec = tween(
800, easing = LinearEasing
)
) + slideIntoContainer(
animationSpec = tween(800),
towards = AnimatedContentTransitionScope.SlideDirection.Right
)
},
) {
RegisterScreen(modifier = Modifier.padding(innerPadding), navController = navController)
}
composable(
route = "LoginScreen",
enterTransition = {
fadeIn(
animationSpec = tween(
800, easing = LinearEasing
)
) + slideIntoContainer(
animationSpec = tween(800),
towards = AnimatedContentTransitionScope.SlideDirection.Up
)
},
) {
LoginScreen(modifier = Modifier.padding(innerPadding), navController)
}
composable(
"ForgotPasswordScreen",
enterTransition =
{
fadeIn(
animationSpec = tween(
800, easing = LinearEasing
)
) + slideIntoContainer(
animationSpec = tween(800),
towards = AnimatedContentTransitionScope.SlideDirection.Left
)
},
) {
ForgotPasswordScreen(modifier = Modifier.padding(innerPadding), navController)
}
composable(
"HomeScreen",
enterTransition = {
fadeIn(
animationSpec = tween(
800, easing = LinearEasing
)
) + slideIntoContainer(
animationSpec = tween(800),
towards = AnimatedContentTransitionScope.SlideDirection.Down
)
} ,
) {
HomeScreen(modifier = Modifier.padding(innerPadding), navController)
}
}
}
}
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... linebutton
Мобильная версия