diff --git a/app/src/main/java/com/depromeet/threedays/ThreeDaysApplication.kt b/app/src/main/java/com/depromeet/threedays/ThreeDaysApplication.kt index 918be1ac..9ad75d44 100644 --- a/app/src/main/java/com/depromeet/threedays/ThreeDaysApplication.kt +++ b/app/src/main/java/com/depromeet/threedays/ThreeDaysApplication.kt @@ -1,6 +1,8 @@ package com.depromeet.threedays import android.app.Application +import dagger.hilt.android.HiltAndroidApp +@HiltAndroidApp class ThreeDaysApplication : Application() { } \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index aa34ccfc..f23605b5 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/core/src/main/java/com/depromeet/threedays/core/BaseFragment.kt b/core/src/main/java/com/depromeet/threedays/core/BaseFragment.kt index c378e1a2..ba45c230 100644 --- a/core/src/main/java/com/depromeet/threedays/core/BaseFragment.kt +++ b/core/src/main/java/com/depromeet/threedays/core/BaseFragment.kt @@ -5,11 +5,12 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.annotation.LayoutRes +import androidx.databinding.DataBindingUtil import androidx.databinding.ViewDataBinding import androidx.fragment.app.Fragment import java.lang.IllegalStateException -abstract class BaseFragment(@LayoutRes layout: Int) : Fragment(layout) { +abstract class BaseFragment(@LayoutRes private val layout: Int) : Fragment(layout) { protected var _binding: VB? = null val binding: VB @@ -22,8 +23,13 @@ abstract class BaseFragment(@LayoutRes container: ViewGroup?, savedInstanceState: Bundle? ): View? { - binding.lifecycleOwner = viewLifecycleOwner - return binding.root + _binding = DataBindingUtil.inflate(inflater, layout, container, false) + return _binding!!.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + _binding?.lifecycleOwner = viewLifecycleOwner } protected fun onBind(body: VB.() -> Unit) { diff --git a/navigator/src/main/java/com/depromeet/threedays/navigator/HomeNavigator.kt b/navigator/src/main/java/com/depromeet/threedays/navigator/HomeNavigator.kt new file mode 100644 index 00000000..f300cf7b --- /dev/null +++ b/navigator/src/main/java/com/depromeet/threedays/navigator/HomeNavigator.kt @@ -0,0 +1,3 @@ +package com.depromeet.threedays.navigator + +interface HomeNavigator : Navigator \ No newline at end of file diff --git a/navigator/src/main/java/com/depromeet/threedays/navigator/Navigator.kt b/navigator/src/main/java/com/depromeet/threedays/navigator/Navigator.kt new file mode 100644 index 00000000..5f45c967 --- /dev/null +++ b/navigator/src/main/java/com/depromeet/threedays/navigator/Navigator.kt @@ -0,0 +1,8 @@ +package com.depromeet.threedays.navigator + +import android.content.Context +import android.content.Intent + +interface Navigator { + fun intent(context: Context): Intent +} \ No newline at end of file diff --git a/presentation/home/build.gradle b/presentation/home/build.gradle index 6f3cb1c6..90077d30 100644 --- a/presentation/home/build.gradle +++ b/presentation/home/build.gradle @@ -45,14 +45,13 @@ dependencies { implementation(project(":core-design-system")) implementation(project(":navigator")) implementation(project(":domain")) + implementation(project(":presentation:statistics")) + implementation(project(":presentation:my")) implementation(jetpackDeps) implementation(coroutines) implementation deps.hilt.core - implementation 'androidx.appcompat:appcompat:1.5.1' - implementation 'com.google.android.material:material:1.4.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' kapt deps.hilt.compiler testImplementation(testDeps) diff --git a/presentation/home/src/main/java/com/depromeet/threedays/home/MainActivity.kt b/presentation/home/src/main/java/com/depromeet/threedays/home/MainActivity.kt index 214b5b08..4baa0a0b 100644 --- a/presentation/home/src/main/java/com/depromeet/threedays/home/MainActivity.kt +++ b/presentation/home/src/main/java/com/depromeet/threedays/home/MainActivity.kt @@ -1,11 +1,44 @@ package com.depromeet.threedays.home -import androidx.appcompat.app.AppCompatActivity import android.os.Bundle +import androidx.fragment.app.Fragment +import com.depromeet.threedays.core.BaseActivity +import com.depromeet.threedays.home.databinding.ActivityMainBinding +import com.depromeet.threedays.home.home.HomeFragment +import com.depromeet.threedays.my.MyFragment +import com.depromeet.threedays.statistics.StatisticsFragment +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class MainActivity : BaseActivity(R.layout.activity_main) { -class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) + + initNavigationBar() + } + + private fun initNavigationBar() { + binding.bnvMain.run { + setOnItemSelectedListener { + when (it.itemId) { + R.id.homeFragment -> { + changeFragment(HomeFragment()) + } + R.id.statisticsFragment -> { + changeFragment(StatisticsFragment()) + } + R.id.myFragment -> { + changeFragment(MyFragment()) + } + } + true + } + selectedItemId = R.id.homeFragment + } + } + + private fun changeFragment(fragment: Fragment) { + supportFragmentManager.beginTransaction().replace(binding.flMain.id, fragment).commit() } } \ No newline at end of file diff --git a/presentation/home/src/main/java/com/depromeet/threedays/home/home/HomeFragment.kt b/presentation/home/src/main/java/com/depromeet/threedays/home/home/HomeFragment.kt index ce9db921..32d03c69 100644 --- a/presentation/home/src/main/java/com/depromeet/threedays/home/home/HomeFragment.kt +++ b/presentation/home/src/main/java/com/depromeet/threedays/home/home/HomeFragment.kt @@ -1,7 +1,29 @@ package com.depromeet.threedays.home.home -import androidx.fragment.app.Fragment +import android.os.Bundle +import android.view.View +import androidx.fragment.app.viewModels +import com.depromeet.threedays.core.BaseFragment +import com.depromeet.threedays.home.R +import com.depromeet.threedays.home.databinding.FragmentHomeBinding +import dagger.hilt.android.AndroidEntryPoint -class HomeFragment : Fragment() { +@AndroidEntryPoint +class HomeFragment: BaseFragment(R.layout.fragment_home) { + override val viewModel by viewModels() + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + initView() + } + + private fun initView() { + // 우선 임시로 setOnClickListener를 달아놨습니다. + // 혜인님 레포에 있는 것처럼 setOnSingleClickListener를 만들어서 사용할 지 여부와 + // viewModel에서 클릭리스너를 달아줄지 등을 협의하고 확정되면 추후에 수정하겠습니다. + binding.btnMakeGoal.setOnClickListener { + // TODO: 만들기 페이지로 이동 + } + } } \ No newline at end of file diff --git a/presentation/home/src/main/java/com/depromeet/threedays/home/home/HomeModule.kt b/presentation/home/src/main/java/com/depromeet/threedays/home/home/HomeModule.kt new file mode 100644 index 00000000..7c9ccf36 --- /dev/null +++ b/presentation/home/src/main/java/com/depromeet/threedays/home/home/HomeModule.kt @@ -0,0 +1,14 @@ +package com.depromeet.threedays.home.home + +import com.depromeet.threedays.navigator.HomeNavigator +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent + +@Module +@InstallIn(SingletonComponent::class) +internal abstract class HomeModule { + @Binds + abstract fun bindHomeNavigator(navigator: HomeNavigatorImpl): HomeNavigator +} \ No newline at end of file diff --git a/presentation/home/src/main/java/com/depromeet/threedays/home/home/HomeNavigatorImpl.kt b/presentation/home/src/main/java/com/depromeet/threedays/home/home/HomeNavigatorImpl.kt new file mode 100644 index 00000000..8401e74c --- /dev/null +++ b/presentation/home/src/main/java/com/depromeet/threedays/home/home/HomeNavigatorImpl.kt @@ -0,0 +1,13 @@ +package com.depromeet.threedays.home.home + +import android.content.Context +import android.content.Intent +import com.depromeet.threedays.home.MainActivity +import com.depromeet.threedays.navigator.HomeNavigator +import javax.inject.Inject + +internal class HomeNavigatorImpl @Inject constructor() : HomeNavigator { + override fun intent(context: Context): Intent { + return Intent(context, MainActivity::class.java) + } +} \ No newline at end of file diff --git a/presentation/home/src/main/java/com/depromeet/threedays/home/home/HomeViewModel.kt b/presentation/home/src/main/java/com/depromeet/threedays/home/home/HomeViewModel.kt new file mode 100644 index 00000000..46fb68b1 --- /dev/null +++ b/presentation/home/src/main/java/com/depromeet/threedays/home/home/HomeViewModel.kt @@ -0,0 +1,6 @@ +package com.depromeet.threedays.home.home + +import com.depromeet.threedays.core.BaseViewModel + +class HomeViewModel : BaseViewModel() { +} \ No newline at end of file diff --git a/presentation/home/src/main/res/drawable/selector_menu_color.xml b/presentation/home/src/main/res/drawable/selector_menu_color.xml new file mode 100644 index 00000000..f4c6fdbb --- /dev/null +++ b/presentation/home/src/main/res/drawable/selector_menu_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/presentation/home/src/main/res/layout/activity_main.xml b/presentation/home/src/main/res/layout/activity_main.xml index 0b15a209..d44f7168 100644 --- a/presentation/home/src/main/res/layout/activity_main.xml +++ b/presentation/home/src/main/res/layout/activity_main.xml @@ -1,9 +1,31 @@ - + xmlns:tools="http://schemas.android.com/tools"> - \ No newline at end of file + + + + + + + + + + + \ No newline at end of file diff --git a/presentation/home/src/main/res/menu/bottom_nav_menu.xml b/presentation/home/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 00000000..23a4cd4f --- /dev/null +++ b/presentation/home/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/presentation/my/.gitignore b/presentation/my/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/presentation/my/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/presentation/my/build.gradle b/presentation/my/build.gradle new file mode 100644 index 00000000..33b52fbd --- /dev/null +++ b/presentation/my/build.gradle @@ -0,0 +1,52 @@ +plugins { + id 'com.android.library' + id 'org.jetbrains.kotlin.android' + id "kotlin-kapt" + id 'dagger.hilt.android.plugin' +} + +android { + compileSdk 32 + + defaultConfig { + minSdk 24 + targetSdk 32 + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } + buildFeatures { + dataBinding true + } +} + +dependencies { + + implementation(project(":core")) + implementation(project(":navigator")) + implementation(project(":domain")) + implementation(project(":core-design-system")) + + implementation(jetpackDeps) + implementation(coroutines) + + implementation deps.hilt.core + kapt deps.hilt.compiler + + testImplementation(testDeps) + androidTestImplementation(androidTestDeps) +} \ No newline at end of file diff --git a/presentation/my/consumer-rules.pro b/presentation/my/consumer-rules.pro new file mode 100644 index 00000000..e69de29b diff --git a/presentation/my/proguard-rules.pro b/presentation/my/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/presentation/my/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/presentation/my/src/androidTest/java/com/depromeet/threedays/my/ExampleInstrumentedTest.kt b/presentation/my/src/androidTest/java/com/depromeet/threedays/my/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..46cab11c --- /dev/null +++ b/presentation/my/src/androidTest/java/com/depromeet/threedays/my/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.depromeet.threedays.my + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.depromeet.threedays.my.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/presentation/my/src/main/AndroidManifest.xml b/presentation/my/src/main/AndroidManifest.xml new file mode 100644 index 00000000..9a7b2479 --- /dev/null +++ b/presentation/my/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/presentation/my/src/main/java/com/depromeet/threedays/my/MyFragment.kt b/presentation/my/src/main/java/com/depromeet/threedays/my/MyFragment.kt new file mode 100644 index 00000000..74b18e39 --- /dev/null +++ b/presentation/my/src/main/java/com/depromeet/threedays/my/MyFragment.kt @@ -0,0 +1,12 @@ +package com.depromeet.threedays.my + +import androidx.fragment.app.viewModels +import com.depromeet.threedays.core.BaseFragment +import com.depromeet.threedays.my.databinding.FragmentMyBinding +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class MyFragment: BaseFragment(R.layout.fragment_my) { + override val viewModel by viewModels() + +} \ No newline at end of file diff --git a/presentation/my/src/main/java/com/depromeet/threedays/my/MyViewModel.kt b/presentation/my/src/main/java/com/depromeet/threedays/my/MyViewModel.kt new file mode 100644 index 00000000..d2682d55 --- /dev/null +++ b/presentation/my/src/main/java/com/depromeet/threedays/my/MyViewModel.kt @@ -0,0 +1,6 @@ +package com.depromeet.threedays.my + +import com.depromeet.threedays.core.BaseViewModel + +class MyViewModel : BaseViewModel() { +} \ No newline at end of file diff --git a/presentation/my/src/main/res/layout/fragment_my.xml b/presentation/my/src/main/res/layout/fragment_my.xml new file mode 100644 index 00000000..41ecd6b1 --- /dev/null +++ b/presentation/my/src/main/res/layout/fragment_my.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/presentation/my/src/test/java/com/depromeet/threedays/my/ExampleUnitTest.kt b/presentation/my/src/test/java/com/depromeet/threedays/my/ExampleUnitTest.kt new file mode 100644 index 00000000..88e249a3 --- /dev/null +++ b/presentation/my/src/test/java/com/depromeet/threedays/my/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.depromeet.threedays.my + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/presentation/statistics/.gitignore b/presentation/statistics/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/presentation/statistics/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/presentation/statistics/build.gradle b/presentation/statistics/build.gradle new file mode 100644 index 00000000..33b52fbd --- /dev/null +++ b/presentation/statistics/build.gradle @@ -0,0 +1,52 @@ +plugins { + id 'com.android.library' + id 'org.jetbrains.kotlin.android' + id "kotlin-kapt" + id 'dagger.hilt.android.plugin' +} + +android { + compileSdk 32 + + defaultConfig { + minSdk 24 + targetSdk 32 + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } + buildFeatures { + dataBinding true + } +} + +dependencies { + + implementation(project(":core")) + implementation(project(":navigator")) + implementation(project(":domain")) + implementation(project(":core-design-system")) + + implementation(jetpackDeps) + implementation(coroutines) + + implementation deps.hilt.core + kapt deps.hilt.compiler + + testImplementation(testDeps) + androidTestImplementation(androidTestDeps) +} \ No newline at end of file diff --git a/presentation/statistics/consumer-rules.pro b/presentation/statistics/consumer-rules.pro new file mode 100644 index 00000000..e69de29b diff --git a/presentation/statistics/proguard-rules.pro b/presentation/statistics/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/presentation/statistics/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/presentation/statistics/src/androidTest/java/com/depromeet/threedays/statistics/ExampleInstrumentedTest.kt b/presentation/statistics/src/androidTest/java/com/depromeet/threedays/statistics/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..49ef7c5a --- /dev/null +++ b/presentation/statistics/src/androidTest/java/com/depromeet/threedays/statistics/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.depromeet.threedays.statistics + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.depromeet.threedays.statistics.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/presentation/statistics/src/main/AndroidManifest.xml b/presentation/statistics/src/main/AndroidManifest.xml new file mode 100644 index 00000000..8408eb14 --- /dev/null +++ b/presentation/statistics/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/presentation/statistics/src/main/java/com/depromeet/threedays/statistics/StatisticsFragment.kt b/presentation/statistics/src/main/java/com/depromeet/threedays/statistics/StatisticsFragment.kt new file mode 100644 index 00000000..d9d3f2ba --- /dev/null +++ b/presentation/statistics/src/main/java/com/depromeet/threedays/statistics/StatisticsFragment.kt @@ -0,0 +1,12 @@ +package com.depromeet.threedays.statistics + +import androidx.fragment.app.viewModels +import com.depromeet.threedays.core.BaseFragment +import com.depromeet.threedays.statistics.databinding.FragmentStatisticsBinding +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class StatisticsFragment: BaseFragment(R.layout.fragment_statistics) { + override val viewModel by viewModels() + +} \ No newline at end of file diff --git a/presentation/statistics/src/main/java/com/depromeet/threedays/statistics/StatisticsViewModel.kt b/presentation/statistics/src/main/java/com/depromeet/threedays/statistics/StatisticsViewModel.kt new file mode 100644 index 00000000..c6aa6158 --- /dev/null +++ b/presentation/statistics/src/main/java/com/depromeet/threedays/statistics/StatisticsViewModel.kt @@ -0,0 +1,6 @@ +package com.depromeet.threedays.statistics + +import com.depromeet.threedays.core.BaseViewModel + +class StatisticsViewModel : BaseViewModel() { +} \ No newline at end of file diff --git a/presentation/statistics/src/main/res/layout/fragment_statistics.xml b/presentation/statistics/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 00000000..aef40094 --- /dev/null +++ b/presentation/statistics/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/presentation/statistics/src/test/java/com/depromeet/threedays/statistics/ExampleUnitTest.kt b/presentation/statistics/src/test/java/com/depromeet/threedays/statistics/ExampleUnitTest.kt new file mode 100644 index 00000000..1732c122 --- /dev/null +++ b/presentation/statistics/src/test/java/com/depromeet/threedays/statistics/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.depromeet.threedays.statistics + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 227d6b5f..2ea92552 100644 --- a/settings.gradle +++ b/settings.gradle @@ -21,3 +21,5 @@ include ':navigator' include ':domain' include ':presentation' include ':presentation:home' +include ':presentation:my' +include ':presentation:statistics'