diff --git a/app/build.gradle b/app/build.gradle index d2c34c895d..c193ae0350 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -125,4 +125,7 @@ dependencies { debugImplementation "androidx.compose.ui:ui-tooling" debugImplementation "androidx.compose.ui:ui-test-manifest" implementation 'com.airbnb.android:mavericks-compose:3.0.1' + + implementation("com.airbnb.android:showkase:1.0.0-beta14") + ksp("com.airbnb.android:showkase-processor:1.0.0-beta14") } \ No newline at end of file diff --git a/app/src/main/java/io/element/android/x/MainActivity.kt b/app/src/main/java/io/element/android/x/MainActivity.kt index 0d7b903361..c01ec386ee 100644 --- a/app/src/main/java/io/element/android/x/MainActivity.kt +++ b/app/src/main/java/io/element/android/x/MainActivity.kt @@ -13,13 +13,23 @@ import androidx.compose.animation.AnimatedContentScope import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.animation.core.tween import androidx.compose.foundation.background -import androidx.compose.material3.MaterialTheme +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Close +import androidx.compose.material3.* import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp import androidx.core.view.WindowCompat import androidx.navigation.NavHostController +import com.airbnb.android.showkase.models.Showkase import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi import com.ramcosta.composedestinations.DestinationsNavHost import com.ramcosta.composedestinations.animations.defaults.RootNavGraphDefaultAnimations @@ -40,8 +50,38 @@ class MainActivity : ComponentActivity() { // FIXME Scrolling is broken on login screens. Commenting this line fixes the issue. WindowCompat.setDecorFitsSystemWindows(window, false) setContent { - ElementXTheme { - MainScreen(viewModel = viewModel) + Box(modifier = Modifier.fillMaxSize()) { + ElementXTheme { + MainScreen(viewModel = viewModel) + } + ShowkaseButton( + onClick = { startActivity(Showkase.getBrowserIntent(this@MainActivity)) } + ) + } + } + } + +} + +@Composable +private fun ShowkaseButton( + onClick: () -> Unit = {} +) { + val showkaseButtonVisible = remember { mutableStateOf(true) } + if (showkaseButtonVisible.value) { + Button( + modifier = Modifier + .padding(top = 32.dp, start = 16.dp), + onClick = onClick + ) { + Text(text = "Showkase Browser") + IconButton( + modifier = Modifier + .padding(start = 8.dp) + .size(16.dp), + onClick = { showkaseButtonVisible.value = false }, + ) { + Icon(imageVector = Icons.Filled.Close, contentDescription = "") } } } @@ -122,6 +162,6 @@ private fun LogNavigation(navController: NavHostController) { @Composable @Preview -private fun MainContentPreview() { +fun MainContentPreview() { MainContent(startRoute = OnBoardingScreenNavigationDestination) } \ No newline at end of file diff --git a/app/src/main/java/io/element/android/x/Showkase.kt b/app/src/main/java/io/element/android/x/Showkase.kt new file mode 100644 index 0000000000..999cc5bc68 --- /dev/null +++ b/app/src/main/java/io/element/android/x/Showkase.kt @@ -0,0 +1,7 @@ +package io.element.android.x + +import com.airbnb.android.showkase.annotation.ShowkaseRoot +import com.airbnb.android.showkase.annotation.ShowkaseRootModule + +@ShowkaseRoot +class ElementRootModule : ShowkaseRootModule \ No newline at end of file diff --git a/build.gradle b/build.gradle index ce9450edaf..a76107c6f3 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,10 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. +// TODO Convert to .kts plugins { id 'com.android.application' version '7.3.0' apply false id 'com.android.library' version '7.3.0' apply false id 'org.jetbrains.kotlin.android' version '1.7.20' apply false + id 'com.google.devtools.ksp' version '1.7.20-1.0.7' apply false } task clean(type: Delete) { diff --git a/docs/usefulLinks.md b/docs/usefulLinks.md index 042467dfdc..35ae4cf8c8 100644 --- a/docs/usefulLinks.md +++ b/docs/usefulLinks.md @@ -1,3 +1,7 @@ +### VersionCatalog + + + ### Jetpack Compose diff --git a/features/login/build.gradle.kts b/features/login/build.gradle.kts index bbc5219123..c59b274c78 100644 --- a/features/login/build.gradle.kts +++ b/features/login/build.gradle.kts @@ -1,5 +1,7 @@ plugins { id("io.element.android-compose") + // TODO Move to common config + id("com.google.devtools.ksp") version "1.7.20-1.0.7" } android { @@ -16,4 +18,7 @@ dependencies { testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.3") androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") + + // TODO Move to common config + ksp("com.airbnb.android:showkase-processor:1.0.0-beta14") } \ No newline at end of file diff --git a/features/login/src/main/java/io/element/android/x/features/login/LoginScreen.kt b/features/login/src/main/java/io/element/android/x/features/login/LoginScreen.kt index 02aba50ae4..bb059a1267 100644 --- a/features/login/src/main/java/io/element/android/x/features/login/LoginScreen.kt +++ b/features/login/src/main/java/io/element/android/x/features/login/LoginScreen.kt @@ -202,7 +202,7 @@ fun LoginContent( @Composable @Preview -private fun LoginContentPreview() { +fun LoginContentPreview() { ElementXTheme(darkTheme = false) { LoginContent( state = LoginViewState( diff --git a/features/login/src/main/java/io/element/android/x/features/login/changeserver/ChangeServerScreen.kt b/features/login/src/main/java/io/element/android/x/features/login/changeserver/ChangeServerScreen.kt index 4bb6b12a95..95340abc10 100644 --- a/features/login/src/main/java/io/element/android/x/features/login/changeserver/ChangeServerScreen.kt +++ b/features/login/src/main/java/io/element/android/x/features/login/changeserver/ChangeServerScreen.kt @@ -150,7 +150,7 @@ fun ChangeServerContent( @Composable @Preview -private fun ChangeServerContentPreview() { +fun ChangeServerContentPreview() { ChangeServerContent( state = ChangeServerViewState(homeserver = "matrix.org"), ) diff --git a/features/messages/build.gradle.kts b/features/messages/build.gradle.kts index 70e3455d1f..00a0e50b0b 100644 --- a/features/messages/build.gradle.kts +++ b/features/messages/build.gradle.kts @@ -1,5 +1,7 @@ plugins { id("io.element.android-compose") + // TODO Move to common config + id("com.google.devtools.ksp") version "1.7.20-1.0.7" } android { @@ -19,4 +21,7 @@ dependencies { testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.3") androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") -} \ No newline at end of file + + // TODO Move to common config + ksp("com.airbnb.android:showkase-processor:1.0.0-beta14") +} diff --git a/features/messages/src/main/java/io/element/android/x/features/messages/MessagesScreen.kt b/features/messages/src/main/java/io/element/android/x/features/messages/MessagesScreen.kt index 01f54c9c8d..c6a1b58d65 100644 --- a/features/messages/src/main/java/io/element/android/x/features/messages/MessagesScreen.kt +++ b/features/messages/src/main/java/io/element/android/x/features/messages/MessagesScreen.kt @@ -515,7 +515,7 @@ class MessagesItemGroupPositionToMessagesTimelineItemContentProvider : @Preview(showBackground = true) @Composable -private fun TimelineItemsPreview( +fun TimelineItemsPreview( @PreviewParameter(MessagesTimelineItemContentProvider::class) content: MessagesTimelineItemContent ) { diff --git a/features/onboarding/build.gradle.kts b/features/onboarding/build.gradle.kts index 5c67c8df53..7945f93d57 100644 --- a/features/onboarding/build.gradle.kts +++ b/features/onboarding/build.gradle.kts @@ -1,5 +1,7 @@ plugins { id("io.element.android-compose") + // TODO Move to common config + id("com.google.devtools.ksp") version "1.7.20-1.0.7" } android { @@ -17,4 +19,6 @@ dependencies { testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.3") androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") + // TODO Move to common config + ksp("com.airbnb.android:showkase-processor:1.0.0-beta14") } \ No newline at end of file diff --git a/features/roomlist/build.gradle.kts b/features/roomlist/build.gradle.kts index a745356971..235cdba1e5 100644 --- a/features/roomlist/build.gradle.kts +++ b/features/roomlist/build.gradle.kts @@ -1,5 +1,7 @@ plugins { id("io.element.android-compose") + // TODO Move to common config + id("com.google.devtools.ksp") version "1.7.20-1.0.7" } android { @@ -17,4 +19,6 @@ dependencies { testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.3") androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") + // TODO Move to common config + ksp("com.airbnb.android:showkase-processor:1.0.0-beta14") } \ No newline at end of file diff --git a/features/roomlist/src/main/java/io/element/android/x/features/roomlist/RoomListScreen.kt b/features/roomlist/src/main/java/io/element/android/x/features/roomlist/RoomListScreen.kt index 85fd887373..148cfd0ecc 100644 --- a/features/roomlist/src/main/java/io/element/android/x/features/roomlist/RoomListScreen.kt +++ b/features/roomlist/src/main/java/io/element/android/x/features/roomlist/RoomListScreen.kt @@ -145,7 +145,7 @@ private fun LazyListState.isScrolled(): Boolean { @Preview @Composable -private fun PreviewableRoomListContent() { +fun PreviewableRoomListContent() { ElementXTheme(darkTheme = false) { RoomListContent( roomSummaries = stubbedRoomSummaries(), @@ -162,7 +162,7 @@ private fun PreviewableRoomListContent() { @Preview @Composable -private fun PreviewableDarkRoomListContent() { +fun PreviewableDarkRoomListContent() { ElementXTheme(darkTheme = true) { RoomListContent( roomSummaries = stubbedRoomSummaries(), diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2332b3ebb2..8b3eec9929 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,6 +3,7 @@ android_gradle_plugin = "7.3.1" firebase_gradle_plugin = "3.0.2" kotlin = "1.7.20" +ksp = "1.7.20-1.0.7" # AndroidX material = "1.6.1" @@ -92,3 +93,5 @@ wysiwyg = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" } [bundles] +[plugins] +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } diff --git a/libraries/designsystem/build.gradle.kts b/libraries/designsystem/build.gradle.kts index 3d7bfff108..f56a38445d 100644 --- a/libraries/designsystem/build.gradle.kts +++ b/libraries/designsystem/build.gradle.kts @@ -1,5 +1,7 @@ plugins { id("io.element.android-compose") + // TODO Move to common config + id("com.google.devtools.ksp") version "1.7.20-1.0.7" } android { @@ -9,5 +11,7 @@ android { // Should not be there, but this is a POC implementation("io.coil-kt:coil-compose:2.2.1") implementation(libs.accompanist.systemui) + // TODO Move to common config + ksp("com.airbnb.android:showkase-processor:1.0.0-beta14") } } \ No newline at end of file diff --git a/libraries/designsystem/src/main/java/io/element/android/x/designsystem/Color.kt b/libraries/designsystem/src/main/java/io/element/android/x/designsystem/Color.kt index 53126611dc..33925b8fbc 100644 --- a/libraries/designsystem/src/main/java/io/element/android/x/designsystem/Color.kt +++ b/libraries/designsystem/src/main/java/io/element/android/x/designsystem/Color.kt @@ -1,8 +1,11 @@ package io.element.android.x.designsystem import androidx.compose.ui.graphics.Color +import com.airbnb.android.showkase.annotation.ShowkaseColor +@ShowkaseColor(name = "LightGrey", group = "Material Design") val LightGrey = Color(0x993C3C43) +@ShowkaseColor(name = "DarkGrey", group = "Material Design") val DarkGrey = Color(0x99EBEBF5) val AvatarGradientStart = Color(0xFF4CA1AF) diff --git a/libraries/designsystem/src/main/java/io/element/android/x/designsystem/Type.kt b/libraries/designsystem/src/main/java/io/element/android/x/designsystem/Type.kt index 233bdbe98f..3cfdcf85f3 100644 --- a/libraries/designsystem/src/main/java/io/element/android/x/designsystem/Type.kt +++ b/libraries/designsystem/src/main/java/io/element/android/x/designsystem/Type.kt @@ -7,24 +7,31 @@ import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.sp +import com.airbnb.android.showkase.annotation.ShowkaseTypography + + +@ShowkaseTypography(name = "Body Large", group = "Element") +val bodyLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp +) + +@ShowkaseTypography(name = "Headline Small", group = "Element") +val headlineSmall = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Bold, + fontSize = 32.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp +) // Set of Material typography styles to start with val Typography = Typography( - - bodyLarge = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 16.sp, - lineHeight = 24.sp, - letterSpacing = 0.5.sp - ), - headlineSmall = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Bold, - fontSize = 32.sp, - lineHeight = 24.sp, - letterSpacing = 0.5.sp - ), + bodyLarge = bodyLarge, + headlineSmall = headlineSmall, /* Other default text styles to override titleLarge = TextStyle( fontFamily = FontFamily.Default, diff --git a/libraries/designsystem/src/main/java/io/element/android/x/designsystem/components/ProgressDialog.kt b/libraries/designsystem/src/main/java/io/element/android/x/designsystem/components/ProgressDialog.kt index 7e545b66c5..a01c2eeddc 100644 --- a/libraries/designsystem/src/main/java/io/element/android/x/designsystem/components/ProgressDialog.kt +++ b/libraries/designsystem/src/main/java/io/element/android/x/designsystem/components/ProgressDialog.kt @@ -51,6 +51,6 @@ fun ProgressDialog(text: String? = null, onDismiss: () -> Unit = {}) { @Composable @Preview -private fun ProgressDialogPreview() { +fun ProgressDialogPreview() { ProgressDialog("test dialog content") } \ No newline at end of file diff --git a/libraries/designsystem/src/main/java/io/element/android/x/designsystem/components/dialogs/ConfirmationDialog.kt b/libraries/designsystem/src/main/java/io/element/android/x/designsystem/components/dialogs/ConfirmationDialog.kt index f45d743fd1..1161fcb5f3 100644 --- a/libraries/designsystem/src/main/java/io/element/android/x/designsystem/components/dialogs/ConfirmationDialog.kt +++ b/libraries/designsystem/src/main/java/io/element/android/x/designsystem/components/dialogs/ConfirmationDialog.kt @@ -71,7 +71,7 @@ fun ConfirmationDialog( @Composable @Preview -private fun ConfirmationDialogPreview() { +fun ConfirmationDialogPreview() { ConfirmationDialog( isDisplayed = remember { mutableStateOf(true) }, title = "Title", diff --git a/libraries/textcomposer/build.gradle.kts b/libraries/textcomposer/build.gradle.kts index 7db9a252e5..c8120437ec 100644 --- a/libraries/textcomposer/build.gradle.kts +++ b/libraries/textcomposer/build.gradle.kts @@ -1,5 +1,7 @@ plugins { id("io.element.android-compose") + // TODO Move to common config + id("com.google.devtools.ksp") version "1.7.20-1.0.7" } android { @@ -15,4 +17,6 @@ dependencies { implementation(libs.wysiwyg) implementation(libs.androidx.constraintlayout) implementation("com.google.android.material:material:1.7.0") + // TODO Move to common config + ksp("com.airbnb.android:showkase-processor:1.0.0-beta14") } diff --git a/plugins/src/main/java/io.element.android-compose.gradle.kts b/plugins/src/main/java/io.element.android-compose.gradle.kts index 52dfa891b8..2efafcfb09 100644 --- a/plugins/src/main/java/io.element.android-compose.gradle.kts +++ b/plugins/src/main/java/io.element.android-compose.gradle.kts @@ -5,6 +5,8 @@ import extension.proguardConfig plugins { id("com.android.library") id("kotlin-android") +// alias(libs.plugins.ksp) +// id("com.google.devtools.ksp") // version "1.7.20-1.0.7" } android { @@ -28,4 +30,6 @@ dependencies { debugImplementation("androidx.compose.ui:ui-tooling") debugImplementation("androidx.compose.ui:ui-test-manifest") + implementation("com.airbnb.android:showkase:1.0.0-beta14") + // ksp("com.airbnb.android:showkase-processor:1.0.0-beta14") }