Skip to content

Commit

Permalink
Merge pull request #19 from Team-Wable/feature/#18-profile-hamburger-ui
Browse files Browse the repository at this point in the history
[Feature/#18] : profile hamburger UI
  • Loading branch information
Eonji-sw authored Aug 16, 2024
2 parents c0cb172 + f6cec29 commit ad68d78
Show file tree
Hide file tree
Showing 36 changed files with 1,364 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ class AndroidFeaturePlugin : Plugin<Project> {
plugins.apply("com.android.library")
configureAndroidCommonPlugin()

with(plugins) {
apply("androidx.navigation.safeargs")
}

val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")
dependencies {
"implementation"(libs.findLibrary("androidx.constraintlayout").get())
}
}
}
}
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ buildscript {
classpath(libs.kotlin.gradleplugin)
classpath(libs.hilt.plugin)
classpath(libs.agp)
classpath(libs.androidx.navigation.safe.args)
}
}

Expand Down
13 changes: 13 additions & 0 deletions core/common/src/main/res/drawable/ic_share_bottomsheet_bar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="46dp"
android:height="4dp"
android:viewportWidth="46"
android:viewportHeight="4">
<path
android:pathData="M2,2H44"
android:strokeLineJoin="round"
android:strokeWidth="4"
android:fillColor="#00000000"
android:strokeColor="#AEAEAE"
android:strokeLineCap="round"/>
</vector>
9 changes: 9 additions & 0 deletions core/ui/src/main/java/com/teamwable/ui/util/Constants.kt
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
package com.teamwable.ui.util

// 전역적으로 쓰이는 키 값 관리
object BottomSheetTag {
const val PROFILE_HAMBURGER_BOTTOM_SHEET = "ProfileHamburgerBottomSheet"
}

object DialogTag {
const val PROFILE_DELETE_DIALOG = "ProfileDeleteDialog"
const val LOGOUT_DIALOG = "LogoutDialog"
}
5 changes: 5 additions & 0 deletions core/ui/src/main/res/color/sel_bottom_btn_color.xml
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="@color/purple_50" android:state_enabled="true" />
<item android:color="@color/gray_200" android:state_enabled="false" />
</selector>
4 changes: 4 additions & 0 deletions core/ui/src/main/res/drawable/shape_fill_12_rect.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="12dp" />
</shape>
6 changes: 6 additions & 0 deletions core/ui/src/main/res/drawable/shape_fill_top_16_rect.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:topLeftRadius="16dp"
android:topRightRadius="16dp" />
</shape>
9 changes: 9 additions & 0 deletions core/ui/src/main/res/drawable/shape_gray200_line_16_rect.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/white" />
<stroke
android:width="1dp"
android:color="@color/gray_200" />
<corners android:radius="16dp" />
</shape>
13 changes: 13 additions & 0 deletions feature/home/src/main/res/navigation/graph_home.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation 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:id="@+id/graph_home"
app:startDestination="@id/navigation_home">

<fragment
android:id="@+id/navigation_home"
android:name="com.teamwable.home.HomeFragment"
android:label="HomeFragment"
tools:layout="@layout/fragment_home" />
</navigation>
16 changes: 13 additions & 3 deletions feature/main/src/main/java/com/teamwable/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,26 @@ class MainActivity : AppCompatActivity() {
private fun initBottomNavigationChangedListener(navController: NavController) {
navController.addOnDestinationChangedListener { controller, destination, arguments ->
handleBottomNavigationVisibility(destination)
if (destination.id == R.id.navigation_notification) setBadgeOnNotification(false)
if (destination.id == com.teamwable.notification.R.id.navigation_notification) setBadgeOnNotification(false)
}
}

private fun handleBottomNavigationVisibility(destination: NavDestination) {
binding.groupMainBnv.visible(destination.id != R.id.navigation_posting)
if (destination.id in listOf(
com.teamwable.home.R.id.navigation_home,
com.teamwable.news.R.id.navigation_news,
com.teamwable.notification.R.id.navigation_notification,
com.teamwable.profile.R.id.navigation_profile,
)
) {
binding.groupMainBnv.visible(true)
} else {
binding.groupMainBnv.visible(false)
}
}

private fun setBadgeOnNotification(isVisible: Boolean) {
binding.bnvMain.getOrCreateBadge(R.id.navigation_notification).apply {
binding.bnvMain.getOrCreateBadge(R.id.graph_notification).apply {
this.isVisible = isVisible
horizontalOffset = 1
if (isVisible) backgroundColor = colorOf(com.teamwable.ui.R.color.error) else clearNumber()
Expand Down
8 changes: 4 additions & 4 deletions feature/main/src/main/res/menu/menu_main_navigation.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/navigation_home"
android:id="@+id/graph_home"
android:icon="@drawable/sel_main_bnv_home"
android:title="@string/label_bnv_home" />
<item
android:id="@+id/navigation_news"
android:id="@+id/graph_news"
android:icon="@drawable/sel_main_bnv_news"
android:title="@string/label_bnv_news" />
<item
android:id="@+id/navigation_notification"
android:id="@+id/graph_notification"
android:icon="@drawable/sel_main_bnv_notification"
android:title="@string/label_bnv_notification" />
<item
android:id="@+id/navigation_profile"
android:id="@+id/graph_profile"
android:icon="@drawable/sel_main_bnv_profile"
android:title="@string/label_bnv_profile" />
</menu>
33 changes: 6 additions & 27 deletions feature/main/src/main/res/navigation/graph_main.xml
Original file line number Diff line number Diff line change
@@ -1,33 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation 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:id="@+id/graph_main"
app:startDestination="@id/navigation_home">
app:startDestination="@id/graph_home">

<fragment
android:id="@+id/navigation_home"
android:name="com.teamwable.home.HomeFragment"
android:label="HomeFragment"
tools:layout="@layout/fragment_home" />
<fragment
android:id="@+id/navigation_news"
android:name="com.teamwable.news.NewsFragment"
android:label="NewsFragment"
tools:layout="@layout/fragment_news" />
<fragment
android:id="@+id/navigation_notification"
android:name="com.teamwable.notification.NotificationFragment"
android:label="NotificationFragment"
tools:layout="@layout/fragment_notification" />
<fragment
android:id="@+id/navigation_profile"
android:name="com.teamwable.profile.ProfileFragment"
android:label="ProfileFragment"
tools:layout="@layout/fragment_profile" />
<fragment
android:id="@+id/navigation_posting"
android:name="com.teamwable.posting.PostingFragment"
android:label="PostingFragment"
tools:layout="@layout/fragment_posting" />
<include app:graph="@navigation/graph_home" />
<include app:graph="@navigation/graph_news" />
<include app:graph="@navigation/graph_notification" />
<include app:graph="@navigation/graph_profile" />
<include app:graph="@navigation/graph_posting" />
</navigation>
13 changes: 13 additions & 0 deletions feature/news/src/main/res/navigation/graph_news.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation 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:id="@+id/graph_news"
app:startDestination="@id/navigation_news">

<fragment
android:id="@+id/navigation_news"
android:name="com.teamwable.news.NewsFragment"
android:label="NewsFragment"
tools:layout="@layout/fragment_news" />
</navigation>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation 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:id="@+id/graph_notification"
app:startDestination="@id/navigation_notification">

<fragment
android:id="@+id/navigation_notification"
android:name="com.teamwable.notification.NotificationFragment"
android:label="NotificationFragment"
tools:layout="@layout/fragment_notification" />
</navigation>
13 changes: 13 additions & 0 deletions feature/posting/src/main/res/navigation/graph_posting.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation 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:id="@+id/graph_posting"
app:startDestination="@id/navigation_posting">

<fragment
android:id="@+id/navigation_posting"
android:name="com.teamwable.posting.PostingFragment"
android:label="PostingFragment"
tools:layout="@layout/fragment_posting" />
</navigation>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.teamwable.profile

import com.teamwable.profile.databinding.FragmentDeleteDialogBinding
import com.teamwable.ui.base.BindingDialogFragment
import com.teamwable.ui.extensions.dialogFragmentResize
import com.teamwable.ui.extensions.stringOf

class LogoutDialogFragment : BindingDialogFragment<FragmentDeleteDialogBinding>(R.layout.fragment_delete_dialog, FragmentDeleteDialogBinding::inflate) {
override fun initView() {
initText()
initCancelBtnClickListener()
initDeleteBtnClickListener()
}

private fun initText() {
with(binding) {
tvDeleteDialogTitle.text = stringOf(R.string.tv_logout_dialog_title)
btnDeleteDialogDelete.text = stringOf(R.string.btn_logout_dialog_delete)
}
}

override fun onResume() {
super.onResume()
context?.dialogFragmentResize(this, 30.0f)
}

private fun initCancelBtnClickListener() {
binding.btnDeleteDialogCancel.setOnClickListener {
dismiss()
}
}

private fun initDeleteBtnClickListener() {
binding.btnDeleteDialogDelete.setOnClickListener {
// Todo : 나중에 추가해야 함
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.teamwable.profile

import androidx.navigation.fragment.findNavController
import com.teamwable.profile.databinding.FragmentProfileDeleteConfirmBinding
import com.teamwable.ui.base.BindingFragment
import com.teamwable.ui.extensions.colorOf
import com.teamwable.ui.extensions.stringOf
import com.teamwable.ui.util.DialogTag.PROFILE_DELETE_DIALOG

class ProfileDeleteConfirmFragment : BindingFragment<FragmentProfileDeleteConfirmBinding>(FragmentProfileDeleteConfirmBinding::inflate) {
override fun initView() {
setAppbarText()
initBackBtnClickListener()
initCheckBoxClickListener()
}

private fun initCheckBoxClickListener() {
binding.cbProfileDeleteConfirm.setOnClickListener {
binding.btnProfileDeleteConfirmNext.apply {
isEnabled = binding.cbProfileDeleteConfirm.isChecked
if (isEnabled) {
setTextColor(colorOf(com.teamwable.ui.R.color.white))
setOnClickListener {
showToProfileDeleteDialogFragment()
}
} else {
setTextColor(colorOf(com.teamwable.ui.R.color.gray_600))
}
}
}
}

private fun setAppbarText() {
binding.viewProfileDeleteConfirmAppbar.tvProfileAppbarTitle.text = stringOf(R.string.appbar_profile_delete_title)
}

private fun initBackBtnClickListener() {
binding.viewProfileDeleteConfirmAppbar.btnProfileAppbarBack.setOnClickListener {
findNavController().popBackStack()
}
}

private fun showToProfileDeleteDialogFragment() {
ProfileDeleteDialogFragment().show(childFragmentManager, PROFILE_DELETE_DIALOG)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.teamwable.profile

import com.teamwable.profile.databinding.FragmentDeleteDialogBinding
import com.teamwable.ui.base.BindingDialogFragment
import com.teamwable.ui.extensions.dialogFragmentResize
import com.teamwable.ui.extensions.stringOf

class ProfileDeleteDialogFragment : BindingDialogFragment<FragmentDeleteDialogBinding>(R.layout.fragment_delete_dialog, FragmentDeleteDialogBinding::inflate) {
override fun initView() {
initText()
initCancelBtnClickListener()
initDeleteBtnClickListener()
}

private fun initText() {
with(binding) {
tvDeleteDialogTitle.text = stringOf(R.string.tv_profile_delete_dialog_title)
}
}

override fun onResume() {
super.onResume()
context?.dialogFragmentResize(this, 30.0f)
}

private fun initCancelBtnClickListener() {
binding.btnDeleteDialogCancel.setOnClickListener {
dismiss()
}
}

private fun initDeleteBtnClickListener() {
binding.btnDeleteDialogDelete.setOnClickListener {
// Todo : 나중에 추가해야 함
}
}
}
Loading

0 comments on commit ad68d78

Please sign in to comment.