Skip to content

Commit

Permalink
커스텀 네비게이터 적용 보류
Browse files Browse the repository at this point in the history
  • Loading branch information
pknujsp committed Jul 26, 2023
1 parent 02985e9 commit 45f695f
Show file tree
Hide file tree
Showing 32 changed files with 812 additions and 319 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions app/src/main/java/com/android/mediproject/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ import com.android.mediproject.core.common.uiutil.LayoutController
import com.android.mediproject.core.common.uiutil.SystemBarColorAnalyzer
import com.android.mediproject.core.common.uiutil.SystemBarController
import com.android.mediproject.core.common.uiutil.SystemBarStyler
import com.android.mediproject.core.common.util.SavingFragmentNavigator
import com.android.mediproject.core.network.InternetNetworkListener
import com.android.mediproject.core.ui.WindowViewModel
import com.android.mediproject.core.ui.base.BaseActivity
import com.android.mediproject.databinding.ActivityMainBinding
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.lastOrNull
import repeatOnStarted
import javax.inject.Inject

Expand Down Expand Up @@ -98,25 +96,9 @@ class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>(ActivityMa
itemIconTintList = null
background = null
menu.getItem(2).isEnabled = false

navController.navigatorProvider.addNavigator(
SavingFragmentNavigator(
fragmentContainerView.id,
navHostFragment.childFragmentManager,
systemBarColorAnalyzer,
),
)

navController.setGraph(R.navigation.main_nav)
bottomNav.setupWithNavController(navController)
}
setDestinationListener()

repeatOnStarted {
activityViewModel.selectedBottomNavFragmentId.lastOrNull()?.let { lastSelectedId ->
//bottomNav.selectedItemId = lastSelectedId
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:navGraph="@navigation/main_nav"
app:defaultNavHost="true" />

<com.google.android.material.bottomappbar.BottomAppBar
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/menu/main_menu.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@id/homeFragment"
android:id="@id/home_nav"
android:title="@string/home"
android:icon="@drawable/menu_selector_home_color" />

<item
android:id="@id/newsFragment"
android:id="@id/news_nav"
android:title="@string/news"
android:icon="@drawable/menu_selector_news_color" />

Expand All @@ -15,12 +15,12 @@
android:title=""/>

<item
android:id="@id/myPageFragment"
android:id="@id/mypage_nav"
android:title="@string/myPage"
android:icon="@drawable/menu_selector_mypage_color" />

<item
android:id="@id/etcFragment"
android:id="@id/etc_nav"
android:title="@string/etc"
android:icon="@drawable/menu_selector_etc_color" />
</menu>
24 changes: 0 additions & 24 deletions app/src/main/res/navigation/main_nav.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,6 @@
android:id="@+id/main_nav"
app:startDestination="@id/intro_nav">

<savingfragment
android:id="@+id/myPageFragment"
android:name="com.android.mediproject.feature.mypage.MyPageFragment"
android:label="MyPageFragment" />

<savingfragment
android:id="@+id/etcFragment"
android:name="com.android.mediproject.feature.etc.EtcFragment"
android:label="EtcFragment" />

<savingfragment
android:id="@+id/homeFragment"
android:name="com.android.mediproject.feature.home.HomeFragment"
android:label="HomeFragment">
<action
android:id="@+id/action_homeFragment_to_searchMedicinesFragment"
app:destination="@id/searchMedicinesFragment" />
</savingfragment>

<savingfragment
android:id="@+id/newsFragment"
android:name="com.android.mediproject.feature.news.NewsFragment"
android:label="NewsFragment" />

<include app:graph="@navigation/mypage_nav" />
<include app:graph="@navigation/etc_nav" />
<include app:graph="@navigation/intro_nav" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import android.text.style.StyleSpan
import android.text.style.UnderlineSpan
import androidx.core.text.toSpanned
import com.android.mediproject.core.common.R
import com.android.mediproject.core.model.medicine.medicinedetailinfo.MedicineDetailInfo
import com.android.mediproject.core.model.remote.granule.GranuleIdentificationInfoDto
import com.android.mediproject.core.model.medicine.medicinedetailinfo.MedicineDetatilInfoDto
import com.android.mediproject.core.model.util.XMLParsedResult
import java.lang.ref.WeakReference
import javax.inject.Inject
Expand Down Expand Up @@ -75,11 +75,11 @@ class MedicineInfoMapper @Inject constructor() {
/**
* 의약품 기본 정보 데이터를 UI에 맞게 변환
*/
fun toMedicineInfo(medicineDetatilInfoDto: MedicineDetatilInfoDto): Spanned {
fun toMedicineInfo(medicineDetailInfo: MedicineDetailInfo): Spanned {
val stringBuilder = WeakReference(StringBuilder())

return stringBuilder.get()?.let { builder ->
with(medicineDetatilInfoDto) {
with(medicineDetailInfo) {
builder.append("<p><b>의약품 이름:</b> $itemName</p>").append("<p><b>의약품 영문 이름:</b> $itemEnglishName</p>")
.append("<p><b>의약품 시퀀스 번호:</b> $itemSequence</p>").append("<p><b>의약품 허가 날짜:</b> $itemPermitDate</p>")
.append("<p><b>제조사 이름:</b> $entpName</p>").append("<p><b>제조사 영문 이름:</b> $entpEnglishName</p>")
Expand Down Expand Up @@ -188,13 +188,15 @@ class MedicineInfoMapper @Inject constructor() {

fun initHeaderSpan(context: Context, text: String): SpannableStringBuilder {
return SpannableStringBuilder(text).apply {
val underline1Idx = text.indexOf(context.getString(R.string.highlightWord1)) to text.indexOf(context.getString(R.string.highlightWord1)) + 2
val underline1Idx =
text.indexOf(context.getString(R.string.highlightWord1)) to text.indexOf(context.getString(R.string.highlightWord1)) + 2

setSpan(UnderlineSpan(), underline1Idx.first, underline1Idx.second, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
setSpan(StyleSpan(Typeface.BOLD), underline1Idx.first, underline1Idx.second, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
setSpan(RelativeSizeSpan(TEXT_SIZE_PERCENT), underline1Idx.first, underline1Idx.second, Spanned.SPAN_INCLUSIVE_INCLUSIVE)

val underline2Idx = text.indexOf(context.getString(R.string.highlightWord2)) to text.indexOf(context.getString(R.string.highlightWord2)) + 2
val underline2Idx =
text.indexOf(context.getString(R.string.highlightWord2)) to text.indexOf(context.getString(R.string.highlightWord2)) + 2

setSpan(UnderlineSpan(), underline2Idx.first, underline2Idx.second, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
setSpan(StyleSpan(Typeface.BOLD), underline2Idx.first, underline2Idx.second, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
Expand Down
Loading

0 comments on commit 45f695f

Please sign in to comment.