Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Add detail module with compose using #56

Merged
merged 5 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ setupApp(AppModule.App)
dependencies {
implementation(projects.login)
implementation(projects.main)
implementation(projects.detail)
implementation(projects.web)

implementation(libs.androidX.hilt)
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/kotlin/io/goooler/demoapp/RouterManagerImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.goooler.demoapp
import android.content.Context
import android.content.Intent
import io.goooler.demoapp.common.router.RouterManager
import io.goooler.demoapp.detail.ui.RepoDetailActivity
import io.goooler.demoapp.login.ui.LoginActivity
import io.goooler.demoapp.main.ui.AudioPlayActivity
import io.goooler.demoapp.main.ui.MainActivity
Expand Down Expand Up @@ -31,6 +32,11 @@ object RouterManagerImpl : RouterManager {
.let(context::startActivity)
}

override fun goRepoDetail(context: Context) {
Intent(context, RepoDetailActivity::class.java)
.let(context::startActivity)
}

override fun goAudioPlay(context: Context) {
Intent(context, AudioPlayActivity::class.java)
.let(context::startActivity)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ allprojects {
if ("multidex" !in requested.name) useVersion(libs.versions.support.get())
}
libs.androidX.appCompat.get().module.group -> useVersion(libs.versions.androidX.appCompat.get())
libs.androidX.activity.get().module.group -> useVersion(libs.versions.androidX.activity.get())
libs.androidX.activity.compose.get().module.group -> useVersion(libs.versions.androidX.activity.get())
libs.androidX.collection.get().module.group -> useVersion(libs.versions.androidX.collection.get())
libs.androidX.core.get().module.group -> useVersion(libs.versions.androidX.core.get())
libs.androidX.fragment.get().module.group -> useVersion(libs.versions.androidX.fragment.get())
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/Enums.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum class LibModule(override val tag: String, override val id: String) : Module
//---------------------biz-------------------------------//
Login("login", "io.goooler.demoapp.login"),
Main("main", "io.goooler.demoapp.main"),
Detail("detail", "io.goooler.demoapp.detail"),
Web("web", "io.goooler.demoapp.web"),

//---------------------func-------------------------------//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ interface RouterManager {

fun goMain(context: Context)

fun goRepoDetail(context: Context)

fun goAudioPlay(context: Context)

fun goWeb(context: Context, url: String, useChrome: Boolean = false)
Expand All @@ -33,6 +35,10 @@ interface RouterManager {
impl.goMain(context)
}

override fun goRepoDetail(context: Context) {
impl.goRepoDetail(context)
}

override fun goAudioPlay(context: Context) {
impl.goAudioPlay(context)
}
Expand Down
14 changes: 14 additions & 0 deletions detail/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
plugins {
id(libs.plugins.android.library.get().pluginId)
id(libs.plugins.kotlin.android.get().pluginId)
}

setupLib(LibModule.Detail) {
buildFeatures.compose = true
composeOptions.kotlinCompilerExtensionVersion = libs.versions.androidX.compose.get()
}

dependencies {
implementation(libs.androidX.activity.compose)
implementation(libs.bundles.androidX.compose)
}
8 changes: 8 additions & 0 deletions detail/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<activity android:name=".ui.RepoDetailActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.goooler.demoapp.detail.ui

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import io.goooler.demoapp.base.core.BaseActivity

class RepoDetailActivity : BaseActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
HelloScreen()
}
}
}

@Preview
@Composable
fun HelloScreen() {
Text(text = "Hello Compose")
}
21 changes: 21 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ agp = "7.1.2"
androidX-activity = "1.4.0"
androidX-appCompat = "1.4.1"
androidX-collection = "1.2.0"
androidX-compose = "1.1.1"
androidX-core = "1.7.0"
androidX-fragment = "1.4.1"
androidX-hilt = "2.41"
Expand Down Expand Up @@ -35,7 +36,17 @@ gradlePlugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", ve
kotlin-junit5 = { module = "org.jetbrains.kotlin:kotlin-test-junit5", version.ref = "kotlin" }
kotlinX-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }

androidX-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "androidX-compose" }
androidX-compose-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "androidX-compose" }
androidX-compose-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "androidX-compose" }
androidX-compose-material = { module = "androidx.compose.material:material", version.ref = "androidX-compose" }
androidX-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "androidX-compose" }
androidX-compose-livedata = { module = "androidx.compose.runtime:runtime-livedata", version.ref = "androidX-compose" }
androidX-compose-icons-core = { module = "androidx.compose.material:material-icons-core", version.ref = "androidX-compose" }
androidX-compose-icons-extended = { module = "androidx.compose.material:material-icons-extended", version.ref = "androidX-compose" }

androidX-activity = { module = "androidx.activity:activity-ktx", version.ref = "androidX-activity" }
androidX-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidX-activity" }
androidX-annotation = "androidx.annotation:annotation:1.3.0"
androidX-appCompat = { module = "androidx.appcompat:appcompat", version.ref = "androidX-appCompat" }
androidX-browser = "androidx.browser:browser:1.4.0"
Expand Down Expand Up @@ -89,6 +100,16 @@ srl-kernel = { module = "com.scwang.smart:refresh-layout-kernel", version.ref =
utils = "com.blankj:utilcodex:1.31.0"

[bundles]
androidX-compose = [
"androidX-compose-ui",
"androidX-compose-tooling",
"androidX-compose-tooling-preview",
"androidX-compose-material",
"androidX-compose-foundation",
"androidX-compose-livedata",
"androidX-compose-icons-core",
"androidX-compose-icons-extended"
]
androidX-lifecycle = [
"androidX-lifecycle-viewModel",
"androidX-lifecycle-liveData",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import dagger.hilt.android.AndroidEntryPoint
import io.goooler.demoapp.adapter.rv.core.ItemTouchHelperCallback
import io.goooler.demoapp.base.util.unsafeLazy
import io.goooler.demoapp.common.base.binding.BaseBindingFragment
import io.goooler.demoapp.common.router.RouterManager
import io.goooler.demoapp.common.util.enableRefreshAndLoadMore
import io.goooler.demoapp.common.util.getThemeViewModel
import io.goooler.demoapp.common.util.showToast
import io.goooler.demoapp.main.databinding.MainSrlFragmentBinding
import io.goooler.demoapp.main.ui.adapter.MainSrlRvAdapter
import io.goooler.demoapp.main.vm.MainSrlViewModel
Expand Down Expand Up @@ -49,7 +49,7 @@ class MainSrlFragment : BaseBindingFragment<MainSrlFragmentBinding>() {
ItemTouchHelperCallback.ItemChangeListener,
View.OnClickListener {
override fun onContentClick(content: String) {
content.showToast()
RouterManager.goRepoDetail(requireContext())
}

override fun onRefresh(refreshLayout: RefreshLayout) {
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ include(
":common",
":login",
":main",
":detail",
":web",
":adapter",
":test"
Expand Down