mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-08-15 06:56:30 +00:00
Merge f43c74187726d2873c71d93e8b9aff351c6f8c35 into 094657efa0aabbb6f71c9050149d1d01aee96400
This commit is contained in:
commit
f1cf2af444
@ -39,6 +39,7 @@ import androidx.compose.ui.unit.IntOffset
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.bitchat.android.ui.theme.BitchatFontFamily
|
||||
@ -46,6 +47,8 @@ import com.bitchat.android.R
|
||||
import com.bitchat.android.core.ui.icon.BitChatIcon
|
||||
import com.bitchat.android.ui.theme.BitchatMotion
|
||||
import com.bitchat.android.ui.theme.LocalBitchatPalette
|
||||
import com.bitchat.android.util.sdp
|
||||
import com.bitchat.android.util.ssp
|
||||
|
||||
/**
|
||||
* Building blocks for the redesigned About sheet.
|
||||
@ -497,14 +500,14 @@ internal fun BitchatBadge(
|
||||
Box(
|
||||
modifier = modifier
|
||||
.background(colorScheme.primary.copy(alpha = 0.15f), RoundedCornerShape(4.dp))
|
||||
.padding(horizontal = 5.dp, vertical = 2.dp)
|
||||
.padding(horizontal = 5.sdp(), vertical = 2.sdp())
|
||||
) {
|
||||
Text(
|
||||
text = text.uppercase(),
|
||||
fontFamily = BitchatFontFamily,
|
||||
fontSize = 10.sp,
|
||||
fontSize = 9.ssp(),
|
||||
fontWeight = FontWeight.Bold,
|
||||
letterSpacing = 0.5.sp,
|
||||
letterSpacing = 0.5.ssp(),
|
||||
color = colorScheme.primary
|
||||
)
|
||||
}
|
||||
@ -513,7 +516,8 @@ internal fun BitchatBadge(
|
||||
// MARK: - Shared bottom-sheet primitives
|
||||
|
||||
/** Horizontal inset for sheet content. Cards inset from here; labels align to the same edge. */
|
||||
internal val SheetHorizontalPadding = 16.dp
|
||||
internal val SheetHorizontalPadding: Dp
|
||||
@Composable get() = 16.sdp()
|
||||
|
||||
/**
|
||||
* Section divider label used across the sheets, e.g. `BOOKMARKED`, `NEARBY`, `ON LOCATION`.
|
||||
|
||||
@ -74,6 +74,8 @@ import com.bitchat.android.net.TorMode
|
||||
import com.bitchat.android.net.TorPreferenceManager
|
||||
import com.bitchat.android.ui.theme.BitchatMotion
|
||||
import com.bitchat.android.ui.theme.LocalBitchatPalette
|
||||
import com.bitchat.android.util.sdp
|
||||
import com.bitchat.android.util.ssp
|
||||
import com.bitchat.android.wifiaware.WifiAwareController
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.first
|
||||
@ -237,13 +239,13 @@ fun LocationChannelsSheet(
|
||||
iconRes = R.drawable.ic_spec_range,
|
||||
title = stringResource(R.string.mesh_title),
|
||||
subtitle = stringResource(R.string.mesh_section_subtitle),
|
||||
modifier = Modifier.padding(top = 8.dp)
|
||||
modifier = Modifier.padding(top = 8.sdp())
|
||||
)
|
||||
Surface(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = AboutHorizontalPadding)
|
||||
.padding(top = 10.dp),
|
||||
.padding(top = 10.sdp()),
|
||||
color = colorScheme.surface,
|
||||
shape = AboutCardShape
|
||||
) {
|
||||
@ -1049,7 +1051,7 @@ private fun ChannelSettingsToggleRow(
|
||||
Text(
|
||||
text = title,
|
||||
fontFamily = BitchatFontFamily,
|
||||
fontSize = 14.sp,
|
||||
fontSize = 14.ssp(),
|
||||
fontWeight = FontWeight.Medium,
|
||||
color = if (enabled) colorScheme.onSurface else palette.textTertiary
|
||||
)
|
||||
@ -1058,12 +1060,12 @@ private fun ChannelSettingsToggleRow(
|
||||
Text(
|
||||
text = subtitle,
|
||||
fontFamily = BitchatFontFamily,
|
||||
fontSize = 12.sp,
|
||||
lineHeight = 17.sp,
|
||||
fontSize = 12.ssp(),
|
||||
lineHeight = 17.ssp(),
|
||||
color = if (enabled) colorScheme.onSurfaceVariant else palette.textTertiary
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
Spacer(modifier = Modifier.width(16.sdp()))
|
||||
Switch(
|
||||
checked = checked,
|
||||
onCheckedChange = { if (enabled) onCheckedChange(it) },
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
package com.bitchat.android.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.TextUnit
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import kotlin.math.min
|
||||
|
||||
/** Reference design width (dp) the UI was designed against — matches a standard phone viewport. */
|
||||
private const val BASE_WIDTH = 360f
|
||||
|
||||
/** Clamp scaling so tiny/huge screens (foldables, tablets) don't over- or under-scale content. */
|
||||
private const val MIN_SCALE = 0.85f
|
||||
private const val MAX_SCALE = 1.30f
|
||||
|
||||
/**
|
||||
* Returns the current width-based scale factor, clamped to [MIN_SCALE, MAX_SCALE].
|
||||
* Uses the smaller of width/height dp so rotation to landscape doesn't blow up the scale.
|
||||
*/
|
||||
@SuppressLint("ConfigurationScreenWidthHeight")
|
||||
@Composable
|
||||
private fun rememberUiScale(): Float {
|
||||
val configuration = LocalConfiguration.current
|
||||
val shortestDp = min(configuration.screenWidthDp, configuration.screenHeightDp)
|
||||
return remember(shortestDp) {
|
||||
(shortestDp / BASE_WIDTH).coerceIn(MIN_SCALE, MAX_SCALE)
|
||||
}
|
||||
}
|
||||
|
||||
/** Scales a dp value relative to [BASE_WIDTH], clamped to avoid extreme scaling on outlier screens. */
|
||||
@Composable
|
||||
fun Float.sdp(): Dp = (this * rememberUiScale()).dp
|
||||
|
||||
/** Scales a sp value relative to [BASE_WIDTH], clamped to avoid extreme scaling on outlier screens. */
|
||||
@Composable
|
||||
fun Float.ssp(): TextUnit = (this * rememberUiScale()).sp
|
||||
|
||||
/** Int convenience overload — lets you write `16.sdp()` directly. */
|
||||
@Composable
|
||||
fun Int.sdp(): Dp = this.toFloat().sdp()
|
||||
|
||||
@Composable
|
||||
fun Int.ssp(): TextUnit = this.toFloat().ssp()
|
||||
|
||||
/** Double convenience overload — covers decimal literals like `8.5.sdp()`, which Kotlin infers as Double by default. */
|
||||
@Composable
|
||||
fun Double.sdp(): Dp = this.toFloat().sdp()
|
||||
|
||||
@Composable
|
||||
fun Double.ssp(): TextUnit = this.toFloat().ssp()
|
||||
@ -3,11 +3,6 @@
|
||||
<configuration>
|
||||
<verify-metadata>true</verify-metadata>
|
||||
<verify-signatures>false</verify-signatures>
|
||||
<trusted-artifacts>
|
||||
<trust file=".*-javadoc[.]jar" regex="true" reason="IDE documentation attachments are not build inputs"/>
|
||||
<trust file=".*-sources[.]jar" regex="true" reason="IDE source attachments are not build inputs"/>
|
||||
<trust file=".*-src[.]zip" regex="true" reason="Gradle IDE source attachments are not build inputs"/>
|
||||
</trusted-artifacts>
|
||||
</configuration>
|
||||
<components>
|
||||
<component group="androidx.activity" name="activity" version="1.13.0">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user