fix: Added correct font

This commit is contained in:
PartyDonut 2025-10-18 14:20:32 +02:00
parent f25ed59a37
commit 01a98f974f
9 changed files with 98 additions and 24 deletions

View file

@ -3,12 +3,17 @@ package nl.jknaapen.fladder
import android.os.Build
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Typography
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import com.materialkolor.PaletteStyle
import com.materialkolor.dynamiccolor.ColorSpec
import com.materialkolor.rememberDynamicColorScheme
@ -38,8 +43,44 @@ fun VideoPlayerTheme(
MaterialTheme(
colorScheme = chosenScheme,
typography = customTypography
) {
content()
}
}
val customTypography: Typography
@Composable
get() {
val rubikFamily = FontFamily(
Font(R.font.rubik_light, FontWeight.Light),
Font(R.font.rubik_normal, FontWeight.Normal),
Font(R.font.rubik_italic, FontWeight.Normal, FontStyle.Italic),
Font(R.font.rubik_medium, FontWeight.Medium),
Font(R.font.rubik_bold, FontWeight.Bold)
)
val defaultTypography = MaterialTheme.typography
return defaultTypography.copy(
displayLarge = defaultTypography.displayLarge.copy(fontFamily = rubikFamily),
displayMedium = defaultTypography.displayMedium.copy(fontFamily = rubikFamily),
displaySmall = defaultTypography.displaySmall.copy(fontFamily = rubikFamily),
headlineLarge = defaultTypography.headlineLarge.copy(fontFamily = rubikFamily),
headlineMedium = defaultTypography.headlineMedium.copy(fontFamily = rubikFamily),
headlineSmall = defaultTypography.headlineSmall.copy(fontFamily = rubikFamily),
titleLarge = defaultTypography.titleLarge.copy(fontFamily = rubikFamily),
titleMedium = defaultTypography.titleMedium.copy(fontFamily = rubikFamily),
titleSmall = defaultTypography.titleSmall.copy(fontFamily = rubikFamily),
bodyLarge = defaultTypography.bodyLarge.copy(fontFamily = rubikFamily),
bodyMedium = defaultTypography.bodyMedium.copy(fontFamily = rubikFamily),
bodySmall = defaultTypography.bodySmall.copy(fontFamily = rubikFamily),
labelLarge = defaultTypography.labelLarge.copy(fontFamily = rubikFamily),
labelMedium = defaultTypography.labelMedium.copy(fontFamily = rubikFamily),
labelSmall = defaultTypography.labelSmall.copy(fontFamily = rubikFamily)
)
}

View file

@ -48,6 +48,7 @@ import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.input.key.Key.Companion.Back
import androidx.compose.ui.input.key.Key.Companion.DirectionLeft
import androidx.compose.ui.input.key.Key.Companion.DirectionRight
import androidx.compose.ui.input.key.KeyEvent
@ -79,7 +80,12 @@ import nl.jknaapen.fladder.utility.ImmersiveSystemBars
import nl.jknaapen.fladder.utility.defaultSelected
import nl.jknaapen.fladder.utility.leanBackEnabled
import nl.jknaapen.fladder.utility.visible
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import kotlin.time.Clock
import kotlin.time.Duration.Companion.seconds
import kotlin.time.ExperimentalTime
import kotlin.time.toJavaInstant
@RequiresApi(Build.VERSION_CODES.O)
@ -112,14 +118,12 @@ fun CustomVideoControls(
bottomControlFocusRequester.requestFocus()
}
BackHandler(
enabled = showControls
) {
hideControls()
}
// Restart the hide timer whenever `lastInteraction` changes.
LaunchedEffect(lastInteraction.longValue) {
delay(5.seconds)
@ -166,6 +170,7 @@ fun CustomVideoControls(
if (!showControls) {
when (keyEvent.key) {
Back -> return@onKeyEvent true
DirectionLeft -> {
currentSkipTime -= backwardSpeed.inWholeMilliseconds
updateSeekInteraction()
@ -225,18 +230,23 @@ fun CustomVideoControls(
) {
Column(
modifier = Modifier
.padding(controlsPadding)
.weight(1f),
) {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
) {
val state by VideoPlayerObject.implementation.playbackData.collectAsState(
null
)
state?.let {
ItemHeader(
modifier = Modifier.padding(controlsPadding),
modifier = Modifier
.weight(1f),
it
)
}
}
if (!leanBackEnabled(LocalContext.current)) {
IconButton(
{
@ -252,6 +262,10 @@ fun CustomVideoControls(
tint = Color.White,
)
}
} else {
CurrentTime()
}
}
}
}
Spacer(modifier = Modifier.weight(1f))
@ -507,3 +521,22 @@ internal fun RowScope.RightButtons(
}
}
}
@RequiresApi(Build.VERSION_CODES.O)
@kotlin.OptIn(ExperimentalTime::class)
@Composable
private fun CurrentTime() {
val startInstant = Clock.System.now()
val zone = ZoneId.systemDefault()
val endInstant = startInstant.toJavaInstant()
val endZoned = endInstant.atZone(zone)
val formatter = DateTimeFormatter.ofPattern("hh:mm a")
Text(
endZoned.format(formatter),
style = MaterialTheme.typography.titleMedium,
color = Color.White
)
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.