package com.suno.android.ui.screens.onboarding.welcome import android.os.Build.VERSION import android.os.Build.VERSION_CODES import androidx.annotation.OptIn import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.safeDrawing import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.drawWithContent import androidx.compose.ui.draw.paint import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.LinkAnnotation import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.TextLinkStyles import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.withLink import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.media3.common.util.UnstableApi import androidx.media3.ui.compose.PlayerSurface import androidx.media3.ui.compose.modifiers.resizeWithContentScale import androidx.media3.ui.compose.state.rememberPresentationState import com.suno.android.common_ui.R import com.suno.android.common_ui.components.aura.auraBackground import com.suno.android.common_ui.extensions.conditional import com.suno.android.common_ui.theme.ExtendedTheme import com.suno.android.common_ui.theme.SunoTheme import com.suno.android.common_res.R as CommonResR @OptIn(UnstableApi::class) @Composable fun WelcomeScreen( vm: WelcomeScreenVM?, onLoginClicked: () -> Unit, onSignUpClicked: () -> Unit, ) { LaunchedEffect(Unit) { vm?.effects?.collect { effect -> when (effect) { WelcomeScreenEffect.NavigateToLoginOptionsEffect -> { onLoginClicked.invoke() } WelcomeScreenEffect.NavigateToSignUpOptionsEffect -> { onSignUpClicked.invoke() } } } } Box( modifier = Modifier.fillMaxSize(), ) { vm?.exoPlayer?.let { player -> val presentationState = rememberPresentationState(player) PlayerSurface( player = player, modifier = Modifier .fillMaxSize() .resizeWithContentScale( ContentScale.Crop, sourceSizeDp = presentationState.videoSizeDp, ) .drawWithContent { val gradient = Brush.verticalGradient( listOf( Color(0x00000000), Color(0xff000000), ), ) drawContent() drawRect(brush = gradient) }.alpha( if (presentationState.coverSurface) 0f else 1f, ), ) } Column( horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier .align(Alignment.BottomCenter) .windowInsetsPadding(WindowInsets.safeDrawing) .padding(32.dp), ) { Text( style = ExtendedTheme.typography.largeHeadline.copy( fontSize = 56.sp, lineHeight = 64.sp, ), color = Color.White, text = stringResource(CommonResR.string.make_your_own_music), modifier = Modifier.align(Alignment.Start), ) Spacer(Modifier.height(16.dp)) Text( text = stringResource(CommonResR.string.turn_ideas_into_anthems), style = ExtendedTheme.typography.introCopy, color = Color.LightGray, modifier = Modifier.align(Alignment.Start), ) Spacer(Modifier.height(64.dp)) Box( modifier = Modifier .clip(RoundedCornerShape(32.dp)) .fillMaxWidth() .heightIn(54.dp) .conditional( condition = VERSION.SDK_INT >= VERSION_CODES.TIRAMISU, ifTrue = { auraBackground() }, ifFalse = { paint( painter = painterResource(R.drawable.full_width_button_bg), contentScale = ContentScale.Crop, ) }, ) .clickable { vm?.sendEvent( event = WelcomeScreenEvent.OnSignUpClicked, ) } .padding( vertical = 16.dp, horizontal = 16.dp, ), contentAlignment = Alignment.Center, ) { Text( text = stringResource(CommonResR.string.create_free_account), textAlign = TextAlign.Center, color = Color.White, style = ExtendedTheme.typography.introCopy, ) } Spacer(Modifier.height(16.dp)) Text( text = buildAnnotatedString { append(stringResource(CommonResR.string.already_have_account)) append(" ") withLink( LinkAnnotation.Clickable( tag = "sign-in", styles = TextLinkStyles( style = SpanStyle(Color.White), focusedStyle = SpanStyle(Color.White.copy(alpha = .75f)), hoveredStyle = SpanStyle(Color.White.copy(alpha = .75f)), pressedStyle = SpanStyle(Color.White.copy(alpha = .5f)), ), ) { vm?.sendEvent( event = WelcomeScreenEvent.OnSignInClicked, ) }, ) { append(stringResource(CommonResR.string.sign_in)) } }, style = ExtendedTheme.typography.body, textAlign = TextAlign.Center, color = Color.Gray, ) } } } @PreviewLightDark @Composable private fun WelcomeScreen_Preview() { SunoTheme { WelcomeScreen( vm = null, onLoginClicked = {}, onSignUpClicked = {}, ) } }