@ -26,7 +26,6 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.ArrowDropDown
import androidx.compose.material.icons.outlined.ArrowDropDown
import androidx.compose.material.icons.outlined.Clear
import androidx.compose.material.icons.outlined.Clear
import androidx.compose.material.icons.outlined.Close
import androidx.compose.material.icons.outlined.Close
import androidx.compose.material.icons.outlined.Lock
import androidx.compose.material.icons.outlined.Search
import androidx.compose.material.icons.outlined.Search
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material3.Button
import androidx.compose.material3.Button
@ -107,6 +106,7 @@ fun MainView(navigation: MainViewNavigation, viewModel: MainViewModel = viewMode
val stateVal = viewModel . stateRes . collectAsState ( initial = R . string . placeholder ) . value
val stateVal = viewModel . stateRes . collectAsState ( initial = R . string . placeholder ) . value
val stateStr = stringResource ( id = stateVal )
val stateStr = stringResource ( id = stateVal )
val netmap = viewModel . netmap . collectAsState ( initial = null )
val netmap = viewModel . netmap . collectAsState ( initial = null )
val isAdmin = viewModel . isAdmin . collectAsState ( initial = false ) . value
ListItem (
ListItem (
colors = MaterialTheme . colorScheme . surfaceContainerListItem ,
colors = MaterialTheme . colorScheme . surfaceContainerListItem ,
@ -163,7 +163,7 @@ fun MainView(navigation: MainViewNavigation, viewModel: MainViewModel = viewMode
Ipn . State . NoState ,
Ipn . State . NoState ,
Ipn . State . Starting -> StartingView ( )
Ipn . State . Starting -> StartingView ( )
else -> {
else -> {
ConnectView ( state , user , { viewModel . toggleVpn ( ) } , { viewModel . login { } } )
ConnectView ( state , user , { viewModel . toggleVpn ( ) } , { viewModel . login { } } , isAdmin )
}
}
}
}
}
}
@ -257,7 +257,8 @@ fun ConnectView(
state : Ipn . State ,
state : Ipn . State ,
user : IpnLocal . LoginProfile ? ,
user : IpnLocal . LoginProfile ? ,
connectAction : ( ) -> Unit ,
connectAction : ( ) -> Unit ,
loginAction : ( ) -> Unit
loginAction : ( ) -> Unit ,
isAdmin : Boolean ,
) {
) {
val handler = LocalUriHandler . current
val handler = LocalUriHandler . current
@ -269,10 +270,6 @@ fun ConnectView(
horizontalAlignment = Alignment . CenterHorizontally ,
horizontalAlignment = Alignment . CenterHorizontally ,
) {
) {
if ( state == Ipn . State . NeedsMachineAuth ) {
if ( state == Ipn . State . NeedsMachineAuth ) {
Icon (
modifier = Modifier . size ( 40. dp ) ,
imageVector = Icons . Outlined . Lock ,
contentDescription = " Device requires authentication " )
Text (
Text (
text = stringResource ( id = R . string . machine _auth _required ) ,
text = stringResource ( id = R . string . machine _auth _required ) ,
style = MaterialTheme . typography . titleMedium ,
style = MaterialTheme . typography . titleMedium ,
@ -281,12 +278,13 @@ fun ConnectView(
text = stringResource ( id = R . string . machine _auth _explainer ) ,
text = stringResource ( id = R . string . machine _auth _explainer ) ,
style = MaterialTheme . typography . bodyMedium ,
style = MaterialTheme . typography . bodyMedium ,
textAlign = TextAlign . Center )
textAlign = TextAlign . Center )
Spacer ( modifier = Modifier . size ( 1. dp ) )
if ( isAdmin ) {
PrimaryActionButton ( onClick = { handler . openUri ( Links . ADMIN _URL ) } ) {
PrimaryActionButton ( onClick = { handler . openUri ( Links . ADMIN _URL ) } ) {
Text (
Text (
text = stringResource ( id = R . string . open _admin _console ) ,
text = stringResource ( id = R . string . open _admin _console ) ,
fontSize = MaterialTheme . typography . titleMedium . fontSize )
fontSize = MaterialTheme . typography . titleMedium . fontSize )
}
}
}
} else if ( state != Ipn . State . NeedsLogin && user != null && ! user . isEmpty ( ) ) {
} else if ( state != Ipn . State . NeedsLogin && user != null && ! user . isEmpty ( ) ) {
Icon (
Icon (
painter = painterResource ( id = R . drawable . power ) ,
painter = painterResource ( id = R . drawable . power ) ,