Skip to content
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

[Feat/#22] Main Bottom Nav 구현 #24

Merged
merged 3 commits into from
Jul 9, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,39 @@ import com.sopt.umbba_android.R
import com.sopt.umbba_android.databinding.ActivityMainBinding
import com.sopt.umbba_android.presentation.home.HomeFragment
import com.sopt.umbba_android.presentation.qna.QuestionAnswerActivity
import com.sopt.umbba_android.presentation.setting.SettingFragment
import com.sopt.umbba_android.util.binding.BindingActivity

class MainActivity :BindingActivity<ActivityMainBinding>(R.layout.activity_main){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
initView()
setBottomNav()
}

private fun initView(){
val currentFragment = supportFragmentManager.findFragmentById(R.id.fcv_main)
if (currentFragment == null) {
changeFragment(HomeFragment())
}
}
private fun setBottomNav(){
binding.bnvMain.run(){
setOnItemSelectedListener {
changeFragment(
when(it.itemId){
R.id.menu_home -> HomeFragment()
R.id.menu_setting -> SettingFragment()
else -> HomeFragment()
}
)
true
}
}
}
private fun changeFragment(fragment: Fragment) {
supportFragmentManager.beginTransaction()
.replace(R.id.fcv_main, fragment)
.commit()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(R.layout.fragment_home
super.onViewCreated(view, savedInstanceState)
setBackground()
}

private fun setBackground(){
with(binding){
ivBackground.load("https://i.ibb.co/sRV9Vr4/iv-maru.jpg")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class QuestionAnswerActivity :

private fun setBlurText(isBlur: Boolean) {
with(binding) {
tvAnswerOther.setLayerType(View.LAYER_TYPE_SOFTWARE, null).apply{
tvAnswerOther.setLayerType(View.LAYER_TYPE_SOFTWARE, null).apply {
if (isBlur) tvAnswerOther.paint.maskFilter =
BlurMaskFilter(13f, BlurMaskFilter.Blur.NORMAL)
else tvAnswerOther.paint.maskFilter = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package com.sopt.umbba_android.presentation.setting

import android.os.Bundle
import android.view.View
import com.sopt.umbba_android.R
import com.sopt.umbba_android.databinding.FragmentSettingBinding
import com.sopt.umbba_android.util.binding.BindingFragment

class SettingFragment:BindingFragment<FragmentSettingBinding>(R.layout.fragment_setting) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}
15 changes: 11 additions & 4 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@
android:layout_height="match_parent"
tools:context=".presentation.MainActivity">

<FrameLayout
android:id="@+id/fragment_fv"
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fcv_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintTop_toTopOf="parent"/>

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bnv_main"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:itemIconSize="24dp"
app:menu="@menu/menu_bottom"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_quest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="12dp"
android:text="@string/quest_activity_title"
android:lineSpacingExtra="8dp"
android:text="@string/quest_activity_title"
android:textColor="@color/black"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/layout_appbar" />
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/activity_question_answer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
app:layout_constraintTop_toBottomOf="@id/tv_title" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_answer_other"
android:id="@+id/cl_answer_other"
android:layout_width="match_parent"
android:layout_height="172dp"
android:layout_marginHorizontal="16dp"
Expand Down Expand Up @@ -91,10 +91,10 @@
android:text="@string/question_answer_quesiton_me"
android:textAppearance="@style/AndroidSubHead1SemiBold20"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/layout_answer_other" />
app:layout_constraintTop_toBottomOf="@id/cl_answer_other" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_answer_me"
android:id="@+id/cl_answer_me"
android:layout_width="match_parent"
android:layout_height="172dp"
android:layout_marginHorizontal="16dp"
Expand Down
78 changes: 40 additions & 38 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
@@ -1,44 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv_background"

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
android:layout_height="match_parent">

<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:paddingHorizontal="40dp"
android:background="@drawable/shape_grey_fill_r84_rect"
android:textAppearance="@style/BrandTypeBigRegular20"
android:text="#1 가장 오래된 기억"
android:gravity="center"
android:textColor="@color/white"
android:layout_marginTop="40dp"
android:layout_marginStart="24dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<ImageView
android:id="@+id/iv_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_answer"
android:layout_width="match_parent"
android:layout_height="60dp"
android:textSize="16sp"
android:text="@string/home_question_answer"
android:textColor="@color/white"
android:background="@drawable/shape_black_fill_r50_rect"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginHorizontal="24dp"
android:layout_marginBottom="12dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_marginStart="24dp"
android:layout_marginTop="40dp"
android:background="@drawable/shape_grey_fill_r84_rect"
android:gravity="center"
android:paddingHorizontal="40dp"
android:text="@string/answer_title"
android:textAppearance="@style/BrandTypeBigRegular20"
android:textColor="@color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_answer"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginHorizontal="24dp"
android:layout_marginBottom="12dp"
android:background="@drawable/shape_black_fill_r50_rect"
android:text="@string/home_question_answer"
android:textColor="@color/white"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_quest_one.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@

<TextView
android:id="@+id/tv_question"
style="@style/AndroidSubHead1SemiBold20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="16dp"
style="@style/AndroidSubHead1SemiBold20"
android:textColor="@color/black"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="어머니와 지금 같이 살고 있어?" />

<TextView
android:id="@+id/tv_sub_title"
style="@style/AndroidCaptionRegular12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="12dp"
style="@style/AndroidCaptionRegular12"
android:text="@string/quest_sub_title"
android:textColor="@color/grey_999999"
app:layout_constraintStart_toStartOf="parent"
Expand Down
18 changes: 9 additions & 9 deletions app/src/main/res/layout/fragment_setting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:layout_height="match_parent">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_title_bar"
android:id="@+id/cl_title_bar"
android:layout_width="match_parent"
android:layout_height="60dp"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -28,12 +28,12 @@
</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_notification"
android:id="@+id/cl_notification"
android:layout_width="match_parent"
android:layout_height="76dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/layout_title_bar">
app:layout_constraintTop_toBottomOf="@id/cl_title_bar">

<TextView
android:id="@+id/tv_notification"
Expand Down Expand Up @@ -66,12 +66,12 @@
</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_about_umbba"
android:id="@+id/cl_about_umbba"
android:layout_width="match_parent"
android:layout_height="72dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/layout_notification">
app:layout_constraintTop_toBottomOf="@id/cl_notification">

<TextView
android:id="@+id/tv_about_umbba"
Expand All @@ -97,12 +97,12 @@
</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_tos"
android:id="@+id/cl_tos"
android:layout_width="match_parent"
android:layout_height="72dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/layout_about_umbba">
app:layout_constraintTop_toBottomOf="@id/cl_about_umbba">

<TextView
android:id="@+id/tv_tos"
Expand All @@ -129,12 +129,12 @@
</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_notice"
android:id="@+id/cl_notice"
android:layout_width="match_parent"
android:layout_height="72dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/layout_tos">
app:layout_constraintTop_toBottomOf="@id/cl_tos">

<TextView
android:id="@+id/tv_notice"
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/res/menu/menu_bottom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_home"
android:title="홈"
android:icon="@drawable/ic_close" />
<item
android:id="@+id/menu_list"
android:title="리스트"
android:icon="@drawable/ic_close" />
<item
android:id="@+id/menu_setting"
android:title="설정"
android:icon="@drawable/ic_close" />
</menu>