feat: Round avatars
This commit is contained in:
parent
c0944ec0a8
commit
e70049f1f5
6
.idea/copyright/profiles_settings.xml
generated
6
.idea/copyright/profiles_settings.xml
generated
@ -1,7 +1,3 @@
|
|||||||
<component name="CopyrightManager">
|
<component name="CopyrightManager">
|
||||||
<settings default="My">
|
<settings default="My" />
|
||||||
<module2copyright>
|
|
||||||
<element module="All" copyright="My" />
|
|
||||||
</module2copyright>
|
|
||||||
</settings>
|
|
||||||
</component>
|
</component>
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Created by sweetbread on 22.02.2025, 17:56
|
* Created by sweetbread
|
||||||
* Copyright (c) 2025. All rights reserved.
|
* Copyright (c) 2025. All rights reserved.
|
||||||
* Last modified 22.02.2025, 17:48
|
* Last modified 22.02.2025, 19:52
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package ru.risdeveau.pixeldragon.api
|
package ru.risdeveau.pixeldragon.api
|
||||||
@ -38,9 +38,10 @@ suspend fun getRoom(rid: String): Room {
|
|||||||
var room = db.roomDoa().getById(rid)
|
var room = db.roomDoa().getById(rid)
|
||||||
if (room == null) {
|
if (room == null) {
|
||||||
val name = getState(rid, "m.room.name", "name")
|
val name = getState(rid, "m.room.name", "name")
|
||||||
|
val type = getState(rid, "m.room.create", "type") ?: "m.room"
|
||||||
val creator = getState(rid, "m.room.create", "creator")
|
val creator = getState(rid, "m.room.create", "creator")
|
||||||
val avatar = getState(rid, "m.room.avatar", "url")
|
val avatar = getState(rid, "m.room.avatar", "url")
|
||||||
room = Room(rid, name, creator, null, avatar, null, true)
|
room = Room(rid, name, type, creator, null, avatar, null, true)
|
||||||
db.roomDoa().insert(room)
|
db.roomDoa().insert(room)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Created by sweetbread on 22.02.2025, 15:45
|
* Created by sweetbread
|
||||||
* Copyright (c) 2025. All rights reserved.
|
* Copyright (c) 2025. All rights reserved.
|
||||||
* Last modified 22.02.2025, 15:45
|
* Last modified 22.02.2025, 19:49
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package ru.risdeveau.pixeldragon.db
|
package ru.risdeveau.pixeldragon.db
|
||||||
@ -22,6 +22,7 @@ import androidx.room.RoomDatabase
|
|||||||
data class Room(
|
data class Room(
|
||||||
@PrimaryKey val roomId: String,
|
@PrimaryKey val roomId: String,
|
||||||
val name: String?,
|
val name: String?,
|
||||||
|
val type: String,
|
||||||
val creatorId: String?,
|
val creatorId: String?,
|
||||||
val createTime: Long?,
|
val createTime: Long?,
|
||||||
val avatarUrl: String?,
|
val avatarUrl: String?,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Created by sweetbread on 22.02.2025, 17:56
|
* Created by sweetbread
|
||||||
* Copyright (c) 2025. All rights reserved.
|
* Copyright (c) 2025. All rights reserved.
|
||||||
* Last modified 22.02.2025, 17:56
|
* Last modified 22.02.2025, 20:24
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package ru.risdeveau.pixeldragon.ui.activity
|
package ru.risdeveau.pixeldragon.ui.activity
|
||||||
@ -21,6 +21,7 @@ import androidx.compose.foundation.layout.width
|
|||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material3.CircularProgressIndicator
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
@ -38,6 +39,8 @@ import androidx.compose.runtime.remember
|
|||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import coil3.compose.SubcomposeAsyncImage
|
import coil3.compose.SubcomposeAsyncImage
|
||||||
import coil3.network.NetworkHeaders
|
import coil3.network.NetworkHeaders
|
||||||
@ -134,7 +137,7 @@ fun RoomItem(modifier: Modifier = Modifier, rid: String) {
|
|||||||
Row(
|
Row(
|
||||||
modifier
|
modifier
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
.height(72.dp)
|
.height(80.dp)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.background(MaterialTheme.colorScheme.primaryContainer, RoundedCornerShape(16.dp))
|
.background(MaterialTheme.colorScheme.primaryContainer, RoundedCornerShape(16.dp))
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
@ -143,7 +146,13 @@ fun RoomItem(modifier: Modifier = Modifier, rid: String) {
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(end = 4.dp)
|
.padding(end = 4.dp)
|
||||||
.height(64.dp)
|
.height(64.dp)
|
||||||
.width(64.dp),
|
.width(64.dp)
|
||||||
|
.let {
|
||||||
|
if (room!!.type == "m.space")
|
||||||
|
it.clip(RoundedCornerShape(12.dp))
|
||||||
|
else
|
||||||
|
it.clip(CircleShape)
|
||||||
|
},
|
||||||
model = ImageRequest.Builder(appCtx)
|
model = ImageRequest.Builder(appCtx)
|
||||||
.data(mxcToUrl(room!!.avatarUrl ?: ""))
|
.data(mxcToUrl(room!!.avatarUrl ?: ""))
|
||||||
.httpHeaders(
|
.httpHeaders(
|
||||||
@ -154,16 +163,31 @@ fun RoomItem(modifier: Modifier = Modifier, rid: String) {
|
|||||||
)
|
)
|
||||||
.build(),
|
.build(),
|
||||||
contentDescription = room!!.roomId,
|
contentDescription = room!!.roomId,
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
loading = {
|
loading = {
|
||||||
CircularProgressIndicator()
|
CircularProgressIndicator()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
Column {
|
Column {
|
||||||
Text(room!!.name ?: "Unknown", maxLines = 1)
|
Text(
|
||||||
|
room!!.name ?: "Unnamed",
|
||||||
|
maxLines = 1,
|
||||||
|
color = MaterialTheme.colorScheme.primary,
|
||||||
|
fontSize = MaterialTheme.typography.titleLarge.fontSize
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LinearProgressIndicator(Modifier.fillMaxWidth())
|
Row(
|
||||||
|
modifier
|
||||||
|
.padding(8.dp)
|
||||||
|
.height(80.dp)
|
||||||
|
.fillMaxWidth()
|
||||||
|
.background(MaterialTheme.colorScheme.primaryContainer, RoundedCornerShape(16.dp))
|
||||||
|
.padding(8.dp)
|
||||||
|
) {
|
||||||
|
LinearProgressIndicator(Modifier.fillMaxWidth())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user