Skip to content

Commit

Permalink
initial series loading
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed Nov 8, 2023
1 parent ee09736 commit 8ac3b78
Show file tree
Hide file tree
Showing 28 changed files with 2,235 additions and 102 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "compose-collapsing-toolbar"]
path = compose-collapsing-toolbar
url = [email protected]:onebone/compose-collapsing-toolbar.git
1 change: 0 additions & 1 deletion app/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ kotlin {

api(project(":model"))
api(project(":network"))
api(project(":compose-collapsing-toolbar:lib"))
}
}
val androidMain by getting {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package dev.datlag.burningseries.ui.custom

import androidx.compose.foundation.Image
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import dev.datlag.burningseries.common.ifTrue
import dev.icerock.moko.resources.compose.painterResource

@Composable
fun CountryImage(
code: String,
description: String?,
modifier: Modifier = Modifier
) {
val res = remember(code) { dev.datlag.burningseries.ui.theme.CountryImage.getByFlag(code) }
var iconSize by remember { mutableStateOf(DpSize(24.dp, 24.dp)) }

Box(
modifier = modifier.onSizeChanged {
val thirdWidth = it.width.toFloat() - (it.width.toFloat() / 3F)
val thirdHeight = it.height.toFloat() - (it.height.toFloat() / 3F)
iconSize = DpSize(thirdWidth.dp, thirdHeight.dp)
},
contentAlignment = Alignment.Center
) {
Image(
painter = painterResource(res.last()),
contentDescription = description,
modifier = Modifier
.size(iconSize)
.clip(MaterialTheme.shapes.extraSmall)
.border(1.dp, LocalContentColor.current, MaterialTheme.shapes.extraSmall)
.ifTrue(res.size >= 2) { this.align(Alignment.TopStart).alpha(0.75F) }
)
if (res.size >= 2) {
Image(
painter = painterResource(res.first()),
contentDescription = description,
modifier = Modifier
.size(iconSize)
.clip(MaterialTheme.shapes.extraSmall)
.border(1.dp, LocalContentColor.current, MaterialTheme.shapes.extraSmall)
.align(Alignment.BottomEnd)
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.AppBarDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.TopAppBar
Expand All @@ -15,11 +14,11 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import dev.datlag.burningseries.common.launchMain
import dev.datlag.burningseries.common.withIOContext
import dev.datlag.burningseries.ui.custom.toolbar.*
import kotlinx.coroutines.delay
import me.onebone.toolbar.*
import kotlin.math.abs

@OptIn(ExperimentalMaterial3Api::class, ExperimentalToolbarApi::class)
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun DefaultCollapsingToolbar(
state: CollapsingToolbarScaffoldState = rememberCollapsingToolbarScaffoldState(),
Expand All @@ -39,6 +38,7 @@ fun DefaultCollapsingToolbar(
state = state,
scrollStrategy = ScrollStrategy.ExitUntilCollapsed,
toolbarModifier = Modifier.fillMaxWidth().defaultMinSize(minHeight = 56.dp).verticalScroll(rememberScrollState()),
toolbarScrollable = true,
toolbar = {
expandedBody(state)

Expand Down
Loading

0 comments on commit 8ac3b78

Please sign in to comment.