From 723b4b5e9faf313f8e4f82ea182f5a399d45b877 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Thu, 24 Apr 2025 16:58:40 -0400 Subject: [PATCH] Removes dependency on a modifier for SettingsCategory --- .../mediaServers/AllMediaServersLIstView.kt | 35 ++++++++++--------- .../ui/screen/loggedIn/AccountViewModel.kt | 16 --------- .../metadata/ChannelMetadataScreen.kt | 5 ++- .../loggedIn/relays/AllRelayListScreen.kt | 30 ++++++++++------ .../vitorpamplona/amethyst/ui/theme/Shape.kt | 3 ++ .../vitorpamplona/amethyst/ui/theme/Theme.kt | 14 -------- 6 files changed, 45 insertions(+), 58 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/mediaServers/AllMediaServersLIstView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/mediaServers/AllMediaServersLIstView.kt index 94812d35d..97bdfe3e3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/mediaServers/AllMediaServersLIstView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/mediaServers/AllMediaServersLIstView.kt @@ -67,6 +67,8 @@ import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.amethyst.ui.theme.DoubleHorzSpacer import com.vitorpamplona.amethyst.ui.theme.DoubleVertPadding import com.vitorpamplona.amethyst.ui.theme.FeedPadding +import com.vitorpamplona.amethyst.ui.theme.SettingsCategoryFirstModifier +import com.vitorpamplona.amethyst.ui.theme.SettingsCategorySpacingModifier import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer import com.vitorpamplona.amethyst.ui.theme.grayText @@ -184,7 +186,7 @@ fun AllMediaBody( SettingsCategory( stringRes(R.string.media_servers_nip96_section), stringRes(R.string.media_servers_nip96_explainer), - Modifier.padding(bottom = 8.dp), + SettingsCategoryFirstModifier, ) } @@ -205,6 +207,7 @@ fun AllMediaBody( SettingsCategory( stringRes(R.string.media_servers_blossom_section), stringRes(R.string.media_servers_blossom_explainer), + SettingsCategorySpacingModifier, ) } @@ -226,22 +229,22 @@ fun AllMediaBody( SettingsCategoryWithButton( title = stringRes(id = R.string.built_in_media_servers_title), description = stringRes(id = R.string.built_in_servers_description), - action = { - OutlinedButton( - onClick = { - nip96ServersViewModel.addServerList( - it.mapNotNull { s -> if (s.type == ServerType.NIP96) s.baseUrl else null }, - ) + modifier = SettingsCategorySpacingModifier, + ) { + OutlinedButton( + onClick = { + nip96ServersViewModel.addServerList( + it.mapNotNull { s -> if (s.type == ServerType.NIP96) s.baseUrl else null }, + ) - blossomServersViewModel.addServerList( - it.mapNotNull { s -> if (s.type == ServerType.Blossom) s.baseUrl else null }, - ) - }, - ) { - Text(text = stringRes(id = R.string.use_default_servers)) - } - }, - ) + blossomServersViewModel.addServerList( + it.mapNotNull { s -> if (s.type == ServerType.Blossom) s.baseUrl else null }, + ) + }, + ) { + Text(text = stringRes(id = R.string.use_default_servers)) + } + } } itemsIndexed( it, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index 82b0a40ec..bf9b24944 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -60,7 +60,6 @@ import com.vitorpamplona.amethyst.service.OnlineChecker import com.vitorpamplona.amethyst.service.ZapPaymentHandler import com.vitorpamplona.amethyst.service.checkNotInMainThread import com.vitorpamplona.amethyst.service.lnurl.LightningAddressResolver -import com.vitorpamplona.amethyst.service.proxyPort.ProxyPortFlow import com.vitorpamplona.amethyst.ui.actions.Dao import com.vitorpamplona.amethyst.ui.components.UrlPreviewState import com.vitorpamplona.amethyst.ui.components.toasts.ToastManager @@ -155,21 +154,6 @@ class AccountViewModel( val newNotesPreProcessor = PrecacheNewNotesProcessor(account, LocalCache) - val proxyPortLogic = - ProxyPortFlow( - account.settings.torSettings.torType, - account.settings.torSettings.externalSocksPort, - Amethyst.instance.torManager.status, - ).status.stateIn( - viewModelScope, - SharingStarted.WhileSubscribed(30000), - ProxyPortFlow.computePort( - account.settings.torSettings.torType.value, - account.settings.torSettings.externalSocksPort.value, - Amethyst.instance.torManager.status.value, - ), - ) - var firstRoute: Route? = null // TODO: contact lists are not notes yet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip28PublicChat/metadata/ChannelMetadataScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip28PublicChat/metadata/ChannelMetadataScreen.kt index 715f8b1af..f2df07fe2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip28PublicChat/metadata/ChannelMetadataScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip28PublicChat/metadata/ChannelMetadataScreen.kt @@ -71,6 +71,8 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common.relaySetupInf import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.amethyst.ui.theme.DoubleVertSpacer import com.vitorpamplona.amethyst.ui.theme.MinHorzSpacer +import com.vitorpamplona.amethyst.ui.theme.SettingsCategoryFirstModifier +import com.vitorpamplona.amethyst.ui.theme.SettingsCategorySpacingModifier import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn import com.vitorpamplona.amethyst.ui.theme.placeholderText @@ -208,7 +210,7 @@ private fun ChannelMetadataScaffold( SettingsCategory( stringRes(R.string.public_chat_title), stringRes(R.string.public_chat_explainer), - Modifier.padding(bottom = 8.dp), + SettingsCategoryFirstModifier, ) ChannelName(postViewModel) @@ -224,6 +226,7 @@ private fun ChannelMetadataScaffold( SettingsCategory( stringRes(R.string.public_chat_relays_title), stringRes(R.string.public_chat_relays_explainer), + SettingsCategorySpacingModifier, ) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/AllRelayListScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/AllRelayListScreen.kt index e52a465db..f0bec9d55 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/AllRelayListScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/AllRelayListScreen.kt @@ -20,6 +20,7 @@ */ package com.vitorpamplona.amethyst.ui.screen.loggedIn.relays +import android.R.attr.action import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -73,6 +74,8 @@ import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.amethyst.ui.theme.FeedPadding import com.vitorpamplona.amethyst.ui.theme.MinHorzSpacer import com.vitorpamplona.amethyst.ui.theme.RowColSpacing +import com.vitorpamplona.amethyst.ui.theme.SettingsCategoryFirstModifier +import com.vitorpamplona.amethyst.ui.theme.SettingsCategorySpacingModifier import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer import com.vitorpamplona.amethyst.ui.theme.grayText import com.vitorpamplona.ammolite.relays.Constants @@ -196,7 +199,7 @@ fun MappedAllRelayListView( SettingsCategory( stringRes(R.string.public_home_section), stringRes(R.string.public_home_section_explainer), - Modifier.padding(bottom = 8.dp), + SettingsCategoryFirstModifier, ) } renderNip65HomeItems(homeFeedState, nip65ViewModel, accountViewModel, newNav) @@ -205,6 +208,7 @@ fun MappedAllRelayListView( SettingsCategory( stringRes(R.string.public_notif_section), stringRes(R.string.public_notif_section_explainer), + SettingsCategorySpacingModifier, ) } renderNip65NotifItems(notifFeedState, nip65ViewModel, accountViewModel, newNav) @@ -213,6 +217,7 @@ fun MappedAllRelayListView( SettingsCategoryWithButton( stringRes(R.string.private_inbox_section), stringRes(R.string.private_inbox_section_explainer), + SettingsCategorySpacingModifier, action = { ResetDMRelays(dmViewModel) }, @@ -224,6 +229,7 @@ fun MappedAllRelayListView( SettingsCategory( stringRes(R.string.private_outbox_section), stringRes(R.string.private_outbox_section_explainer), + SettingsCategorySpacingModifier, ) } renderPrivateOutboxItems(privateOutboxFeedState, privateOutboxViewModel, accountViewModel, newNav) @@ -232,10 +238,10 @@ fun MappedAllRelayListView( SettingsCategoryWithButton( stringRes(R.string.search_section), stringRes(R.string.search_section_explainer), - action = { - ResetSearchRelays(searchViewModel) - }, - ) + SettingsCategorySpacingModifier, + ) { + ResetSearchRelays(searchViewModel) + } } renderSearchItems(searchFeedState, searchViewModel, accountViewModel, newNav) @@ -243,6 +249,7 @@ fun MappedAllRelayListView( SettingsCategory( stringRes(R.string.local_section), stringRes(R.string.local_section_explainer), + SettingsCategorySpacingModifier, ) } renderLocalItems(localFeedState, localViewModel, accountViewModel, newNav) @@ -251,10 +258,10 @@ fun MappedAllRelayListView( SettingsCategoryWithButton( stringRes(R.string.kind_3_section), stringRes(R.string.kind_3_section_description), - action = { - ResetKind3Relays(kind3ViewModel) - }, - ) + SettingsCategorySpacingModifier, + ) { + ResetKind3Relays(kind3ViewModel) + } } renderKind3Items(kind3FeedState, kind3ViewModel, accountViewModel, newNav, relayToAdd) @@ -263,6 +270,7 @@ fun MappedAllRelayListView( SettingsCategory( stringRes(R.string.kind_3_recommended_section), stringRes(R.string.kind_3_recommended_section_description), + SettingsCategorySpacingModifier, ) } renderKind3ProposalItems(kind3Proposals, kind3ViewModel, accountViewModel, newNav) @@ -320,7 +328,7 @@ fun ResetDMRelays(postViewModel: DMRelayListViewModel) { fun SettingsCategory( title: String, description: String? = null, - modifier: Modifier = Modifier.padding(top = 24.dp, bottom = 8.dp), + modifier: Modifier, ) { Column(modifier) { Text( @@ -342,8 +350,8 @@ fun SettingsCategory( fun SettingsCategoryWithButton( title: String, description: String? = null, + modifier: Modifier, action: @Composable () -> Unit, - modifier: Modifier = Modifier.padding(top = 24.dp, bottom = 8.dp), ) { Row(modifier, horizontalArrangement = RowColSpacing) { Column(modifier = Modifier.weight(1f)) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Shape.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Shape.kt index dfcc59827..ed175f249 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Shape.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Shape.kt @@ -314,3 +314,6 @@ val PostKeyboard = autoCorrectEnabled = true, capitalization = KeyboardCapitalization.Sentences, ) + +val SettingsCategoryFirstModifier = Modifier.padding(bottom = 8.dp) +val SettingsCategorySpacingModifier = Modifier.padding(top = 24.dp, bottom = 8.dp) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt index ff1043e4c..0d3256864 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt @@ -172,20 +172,6 @@ val LightReplyBorderModifier = .clip(shape = QuoteBorder) .border(1.dp, LightSubtleBorder, QuoteBorder) -val DarkVideoBorderModifier = - Modifier - .padding(top = 5.dp) - .fillMaxWidth() - .clip(shape = RectangleShape) - .border(1.dp, DarkSubtleBorder, RectangleShape) - -val LightVideoBorderModifier = - Modifier - .padding(top = 2.dp, bottom = 0.dp, start = 0.dp, end = 0.dp) - .fillMaxWidth() - .clip(shape = RectangleShape) - .border(1.dp, LightSubtleBorder, RectangleShape) - val DarkInnerPostBorderModifier = Modifier .padding(vertical = 5.dp)