-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DEP-51 feat: Navigator 구현 #17
Changes from all commits
8393c6c
093f489
6bc6fa1
4d95188
f405f64
36f6fa7
0d2037b
2cfc97b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package com.depromeet.threedays | ||
|
||
import android.app.Application | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
@HiltAndroidApp | ||
class ThreeDaysApplication : Application() { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.depromeet.threedays.navigator | ||
|
||
interface HomeNavigator : Navigator |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.depromeet.threedays.navigator | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
|
||
interface Navigator { | ||
fun intent(context: Context): Intent | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ActivityMainBinding>(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() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<FragmentHomeBinding, HomeViewModel>(R.layout.fragment_home) { | ||
override val viewModel by viewModels<HomeViewModel>() | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
initView() | ||
} | ||
|
||
private fun initView() { | ||
// 우선 임시로 setOnClickListener를 달아놨습니다. | ||
// 혜인님 레포에 있는 것처럼 setOnSingleClickListener를 만들어서 사용할 지 여부와 | ||
// viewModel에서 클릭리스너를 달아줄지 등을 협의하고 확정되면 추후에 수정하겠습니다. | ||
Comment on lines
+23
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. viewModel에서 클릭리스너를 다는 방식은 어떤건가용 ?.? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 양방향 바인딩이용! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아하!! 흠 그러게요,,.. 섞어서 써도 괜찮을 것 같고 그냥 하나로 정하는 것도 좋을 것 같아요! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. setOnSingleClickListener 이거 interval을 주고 그러던데 정확히 무엇을 위한 커스텀인가요? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저도 굳이 interval 값을 고정하는게 아니라 파라미터로서 주는 이유는 잘 모르겠습니닷..... |
||
binding.btnMakeGoal.setOnClickListener { | ||
// TODO: 만들기 페이지로 이동 | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.depromeet.threedays.home.home | ||
|
||
import com.depromeet.threedays.core.BaseViewModel | ||
|
||
class HomeViewModel : BaseViewModel() { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:color="#1A1F27" android:state_checked="true" /> | ||
<item android:color="#B0B8C1" /> | ||
</selector> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".MainActivity"> | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
<data> | ||
|
||
</data> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".MainActivity"> | ||
|
||
<FrameLayout | ||
android:id="@+id/fl_main" | ||
android:layout_width="match_parent" | ||
android:layout_height="0dp" | ||
app:layout_constraintBottom_toTopOf="@+id/bnv_main" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<com.google.android.material.bottomnavigation.BottomNavigationView | ||
android:id="@+id/bnv_main" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
app:itemIconTint="@drawable/selector_menu_color" | ||
app:itemTextColor="@drawable/selector_menu_color" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:menu="@menu/bottom_nav_menu"/> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
<item | ||
android:id="@+id/homeFragment" | ||
android:icon="@drawable/ic_tab_home" | ||
android:title="홈" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. title 값은 string.xml 에 정의하는 것보다 bottom_nav_menu.xml 에서 관리하는게 나을까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기서 노란색으로 경고표시..?가 뜬다면 추출하고 아니라면 굳이 안해도 되지 않을까 싶습니닷 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 노란색 경고 뜨긴합니다... ㅎㅎ... |
||
<item | ||
android:id="@+id/statisticsFragment" | ||
android:icon="@drawable/ic_tab_statistics" | ||
android:title="통계" /> | ||
<item | ||
android:id="@+id/myFragment" | ||
android:icon="@drawable/ic_tab_my" | ||
android:title="마이페이지" /> | ||
</menu> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 엇 친절하게 설명과 링크까지... 감사합니다 ㅎㅎ! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.depromeet.threedays.my"> | ||
|
||
</manifest> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 transaction 이 있네요. 신기하네요 ㅋㅋ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flutter에도 있나보군요! ㅋㅋㅋ