add protonSnapshot utility function for paparazzi

This commit is contained in:
Yoann Goular
2025-08-18 17:34:26 +02:00
committed by Niccolò Forlini
parent 394bf34cb8
commit 10a653b124
5 changed files with 40 additions and 4 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ buildscript {
classpath(libs.hilt.android.gradle)
classpath(libs.google.services)
classpath(libs.sentry.gradle)
classpath(libs.paparazzi)
classpath(libs.paparazzi.plugin)
}
}
@@ -24,10 +24,12 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalInspectionMode
@Composable
fun ProtonTheme(
isDark: Boolean = isNightMode(),
localInspectionMode: Boolean = LocalInspectionMode.current,
colors: ProtonColors = if (isDark) ProtonColors.Dark else ProtonColors.Light,
typography: ProtonTypography = ProtonTypography.Default,
shapes: ProtonShapes = ProtonShapes(),
@@ -39,7 +41,8 @@ fun ProtonTheme(
LocalColors provides rememberedColors,
LocalTypography provides typography,
LocalShapes provides shapes,
LocalContentColor provides rememberedColors.textNorm
LocalContentColor provides rememberedColors.textNorm,
LocalInspectionMode provides localInspectionMode
) {
androidx.compose.material3.MaterialTheme(
typography = typography.toMaterial3ThemeTypography(),
@@ -102,6 +105,7 @@ fun isNightMode() = when (AppCompatDelegate.getDefaultNightMode()) {
}
object ProtonTheme {
val colors: ProtonColors
@Composable
@ReadOnlyComposable
+2 -1
View File
@@ -92,7 +92,7 @@ kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.
hilt-android-gradle = { module = "com.google.dagger:hilt-android-gradle-plugin", version.ref = "dagger" }
google-services = { module = "com.google.gms:google-services", version.ref = "google-services-plugin" }
sentry-gradle = { module = "io.sentry:sentry-android-gradle-plugin", version.ref = "sentry-gradle-plugin" }
paparazzi = { module = "app.cash.paparazzi:paparazzi-gradle-plugin", version.ref = "paparazzi" }
paparazzi-plugin = { module = "app.cash.paparazzi:paparazzi-gradle-plugin", version.ref = "paparazzi" }
# Standard dependencies
accompanist-webview = { module = "com.google.accompanist:accompanist-webview", version.ref = "accompanist-webview" }
@@ -194,6 +194,7 @@ sentry = { module = "io.sentry:sentry", version.ref = "sentry" }
plumber = { module = "com.squareup.leakcanary:plumber-android", version.ref = "leakcanary" }
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
zxing-embedded = { module = "com.journeyapps:zxing-android-embedded", version.ref = "zxing-embedded" }
paparazzi = { group = "app.cash.paparazzi", name = "paparazzi" , version.ref = "paparazzi" }
# Proton Core libraries
proton-core-auth-domain = { module = "me.proton.core:auth-domain", version.ref = "proton-core" }
+1 -1
View File
@@ -53,6 +53,6 @@ dependencies {
debugImplementation(libs.bundles.app.debug)
testImplementation(libs.bundles.test)
compileOnly(libs.paparazzi)
implementation(project(":design-system"))
}
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2025 Proton Technologies AG
* This file is part of Proton Technologies AG and Proton Mail.
*
* Proton Mail is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Proton Mail is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proton Mail. If not, see <https://www.gnu.org/licenses/>.
*/
package ch.protonmail.android.design.compose.paparazzi
import androidx.compose.runtime.Composable
import app.cash.paparazzi.Paparazzi
import ch.protonmail.android.design.compose.theme.ProtonTheme
fun Paparazzi.protonSnapshot(localInspectionMode: Boolean = true, content: @Composable () -> Unit) {
snapshot {
ProtonTheme(localInspectionMode = localInspectionMode) {
content()
}
}
}