@ -42,89 +42,96 @@ fun TailnetLockSetupView(
backToSettings : BackNavigation ,
backToSettings : BackNavigation ,
model : TailnetLockSetupViewModel = viewModel ( factory = TailnetLockSetupViewModelFactory ( ) )
model : TailnetLockSetupViewModel = viewModel ( factory = TailnetLockSetupViewModelFactory ( ) )
) {
) {
val statusItems by model . statusItems . collectAsState ( )
val statusItems by model . statusItems . collectAsState ( )
val nodeKey by model . nodeKey . collectAsState ( )
val nodeKey by model . nodeKey . collectAsState ( )
val tailnetLockKey by model . tailnetLockKey . collectAsState ( )
val tailnetLockKey by model . tailnetLockKey . collectAsState ( )
val tailnetLockTlPubKey = tailnetLockKey . replace ( " nlpub " , " tlpub " )
val tailnetLockTlPubKey = tailnetLockKey . replace ( " nlpub " , " tlpub " )
Scaffold ( topBar = { Header ( R . string . tailnet _lock , onBack = backToSettings ) } ) { innerPadding ->
Scaffold ( topBar = { Header ( R . string . tailnet _lock , onBack = backToSettings ) } ) { innerPadding ->
LoadingIndicator . Wrap {
LoadingIndicator . Wrap {
LazyColumn ( modifier = Modifier . padding ( innerPadding ) ) {
Column (
item ( key = " header " ) { ExplainerView ( ) }
modifier = Modifier
. padding ( innerPadding )
items ( items = statusItems , key = { " status_ ${it.title} " } ) { statusItem ->
. focusable ( )
Lists . ItemDivider ( )
. verticalScroll ( rememberScrollState ( ) )
. fillMaxSize ( )
ListItem (
) {
leadingContent = {
ExplainerView ( )
Icon (
painter = painterResource ( id = statusItem . icon ) ,
statusItems . forEach { statusItem ->
contentDescription = null ,
Lists . ItemDivider ( )
tint = MaterialTheme . colorScheme . onSurfaceVariant )
} ,
ListItem (
headlineContent = { Text ( stringResource ( statusItem . title ) ) } )
leadingContent = {
}
Icon (
painter = painterResource ( id = statusItem . icon ) ,
item ( key = " nodeKey " ) {
contentDescription = null ,
Lists . SectionDivider ( )
tint = MaterialTheme . colorScheme . onSurfaceVariant
)
ClipboardValueView (
} ,
value = nodeKey ,
headlineContent = { Text ( stringResource ( statusItem . title ) ) }
title = stringResource ( R . string . node _key ) ,
)
subtitle = stringResource ( R . string . node _key _explainer ) )
}
}
//Node key
Lists . SectionDivider ( )
item ( key = " tailnetLockKey " ) {
ClipboardValueView (
Lists . SectionDivider ( )
value = nodeKey ,
title = stringResource ( R . string . node _key ) ,
ClipboardValueView (
subtitle = stringResource ( R . string . node _key _explainer )
value = tailnetLockTlPubKey ,
)
title = stringResource ( R . string . tailnet _lock _key ) ,
subtitle = stringResource ( R . string . tailnet _lock _key _explainer ) )
// Tailnet lock key
Lists . SectionDivider ( )
ClipboardValueView (
value = tailnetLockTlPubKey ,
title = stringResource ( R . string . tailnet _lock _key ) ,
subtitle = stringResource ( R . string . tailnet _lock _key _explainer )
)
}
}
}
}
}
}
}
}
}
@Composable
@Composable
private fun ExplainerView ( ) {
private fun ExplainerView ( ) {
val handler = LocalUriHandler . current
val handler = LocalUriHandler . current
Lists . MultilineDescription {
Lists . MultilineDescription {
ClickableText (
ClickableText (
explainerText ( ) ,
explainerText ( ) ,
onClick = { handler . openUri ( Links . TAILNET _LOCK _KB _URL ) } ,
onClick = { handler . openUri ( Links . TAILNET _LOCK _KB _URL ) } ,
style = MaterialTheme . typography . bodyMedium )
style = MaterialTheme . typography . bodyMedium
}
)
}
}
}
@Composable
@Composable
fun explainerText ( ) : AnnotatedString {
fun explainerText ( ) : AnnotatedString {
val annotatedString = buildAnnotatedString {
val annotatedString = buildAnnotatedString {
withStyle ( SpanStyle ( color = MaterialTheme . colorScheme . defaultTextColor ) ) {
withStyle ( SpanStyle ( color = MaterialTheme . colorScheme . defaultTextColor ) ) {
append ( stringResource ( id = R . string . tailnet _lock _explainer ) )
append ( stringResource ( id = R . string . tailnet _lock _explainer ) )
}
}
pushStringAnnotation ( tag = " tailnetLockSupportURL " , annotation = Links . TAILNET _LOCK _KB _URL )
pushStringAnnotation ( tag = " tailnetLockSupportURL " , annotation = Links . TAILNET _LOCK _KB _URL )
withStyle (
withStyle (
style =
style = SpanStyle (
SpanStyle (
color = MaterialTheme . colorScheme . link ,
color = MaterialTheme . colorScheme . link ,
textDecoration = TextDecoration . Underline ) ) {
textDecoration = TextDecoration . Underline
append ( stringResource ( id = R . string . learn _more ) )
)
) {
append ( stringResource ( id = R . string . learn _more ) )
}
}
pop ( )
pop ( )
}
}
return annotatedString
return annotatedString
}
}
@Composable
@Composable
@Preview
@Preview
fun TailnetLockSetupViewPreview ( ) {
fun TailnetLockSetupViewPreview ( ) {
val vm = TailnetLockSetupViewModel ( )
val vm = TailnetLockSetupViewModel ( )
vm . nodeKey . set ( " 8BADF00D-EA7-1337-DEAD-BEEF " )
vm . nodeKey . set ( " 8BADF00D-EA7-1337-DEAD-BEEF " )
vm . tailnetLockKey . set ( " C0FFEE-CAFE-50DA " )
vm . tailnetLockKey . set ( " C0FFEE-CAFE-50DA " )
TailnetLockSetupView ( backToSettings = { } , vm )
TailnetLockSetupView ( backToSettings = { } , vm )
}
}