-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Squoosh to be enabled at runtime, add DesignDocSettings (#955)
This is implemented as a class that can be applied to a DesignCompose composable via a localComposition.
- Loading branch information
1 parent
8f43138
commit 9dd5d81
Showing
5 changed files
with
68 additions
and
8 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
designcompose/src/main/java/com/android/designcompose/DesignDocSettings.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,35 @@ | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.android.designcompose | ||
|
||
import androidx.compose.runtime.compositionLocalOf | ||
|
||
/** | ||
* When applied as a compositionLocal, these settings will alter features or add functionality to | ||
* DesignCompose Composables | ||
* | ||
* @property useSquoosh: Enable use of the Squoosh renderer. Squoosh implements its own view tree, | ||
* rather than using Compose, which brings some performance and flexibility benefits. Squoosh | ||
* isn't feature complete (no scrolling, no lists, no transformed input), but it does add | ||
* animations and is likely the direction that DesignCompose will move in to be lighter weight and | ||
* better integrate with external layout. | ||
*/ | ||
class DesignDocSettings( | ||
val useSquoosh: Boolean = false, | ||
) | ||
|
||
val LocalDesignDocSettings = compositionLocalOf { DesignDocSettings() } |
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
31 changes: 31 additions & 0 deletions
31
...ation/src/main/java/com/android/designcompose/testapp/validation/examples/HelloSquoosh.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,31 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.android.designcompose.testapp.validation.examples | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.CompositionLocalProvider | ||
import com.android.designcompose.DesignDocSettings | ||
import com.android.designcompose.LocalDesignDocSettings | ||
|
||
@Composable | ||
fun HelloSquoosh() { | ||
CompositionLocalProvider(LocalDesignDocSettings provides DesignDocSettings(useSquoosh = true)) { | ||
HelloWorldDoc.Main( | ||
name = "Squoosh", | ||
) | ||
} | ||
} |
Binary file added
BIN
+70.6 KB
...ion-tests/validation/src/testDebug/roborazzi/RenderAllExamples/HelloSquoosh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.