Improves the composition of NIP-05 lines
This commit is contained in:
+17
-25
@@ -20,7 +20,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.components
|
package com.vitorpamplona.amethyst.ui.components
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
@@ -122,19 +121,17 @@ fun nip05VerificationAsAState(
|
|||||||
@Composable
|
@Composable
|
||||||
fun ObserveDisplayNip05Status(
|
fun ObserveDisplayNip05Status(
|
||||||
baseNote: Note,
|
baseNote: Note,
|
||||||
columnModifier: Modifier = Modifier,
|
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
WatchAuthor(baseNote = baseNote, accountViewModel) {
|
WatchAuthor(baseNote = baseNote, accountViewModel) {
|
||||||
ObserveDisplayNip05Status(it, columnModifier, accountViewModel, nav)
|
ObserveDisplayNip05Status(it, accountViewModel, nav)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ObserveDisplayNip05Status(
|
fun ObserveDisplayNip05Status(
|
||||||
baseUser: User,
|
baseUser: User,
|
||||||
columnModifier: Modifier = Modifier,
|
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
@@ -143,14 +140,12 @@ fun ObserveDisplayNip05Status(
|
|||||||
|
|
||||||
CrossfadeIfEnabled(
|
CrossfadeIfEnabled(
|
||||||
targetState = nip05,
|
targetState = nip05,
|
||||||
modifier = columnModifier,
|
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
) {
|
) {
|
||||||
VerifyAndDisplayNIP05OrStatusLine(
|
VerifyAndDisplayNIP05OrStatusLine(
|
||||||
it,
|
it,
|
||||||
statuses,
|
statuses,
|
||||||
baseUser,
|
baseUser,
|
||||||
columnModifier,
|
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav,
|
nav,
|
||||||
)
|
)
|
||||||
@@ -162,29 +157,26 @@ private fun VerifyAndDisplayNIP05OrStatusLine(
|
|||||||
nip05: String?,
|
nip05: String?,
|
||||||
statuses: ImmutableList<AddressableNote>,
|
statuses: ImmutableList<AddressableNote>,
|
||||||
baseUser: User,
|
baseUser: User,
|
||||||
columnModifier: Modifier = Modifier,
|
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
Column(modifier = columnModifier) {
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
if (nip05 != null) {
|
||||||
if (nip05 != null) {
|
val nip05Verified =
|
||||||
val nip05Verified =
|
nip05VerificationAsAState(baseUser.info!!, baseUser.pubkeyHex, accountViewModel)
|
||||||
nip05VerificationAsAState(baseUser.info!!, baseUser.pubkeyHex, accountViewModel)
|
|
||||||
|
|
||||||
if (nip05Verified.value != true) {
|
if (nip05Verified.value != true) {
|
||||||
DisplayNIP05(nip05, nip05Verified, accountViewModel)
|
DisplayNIP05(nip05, nip05Verified, accountViewModel)
|
||||||
} else if (!statuses.isEmpty()) {
|
} else if (!statuses.isEmpty()) {
|
||||||
ObserveRotateStatuses(statuses, accountViewModel, nav)
|
ObserveRotateStatuses(statuses, accountViewModel, nav)
|
||||||
} else {
|
|
||||||
DisplayNIP05(nip05, nip05Verified, accountViewModel)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (!statuses.isEmpty()) {
|
DisplayNIP05(nip05, nip05Verified, accountViewModel)
|
||||||
RotateStatuses(statuses, accountViewModel, nav)
|
}
|
||||||
} else {
|
} else {
|
||||||
DisplayUsersNpub(baseUser.pubkeyDisplayHex())
|
if (!statuses.isEmpty()) {
|
||||||
}
|
RotateStatuses(statuses, accountViewModel, nav)
|
||||||
|
} else {
|
||||||
|
DisplayUsersNpub(baseUser.pubkeyDisplayHex())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -253,7 +245,7 @@ fun DisplayStatus(
|
|||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
val noteState by observeNote(addressableNote, accountViewModel)
|
val noteState by observeNote(addressableNote, accountViewModel)
|
||||||
val noteEvent = noteState?.note?.event as? StatusEvent ?: return
|
val noteEvent = noteState.note.event as? StatusEvent ?: return
|
||||||
|
|
||||||
DisplayStatus(noteEvent, accountViewModel, nav)
|
DisplayStatus(noteEvent, accountViewModel, nav)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1062,10 +1062,12 @@ fun SecondUserInfoRow(
|
|||||||
verticalAlignment = CenterVertically,
|
verticalAlignment = CenterVertically,
|
||||||
modifier = UserNameMaxRowHeight,
|
modifier = UserNameMaxRowHeight,
|
||||||
) {
|
) {
|
||||||
if (noteEvent is BaseThreadedEvent && noteEvent.isAFork()) {
|
Column(modifier = remember(noteEvent) { Modifier.weight(1f) }) {
|
||||||
ShowForkInformation(noteEvent, remember(noteEvent) { Modifier.weight(1f) }, accountViewModel, nav)
|
if (noteEvent is BaseThreadedEvent && noteEvent.isAFork()) {
|
||||||
} else {
|
ShowForkInformation(noteEvent, remember(noteEvent) { Modifier.weight(1f) }, accountViewModel, nav)
|
||||||
ObserveDisplayNip05Status(noteAuthor, remember(noteEvent) { Modifier.weight(1f) }, accountViewModel, nav)
|
} else {
|
||||||
|
ObserveDisplayNip05Status(noteAuthor, accountViewModel, nav)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val geo = remember(noteEvent) { noteEvent.geoHashOrScope() }
|
val geo = remember(noteEvent) { noteEvent.geoHashOrScope() }
|
||||||
|
|||||||
+8
-5
@@ -505,12 +505,15 @@ private fun FullBleedNoteCompose(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
ObserveDisplayNip05Status(
|
Column(
|
||||||
baseNote,
|
|
||||||
remember { Modifier.weight(1f) },
|
remember { Modifier.weight(1f) },
|
||||||
accountViewModel,
|
) {
|
||||||
nav,
|
ObserveDisplayNip05Status(
|
||||||
)
|
baseNote,
|
||||||
|
accountViewModel,
|
||||||
|
nav,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val geo = remember { noteEvent.geoHashOrScope() }
|
val geo = remember { noteEvent.geoHashOrScope() }
|
||||||
if (geo != null) {
|
if (geo != null) {
|
||||||
|
|||||||
+2
-3
@@ -311,7 +311,7 @@ private fun RenderAuthorInformation(
|
|||||||
nav: INav,
|
nav: INav,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
) {
|
) {
|
||||||
Row(modifier = Modifier.padding(start = 10.dp, end = 10.dp, bottom = 10.dp), verticalAlignment = Alignment.CenterVertically) {
|
Row(modifier = Modifier.fillMaxWidth().padding(start = 10.dp, end = 10.dp, bottom = 10.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||||
NoteAuthorPicture(note, Size55dp, accountViewModel = accountViewModel, nav = nav)
|
NoteAuthorPicture(note, Size55dp, accountViewModel = accountViewModel, nav = nav)
|
||||||
|
|
||||||
Spacer(modifier = DoubleHorzSpacer)
|
Spacer(modifier = DoubleHorzSpacer)
|
||||||
@@ -327,10 +327,9 @@ private fun RenderAuthorInformation(
|
|||||||
VideoUserOptionAction(note, accountViewModel, nav)
|
VideoUserOptionAction(note, accountViewModel, nav)
|
||||||
}
|
}
|
||||||
if (accountViewModel.settings.isCompleteUIMode()) {
|
if (accountViewModel.settings.isCompleteUIMode()) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(modifier = Modifier.fillMaxWidth()) {
|
||||||
ObserveDisplayNip05Status(
|
ObserveDisplayNip05Status(
|
||||||
note.author!!,
|
note.author!!,
|
||||||
Modifier.weight(1f),
|
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user