mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-05 19:08:23 +00:00
Add HistoryDatabase schema version 3 and customize section padding in ActivitiesScreen
- Add `HistoryDatabase` version 3 schema definition including the `history` table and its associated indices. - Update `EventSection` and `TagsSection` components to accept custom padding parameters, defaulting to previous values for backward compatibility. - Adjust `ActivitiesScreen` to use zero-padding and spacers for content and tags sections, improving the layout density of activity items.
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 3,
|
||||
"identityHash": "05375ac6ff0b7b2ab82afd950bea114c",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "history",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `pkKey` TEXT NOT NULL, `type` TEXT NOT NULL, `kind` INTEGER, `time` INTEGER NOT NULL, `accepted` INTEGER NOT NULL, `translatedPermission` TEXT NOT NULL, `content` TEXT NOT NULL)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "pkKey",
|
||||
"columnName": "pkKey",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "type",
|
||||
"columnName": "type",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "kind",
|
||||
"columnName": "kind",
|
||||
"affinity": "INTEGER"
|
||||
},
|
||||
{
|
||||
"fieldPath": "time",
|
||||
"columnName": "time",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "accepted",
|
||||
"columnName": "accepted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "translatedPermission",
|
||||
"columnName": "translatedPermission",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "content",
|
||||
"columnName": "content",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"autoGenerate": true,
|
||||
"columnNames": [
|
||||
"id"
|
||||
]
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "history_by_pk_key",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"pkKey"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `history_by_pk_key` ON `${TABLE_NAME}` (`pkKey`)"
|
||||
},
|
||||
{
|
||||
"name": "history_by_id",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `history_by_id` ON `${TABLE_NAME}` (`id`)"
|
||||
},
|
||||
{
|
||||
"name": "history_by_time",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"time"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `history_by_time` ON `${TABLE_NAME}` (`time`)"
|
||||
},
|
||||
{
|
||||
"name": "history_by_key_and_time",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"pkKey",
|
||||
"time"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `history_by_key_and_time` ON `${TABLE_NAME}` (`pkKey`, `time`)"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '05375ac6ff0b7b2ab82afd950bea114c')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.text.input.TextFieldState
|
||||
@@ -189,14 +190,19 @@ fun ActivityRow(activity: HistoryEntity, account: Account) {
|
||||
|
||||
if (parsedEvent != null) {
|
||||
if (parsedEvent.content.isNotBlank()) {
|
||||
Spacer(Modifier.height(4.dp))
|
||||
EventSection(
|
||||
padding = 0.dp,
|
||||
label = stringResource(R.string.content),
|
||||
displayValue = parsedEvent.content,
|
||||
onCopy = { copyToClipboard(clipboard, parsedEvent.content) },
|
||||
)
|
||||
}
|
||||
if (parsedEvent.tags.isNotEmpty()) {
|
||||
Spacer(Modifier.height(4.dp))
|
||||
TagsSection(
|
||||
horizontalPadding = 0,
|
||||
verticalPadding = 0,
|
||||
label = stringResource(R.string.tags),
|
||||
tags = parsedEvent.tags,
|
||||
onCopy = {
|
||||
@@ -210,6 +216,7 @@ fun ActivityRow(activity: HistoryEntity, account: Account) {
|
||||
)
|
||||
}
|
||||
} else if (activity.content.isNotBlank()) {
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Text(
|
||||
modifier = Modifier.padding(top = 2.dp),
|
||||
text = activity.content,
|
||||
|
||||
@@ -18,6 +18,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.greenart7c3.nostrsigner.R
|
||||
@@ -27,11 +28,12 @@ fun EventSection(
|
||||
label: String,
|
||||
displayValue: String,
|
||||
onCopy: () -> Unit,
|
||||
padding: Dp = 16.dp,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp),
|
||||
.padding(padding),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.Top,
|
||||
) {
|
||||
|
||||
@@ -27,6 +27,8 @@ fun TagsSection(
|
||||
label: String,
|
||||
tags: Array<Array<String>>,
|
||||
onCopy: () -> Unit,
|
||||
horizontalPadding: Int = 16,
|
||||
verticalPadding: Int = 12,
|
||||
) {
|
||||
val tagsToShow = tags.take(10)
|
||||
val moreCount = tags.size - 10
|
||||
@@ -34,7 +36,7 @@ fun TagsSection(
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp),
|
||||
.padding(horizontal = horizontalPadding.dp, vertical = verticalPadding.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.Top,
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user