mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-04 18:33:47 +02:00
Move relay dialog to a route
This commit is contained in:
@@ -37,6 +37,7 @@ import androidx.compose.material3.Text
|
|||||||
import androidx.compose.material3.TopAppBar
|
import androidx.compose.material3.TopAppBar
|
||||||
import androidx.compose.material3.TopAppBarDefaults
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.DisposableEffect
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
@@ -45,8 +46,6 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.window.Dialog
|
|
||||||
import androidx.compose.ui.window.DialogProperties
|
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
@@ -66,20 +65,25 @@ import com.vitorpamplona.amethyst.ui.theme.grayText
|
|||||||
import com.vitorpamplona.ammolite.relays.Constants
|
import com.vitorpamplona.ammolite.relays.Constants
|
||||||
import com.vitorpamplona.ammolite.relays.RelayStat
|
import com.vitorpamplona.ammolite.relays.RelayStat
|
||||||
|
|
||||||
|
object RelayToAdd {
|
||||||
|
var relayToAdd: String = ""
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AllRelayListView(
|
fun AllRelayListView(
|
||||||
onClose: () -> Unit,
|
|
||||||
relayToAdd: String = "",
|
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
MappedAllRelayListView(onClose, relayToAdd, accountViewModel, rememberExtendedNav(nav, onClose))
|
DisposableEffect(Unit) {
|
||||||
|
onDispose { RelayToAdd.relayToAdd = "" }
|
||||||
|
}
|
||||||
|
|
||||||
|
MappedAllRelayListView(RelayToAdd.relayToAdd, accountViewModel, rememberExtendedNav(nav, {}))
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun MappedAllRelayListView(
|
fun MappedAllRelayListView(
|
||||||
onClose: () -> Unit,
|
|
||||||
relayToAdd: String = "",
|
relayToAdd: String = "",
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
newNav: INav,
|
newNav: INav,
|
||||||
@@ -113,154 +117,149 @@ fun MappedAllRelayListView(
|
|||||||
privateOutboxViewModel.load(accountViewModel.account)
|
privateOutboxViewModel.load(accountViewModel.account)
|
||||||
}
|
}
|
||||||
|
|
||||||
Dialog(
|
Scaffold(
|
||||||
onDismissRequest = onClose,
|
topBar = {
|
||||||
properties = DialogProperties(usePlatformDefaultWidth = false),
|
TopAppBar(
|
||||||
) {
|
title = {
|
||||||
Scaffold(
|
Row(
|
||||||
topBar = {
|
modifier = Modifier.fillMaxWidth(),
|
||||||
TopAppBar(
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
title = {
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
Row(
|
) {
|
||||||
modifier = Modifier.fillMaxWidth(),
|
Spacer(modifier = MinHorzSpacer)
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
) {
|
|
||||||
Spacer(modifier = MinHorzSpacer)
|
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = stringRes(R.string.relay_settings),
|
text = stringRes(R.string.relay_settings),
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
textAlign = TextAlign.Center,
|
textAlign = TextAlign.Center,
|
||||||
style = MaterialTheme.typography.titleLarge,
|
style = MaterialTheme.typography.titleLarge,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
SaveButton(
|
SaveButton(
|
||||||
onPost = {
|
onPost = {
|
||||||
kind3ViewModel.create()
|
kind3ViewModel.create()
|
||||||
dmViewModel.create()
|
dmViewModel.create()
|
||||||
nip65ViewModel.create()
|
nip65ViewModel.create()
|
||||||
searchViewModel.create()
|
searchViewModel.create()
|
||||||
localViewModel.create()
|
localViewModel.create()
|
||||||
privateOutboxViewModel.create()
|
privateOutboxViewModel.create()
|
||||||
onClose()
|
newNav.popBack()
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
navigationIcon = {
|
|
||||||
Row {
|
|
||||||
Spacer(modifier = StdHorzSpacer)
|
|
||||||
CloseButton(
|
|
||||||
onPress = {
|
|
||||||
kind3ViewModel.clear()
|
|
||||||
dmViewModel.clear()
|
|
||||||
nip65ViewModel.clear()
|
|
||||||
searchViewModel.clear()
|
|
||||||
localViewModel.clear()
|
|
||||||
privateOutboxViewModel.clear()
|
|
||||||
onClose()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
colors =
|
|
||||||
TopAppBarDefaults.topAppBarColors(
|
|
||||||
containerColor = MaterialTheme.colorScheme.surface,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
) { pad ->
|
|
||||||
LazyColumn(
|
|
||||||
contentPadding = FeedPadding,
|
|
||||||
modifier =
|
|
||||||
Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
.padding(
|
|
||||||
start = 10.dp,
|
|
||||||
end = 10.dp,
|
|
||||||
top = pad.calculateTopPadding(),
|
|
||||||
bottom = pad.calculateBottomPadding(),
|
|
||||||
).consumeWindowInsets(pad),
|
|
||||||
) {
|
|
||||||
item {
|
|
||||||
SettingsCategory(
|
|
||||||
stringRes(R.string.public_home_section),
|
|
||||||
stringRes(R.string.public_home_section_explainer),
|
|
||||||
Modifier.padding(bottom = 8.dp),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
renderNip65HomeItems(homeFeedState, nip65ViewModel, accountViewModel, newNav)
|
|
||||||
|
|
||||||
item {
|
|
||||||
SettingsCategory(
|
|
||||||
stringRes(R.string.public_notif_section),
|
|
||||||
stringRes(R.string.public_notif_section_explainer),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
renderNip65NotifItems(notifFeedState, nip65ViewModel, accountViewModel, newNav)
|
|
||||||
|
|
||||||
item {
|
|
||||||
SettingsCategoryWithButton(
|
|
||||||
stringRes(R.string.private_inbox_section),
|
|
||||||
stringRes(R.string.private_inbox_section_explainer),
|
|
||||||
action = {
|
|
||||||
ResetDMRelays(dmViewModel)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
renderDMItems(dmFeedState, dmViewModel, accountViewModel, newNav)
|
|
||||||
|
|
||||||
item {
|
|
||||||
SettingsCategory(
|
|
||||||
stringRes(R.string.private_outbox_section),
|
|
||||||
stringRes(R.string.private_outbox_section_explainer),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
renderPrivateOutboxItems(privateOutboxFeedState, privateOutboxViewModel, accountViewModel, newNav)
|
|
||||||
|
|
||||||
item {
|
|
||||||
SettingsCategoryWithButton(
|
|
||||||
stringRes(R.string.search_section),
|
|
||||||
stringRes(R.string.search_section_explainer),
|
|
||||||
action = {
|
|
||||||
ResetSearchRelays(searchViewModel)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
renderSearchItems(searchFeedState, searchViewModel, accountViewModel, newNav)
|
|
||||||
|
|
||||||
item {
|
|
||||||
SettingsCategory(
|
|
||||||
stringRes(R.string.local_section),
|
|
||||||
stringRes(R.string.local_section_explainer),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
renderLocalItems(localFeedState, localViewModel, accountViewModel, newNav)
|
|
||||||
|
|
||||||
item {
|
|
||||||
SettingsCategoryWithButton(
|
|
||||||
stringRes(R.string.kind_3_section),
|
|
||||||
stringRes(R.string.kind_3_section_description),
|
|
||||||
action = {
|
|
||||||
ResetKind3Relays(kind3ViewModel)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
renderKind3Items(kind3FeedState, kind3ViewModel, accountViewModel, newNav, relayToAdd)
|
|
||||||
|
|
||||||
if (kind3Proposals.isNotEmpty()) {
|
|
||||||
item {
|
|
||||||
SettingsCategory(
|
|
||||||
stringRes(R.string.kind_3_recommended_section),
|
|
||||||
stringRes(R.string.kind_3_recommended_section_description),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
renderKind3ProposalItems(kind3Proposals, kind3ViewModel, accountViewModel, newNav)
|
},
|
||||||
|
navigationIcon = {
|
||||||
|
Row {
|
||||||
|
Spacer(modifier = StdHorzSpacer)
|
||||||
|
CloseButton(
|
||||||
|
onPress = {
|
||||||
|
kind3ViewModel.clear()
|
||||||
|
dmViewModel.clear()
|
||||||
|
nip65ViewModel.clear()
|
||||||
|
searchViewModel.clear()
|
||||||
|
localViewModel.clear()
|
||||||
|
privateOutboxViewModel.clear()
|
||||||
|
newNav.popBack()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
colors =
|
||||||
|
TopAppBarDefaults.topAppBarColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.surface,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
) { pad ->
|
||||||
|
LazyColumn(
|
||||||
|
contentPadding = FeedPadding,
|
||||||
|
modifier =
|
||||||
|
Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(
|
||||||
|
start = 10.dp,
|
||||||
|
end = 10.dp,
|
||||||
|
top = pad.calculateTopPadding(),
|
||||||
|
bottom = pad.calculateBottomPadding(),
|
||||||
|
).consumeWindowInsets(pad),
|
||||||
|
) {
|
||||||
|
item {
|
||||||
|
SettingsCategory(
|
||||||
|
stringRes(R.string.public_home_section),
|
||||||
|
stringRes(R.string.public_home_section_explainer),
|
||||||
|
Modifier.padding(bottom = 8.dp),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
renderNip65HomeItems(homeFeedState, nip65ViewModel, accountViewModel, newNav)
|
||||||
|
|
||||||
|
item {
|
||||||
|
SettingsCategory(
|
||||||
|
stringRes(R.string.public_notif_section),
|
||||||
|
stringRes(R.string.public_notif_section_explainer),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
renderNip65NotifItems(notifFeedState, nip65ViewModel, accountViewModel, newNav)
|
||||||
|
|
||||||
|
item {
|
||||||
|
SettingsCategoryWithButton(
|
||||||
|
stringRes(R.string.private_inbox_section),
|
||||||
|
stringRes(R.string.private_inbox_section_explainer),
|
||||||
|
action = {
|
||||||
|
ResetDMRelays(dmViewModel)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
renderDMItems(dmFeedState, dmViewModel, accountViewModel, newNav)
|
||||||
|
|
||||||
|
item {
|
||||||
|
SettingsCategory(
|
||||||
|
stringRes(R.string.private_outbox_section),
|
||||||
|
stringRes(R.string.private_outbox_section_explainer),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
renderPrivateOutboxItems(privateOutboxFeedState, privateOutboxViewModel, accountViewModel, newNav)
|
||||||
|
|
||||||
|
item {
|
||||||
|
SettingsCategoryWithButton(
|
||||||
|
stringRes(R.string.search_section),
|
||||||
|
stringRes(R.string.search_section_explainer),
|
||||||
|
action = {
|
||||||
|
ResetSearchRelays(searchViewModel)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
renderSearchItems(searchFeedState, searchViewModel, accountViewModel, newNav)
|
||||||
|
|
||||||
|
item {
|
||||||
|
SettingsCategory(
|
||||||
|
stringRes(R.string.local_section),
|
||||||
|
stringRes(R.string.local_section_explainer),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
renderLocalItems(localFeedState, localViewModel, accountViewModel, newNav)
|
||||||
|
|
||||||
|
item {
|
||||||
|
SettingsCategoryWithButton(
|
||||||
|
stringRes(R.string.kind_3_section),
|
||||||
|
stringRes(R.string.kind_3_section_description),
|
||||||
|
action = {
|
||||||
|
ResetKind3Relays(kind3ViewModel)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
renderKind3Items(kind3FeedState, kind3ViewModel, accountViewModel, newNav, relayToAdd)
|
||||||
|
|
||||||
|
if (kind3Proposals.isNotEmpty()) {
|
||||||
|
item {
|
||||||
|
SettingsCategory(
|
||||||
|
stringRes(R.string.kind_3_recommended_section),
|
||||||
|
stringRes(R.string.kind_3_recommended_section_description),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
renderKind3ProposalItems(kind3Proposals, kind3ViewModel, accountViewModel, newNav)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -49,6 +49,7 @@ import androidx.navigation.compose.NavHost
|
|||||||
import androidx.navigation.compose.composable
|
import androidx.navigation.compose.composable
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.ui.MainActivity
|
import com.vitorpamplona.amethyst.ui.MainActivity
|
||||||
|
import com.vitorpamplona.amethyst.ui.actions.relays.AllRelayListView
|
||||||
import com.vitorpamplona.amethyst.ui.components.DisplayErrorMessages
|
import com.vitorpamplona.amethyst.ui.components.DisplayErrorMessages
|
||||||
import com.vitorpamplona.amethyst.ui.components.DisplayNotifyMessages
|
import com.vitorpamplona.amethyst.ui.components.DisplayNotifyMessages
|
||||||
import com.vitorpamplona.amethyst.ui.screen.AccountStateViewModel
|
import com.vitorpamplona.amethyst.ui.screen.AccountStateViewModel
|
||||||
@@ -320,6 +321,16 @@ fun AppNavigation(
|
|||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
composable(
|
||||||
|
Route.EditRelays.route,
|
||||||
|
content = {
|
||||||
|
AllRelayListView(
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
nav = nav,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -89,7 +89,6 @@ import com.vitorpamplona.amethyst.model.Account
|
|||||||
import com.vitorpamplona.amethyst.model.FeatureSetType
|
import com.vitorpamplona.amethyst.model.FeatureSetType
|
||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
import com.vitorpamplona.amethyst.ui.actions.mediaServers.MediaServersListView
|
import com.vitorpamplona.amethyst.ui.actions.mediaServers.MediaServersListView
|
||||||
import com.vitorpamplona.amethyst.ui.actions.relays.AllRelayListView
|
|
||||||
import com.vitorpamplona.amethyst.ui.components.ClickableText
|
import com.vitorpamplona.amethyst.ui.components.ClickableText
|
||||||
import com.vitorpamplona.amethyst.ui.components.CreateTextWithEmoji
|
import com.vitorpamplona.amethyst.ui.components.CreateTextWithEmoji
|
||||||
import com.vitorpamplona.amethyst.ui.components.RobohashFallbackAsyncImage
|
import com.vitorpamplona.amethyst.ui.components.RobohashFallbackAsyncImage
|
||||||
@@ -437,7 +436,6 @@ fun ListContent(
|
|||||||
) {
|
) {
|
||||||
val route = remember(accountViewModel) { "User/${accountViewModel.userProfile().pubkeyHex}" }
|
val route = remember(accountViewModel) { "User/${accountViewModel.userProfile().pubkeyHex}" }
|
||||||
|
|
||||||
var wantsToEditRelays by remember { mutableStateOf(false) }
|
|
||||||
var editMediaServers by remember { mutableStateOf(false) }
|
var editMediaServers by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
var backupDialogOpen by remember { mutableStateOf(false) }
|
var backupDialogOpen by remember { mutableStateOf(false) }
|
||||||
@@ -475,7 +473,7 @@ fun ListContent(
|
|||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
onClick = {
|
onClick = {
|
||||||
nav.closeDrawer()
|
nav.closeDrawer()
|
||||||
wantsToEditRelays = true
|
nav.nav(Route.EditRelays.route)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -537,9 +535,6 @@ fun ListContent(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wantsToEditRelays) {
|
|
||||||
AllRelayListView({ wantsToEditRelays = false }, accountViewModel = accountViewModel, nav = nav)
|
|
||||||
}
|
|
||||||
if (editMediaServers) {
|
if (editMediaServers) {
|
||||||
MediaServersListView({ editMediaServers = false }, accountViewModel = accountViewModel, nav = nav)
|
MediaServersListView({ editMediaServers = false }, accountViewModel = accountViewModel, nav = nav)
|
||||||
}
|
}
|
||||||
|
@@ -68,6 +68,13 @@ sealed class Route(
|
|||||||
contentDescriptor = R.string.route_global,
|
contentDescriptor = R.string.route_global,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
object EditRelays :
|
||||||
|
Route(
|
||||||
|
route = "EditRelays",
|
||||||
|
icon = R.drawable.ic_globe,
|
||||||
|
contentDescriptor = R.string.relays,
|
||||||
|
)
|
||||||
|
|
||||||
object Search :
|
object Search :
|
||||||
Route(
|
Route(
|
||||||
route = "Search",
|
route = "Search",
|
||||||
|
@@ -45,9 +45,10 @@ import androidx.compose.ui.text.style.TextOverflow
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.ui.actions.relays.AllRelayListView
|
import com.vitorpamplona.amethyst.ui.actions.relays.RelayToAdd
|
||||||
import com.vitorpamplona.amethyst.ui.components.ShowMoreButton
|
import com.vitorpamplona.amethyst.ui.components.ShowMoreButton
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.INav
|
import com.vitorpamplona.amethyst.ui.navigation.INav
|
||||||
|
import com.vitorpamplona.amethyst.ui.navigation.Route
|
||||||
import com.vitorpamplona.amethyst.ui.note.AddRelayButton
|
import com.vitorpamplona.amethyst.ui.note.AddRelayButton
|
||||||
import com.vitorpamplona.amethyst.ui.note.RemoveRelayButton
|
import com.vitorpamplona.amethyst.ui.note.RemoveRelayButton
|
||||||
import com.vitorpamplona.amethyst.ui.note.getGradient
|
import com.vitorpamplona.amethyst.ui.note.getGradient
|
||||||
@@ -289,15 +290,15 @@ private fun RelayOptionsAction(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var wantsToAddRelay by remember { mutableStateOf("") }
|
|
||||||
|
|
||||||
if (wantsToAddRelay.isNotEmpty()) {
|
|
||||||
AllRelayListView({ wantsToAddRelay = "" }, wantsToAddRelay, accountViewModel, nav = nav)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isCurrentlyOnTheUsersList) {
|
if (isCurrentlyOnTheUsersList) {
|
||||||
AddRelayButton { wantsToAddRelay = relay }
|
AddRelayButton {
|
||||||
|
RelayToAdd.relayToAdd = relay
|
||||||
|
nav.nav(Route.EditRelays.route)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
RemoveRelayButton { wantsToAddRelay = relay }
|
RemoveRelayButton {
|
||||||
|
RelayToAdd.relayToAdd = relay
|
||||||
|
nav.nav(Route.EditRelays.route)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,13 +26,12 @@ import androidx.compose.foundation.lazy.rememberLazyListState
|
|||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.vitorpamplona.amethyst.ui.actions.relays.AllRelayListView
|
import com.vitorpamplona.amethyst.ui.actions.relays.RelayToAdd
|
||||||
import com.vitorpamplona.amethyst.ui.feeds.RefresheableBox
|
import com.vitorpamplona.amethyst.ui.feeds.RefresheableBox
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.INav
|
import com.vitorpamplona.amethyst.ui.navigation.INav
|
||||||
|
import com.vitorpamplona.amethyst.ui.navigation.Route
|
||||||
import com.vitorpamplona.amethyst.ui.note.RelayCompose
|
import com.vitorpamplona.amethyst.ui.note.RelayCompose
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.theme.DividerThickness
|
import com.vitorpamplona.amethyst.ui.theme.DividerThickness
|
||||||
@@ -47,12 +46,6 @@ fun RelayFeedView(
|
|||||||
) {
|
) {
|
||||||
val feedState by viewModel.feedContent.collectAsStateWithLifecycle()
|
val feedState by viewModel.feedContent.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
var wantsToAddRelay by remember { mutableStateOf("") }
|
|
||||||
|
|
||||||
if (wantsToAddRelay.isNotEmpty()) {
|
|
||||||
AllRelayListView({ wantsToAddRelay = "" }, wantsToAddRelay, accountViewModel, nav = nav)
|
|
||||||
}
|
|
||||||
|
|
||||||
RefresheableBox(viewModel, enablePullRefresh) {
|
RefresheableBox(viewModel, enablePullRefresh) {
|
||||||
val listState = rememberLazyListState()
|
val listState = rememberLazyListState()
|
||||||
|
|
||||||
@@ -64,8 +57,14 @@ fun RelayFeedView(
|
|||||||
RelayCompose(
|
RelayCompose(
|
||||||
item,
|
item,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
onAddRelay = { wantsToAddRelay = item.url },
|
onAddRelay = {
|
||||||
onRemoveRelay = { wantsToAddRelay = item.url },
|
RelayToAdd.relayToAdd = item.url
|
||||||
|
nav.nav(Route.EditRelays.route)
|
||||||
|
},
|
||||||
|
onRemoveRelay = {
|
||||||
|
RelayToAdd.relayToAdd = item.url
|
||||||
|
nav.nav(Route.EditRelays.route)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
HorizontalDivider(
|
HorizontalDivider(
|
||||||
thickness = DividerThickness,
|
thickness = DividerThickness,
|
||||||
|
Reference in New Issue
Block a user