mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-28 22:53:11 +02:00
DVM: show amount and personalized in feed
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
package com.vitorpamplona.amethyst.ui.note
|
package com.vitorpamplona.amethyst.ui.note
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
@@ -33,6 +34,7 @@ import androidx.compose.foundation.layout.fillMaxSize
|
|||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
@@ -55,8 +57,10 @@ import androidx.compose.ui.draw.clip
|
|||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
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.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.lifecycle.distinctUntilChanged
|
import androidx.lifecycle.distinctUntilChanged
|
||||||
@@ -91,6 +95,8 @@ import com.vitorpamplona.amethyst.ui.theme.Size5dp
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
|
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.StdPadding
|
import com.vitorpamplona.amethyst.ui.theme.StdPadding
|
||||||
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.bitcoinColor
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.nip05
|
||||||
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
||||||
import com.vitorpamplona.quartz.events.AppDefinitionEvent
|
import com.vitorpamplona.quartz.events.AppDefinitionEvent
|
||||||
import com.vitorpamplona.quartz.events.ChannelCreateEvent
|
import com.vitorpamplona.quartz.events.ChannelCreateEvent
|
||||||
@@ -542,6 +548,8 @@ data class DVMCard(
|
|||||||
val name: String,
|
val name: String,
|
||||||
val description: String?,
|
val description: String?,
|
||||||
val cover: String?,
|
val cover: String?,
|
||||||
|
val amount: String?,
|
||||||
|
val personalized: Boolean?,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -838,6 +846,71 @@ fun RenderContentDVMThumb(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onBottomRow = {
|
onBottomRow = {
|
||||||
|
card.amount?.let {
|
||||||
|
var color = Color.DarkGray
|
||||||
|
var amount = it
|
||||||
|
if (card.amount == "free" || card.amount == "0") {
|
||||||
|
color = MaterialTheme.colorScheme.secondary
|
||||||
|
amount = "Free"
|
||||||
|
} else if (card.amount == "flexible") {
|
||||||
|
color = MaterialTheme.colorScheme.primaryContainer
|
||||||
|
amount = "Flexible"
|
||||||
|
} else if (card.amount == "") {
|
||||||
|
color = MaterialTheme.colorScheme.secondaryContainer
|
||||||
|
amount = "Unknown"
|
||||||
|
} else {
|
||||||
|
color = MaterialTheme.colorScheme.primary
|
||||||
|
amount = card.amount + " Sats"
|
||||||
|
}
|
||||||
|
Spacer(modifier = StdVertSpacer)
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.Absolute.Right,
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
textAlign = TextAlign.End,
|
||||||
|
text = " $amount ",
|
||||||
|
color = color,
|
||||||
|
maxLines = 3,
|
||||||
|
modifier =
|
||||||
|
Modifier
|
||||||
|
.padding(start = 4.dp)
|
||||||
|
.weight(1f, fill = false)
|
||||||
|
.border(Dp(.1f), color, shape = RoundedCornerShape(20)),
|
||||||
|
fontSize = 12.sp,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Spacer(modifier = StdHorzSpacer)
|
||||||
|
card.personalized?.let {
|
||||||
|
var color = Color.DarkGray
|
||||||
|
var name = "generic"
|
||||||
|
if (card.personalized == true) {
|
||||||
|
color = MaterialTheme.colorScheme.bitcoinColor
|
||||||
|
name = "Personalized"
|
||||||
|
} else {
|
||||||
|
color = MaterialTheme.colorScheme.nip05
|
||||||
|
name = "Generic"
|
||||||
|
}
|
||||||
|
Spacer(modifier = StdVertSpacer)
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.Absolute.Right,
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
textAlign = TextAlign.End,
|
||||||
|
text = " $name ",
|
||||||
|
color = color,
|
||||||
|
maxLines = 3,
|
||||||
|
modifier =
|
||||||
|
Modifier
|
||||||
|
.padding(start = 4.dp)
|
||||||
|
.weight(1f, fill = false)
|
||||||
|
.border(Dp(.1f), color, shape = RoundedCornerShape(20)),
|
||||||
|
fontSize = 12.sp,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -634,6 +634,8 @@ fun observeAppDefinition(appDefinitionNote: Note): DVMCard {
|
|||||||
name = "",
|
name = "",
|
||||||
description = "",
|
description = "",
|
||||||
cover = null,
|
cover = null,
|
||||||
|
amount = "",
|
||||||
|
personalized = false,
|
||||||
)
|
)
|
||||||
|
|
||||||
val card by
|
val card by
|
||||||
@@ -647,6 +649,8 @@ fun observeAppDefinition(appDefinitionNote: Note): DVMCard {
|
|||||||
name = noteEvent?.appMetaData()?.name ?: "",
|
name = noteEvent?.appMetaData()?.name ?: "",
|
||||||
description = noteEvent?.appMetaData()?.about ?: "",
|
description = noteEvent?.appMetaData()?.about ?: "",
|
||||||
cover = noteEvent?.appMetaData()?.profilePicture()?.ifBlank { null },
|
cover = noteEvent?.appMetaData()?.profilePicture()?.ifBlank { null },
|
||||||
|
amount = noteEvent?.appMetaData()?.amount ?: "",
|
||||||
|
personalized = noteEvent?.appMetaData()?.personalized ?: false,
|
||||||
)
|
)
|
||||||
}.distinctUntilChanged()
|
}.distinctUntilChanged()
|
||||||
.observeAsState(
|
.observeAsState(
|
||||||
@@ -654,6 +658,8 @@ fun observeAppDefinition(appDefinitionNote: Note): DVMCard {
|
|||||||
name = noteEvent.appMetaData()?.name ?: "",
|
name = noteEvent.appMetaData()?.name ?: "",
|
||||||
description = noteEvent.appMetaData()?.about ?: "",
|
description = noteEvent.appMetaData()?.about ?: "",
|
||||||
cover = noteEvent.appMetaData()?.profilePicture()?.ifBlank { null },
|
cover = noteEvent.appMetaData()?.profilePicture()?.ifBlank { null },
|
||||||
|
amount = noteEvent.appMetaData()?.amount ?: "",
|
||||||
|
personalized = noteEvent.appMetaData()?.personalized ?: false,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user