mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-04-19 14:27:01 -04:00
[app] some compose fixes
fix previews that required inaccessible classes and make a view expand/scrollable
This commit is contained in:
@@ -16,6 +16,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import androidx.compose.ui.platform.LocalLayoutDirection
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.em
|
||||
@@ -33,8 +34,9 @@ object ComposeUtils {
|
||||
layoutDirection = layoutDirection,
|
||||
)
|
||||
val newColors = (colors ?: MaterialTheme.colors).let { c ->
|
||||
if (!c.isLight && Preferences.get().isPureBlack) c.copy(background = Color.Black)
|
||||
else c
|
||||
if (!LocalInspectionMode.current && !c.isLight && Preferences.get().isPureBlack) {
|
||||
c.copy(background = Color.Black)
|
||||
} else c
|
||||
}
|
||||
MaterialTheme(
|
||||
colors = newColors,
|
||||
|
||||
@@ -19,6 +19,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
@@ -52,8 +53,11 @@ fun AddRepoErrorScreen(paddingValues: PaddingValues, state: AddRepoError) {
|
||||
val title = when (state.errorType) {
|
||||
INVALID_FINGERPRINT -> stringResource(R.string.bad_fingerprint)
|
||||
UNKNOWN_SOURCES_DISALLOWED -> {
|
||||
val context = LocalContext.current
|
||||
getDisallowInstallUnknownSourcesErrorMessage(context)
|
||||
if (LocalInspectionMode.current) {
|
||||
stringResource(R.string.has_disallow_install_unknown_sources)
|
||||
} else {
|
||||
getDisallowInstallUnknownSourcesErrorMessage(LocalContext.current)
|
||||
}
|
||||
}
|
||||
|
||||
INVALID_INDEX -> stringResource(R.string.repo_invalid)
|
||||
|
||||
@@ -14,6 +14,8 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.ButtonDefaults
|
||||
import androidx.compose.material.ContentAlpha
|
||||
import androidx.compose.material.Icon
|
||||
@@ -114,6 +116,7 @@ fun AddRepoIntroContent(paddingValues: PaddingValues, onFetchRepo: (String) -> U
|
||||
horizontalAlignment = CenterHorizontally,
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(16.dp)
|
||||
.padding(paddingValues),
|
||||
) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.fdroid.fdroid.views.repos
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.Arrangement.spacedBy
|
||||
@@ -95,7 +96,10 @@ fun RepoPreviewHeader(
|
||||
localeList: LocaleListCompat,
|
||||
isPreview: Boolean,
|
||||
) {
|
||||
Column(verticalArrangement = spacedBy(8.dp)) {
|
||||
Column(
|
||||
verticalArrangement = spacedBy(8.dp),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
val repo = state.repo ?: error("repo was null")
|
||||
val res = LocalContext.current.resources
|
||||
Row(
|
||||
@@ -240,8 +244,8 @@ fun RepoPreviewScreenFetchingPreview() {
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES, widthDp = 720, heightDp = 360)
|
||||
fun RepoPreviewScreenNewMirrorPreview() {
|
||||
val repo = FDroidApp.createSwapRepo("https://example.org", "foo bar")
|
||||
FDroidContent {
|
||||
|
||||
Reference in New Issue
Block a user