Skip to content

Commit

Permalink
move search bar instead of content
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed Mar 16, 2024
1 parent 3273109 commit f63a30f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
1 change: 1 addition & 0 deletions app/android/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
android:visibleToInstantApps="true"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|layoutDirection|locale|mcc|navigation|smallestScreenSize|touchscreen|uiMode"
android:name=".MainActivity"
android:windowSoftInputMode="adjustResize"
android:supportsPictureInPicture="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ import androidx.compose.ui.graphics.vector.PathBuilder
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.*
import dev.datlag.burningseries.model.common.collectSafe
import dev.datlag.burningseries.shared.LocalPaddingValues
import dev.datlag.burningseries.shared.ui.theme.shape.DiagonalShape
Expand Down Expand Up @@ -225,6 +222,18 @@ operator fun PaddingValues.plus(other: PaddingValues): PaddingValues {
)
}

@Composable
fun PaddingValues.merge(other: PaddingValues): PaddingValues {
val direction = LocalLayoutDirection.current

return PaddingValues(
start = max(this.calculateStartPadding(direction), other.calculateStartPadding(direction)),
top = max(this.calculateTopPadding(), other.calculateTopPadding()),
end = max(this.calculateEndPadding(direction), other.calculateEndPadding(direction)),
bottom = max(this.calculateBottomPadding(), other.calculateBottomPadding())
)
}

fun Modifier.localPadding(additional: PaddingValues = PaddingValues(0.dp)) = composed {
this.padding(LocalPaddingValues.current?.plus(additional) ?: additional)
}
Expand Down Expand Up @@ -254,6 +263,14 @@ fun LocalPadding(horizontal: Dp = 0.dp, vertical: Dp = 0.dp): PaddingValues {
) ?: PaddingValues(horizontal = horizontal, vertical = vertical)
}

fun Modifier.mergedLocalPadding(other: PaddingValues, additional: PaddingValues = PaddingValues(0.dp)) = composed {
this.padding((LocalPaddingValues.current?.merge(other) ?: other).plus(additional))
}

fun Modifier.mergedLocalPadding(other: PaddingValues, additional: Dp) = composed {
this.mergedLocalPadding(other, PaddingValues(additional))
}

fun Modifier.bottomShadowBrush(color: Color, alpha: Float = 1F): Modifier {
val maxAlpha = kotlin.math.min(alpha, 1F)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ import com.arkivanov.decompose.extensions.compose.subscribeAsState
import dev.chrisbanes.haze.haze
import dev.datlag.burningseries.shared.LocalHaze
import dev.datlag.burningseries.shared.SharedRes
import dev.datlag.burningseries.shared.common.LocalPadding
import dev.datlag.burningseries.shared.common.header
import dev.datlag.burningseries.shared.common.*
import dev.datlag.burningseries.shared.common.lifecycle.collectAsStateWithLifecycle
import dev.datlag.burningseries.shared.common.localPadding
import dev.datlag.burningseries.shared.common.onClick
import dev.datlag.burningseries.shared.rememberIsTv
import dev.datlag.burningseries.shared.ui.custom.FloatingSearchButton
import dev.datlag.burningseries.shared.ui.custom.VerticalScrollbar
Expand Down Expand Up @@ -131,7 +128,7 @@ private fun MainView(component: FavoriteComponent, modifier: Modifier = Modifier
VerticalScrollbar(rememberScrollbarAdapter(listState))
}
FloatingSearchButton(
modifier = Modifier.align(Alignment.BottomEnd).localPadding(16.dp),
modifier = Modifier.align(Alignment.BottomEnd).mergedLocalPadding(WindowInsets.ime.asPaddingValues(), 16.dp),
onTextChange = {
component.searchQuery(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import dev.datlag.burningseries.shared.common.LocalPadding
import dev.datlag.burningseries.shared.common.header
import dev.datlag.burningseries.shared.common.lifecycle.collectAsStateWithLifecycle
import dev.datlag.burningseries.shared.common.localPadding
import dev.datlag.burningseries.shared.common.mergedLocalPadding
import dev.datlag.burningseries.shared.other.StateSaver
import dev.datlag.burningseries.shared.rememberIsTv
import dev.datlag.burningseries.shared.ui.custom.FloatingSearchButton
Expand Down Expand Up @@ -215,11 +216,7 @@ private fun MainView(home: Home, component: HomeComponent, modifier: Modifier =
}
}
FloatingSearchButton(
icon = Icons.Default.Search,
contentDescription = null,
clearIcon = Icons.Default.Clear,
closeIcon = Icons.AutoMirrored.Default.KeyboardArrowRight,
modifier = Modifier.align(Alignment.BottomEnd).localPadding(16.dp),
modifier = Modifier.align(Alignment.BottomEnd).mergedLocalPadding(WindowInsets.ime.asPaddingValues(), 16.dp),
onTextChange = {

}
Expand Down

0 comments on commit f63a30f

Please sign in to comment.