Skip to content

Commit

Permalink
Use New theme
Browse files Browse the repository at this point in the history
  • Loading branch information
jsixface committed Apr 12, 2024
1 parent ff3ea13 commit ff6e3f9
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 143 deletions.
2 changes: 1 addition & 1 deletion composeApp/src/commonMain/kotlin/App.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import androidx.compose.runtime.Composable
import org.koin.compose.KoinApplication
import services.Koin
import ui.theme.AppTheme
import ui.MainScreen
import ui.theme.AppTheme

@Composable
fun App() {
Expand Down
35 changes: 10 additions & 25 deletions composeApp/src/commonMain/kotlin/ui/home/FileDetails.kt
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
package ui.home

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilterChip
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateMapOf
import androidx.compose.runtime.remember
Expand All @@ -23,13 +13,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import io.github.jsixface.common.AudioCodecs
import io.github.jsixface.common.Conversion
import io.github.jsixface.common.*
import io.github.jsixface.common.Conversion.Convert
import io.github.jsixface.common.MediaTrack
import io.github.jsixface.common.TrackType
import io.github.jsixface.common.VideoCodecs
import io.github.jsixface.common.VideoFile

@Composable
fun FileDetailsDialog(file: VideoFile, onDismiss: (Map<MediaTrack, Conversion>?) -> Unit) {
Expand All @@ -51,7 +36,7 @@ fun FileDetails(file: VideoFile, onDismiss: (Map<MediaTrack, Conversion>?) -> Un
}

val padder = Modifier.padding(16.dp)
Card(
OutlinedCard(
modifier = padder.width(800.dp),
shape = RoundedCornerShape(16.dp),
) {
Expand Down Expand Up @@ -79,8 +64,8 @@ fun FileDetails(file: VideoFile, onDismiss: (Map<MediaTrack, Conversion>?) -> Un
}

Row {
Button(onClick = { onDismiss(null) }, modifier = padder) { Text("Cancel") }
Button(onClick = { onDismiss(conversion.toMap()) }, modifier = padder) { Text("Convert") }
Button(onClick = { onDismiss(null) }, modifier = padder) { Text("Cancel") }
}
}
}
Expand All @@ -89,7 +74,7 @@ fun FileDetails(file: VideoFile, onDismiss: (Map<MediaTrack, Conversion>?) -> Un
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun CodecRow(ai: Int, track: MediaTrack, selected: Conversion, onSelect: (Conversion) -> Unit) {
val codecsAvailable = if (track.type == TrackType.Audio) AudioCodecs else VideoCodecs
val codecsAvailable = Codec.entries.filter { it.type == track.type }
Row(modifier = Modifier.padding(16.dp, 4.dp), verticalAlignment = Alignment.CenterVertically) {
Text("Track $ai", modifier = Modifier.weight(1f))
Row(modifier = Modifier.weight(2f), verticalAlignment = Alignment.CenterVertically) {
Expand All @@ -103,20 +88,20 @@ private fun CodecRow(ai: Int, track: MediaTrack, selected: Conversion, onSelect:
label = { Text("KEEP") },
modifier = Modifier.padding(3.dp, 0.dp),
)
codecsAvailable.filter { it != track.codec }.forEach { c ->
codecsAvailable.filter { it.name.lowercase() != track.codec.lowercase() }.forEach { c ->
val convert = Convert(c)
FilterChip(
onClick = { onSelect(convert) },
selected = (selected as? Convert)?.codec == c,
label = { Text(c) },
modifier = Modifier.padding(3.dp, 0.dp)
label = { Text(c.name) },
modifier = Modifier.padding(3.dp, 0.dp),
)
}
FilterChip(
onClick = { onSelect(Conversion.Drop) },
selected = (selected == Conversion.Drop),
label = { Text("DROP") },
modifier = Modifier.padding(3.dp, 0.dp)
modifier = Modifier.padding(3.dp, 0.dp),
)
}
}
Expand Down
38 changes: 8 additions & 30 deletions composeApp/src/commonMain/kotlin/ui/home/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,16 @@ package ui.home
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.hoverable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Home
import androidx.compose.material.icons.rounded.ArrowDropDown
import androidx.compose.material.icons.rounded.Refresh
import androidx.compose.material.icons.rounded.Search
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExposedDropdownMenuBox
import androidx.compose.material3.ExposedDropdownMenuDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -204,16 +183,15 @@ object HomeScreen : Screen {
onSelect: (String) -> Unit
) {
var expanded by remember { mutableStateOf(false) }
ExposedDropdownMenuBox(expanded, onExpandedChange = { expanded = it }, modifier = sidePad.height(32.dp)) {
ExposedDropdownMenuBox(expanded, onExpandedChange = { expanded = it }, modifier = sidePad) {
TextField(
// The `menuAnchor` modifier must be passed to the text field for correctness.
modifier = sidePad.menuAnchor(),
readOnly = true,
value = selected,
onValueChange = { onSelect(it) },
onValueChange = { },
readOnly = true,
label = { Text(title) },
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded) },
colors = ExposedDropdownMenuDefaults.textFieldColors(),
trailingIcon = { Icon(Icons.Rounded.ArrowDropDown, contentDescription = "Select") },
)

if (options.isNotEmpty()) {
Expand Down
92 changes: 46 additions & 46 deletions composeApp/src/commonMain/kotlin/ui/theme/Color.kt
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
package ui.theme
import androidx.compose.ui.graphics.Color

val md_theme_light_primary = Color(0xFF006590)
val md_theme_light_primary = Color(0xFF006D42)
val md_theme_light_onPrimary = Color(0xFFFFFFFF)
val md_theme_light_primaryContainer = Color(0xFFC8E6FF)
val md_theme_light_onPrimaryContainer = Color(0xFF001E2F)
val md_theme_light_secondary = Color(0xFF4F606E)
val md_theme_light_primaryContainer = Color(0xFF92F7BC)
val md_theme_light_onPrimaryContainer = Color(0xFF002111)
val md_theme_light_secondary = Color(0xFF4E6355)
val md_theme_light_onSecondary = Color(0xFFFFFFFF)
val md_theme_light_secondaryContainer = Color(0xFFD3E5F5)
val md_theme_light_onSecondaryContainer = Color(0xFF0B1D29)
val md_theme_light_tertiary = Color(0xFF006399)
val md_theme_light_secondaryContainer = Color(0xFFD1E8D6)
val md_theme_light_onSecondaryContainer = Color(0xFF0C1F14)
val md_theme_light_tertiary = Color(0xFF3B6471)
val md_theme_light_onTertiary = Color(0xFFFFFFFF)
val md_theme_light_tertiaryContainer = Color(0xFFCDE5FF)
val md_theme_light_onTertiaryContainer = Color(0xFF001D32)
val md_theme_light_tertiaryContainer = Color(0xFFBFE9F8)
val md_theme_light_onTertiaryContainer = Color(0xFF001F27)
val md_theme_light_error = Color(0xFFBA1A1A)
val md_theme_light_errorContainer = Color(0xFFFFDAD6)
val md_theme_light_onError = Color(0xFFFFFFFF)
val md_theme_light_onErrorContainer = Color(0xFF410002)
val md_theme_light_background = Color(0xFFFCFCFF)
val md_theme_light_onBackground = Color(0xFF191C1E)
val md_theme_light_surface = Color(0xFFFCFCFF)
val md_theme_light_onSurface = Color(0xFF191C1E)
val md_theme_light_surfaceVariant = Color(0xFFDDE3EA)
val md_theme_light_onSurfaceVariant = Color(0xFF41474D)
val md_theme_light_outline = Color(0xFF71787E)
val md_theme_light_inverseOnSurface = Color(0xFFF0F0F3)
val md_theme_light_inverseSurface = Color(0xFF2E3133)
val md_theme_light_inversePrimary = Color(0xFF89CEFF)
val md_theme_light_background = Color(0xFFFBFDF8)
val md_theme_light_onBackground = Color(0xFF191C1A)
val md_theme_light_surface = Color(0xFFFBFDF8)
val md_theme_light_onSurface = Color(0xFF191C1A)
val md_theme_light_surfaceVariant = Color(0xFFDCE5DC)
val md_theme_light_onSurfaceVariant = Color(0xFF404942)
val md_theme_light_outline = Color(0xFF717972)
val md_theme_light_inverseOnSurface = Color(0xFFF0F1ED)
val md_theme_light_inverseSurface = Color(0xFF2E312E)
val md_theme_light_inversePrimary = Color(0xFF76DAA1)
val md_theme_light_shadow = Color(0xFF000000)
val md_theme_light_surfaceTint = Color(0xFF006590)
val md_theme_light_outlineVariant = Color(0xFFC1C7CE)
val md_theme_light_surfaceTint = Color(0xFF006D42)
val md_theme_light_outlineVariant = Color(0xFFC0C9C0)
val md_theme_light_scrim = Color(0xFF000000)

val md_theme_dark_primary = Color(0xFF89CEFF)
val md_theme_dark_onPrimary = Color(0xFF00344D)
val md_theme_dark_primaryContainer = Color(0xFF004C6E)
val md_theme_dark_onPrimaryContainer = Color(0xFFC8E6FF)
val md_theme_dark_secondary = Color(0xFFB7C9D9)
val md_theme_dark_onSecondary = Color(0xFF21323F)
val md_theme_dark_secondaryContainer = Color(0xFF384956)
val md_theme_dark_onSecondaryContainer = Color(0xFFD3E5F5)
val md_theme_dark_tertiary = Color(0xFF95CCFF)
val md_theme_dark_onTertiary = Color(0xFF003352)
val md_theme_dark_tertiaryContainer = Color(0xFF004A75)
val md_theme_dark_onTertiaryContainer = Color(0xFFCDE5FF)
val md_theme_dark_primary = Color(0xFF76DAA1)
val md_theme_dark_onPrimary = Color(0xFF003920)
val md_theme_dark_primaryContainer = Color(0xFF005231)
val md_theme_dark_onPrimaryContainer = Color(0xFF92F7BC)
val md_theme_dark_secondary = Color(0xFFB5CCBA)
val md_theme_dark_onSecondary = Color(0xFF213528)
val md_theme_dark_secondaryContainer = Color(0xFF374B3E)
val md_theme_dark_onSecondaryContainer = Color(0xFFD1E8D6)
val md_theme_dark_tertiary = Color(0xFFA3CDDC)
val md_theme_dark_onTertiary = Color(0xFF043541)
val md_theme_dark_tertiaryContainer = Color(0xFF224C58)
val md_theme_dark_onTertiaryContainer = Color(0xFFBFE9F8)
val md_theme_dark_error = Color(0xFFFFB4AB)
val md_theme_dark_errorContainer = Color(0xFF93000A)
val md_theme_dark_onError = Color(0xFF690005)
val md_theme_dark_onErrorContainer = Color(0xFFFFDAD6)
val md_theme_dark_background = Color(0xFF191C1E)
val md_theme_dark_onBackground = Color(0xFFE2E2E5)
val md_theme_dark_surface = Color(0xFF191C1E)
val md_theme_dark_onSurface = Color(0xFFE2E2E5)
val md_theme_dark_surfaceVariant = Color(0xFF41474D)
val md_theme_dark_onSurfaceVariant = Color(0xFFC1C7CE)
val md_theme_dark_outline = Color(0xFF8B9198)
val md_theme_dark_inverseOnSurface = Color(0xFF191C1E)
val md_theme_dark_inverseSurface = Color(0xFFE2E2E5)
val md_theme_dark_inversePrimary = Color(0xFF006590)
val md_theme_dark_background = Color(0xFF191C1A)
val md_theme_dark_onBackground = Color(0xFFE1E3DE)
val md_theme_dark_surface = Color(0xFF191C1A)
val md_theme_dark_onSurface = Color(0xFFE1E3DE)
val md_theme_dark_surfaceVariant = Color(0xFF404942)
val md_theme_dark_onSurfaceVariant = Color(0xFFC0C9C0)
val md_theme_dark_outline = Color(0xFF8A938B)
val md_theme_dark_inverseOnSurface = Color(0xFF191C1A)
val md_theme_dark_inverseSurface = Color(0xFFE1E3DE)
val md_theme_dark_inversePrimary = Color(0xFF006D42)
val md_theme_dark_shadow = Color(0xFF000000)
val md_theme_dark_surfaceTint = Color(0xFF89CEFF)
val md_theme_dark_outlineVariant = Color(0xFF41474D)
val md_theme_dark_surfaceTint = Color(0xFF76DAA1)
val md_theme_dark_outlineVariant = Color(0xFF404942)
val md_theme_dark_scrim = Color(0xFF000000)


val seed = Color(0xFF006591)
val seed = Color(0xFF2A9260)
4 changes: 2 additions & 2 deletions composeApp/src/commonMain/kotlin/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ fun AppTheme(
content: @Composable() () -> Unit
) {
val colors = if (!useDarkTheme) {
LightColors
LightColors
} else {
DarkColors
DarkColors
}

MaterialTheme(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,21 @@ import io.github.jsixface.common.Conversion
import io.github.jsixface.common.MediaTrack
import io.github.jsixface.common.VideoFile
import io.ktor.utils.io.CancellationException
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.datetime.Clock.System
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
import java.io.File
import java.io.InputStream
import java.io.UncheckedIOException
import java.nio.file.Files
import java.util.UUID
import java.util.*
import kotlin.io.path.Path
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.datetime.Clock.System
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime

class ConversionApi(settingsApi: SettingsApi) {
private val logger = logger()
Expand Down Expand Up @@ -67,7 +60,7 @@ class ConversionApi(settingsApi: SettingsApi) {
val convJob = ConvertingJob(
videoFile = file,
convSpecs = convSpecs,
outFile = File(newDir, file.fileName),
outFile = File(newDir, file.fileName), // TODO convert the output file always to mkv
job = null,
progress = MutableStateFlow(0),
jobId = jobId
Expand Down Expand Up @@ -176,9 +169,8 @@ class ConversionApi(settingsApi: SettingsApi) {
is Conversion.Convert -> result += listOf(
"-map",
"0:${track.index}",
"-codec:$i",
conv.codec
)
"-codec:$i"
) + conv.codec.ffmpegParams
}
}
return result
Expand Down
Loading

0 comments on commit ff6e3f9

Please sign in to comment.