forked from LawnchairLauncher/lawnchair
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This implementation allows users to configure their preferred overlay animation mode when closing app Enabled seamless switching between `FADE_IN` and `SUCK_IN` - closes : LawnchairLauncher#5094 - closes : LawnchairLauncher#5219 - closes : LawnchairLauncher#4377
- Loading branch information
Showing
10 changed files
with
784 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<app.lawnchair.views.LawnchairFloatingSurfaceView | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
lawnchair/src/app/lawnchair/ui/preferences/components/OverlayHandlerPreference.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package app.lawnchair.ui.preferences.components | ||
|
||
import android.R as AndroidR | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.lazy.itemsIndexed | ||
import androidx.compose.material3.OutlinedButton | ||
import androidx.compose.material3.RadioButton | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.rememberCoroutineScope | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import app.lawnchair.preferences.PreferenceAdapter | ||
import app.lawnchair.ui.ModalBottomSheetContent | ||
import app.lawnchair.ui.preferences.components.layout.PreferenceDivider | ||
import app.lawnchair.ui.preferences.components.layout.PreferenceTemplate | ||
import app.lawnchair.ui.util.LocalBottomSheetHandler | ||
import app.lawnchair.views.overlay.FullScreenOverlayMode | ||
import kotlinx.coroutines.launch | ||
|
||
val overlayOptions = listOf( | ||
FullScreenOverlayMode.SUCK_IN, | ||
FullScreenOverlayMode.FADE_IN, | ||
) | ||
|
||
@Composable | ||
fun OverlayHandlerPreference( | ||
adapter: PreferenceAdapter<FullScreenOverlayMode>, | ||
label: String, | ||
modifier: Modifier = Modifier, | ||
) { | ||
val scope = rememberCoroutineScope() | ||
val bottomSheetHandler = LocalBottomSheetHandler.current | ||
|
||
val currentConfig = adapter.state.value | ||
|
||
fun onSelect(option: FullScreenOverlayMode) { | ||
scope.launch { | ||
adapter.onChange(option) | ||
} | ||
} | ||
|
||
PreferenceTemplate( | ||
title = { Text(text = label) }, | ||
description = { Text(text = stringResource(currentConfig.labelRes)) }, | ||
modifier = modifier.clickable { | ||
bottomSheetHandler.show { | ||
ModalBottomSheetContent( | ||
title = { Text(label) }, | ||
buttons = { | ||
OutlinedButton(onClick = { bottomSheetHandler.hide() }) { | ||
Text(text = stringResource(id = AndroidR.string.cancel)) | ||
} | ||
}, | ||
) { | ||
LazyColumn { | ||
itemsIndexed(overlayOptions) { index, option -> | ||
if (index > 0) { | ||
PreferenceDivider(startIndent = 40.dp) | ||
} | ||
val selected = currentConfig == option | ||
PreferenceTemplate( | ||
title = { Text(text = stringResource(option.labelRes)) }, | ||
modifier = Modifier.clickable { | ||
bottomSheetHandler.hide() | ||
onSelect(option) | ||
}, | ||
startWidget = { | ||
RadioButton( | ||
selected = selected, | ||
onClick = null, | ||
) | ||
}, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.