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