Skip to content

Commit 4ac31e4

Browse files
authored
Merge branch 'develop' into feat/signin
2 parents f336964 + cb8f420 commit 4ac31e4

File tree

11 files changed

+193
-1
lines changed

11 files changed

+193
-1
lines changed

.github/workflows/mogakrunci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ jobs:
2020

2121
- name: Create google-service
2222
run: echo '${{ secrets.GOOGLE_SERVICES_JSON }}' > ./data/google-services.json
23+
24+
- name: Create Local Properties
25+
run: echo '${{ secrets.LOCAL_PROPERTIES }}' > ./local.properties
2326

2427
- name: Build with Gradle
2528
run: ./gradlew build

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ buildscript {
2222
lifecycleViewmodelKtxVersion = "2.5.1"
2323
splashVersion = "1.0.0"
2424
dataStoreVersion = "1.0.0"
25+
viewPager2Version = "1.0.0"
2526
}
2627
dependencies {
2728
classpath "com.google.gms:google-services:$googleServiceVersion"

presentation/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,7 @@ dependencies {
7070

7171
// splash
7272
implementation "androidx.core:core-splashscreen:$splashVersion"
73+
74+
// ViewPager2
75+
implementation "androidx.viewpager2:viewpager2:$viewPager2Version"
7376
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.whyranoid.presentation.community
2+
3+
import androidx.annotation.StringRes
4+
import com.whyranoid.presentation.R
5+
6+
enum class CommunityCategory(@StringRes val stringId: Int) {
7+
BOARD(R.string.text_board),
8+
MY_GROUP(R.string.text_my_group),
9+
MY_POST(R.string.text_my_post)
10+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.whyranoid.presentation.community
2+
3+
import androidx.fragment.app.Fragment
4+
import androidx.viewpager2.adapter.FragmentStateAdapter
5+
6+
class CommunityCategoryAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) {
7+
8+
override fun getItemCount(): Int = CATEGORY_COUNT
9+
10+
override fun createFragment(position: Int): Fragment {
11+
return CommunityItemFragment.newInstance(CommunityCategory.values()[position])
12+
}
13+
14+
companion object {
15+
const val CATEGORY_COUNT = 3
16+
}
17+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.whyranoid.presentation.community
2+
3+
import android.os.Bundle
4+
import android.view.View
5+
import androidx.viewpager2.adapter.FragmentStateAdapter
6+
import com.google.android.material.tabs.TabLayoutMediator
7+
import com.whyranoid.presentation.R
8+
import com.whyranoid.presentation.base.BaseFragment
9+
import com.whyranoid.presentation.databinding.FragmentCommunityBinding
10+
11+
internal class CommunityFragment :
12+
BaseFragment<FragmentCommunityBinding>(R.layout.fragment_community) {
13+
14+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
15+
super.onViewCreated(view, savedInstanceState)
16+
17+
val adapter = CommunityCategoryAdapter(this)
18+
setTabLayout(adapter)
19+
}
20+
21+
private fun setTabLayout(adapter: FragmentStateAdapter) {
22+
binding.viewPager.adapter = adapter
23+
TabLayoutMediator(binding.tabLayout, binding.viewPager) { tab, position ->
24+
tab.text = getString(CommunityCategory.values()[position].stringId)
25+
}.attach()
26+
}
27+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.whyranoid.presentation.community
2+
3+
import android.os.Build
4+
import android.os.Bundle
5+
import android.view.View
6+
import androidx.fragment.app.viewModels
7+
import com.whyranoid.presentation.R
8+
import com.whyranoid.presentation.base.BaseFragment
9+
import com.whyranoid.presentation.databinding.FragmentCommunityItemBinding
10+
import dagger.hilt.android.AndroidEntryPoint
11+
12+
@AndroidEntryPoint
13+
internal class CommunityItemFragment :
14+
BaseFragment<FragmentCommunityItemBinding>(R.layout.fragment_community_item) {
15+
16+
private val viewModel: CommunityViewModel by viewModels()
17+
18+
private val category by lazy {
19+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
20+
arguments?.getSerializable(COMMUNITY_CATEGORY_KEY, CommunityCategory::class.java)
21+
?: CommunityCategory.BOARD
22+
} else {
23+
arguments?.getSerializable(COMMUNITY_CATEGORY_KEY) as? CommunityCategory
24+
?: CommunityCategory.BOARD
25+
}
26+
}
27+
28+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
29+
super.onViewCreated(view, savedInstanceState)
30+
}
31+
32+
companion object {
33+
private const val COMMUNITY_CATEGORY_KEY = "communityCategoryKey"
34+
35+
fun newInstance(communityCategory: CommunityCategory): CommunityItemFragment {
36+
val fragment = CommunityItemFragment()
37+
fragment.arguments = Bundle().apply {
38+
putSerializable(COMMUNITY_CATEGORY_KEY, communityCategory)
39+
}
40+
return fragment
41+
}
42+
}
43+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.whyranoid.presentation.community
2+
3+
import androidx.lifecycle.ViewModel
4+
import dagger.hilt.android.lifecycle.HiltViewModel
5+
import javax.inject.Inject
6+
7+
@HiltViewModel
8+
class CommunityViewModel @Inject constructor() : ViewModel()
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools">
5+
6+
<data>
7+
8+
</data>
9+
10+
<androidx.constraintlayout.widget.ConstraintLayout
11+
android:layout_width="match_parent"
12+
android:layout_height="match_parent"
13+
tools:context=".community.CommunityFragment">
14+
15+
<com.google.android.material.appbar.AppBarLayout
16+
android:id="@+id/app_bar"
17+
android:layout_width="match_parent"
18+
android:layout_height="wrap_content"
19+
app:layout_constraintTop_toTopOf="parent">
20+
21+
<com.google.android.material.appbar.MaterialToolbar
22+
android:id="@+id/topAppBar"
23+
style="@style/Widget.MaterialComponents.Toolbar.Primary"
24+
android:layout_width="match_parent"
25+
android:layout_height="?attr/actionBarSize"
26+
app:title="@string/text_community" />
27+
28+
</com.google.android.material.appbar.AppBarLayout>
29+
30+
<com.google.android.material.tabs.TabLayout
31+
android:id="@+id/tab_layout"
32+
android:layout_width="match_parent"
33+
android:layout_height="wrap_content"
34+
app:layout_constraintEnd_toEndOf="parent"
35+
app:layout_constraintStart_toStartOf="parent"
36+
app:layout_constraintTop_toBottomOf="@id/app_bar">
37+
38+
</com.google.android.material.tabs.TabLayout>
39+
40+
<androidx.viewpager2.widget.ViewPager2
41+
android:id="@+id/view_pager"
42+
android:layout_width="0dp"
43+
android:layout_height="0dp"
44+
app:layout_constraintBottom_toBottomOf="parent"
45+
app:layout_constraintEnd_toEndOf="parent"
46+
app:layout_constraintStart_toStartOf="parent"
47+
app:layout_constraintTop_toBottomOf="@id/tab_layout" />
48+
49+
</androidx.constraintlayout.widget.ConstraintLayout>
50+
</layout>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
xmlns:app="http://schemas.android.com/apk/res-auto">
5+
6+
<data>
7+
8+
</data>
9+
10+
<androidx.constraintlayout.widget.ConstraintLayout
11+
android:layout_width="match_parent"
12+
android:layout_height="match_parent"
13+
tools:context=".community.CommunityItemFragment">
14+
15+
<androidx.recyclerview.widget.RecyclerView
16+
android:id="@+id/rv_community"
17+
android:layout_width="0dp"
18+
android:layout_height="0dp"
19+
app:layout_constraintStart_toStartOf="parent"
20+
app:layout_constraintEnd_toEndOf="parent"
21+
app:layout_constraintTop_toTopOf="parent"
22+
app:layout_constraintBottom_toBottomOf="parent"/>
23+
24+
</androidx.constraintlayout.widget.ConstraintLayout>
25+
</layout>

0 commit comments

Comments
 (0)