Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up welcome and notification details compose views (#1902)
* Clean up welcome and notification details compose views * Remove parcel data as its not necessary
- Loading branch information
Showing
5 changed files
with
218 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
app/src/main/java/io/homeassistant/companion/android/onboarding/views/WelcomeView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package io.homeassistant.companion.android.onboarding.views | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.rememberScrollState | ||
import androidx.compose.foundation.text.ClickableText | ||
import androidx.compose.foundation.verticalScroll | ||
import androidx.compose.material.Button | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalUriHandler | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.SpanStyle | ||
import androidx.compose.ui.text.buildAnnotatedString | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.text.style.TextDecoration | ||
import androidx.compose.ui.text.withStyle | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import io.homeassistant.companion.android.R | ||
|
||
@Composable | ||
fun WelcomeView( | ||
onContinue: () -> Unit | ||
) { | ||
val scrollState = rememberScrollState() | ||
Column( | ||
verticalArrangement = Arrangement.Center, | ||
modifier = Modifier.verticalScroll(scrollState) | ||
) { | ||
Image( | ||
painter = painterResource(id = R.drawable.app_icon), | ||
contentDescription = stringResource( | ||
id = R.string.app_name | ||
), | ||
modifier = Modifier | ||
.size(width = 274.dp, height = 202.dp) | ||
.align(Alignment.CenterHorizontally) | ||
.padding(bottom = 15.dp) | ||
) | ||
Text( | ||
fontSize = 19.sp, | ||
fontWeight = FontWeight.Bold, | ||
textAlign = TextAlign.Center, | ||
text = stringResource(R.string.welcome_hass), | ||
modifier = Modifier | ||
.align(Alignment.CenterHorizontally) | ||
) | ||
Text( | ||
fontSize = 17.sp, | ||
text = stringResource(R.string.welcome_hass_desc), | ||
modifier = Modifier | ||
.padding(bottom = 15.dp, start = 30.dp, end = 20.dp, top = 10.dp) | ||
) | ||
val annotatedString = buildAnnotatedString { | ||
pushStringAnnotation("learn", "https://www.home-assistant.io") | ||
withStyle( | ||
style = SpanStyle( | ||
color = MaterialTheme.colors.primary, | ||
textDecoration = TextDecoration.Underline | ||
) | ||
) { | ||
append(stringResource(id = R.string.learn_more)) | ||
} | ||
pop() | ||
} | ||
val uriHandler = LocalUriHandler.current | ||
ClickableText( | ||
text = annotatedString, | ||
onClick = { | ||
annotatedString.getStringAnnotations("learn", it, it).firstOrNull()?.let { link -> | ||
uriHandler.openUri(link.item) | ||
} | ||
}, | ||
modifier = Modifier | ||
.padding(bottom = 15.dp) | ||
.align(Alignment.CenterHorizontally) | ||
) | ||
|
||
Button( | ||
onClick = onContinue, | ||
modifier = Modifier | ||
.align(Alignment.CenterHorizontally) | ||
) { | ||
Text(text = stringResource(id = R.string.continue_connect)) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
@Preview | ||
private fun PreviewWelcome() { | ||
WelcomeView(onContinue = {}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.