Skip to content

Commit 74d9c2b

Browse files
nqmgamingclaude
andcommitted
fix(install): make the sheet look like a sheet
Bottom-sheet style was a dialog card moved to the bottom edge: same AlertDialog container colour, same drop shadow, same dialog shape. It read as a lowered dialog because that is all it was. Now it takes the Material 3 sheet treatment — sheet container colour, no drop shadow, expanded sheet shape — plus a drag handle to grab and navigationBarsPadding so the action row is not sitting on the gesture bar. That last part follows InstallerX Revived's sheet, whose own action row carries navigationBarsPadding with extra bottom padding under gesture navigation. The stage content is still shared with the dialog style; only the container differs, which was the point of splitting them. Verified on device by opening an APK from ZArchiver with the sheet style on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 7b3fa2a commit 74d9c2b

1 file changed

Lines changed: 39 additions & 4 deletions

File tree

app/src/main/java/app/pwhs/universalinstaller/presentation/install/DialogInstallActivity.kt

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,15 @@ import androidx.compose.foundation.layout.fillMaxSize
4747
import androidx.compose.foundation.layout.fillMaxWidth
4848
import androidx.compose.foundation.layout.height
4949
import androidx.compose.foundation.layout.heightIn
50+
import androidx.compose.foundation.layout.navigationBarsPadding
5051
import androidx.compose.foundation.layout.padding
5152
import androidx.compose.foundation.layout.size
5253
import androidx.compose.foundation.layout.systemBars
5354
import androidx.compose.foundation.layout.widthIn
5455
import androidx.compose.foundation.layout.windowInsetsPadding
5556
import androidx.compose.material3.AlertDialogDefaults
57+
import androidx.compose.material3.ExperimentalMaterial3Api
58+
import androidx.compose.material3.BottomSheetDefaults
5659
import androidx.compose.material3.CircularProgressIndicator
5760
import androidx.compose.material3.MaterialTheme
5861
import androidx.compose.material3.Surface
@@ -132,6 +135,7 @@ import androidx.compose.foundation.isSystemInDarkTheme
132135
* - Cancel button → same.
133136
* - Install button → starts install; dialog shows progress then result.
134137
*/
138+
@OptIn(ExperimentalMaterial3Api::class)
135139
class DialogInstallActivity : ComponentActivity() {
136140

137141
private val viewModel: InstallViewModel by viewModel()
@@ -183,6 +187,32 @@ class DialogInstallActivity : ComponentActivity() {
183187
/** Track whether system took us to a confirmation activity. */
184188
private var wentToSystemConfirm = false
185189

190+
/**
191+
* The parts that make a sheet a sheet rather than a lowered dialog: a drag handle to grab, and
192+
* content kept clear of the gesture bar so the action row is not sitting on the system inset.
193+
*
194+
* Mirrors what InstallerX Revived's sheet does — its own action row carries
195+
* `navigationBarsPadding()` plus extra bottom padding under gesture navigation.
196+
*/
197+
@OptIn(ExperimentalMaterial3Api::class)
198+
@Composable
199+
private fun SheetChrome(enabled: Boolean, content: @Composable () -> Unit) {
200+
if (!enabled) {
201+
content()
202+
return
203+
}
204+
Column(
205+
modifier = Modifier
206+
.fillMaxWidth()
207+
.navigationBarsPadding()
208+
.padding(bottom = 8.dp),
209+
horizontalAlignment = Alignment.CenterHorizontally,
210+
) {
211+
BottomSheetDefaults.DragHandle()
212+
content()
213+
}
214+
}
215+
186216
/**
187217
* Slides the sheet up on first composition. The dialog style is left untouched — it already
188218
* arrives with the activity's own window animation, and a second one on top reads as a stutter.
@@ -617,11 +647,15 @@ class DialogInstallActivity : ComponentActivity() {
617647
.pointerInput(Unit) {
618648
detectTapGestures(onTap = { /* consume clicks */ })
619649
},
620-
shape = if (isSheet) SHEET_SHAPE else AlertDialogDefaults.shape,
621-
color = AlertDialogDefaults.containerColor,
622-
tonalElevation = AlertDialogDefaults.TonalElevation,
623-
shadowElevation = 12.dp,
650+
// A sheet is attached to the edge, not floating over the screen: it takes
651+
// the sheet container colour and no drop shadow. Lowering a dialog card to
652+
// the bottom without this still reads as a dialog.
653+
shape = if (isSheet) BottomSheetDefaults.ExpandedShape else AlertDialogDefaults.shape,
654+
color = if (isSheet) BottomSheetDefaults.ContainerColor else AlertDialogDefaults.containerColor,
655+
tonalElevation = if (isSheet) BottomSheetDefaults.Elevation else AlertDialogDefaults.TonalElevation,
656+
shadowElevation = if (isSheet) 0.dp else 12.dp,
624657
) {
658+
SheetChrome(enabled = isSheet) {
625659
val params = generateDialogParams(
626660
uiState = uiState,
627661
dialogTarget = dialogTarget,
@@ -701,6 +735,7 @@ class DialogInstallActivity : ComponentActivity() {
701735
centerContent = dialogInnerWidget(params.content),
702736
centerButton = dialogInnerWidget(params.buttons)
703737
)
738+
}
704739
}
705740
}
706741
}

0 commit comments

Comments
 (0)