Skip to content

Commit

Permalink
Fix issue with bottomsheet content being behind navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed Jun 7, 2024
1 parent 3b54be0 commit 012a8fe
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ class RealmInventoryLocalRepository(realm: Realm) :
return realm.where(Equipment::class.java)
.equalTo("klass", "armoire")
.beginGroup()
.equalTo("released", true)
.or()
.isNull("released")
.endGroup()
.beginGroup()
.equalTo("owned", false)
.or()
.isNull("owned")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class ShopRecyclerAdapter : androidx.recyclerview.widget.RecyclerView.Adapter<Vi
val sectionHolder = holder as? SectionViewHolder ?: return
sectionHolder.bind(obj.text)
sectionHolder.bind(obj.endDate)
(sectionHolder.headerContainer.layoutParams as? LinearLayout.LayoutParams)?.topMargin = if (position > 1) {
(sectionHolder.headerContainer?.layoutParams as? LinearLayout.LayoutParams)?.topMargin = if (position > 1) {
40.dpToPx(context)
} else {
16.dpToPx(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import com.habitrpg.android.habitica.ui.views.CurrencyView
import java.util.Date

class SectionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val headerContainer: LinearLayout = itemView.findViewById(R.id.header_container)
val headerContainer: LinearLayout? = itemView.findViewById(R.id.header_container)
private val label: TextView = itemView.findViewById(R.id.label)
private val switchesInLabel: TextView? = itemView.findViewById(R.id.switches_in_label)
private val selectionSpinner: Spinner? = itemView.findViewById(R.id.class_selection_spinner)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import androidx.activity.compose.BackHandler
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.navigationBarsIgnoringVisibility
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.windowInsetsBottomHeight
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.BottomSheetScaffoldState
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.SheetState
import androidx.compose.material3.SheetValue
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -50,6 +53,7 @@ fun Fragment.showAsBottomSheet(content: @Composable (() -> Unit) -> Unit) {
}

// Helper method
@OptIn(ExperimentalLayoutApi::class)
private fun addContentToView(
viewGroup: ViewGroup,
content: @Composable (() -> Unit) -> Unit,
Expand All @@ -58,14 +62,16 @@ private fun addContentToView(
ComposeView(viewGroup.context).apply {
setContent {
HabiticaTheme {
BottomSheetWrapper(viewGroup, this, content)
Column {
BottomSheetWrapper(viewGroup, this@apply, content)
}
}
}
},
)
}

@OptIn(ExperimentalMaterial3Api::class)
@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class)
@Composable
private fun BottomSheetWrapper(
parent: ViewGroup,
Expand All @@ -79,18 +85,24 @@ private fun BottomSheetWrapper(

val systemUiController = rememberSystemUiController()
val statusBarColor = colorResource(R.color.content_background)
val navigationbarColor = colorResource(R.color.brand_50)
DisposableEffect(systemUiController) {
systemUiController.setStatusBarColor(statusBarColor.copy(alpha = 0.3f), darkIcons = true)
onDispose {}
systemUiController.setNavigationBarColor(navigationbarColor, darkIcons = true)
onDispose {
systemUiController.setNavigationBarColor(navigationbarColor, darkIcons = false)
systemUiController.setStatusBarColor(statusBarColor.copy(alpha = 0.3f), darkIcons = true)
}
}

val radius = 20.dp
ModalBottomSheet(
{},
containerColor = Color.Transparent,
scrimColor = colorResource(R.color.content_background).copy(alpha = 0.5f),
scrimColor = colorResource(R.color.gray_5).copy(alpha = 0.3f),
sheetState = modalBottomSheetState,
shape = RoundedCornerShape(topStart = radius, topEnd = radius),
dragHandle = {},
content = {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
Expand All @@ -116,6 +128,9 @@ private fun BottomSheetWrapper(
modalBottomSheetState.hide() // will trigger the LaunchedEffect
}
}
Spacer(Modifier.windowInsetsBottomHeight(
WindowInsets.navigationBarsIgnoringVisibility
))
}
},
)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.3.2'
classpath 'com.android.tools.build:gradle:8.4.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.gms:google-services:4.4.1'
classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.1'
Expand Down
8 changes: 0 additions & 8 deletions fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ Submit a new Beta Build to Google Play

Deploy a new version to the Google Play

### android upload_to_slack

```sh
[bundle exec] fastlane android upload_to_slack
```

Upload the latest output APK to slack

----

This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Apr 22 16:17:19 CEST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NAME=4.3.7
CODE=7881
CODE=7891

0 comments on commit 012a8fe

Please sign in to comment.