Skip to content

Commit

Permalink
Move buildscript to plugins DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
fornewid committed Jun 1, 2024
1 parent dc4a8eb commit 7b9a075
Show file tree
Hide file tree
Showing 45 changed files with 290 additions and 258 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# https://editorconfig.org/
# This configuration is used by ktlint when spotless invokes it

[*.{kt,kts}]
ij_kotlin_allow_trailing_comma=true
ij_kotlin_allow_trailing_comma_on_call_site=true
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
gradle-home-cache-cleanup: true

- name: Check spotless
run: ./gradlew spotlessCheck --stacktrace
run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --stacktrace

- name: Check metalava
run: ./gradlew metalavaCheckCompatibilityRelease --stacktrace
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ captures/
.idea/dynamic.xml
.idea/uiDesigner.xml
.idea/jarRepositories.xml
.idea/appInsightsSettings.xml
.idea/kotlinc.xml
.idea/deploymentTargetSelector.xml

# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
Expand Down
7 changes: 4 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.plugin.serialization'
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.serialization)

}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,44 +55,44 @@ private data class Category(
Demo(
title = "MaterialSharedAxis",
description = "MaterialSharedAxisScreen",
destination = Destination.MaterialSharedAxis
destination = Destination.MaterialSharedAxis,
),
Demo(
title = "MaterialFadeThrough",
description = "MaterialFadeThroughScreen",
destination = Destination.MaterialFadeThrough
destination = Destination.MaterialFadeThrough,
),
Demo(
title = "MaterialFade",
description = "MaterialFadeScreen",
destination = Destination.MaterialFade
destination = Destination.MaterialFade,
),
Demo(
title = "MaterialElevationScale",
description = "MaterialElevationScaleScreen",
destination = Destination.MaterialElevationScale
destination = Destination.MaterialElevationScale,
),
Demo(
title = "Hold",
description = "HoldScreen",
destination = Destination.Hold
destination = Destination.Hold,
),
Demo(
title = "CircularReveal",
description = "CircularRevealScreen",
destination = Destination.CircularReveal
destination = Destination.CircularReveal,
),
)
),
),
Category(
title = "Additional Examples (Navigation)",
items = listOf(
Demo(
title = "AnimatedNavHost",
description = "AnimatedNavHostScreen",
destination = Destination.AnimatedNavHost
destination = Destination.AnimatedNavHost,
),
)
),
),
)
}
Expand All @@ -103,46 +103,46 @@ fun HomeScreen(onItemClick: (Destination) -> Unit) {
Scaffold(
topBar = {
TopAppBar(title = { Text(text = "Transition for Jetpack Compose") })
}
},
) { contentPadding ->
LazyColumn(
modifier = Modifier.fillMaxSize(),
contentPadding = contentPadding
contentPadding = contentPadding,
) {
item {
Column {
Text(
text = "Description",
modifier = Modifier.padding(start = 16.dp, top = 16.dp, bottom = 16.dp),
style = MaterialTheme.typography.subtitle1
style = MaterialTheme.typography.subtitle1,
)
Text(
text = "Transition choreography is a coordinated sequence of motion" +
" that maintains user focus as the interface adapts.",
modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 16.dp),
style = MaterialTheme.typography.body2
style = MaterialTheme.typography.body2,
)
HomeDemoItem(
Demo(
title = "Demo",
description = "DemoScreen",
destination = Destination.Demo
destination = Destination.Demo,
),
onItemClick = onItemClick
onItemClick = onItemClick,
)
}
}
Category.items.forEachIndexed { index, category ->
item(
key = index,
contentType = { "Category" }
contentType = { "Category" },
) {
Divider()
HomeCategoryItem(title = category.title)
}
items(
items = category.items,
contentType = { "Demo" }
contentType = { "Demo" },
) { demo ->
HomeDemoItem(demo, onItemClick = onItemClick)
}
Expand All @@ -159,7 +159,7 @@ private fun HomeCategoryItem(
Text(
text = title,
modifier = modifier.padding(start = 16.dp, top = 16.dp),
style = MaterialTheme.typography.subtitle1
style = MaterialTheme.typography.subtitle1,
)
}

Expand All @@ -175,18 +175,18 @@ private fun HomeDemoItem(
.fillMaxWidth()
.requiredHeight(64.dp)
.clickable { onItemClick(demo.destination) }
.padding(horizontal = 16.dp)
.padding(horizontal = 16.dp),
) {
Text(
text = demo.title,
modifier = Modifier.fillMaxWidth(),
fontWeight = FontWeight.SemiBold,
style = MaterialTheme.typography.body2
style = MaterialTheme.typography.body2,
)
Text(
modifier = Modifier.fillMaxWidth(),
text = demo.description,
style = MaterialTheme.typography.caption
style = MaterialTheme.typography.caption,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ fun NavGraph(
HomeScreen(
onItemClick = {
navController.navigate(route = it)
}
},
)
}
composable<Destination.Demo> {
DemoScreen(upPress = upPress)
}

/* Core */
// Core
composable<Destination.MaterialSharedAxis> {
MaterialSharedAxisScreen(upPress = upPress)
}
Expand All @@ -111,7 +111,7 @@ fun NavGraph(
CircularRevealScreen(upPress = upPress)
}

/* Navigation */
// Navigation
composable<Destination.AnimatedNavHost> {
AnimatedNavHostScreen(upPress = upPress)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ fun CircularRevealScreen(upPress: () -> Unit) {
POSITIONS.forEach {
TextButton(
onClick = { onStateChanged(State(visible = true, center = it.center)) },
modifier = Modifier.align(it.alignment)
modifier = Modifier.align(it.alignment),
) {
Text(text = it.label)
}
Expand All @@ -133,11 +133,11 @@ fun CircularRevealScreen(upPress: () -> Unit) {
},
)
.fillMaxSize()
.background(color = MaterialTheme.colors.secondary)
.background(color = MaterialTheme.colors.secondary),
) {
Button(
onClick = { onStateChanged(state.copy(visible = false)) },
modifier = Modifier.align(Alignment.Center)
modifier = Modifier.align(Alignment.Center),
) {
Text("Close")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fun BottomTabsControls(
selected = tab == selectedTab,
onClick = { setSelectedTab(tab) },
selectedContentColor = MaterialTheme.colors.primary,
unselectedContentColor = LocalContentColor.current.copy(alpha = ContentAlpha.medium)
unselectedContentColor = LocalContentColor.current.copy(alpha = ContentAlpha.medium),
)
}
}
Expand All @@ -67,7 +67,7 @@ fun BottomTabsContents(selectedTab: BottomTabs, modifier: Modifier = Modifier) {
Surface(
modifier = modifier
.fillMaxSize()
.padding(4.dp)
.padding(4.dp),
) {
Column {
Row(modifier = Modifier.weight(1f)) {
Expand Down Expand Up @@ -105,12 +105,12 @@ private fun BottomTabsContentsItem(
backgroundColor = backgroundColor,
modifier = modifier
.fillMaxSize()
.padding(4.dp)
.padding(4.dp),
) {
Image(
selectedTab.icon,
contentDescription = null,
colorFilter = ColorFilter.tint(contentColor)
colorFilter = ColorFilter.tint(contentColor),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ fun DefaultScaffold(
Scaffold(
topBar = { DefaultTopAppBar(upPress) },
bottomBar = bottomBar,
content = content
content = content,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ fun DefaultTopAppBar(upPress: () -> Unit) {
IconButton(onClick = upPress) {
Icon(
Icons.Default.Close,
contentDescription = null
contentDescription = null,
)
}
}
},
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ fun ForwardBackwardControls(
Box(
modifier = Modifier
.fillMaxWidth()
.padding(all = 16.dp)
.padding(all = 16.dp),
) {
TextButton(
onClick = { onForwardChanged(false) },
modifier = Modifier.align(Alignment.BottomStart),
enabled = forward
enabled = forward,
) {
Text(text = "Back".uppercase())
}
Button(
onClick = { onForwardChanged(true) },
modifier = Modifier.align(Alignment.BottomEnd),
enabled = forward.not()
enabled = forward.not(),
) {
Text(text = "Next".uppercase())
}
Expand Down Expand Up @@ -95,20 +95,20 @@ private fun BackwardContents() {
modifier = Modifier
.requiredSize(72.dp)
.align(Alignment.CenterHorizontally),
tint = LocalContentColor.current.copy(alpha = ContentAlpha.medium)
tint = LocalContentColor.current.copy(alpha = ContentAlpha.medium),
)
Spacer(modifier = Modifier.requiredHeight(8.dp))
Text(
"Hi David Park",
modifier = Modifier.align(Alignment.CenterHorizontally),
style = MaterialTheme.typography.h5
style = MaterialTheme.typography.h5,
)
Spacer(modifier = Modifier.requiredHeight(8.dp))
Text(
"Sign in with your account",
modifier = Modifier.align(Alignment.CenterHorizontally),
color = LocalContentColor.current.copy(alpha = ContentAlpha.medium),
style = MaterialTheme.typography.caption
style = MaterialTheme.typography.caption,
)
Spacer(modifier = Modifier.requiredHeight(24.dp))

Expand All @@ -121,7 +121,7 @@ private fun BackwardContents() {
.align(Alignment.CenterHorizontally),
label = {
Text(text = "Email or phone number")
}
},
)
Spacer(modifier = Modifier.requiredHeight(12.dp))
TextButton(onClick = {}) {
Expand All @@ -140,15 +140,15 @@ private fun ForwardContents() {
Text(
"Streamline your courses",
modifier = Modifier.align(Alignment.CenterHorizontally),
style = MaterialTheme.typography.h6
style = MaterialTheme.typography.h6,
)
Spacer(modifier = Modifier.requiredHeight(8.dp))
Text(
text = "Bundled categories appear as groups in your feed." +
" You can always change this later.",
textAlign = TextAlign.Center,
color = LocalContentColor.current.copy(alpha = ContentAlpha.medium),
style = MaterialTheme.typography.caption
style = MaterialTheme.typography.caption,
)
Spacer(modifier = Modifier.requiredHeight(48.dp))
SwitchableItem(text = "Arts & Crafts")
Expand All @@ -172,7 +172,7 @@ private fun SwitchableItem(text: String) {
Text(
text = if (checked) "Bundled" else "Shown individually",
color = LocalContentColor.current.copy(alpha = ContentAlpha.medium),
style = MaterialTheme.typography.caption
style = MaterialTheme.typography.caption,
)
}
val color = MaterialTheme.colors.surface
Expand All @@ -185,7 +185,7 @@ private fun SwitchableItem(text: String) {
modifier = Modifier
.size(48.dp)
.align(Alignment.CenterEnd),
colors = SwitchDefaults.colors(uncheckedThumbColor = uncheckedThumbColor)
colors = SwitchDefaults.colors(uncheckedThumbColor = uncheckedThumbColor),
)
}
}
Loading

0 comments on commit 7b9a075

Please sign in to comment.