Skip to content

Commit

Permalink
fix(app/ui): cards padding & styles
Browse files Browse the repository at this point in the history
  • Loading branch information
rhunk committed Sep 7, 2024
1 parent 8bdc1f6 commit a9983c9
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.net.Uri
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.ClickableText
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
Expand All @@ -16,6 +17,7 @@ import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.vectorResource
Expand All @@ -35,7 +37,6 @@ import kotlinx.coroutines.launch
import me.rhunk.snapenhance.R
import me.rhunk.snapenhance.action.EnumQuickActions
import me.rhunk.snapenhance.common.BuildConfig
import me.rhunk.snapenhance.common.Constants
import me.rhunk.snapenhance.common.action.EnumAction
import me.rhunk.snapenhance.common.ui.rememberAsyncMutableState
import me.rhunk.snapenhance.common.ui.rememberAsyncMutableStateList
Expand Down Expand Up @@ -75,7 +76,7 @@ class HomeRootSection : Routes.Route() {
) {
OutlinedCard(
modifier = Modifier
.padding(all = cardMargin)
.padding(start = cardMargin, end = cardMargin)
.fillMaxWidth(),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceVariant,
Expand All @@ -85,7 +86,7 @@ class HomeRootSection : Routes.Route() {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(all = 15.dp)
.padding(all = 10.dp)
) {
content()
}
Expand Down Expand Up @@ -117,6 +118,7 @@ class HomeRootSection : Routes.Route() {
tint = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier
.size(size)
.clip(RoundedCornerShape(50))
.then(modifier)
.clickable { openExternalLink(link) }
)
Expand Down Expand Up @@ -174,9 +176,11 @@ class HomeRootSection : Routes.Route() {
Row(
horizontalArrangement = Arrangement.spacedBy(
15.dp, Alignment.CenterHorizontally
), modifier = Modifier
),
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
.padding(all = 10.dp)
.padding(all = 5.dp)
) {
ExternalLinkIcon(
imageVector = ImageVector.vectorResource(id = R.drawable.ic_codeberg),
Expand All @@ -194,10 +198,10 @@ class HomeRootSection : Routes.Route() {
)

ExternalLinkIcon(
size = 38.dp,
modifier = Modifier.offset(x = (-3).dp, y = (-3).dp),
modifier = Modifier.offset(x = (-3).dp),
size = 40.dp,
imageVector = Icons.AutoMirrored.Default.Help,
link = "https://github.com/rhunk/SnapEnhance/wiki"
link = "https://github.com/rhunk/SnapEnhance/wiki",
)
}

Expand Down Expand Up @@ -312,7 +316,7 @@ class HomeRootSection : Routes.Route() {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(start = 20.dp, end = 10.dp, top = 20.dp),
.padding(start = 20.dp, end = 10.dp, top = 5.dp),
verticalAlignment = Alignment.CenterVertically
) {
Text(
Expand Down Expand Up @@ -380,8 +384,8 @@ class HomeRootSection : Routes.Route() {
modifier = Modifier
.height(tileHeight)
.weight(1f)
.clickable { action(routes) }
.padding(all = 6.dp),
onClick = { action(routes) }
) {
Column(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ class SocialRootSection : Routes.Route() {

LazyColumn(
modifier = Modifier
.padding(2.dp)
.fillMaxWidth()
.fillMaxHeight(),
contentPadding = PaddingValues(bottom = 110.dp),
.fillMaxSize(),
contentPadding = PaddingValues(top = 10.dp, bottom = 110.dp, start = 8.dp, end = 8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
//check if scope list is empty
val listSize = when (scope) {
Expand All @@ -80,15 +79,14 @@ class SocialRootSection : Routes.Route() {

ElevatedCard(
modifier = Modifier
.padding(10.dp)
.fillMaxWidth()
.height(80.dp)
.clickable {
routes.manageScope.navigate {
put("id", id)
put("scope", scope.key)
}
},
.height(70.dp),
onClick = {
routes.manageScope.navigate {
put("id", id)
put("scope", scope.key)
}
}
) {
Row(
modifier = Modifier
Expand All @@ -101,7 +99,7 @@ class SocialRootSection : Routes.Route() {
val group = groupList[index]
Column(
modifier = Modifier
.padding(7.dp)
.padding(start = 7.dp)
.fillMaxWidth()
.weight(1f)
) {
Expand All @@ -127,9 +125,10 @@ class SocialRootSection : Routes.Route() {
BitmojiSelfie.BitmojiSelfieType.THREE_D
)
)

Column(
modifier = Modifier
.padding(7.dp)
.padding(start = 7.dp)
.fillMaxWidth()
.weight(1f)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
Expand All @@ -38,7 +39,7 @@ fun ThemeCatalog(root: ThemingRoot) {
val context = remember { root.context }
val coroutineScope = rememberCoroutineScope { Dispatchers.IO }

fun fetchRepoIndexes(): Map<String, RepositoryIndex>? {
fun fetchRepoIndexes(): Map<String, RepositoryIndex> {
val indexes = mutableMapOf<String, RepositoryIndex>()

context.database.getRepositories().forEach { rootUri ->
Expand Down Expand Up @@ -91,7 +92,7 @@ fun ThemeCatalog(root: ThemingRoot) {
isRefreshing = true
coroutineScope {
launch(Dispatchers.IO) {
fetchRepoIndexes()?.let {
fetchRepoIndexes().let {
context.log.verbose("Fetched ${it.size} theme indexes")
it.forEach { (t, u) ->
context.log.verbose("Fetched theme index from $t with ${u.themes.size} themes")
Expand Down Expand Up @@ -146,7 +147,8 @@ fun ThemeCatalog(root: ThemingRoot) {
modifier = Modifier
.fillMaxSize()
.pullRefresh(pullRefreshState),
contentPadding = PaddingValues(8.dp)
contentPadding = PaddingValues(8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
item {
if (remoteThemes.isEmpty()) {
Expand Down Expand Up @@ -192,32 +194,32 @@ fun ThemeCatalog(root: ThemingRoot) {
Icon(Icons.Default.Palette, contentDescription = null, modifier = Modifier.padding(16.dp))
Column(
modifier = Modifier.weight(1f),
verticalArrangement = Arrangement.Center
) {
Row(
horizontalArrangement = Arrangement.spacedBy(4.dp),
verticalAlignment = Alignment.Bottom
) {
Text(
text = themeManifest.name,
maxLines = 1,
fontSize = 16.sp,
lineHeight = 10.sp,
overflow = TextOverflow.Ellipsis,
fontWeight = FontWeight.Bold,
)
themeManifest.author?.let {
Text(
text = themeManifest.name,
text = "by $it",
maxLines = 1,
overflow = TextOverflow.Ellipsis,
fontSize = 10.sp,
lineHeight = 16.sp,
textDecoration = TextDecoration.Underline,
fontWeight = FontWeight.Light,
overflow = TextOverflow.Visible,
)
themeManifest.author?.let {
Text(
text = "by $it",
maxLines = 1,
fontSize = 10.sp,
fontWeight = FontWeight.Light,
overflow = TextOverflow.Ellipsis,
)
}
}
themeManifest.description?.let {
Text(
text = it,
fontSize = 12.sp,
maxLines = 3,
lineHeight = 16.sp,
overflow = TextOverflow.Ellipsis,
)
}
Expand Down Expand Up @@ -261,6 +263,9 @@ fun ThemeCatalog(root: ThemingRoot) {
}
}
}
item {
Spacer(modifier = Modifier.height(80.dp))
}
}

PullRefreshIndicator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ class ThemingRoot: Routes.Route() {

LazyColumn(
modifier = Modifier
.fillMaxSize()
.padding(2.dp),
verticalArrangement = Arrangement.spacedBy(5.dp)
.fillMaxSize(),
contentPadding = PaddingValues(8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
item {
if (themes.isEmpty()) {
Expand All @@ -326,13 +326,12 @@ class ThemingRoot: Routes.Route() {

ElevatedCard(
modifier = Modifier
.fillMaxWidth()
.clickable {
routes.editTheme.navigate {
this["theme_id"] = theme.id.toString()
}
.fillMaxWidth(),
onClick = {
routes.editTheme.navigate {
this["theme_id"] = theme.id.toString()
}
.padding(8.dp)
}
) {
Row(
modifier = Modifier
Expand Down Expand Up @@ -408,7 +407,7 @@ class ThemingRoot: Routes.Route() {
}
}
item {
Spacer(modifier = Modifier.height(100.dp))
Spacer(modifier = Modifier.height(200.dp))
}
}
}
Expand Down

0 comments on commit a9983c9

Please sign in to comment.