|
|
|
@ -5,10 +5,9 @@ package com.tailscale.ipn.ui.view
|
|
|
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
|
import androidx.compose.foundation.layout.Spacer
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
|
|
import androidx.compose.foundation.layout.height
|
|
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
|
import androidx.compose.foundation.lazy.LazyColumn
|
|
|
|
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
|
|
|
import androidx.compose.material3.Scaffold
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
@ -19,8 +18,9 @@ import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
|
|
|
import com.tailscale.ipn.R
|
|
|
|
|
import com.tailscale.ipn.ui.util.Lists
|
|
|
|
|
import com.tailscale.ipn.ui.util.itemsWithDividers
|
|
|
|
|
import com.tailscale.ipn.ui.util.set
|
|
|
|
|
import com.tailscale.ipn.ui.util.settingsRowModifier
|
|
|
|
|
import com.tailscale.ipn.ui.viewModel.UserSwitcherViewModel
|
|
|
|
|
|
|
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
|
|
@ -39,8 +39,6 @@ fun UserSwitcherView(nav: BackNavigation, viewModel: UserSwitcherViewModel = vie
|
|
|
|
|
// Show the error overlay if need be
|
|
|
|
|
showDialog?.let { ErrorDialog(type = it, action = { viewModel.showDialog.set(null) }) }
|
|
|
|
|
|
|
|
|
|
Column(modifier = settingsRowModifier()) {
|
|
|
|
|
|
|
|
|
|
// When switch is invoked, this stores the ID of the user we're trying to switch to
|
|
|
|
|
// so we can decorate it with a spinner. The actual logged in user will not change
|
|
|
|
|
// until
|
|
|
|
@ -49,7 +47,8 @@ fun UserSwitcherView(nav: BackNavigation, viewModel: UserSwitcherViewModel = vie
|
|
|
|
|
// "switching users" state globally (if ipnState is insufficient)
|
|
|
|
|
val nextUserId = remember { mutableStateOf<String?>(null) }
|
|
|
|
|
|
|
|
|
|
users?.forEach { user ->
|
|
|
|
|
LazyColumn {
|
|
|
|
|
itemsWithDividers(users ?: emptyList()) { user ->
|
|
|
|
|
if (user.ID == currentUser?.ID) {
|
|
|
|
|
UserView(profile = user, actionState = UserActionState.CURRENT)
|
|
|
|
|
} else {
|
|
|
|
@ -70,15 +69,16 @@ fun UserSwitcherView(nav: BackNavigation, viewModel: UserSwitcherViewModel = vie
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
SettingRow(viewModel.addProfileSetting)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Spacer(modifier = Modifier.height(8.dp))
|
|
|
|
|
|
|
|
|
|
Column(modifier = settingsRowModifier()) {
|
|
|
|
|
item {
|
|
|
|
|
Lists.SectionDivider()
|
|
|
|
|
SettingRow(viewModel.addProfileSetting)
|
|
|
|
|
Lists.ItemDivider()
|
|
|
|
|
SettingRow(viewModel.loginSetting)
|
|
|
|
|
Lists.ItemDivider()
|
|
|
|
|
SettingRow(viewModel.logoutSetting)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|