-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[build]: setup is made with Jetpack Compose
- Loading branch information
Showing
40 changed files
with
1,412 additions
and
378 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
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
34 changes: 34 additions & 0 deletions
34
build-logic/convention/src/main/kotlin/additional/AndroidComposeConventionPlugin.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,34 @@ | ||
package additional | ||
|
||
import com.android.build.api.dsl.ApplicationExtension | ||
import com.android.build.api.dsl.CommonExtension | ||
import com.android.build.api.dsl.LibraryExtension | ||
import extensions.bundle | ||
import extensions.implementation | ||
import extensions.pluginId | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
|
||
class AndroidComposeConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) = with(target) { | ||
with(pluginManager) { | ||
apply(pluginId("compose-compiler")) | ||
} | ||
|
||
listOf( | ||
LibraryExtension::class.java, | ||
ApplicationExtension::class.java, | ||
).forEach { extensionClass -> | ||
extensions.findByType(extensionClass)?.enableCompose() | ||
} | ||
|
||
dependencies { | ||
implementation(bundle("androidx-compose")) | ||
} | ||
} | ||
|
||
private fun CommonExtension<*, *, *, *, *, *>.enableCompose() { | ||
buildFeatures.compose = true | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
...ain/kotlin/AndroidHiltConventionPlugin.kt → ...additional/AndroidHiltConventionPlugin.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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
package additional | ||
|
||
import extensions.implementation | ||
import extensions.ksp | ||
import extensions.library | ||
|
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
2 changes: 2 additions & 0 deletions
2
...ain/kotlin/AndroidCoreConventionPlugin.kt → ...otlin/main/AndroidCoreConventionPlugin.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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
package main | ||
|
||
import extensions.bundle | ||
import extensions.implementation | ||
import extensions.library | ||
|
2 changes: 2 additions & 0 deletions
2
.../kotlin/AndroidLibraryConventionPlugin.kt → ...in/main/AndroidLibraryConventionPlugin.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
19 changes: 19 additions & 0 deletions
19
build-logic/convention/src/main/kotlin/main/feature/AndroidComposeFeatureConventionPlugin.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,19 @@ | ||
package main.feature | ||
|
||
import extensions.implementation | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
|
||
class AndroidComposeFeatureConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) = with(target) { | ||
with(pluginManager) { | ||
apply("logfox.android.feature") | ||
apply("logfox.android.compose") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":core:core-ui-compose")) | ||
} | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
.../kotlin/AndroidFeatureConventionPlugin.kt → ...feature/AndroidFeatureConventionPlugin.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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
package main.feature | ||
|
||
import extensions.bundle | ||
import extensions.implementation | ||
import extensions.ksp | ||
|
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
28 changes: 28 additions & 0 deletions
28
...ore-arch/src/main/kotlin/com/f0x1d/logfox/arch/ui/fragment/compose/BaseComposeFragment.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,28 @@ | ||
package com.f0x1d.logfox.arch.ui.fragment.compose | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.compose.runtime.Composable | ||
import com.f0x1d.logfox.arch.databinding.FragmentComposeBinding | ||
import com.f0x1d.logfox.arch.ui.fragment.BaseFragment | ||
|
||
abstract class BaseComposeFragment : BaseFragment<FragmentComposeBinding>() { | ||
|
||
override fun inflateBinding( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
) = FragmentComposeBinding.inflate(inflater, container, false) | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
binding.composeView.setContent { | ||
Content() | ||
} | ||
} | ||
|
||
@Composable | ||
abstract fun Content() | ||
} |
45 changes: 45 additions & 0 deletions
45
...src/main/kotlin/com/f0x1d/logfox/arch/ui/fragment/compose/BaseComposeViewModelFragment.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,45 @@ | ||
package com.f0x1d.logfox.arch.ui.fragment.compose | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.compose.foundation.layout.consumeWindowInsets | ||
import androidx.compose.runtime.Composable | ||
import com.f0x1d.logfox.arch.databinding.FragmentComposeBinding | ||
import com.f0x1d.logfox.arch.ui.fragment.BaseViewModelFragment | ||
import com.f0x1d.logfox.arch.ui.snackbar | ||
import com.f0x1d.logfox.arch.viewmodel.BaseViewModel | ||
import com.google.android.material.snackbar.Snackbar | ||
import dev.chrisbanes.insetter.applyInsetter | ||
|
||
abstract class BaseComposeViewModelFragment<T : BaseViewModel> : BaseViewModelFragment<T, FragmentComposeBinding>() { | ||
|
||
override fun inflateBinding( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
) = FragmentComposeBinding.inflate(inflater, container, false) | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
binding.composeView.apply { | ||
consumeWindowInsets = false | ||
|
||
setContent { | ||
this@BaseComposeViewModelFragment.Content() | ||
} | ||
} | ||
} | ||
|
||
override fun snackbar(text: String): Snackbar = requireView().snackbar(text).apply { | ||
view.applyInsetter { | ||
type(navigationBars = true) { | ||
margin() | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
abstract fun 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<androidx.compose.ui.platform.ComposeView | ||
android:id="@+id/compose_view" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintBottom_toBottomOf="parent" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/ |
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,10 @@ | ||
plugins { | ||
id("logfox.android.core") | ||
id("logfox.android.compose") | ||
} | ||
|
||
android.namespace = "com.f0x1d.logfox.ui.compose" | ||
|
||
dependencies { | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
...ore-ui-compose/src/main/kotlin/com/f0x1d/logfox/ui/compose/component/button/RichButton.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,56 @@ | ||
package com.f0x1d.logfox.ui.compose.component.button | ||
|
||
import androidx.annotation.DrawableRes | ||
import androidx.annotation.StringRes | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.f0x1d.logfox.strings.Strings | ||
import com.f0x1d.logfox.ui.compose.R | ||
import com.f0x1d.logfox.ui.compose.theme.LogFoxTheme | ||
|
||
@Composable | ||
fun RichButton( | ||
@StringRes text: Int, | ||
@DrawableRes icon: Int, | ||
onClick: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Button( | ||
modifier = modifier, | ||
onClick = onClick, | ||
) { | ||
Icon( | ||
painter = painterResource(id = icon), | ||
contentDescription = null, | ||
) | ||
Spacer(modifier = Modifier.width(8.dp)) | ||
Text( | ||
text = stringResource(id = text), | ||
style = MaterialTheme.typography.bodyLarge, | ||
fontWeight = FontWeight.Bold, | ||
) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun RichButtonPreview() { | ||
LogFoxTheme { | ||
RichButton( | ||
text = Strings.root, | ||
icon = R.drawable.ic_test_icon, | ||
onClick = { }, | ||
) | ||
} | ||
} |
Oops, something went wrong.