Skip to content

Commit

Permalink
Merge pull request #86 from team-JMT/fix/mypage_design
Browse files Browse the repository at this point in the history
마이페이지 디자인 이슈 처리
  • Loading branch information
dogdduddy authored Sep 28, 2023
2 parents 75dafb3 + 2fb7097 commit c905020
Show file tree
Hide file tree
Showing 23 changed files with 282 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ class RestaurantDataSourceImpl @Inject constructor(
) {
with(db.restaurantDao()) {
when (sortType) {
SortType.INIT -> getRegisteredRestaurants(userId, categoryFilter, isCanDrinkLiquor)
SortType.DISTANCE -> getRegisteredRestaurantsSortedDistance(userId, categoryFilter, isCanDrinkLiquor)
SortType.RECENCY -> getRegisteredRestaurantsSortedRecent(userId, categoryFilter, isCanDrinkLiquor)
SortType.LIKED -> getRegisteredRestaurants(userId, categoryFilter, isCanDrinkLiquor)
Expand Down
2 changes: 1 addition & 1 deletion domain/src/main/java/org/gdsc/domain/FoodCategory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ enum class FoodCategory(val id: Long, val text: String, val key:String) {
CAFE(6L, "카페", "CAFE"),
BAR(7L, "주점", "BAR"),
ETC(8L, "기타", "ETC"),
INIT(-1L, "(필수) 어떤 종류의 식당인가요?", "");
INIT(-1L, "종류", "");

companion object {
fun getAllText(): List<String> {
Expand Down
3 changes: 1 addition & 2 deletions domain/src/main/java/org/gdsc/domain/SortType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package org.gdsc.domain
enum class SortType(val text: String) {
DISTANCE("가까운 순"),
LIKED("좋아요 순"),
RECENCY("최신 순"),
INIT("정렬");
RECENCY("최신 순");


companion object {
Expand Down
2 changes: 1 addition & 1 deletion presentation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ dependencies {

implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class MainActivity : BaseActivity() {
binding.navHostFragment.setPadding(0, 0, 0, 0)
}
}

// toolbar visibility Control
when(destination.id) {
R.id.home_fragment -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package org.gdsc.presentation.view.custom

import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.text.Editable
import android.text.InputType.TYPE_CLASS_TEXT
import android.text.TextWatcher
import android.util.AttributeSet
import android.util.Log
import android.view.MotionEvent
import android.widget.EditText
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import com.google.android.material.textfield.TextInputEditText
import org.gdsc.presentation.R

class ClassicEditText(context: Context, attrs: AttributeSet) : TextInputEditText(context, attrs) {
private val underlinePaint = Paint()
private var clearIcon: Drawable? = null
private var showClearIcon = false

init {
inputType = TYPE_CLASS_TEXT
setLines(1)

underlinePaint.color = ContextCompat.getColor(context, R.color.grey400)
underlinePaint.strokeWidth = 4f

minHeight = height

// EditText 기본 배경 지우기
background = null
setPadding(0, paddingTop, paddingRight, paddingBottom)

// Clear 아이콘 초기화
val drawable = ContextCompat.getDrawable(context, R.drawable.ic_cancel)
clearIcon = DrawableCompat.wrap(drawable!!)
clearIcon!!.setBounds(0, 0, clearIcon!!.intrinsicWidth, clearIcon!!.intrinsicHeight)
val padding = resources.getDimensionPixelSize(R.dimen.drawable_icon_spacing)
setCompoundDrawablePadding(padding)

// Clear 아이콘 보이기/숨기기 설정
addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}

override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
setClearIconVisible(s?.isNotEmpty() == true)
}

override fun afterTextChanged(s: Editable?) {}
})
}

private fun setClearIconVisible(visible: Boolean) {
showClearIcon = visible
setCompoundDrawablesWithIntrinsicBounds(
null,
null,
if (visible) clearIcon else null,
null
)
}

override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)

val startY = height
val scrollX = scrollX

canvas.drawLine(
scrollX.toFloat(),
startY.toFloat() - paddingBottom,
(scrollX + width).toFloat(),
startY.toFloat() - paddingBottom,
underlinePaint
)
}

override fun onFocusChanged(focused: Boolean, direction: Int, previouslyFocusedRect: Rect?) {
super.onFocusChanged(focused, direction, previouslyFocusedRect)

// 포커스가 없을 때 Clear 아이콘 숨기기
if (!focused) {
setClearIconVisible(false)
}
}

override fun onTouchEvent(event: MotionEvent): Boolean {
// Clear 아이콘 클릭 이벤트
if (event.action == MotionEvent.ACTION_DOWN) {
if (showClearIcon && event.x >= width - paddingRight - clearIcon!!.intrinsicWidth) {
setText("")
return true
}
}
return super.onTouchEvent(event)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class JmtAlert(private val context: Context) {
TextView(context).apply {
gravity = Gravity.CENTER
text = content
setLineSpacing(0f, 1.2f)
}.let {
binding.dialogContentLay.removeAllViewsInLayout()
binding.dialogContentLay.isVisible = true
Expand Down Expand Up @@ -125,6 +126,7 @@ class JmtAlert(private val context: Context) {
) {
leftButton = AppCompatButton(context).apply {
this.text = text
this.stateListAnimator = null
this.layoutParams =
LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f).apply {
height = 48.toDp
Expand Down Expand Up @@ -167,34 +169,20 @@ class JmtAlert(private val context: Context) {
) {
rightButton = AppCompatButton(context).apply {
this.text = text
this.layoutParams =
LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f).apply {
leftMargin = 12.toDp
height = 48.toDp
}
this.background = when (_fillType) {
FILL_FILL -> ContextCompat.getDrawable(
context,
R.drawable.jmt_button_background_main
)

FILL_OUTLINE -> ContextCompat.getDrawable(
context,
R.drawable.jmt_button_outline_background_main
)

else -> ContextCompat.getDrawable(
context,
R.drawable.jmt_button_background_main
)
this.layoutParams = LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f).apply {
leftMargin = 12.toDp
height = 48.toDp
}
this.setTextColor(
when (_fillType) {
FILL_FILL -> ContextCompat.getColor(context, R.color.white)
FILL_OUTLINE -> ContextCompat.getColor(context, R.color.main500)
else -> ContextCompat.getColor(context, R.color.white)
}
)
this.background = when(_fillType) {
FILL_FILL -> ContextCompat.getDrawable(context, R.drawable.jmt_button_background_main)
FILL_OUTLINE -> ContextCompat.getDrawable(context, R.drawable.jmt_button_outline_background_main)
else -> ContextCompat.getDrawable(context, R.drawable.jmt_button_background_main)
}
this.setTextColor(when(_fillType) {
FILL_FILL -> ContextCompat.getColor(context, R.color.white)
FILL_OUTLINE -> ContextCompat.getColor(context, R.color.main500)
else -> ContextCompat.getColor(context, R.color.white)
})
this.setOnClickListener {
onClick(it)
if (autoDismiss) dismiss()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -38,6 +39,7 @@ class LikedRestaurantFragment : Fragment() {
observeState()
setSpinners()

binding.notYetLayout.root.isVisible = true
}

private fun setSpinners() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ class RegisteredRestaurantFragment : Fragment() {

myRestaurantAdapter.addLoadStateListener { combinedLoadStates ->
if (combinedLoadStates.append.endOfPaginationReached) {
binding.notYetLayout.root.isVisible = myRestaurantAdapter.itemCount == 0
binding.emptyLayout.isVisible = myRestaurantAdapter.itemCount == 0
} else {
binding.notYetLayout.root.isVisible = false
binding.emptyLayout.isVisible = false
}

if(combinedLoadStates.refresh is LoadState.Error) {
binding.notYetLayout.root.isVisible = true
binding.emptyLayout.isVisible = true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import com.bumptech.glide.Glide
import com.google.android.material.snackbar.Snackbar
import com.naver.maps.map.BuildConfig
import dagger.hilt.android.AndroidEntryPoint
import okhttp3.MediaType
import okhttp3.MultipartBody
Expand Down Expand Up @@ -64,6 +65,7 @@ class SettingsFragment: BaseFragment() {
initUserInfo()
setToolbarTitle()
observeState()
initVersion()

binding.profileImageButton.setOnClickListener {
BottomSheetDialog(requireContext())
Expand Down Expand Up @@ -101,6 +103,11 @@ class SettingsFragment: BaseFragment() {
}
}

// 업데이트는 플레이스토어에 출시 이후에 추가해주기
private fun initVersion() {
binding.tvVersionInfo.text = BuildConfig.VERSION_NAME + " v"
}

private fun initUserInfo() {
repeatWhenUiStarted {
viewModel.getUserInfo()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import javax.inject.Inject
class LikedRestaurantViewModel
@Inject constructor() : ViewModel() {

private var _sortTypeState = MutableStateFlow(SortType.INIT)
private var _sortTypeState = MutableStateFlow(SortType.DISTANCE)
val sortTypeState: StateFlow<SortType>
get() = _sortTypeState

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class MyPageViewModel @Inject constructor(



private var _sortTypeState = MutableStateFlow(SortType.INIT)
private var _sortTypeState = MutableStateFlow(SortType.DISTANCE)
val sortTypeState: StateFlow<SortType>
get() = _sortTypeState

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<item>
<shape android:shape="rectangle">
<stroke android:color="@color/main500"
android:width="1.5dp"/>
android:width="1dp"/>
<corners android:radius="8dp" />
</shape>
</item>
Expand Down
15 changes: 15 additions & 0 deletions presentation/src/main/res/drawable/tab_underline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/grey100" />
</shape>
</item>
<item>
<inset android:insetBottom="1.5dp">
<shape android:shape="rectangle">
<solid android:color="@color/white" />
</shape>
</inset>
</item>
</layer-list>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<View
android:id="@+id/logOutDivider"
android:layout_width="match_parent"
android:layout_height="@dimen/divider_small"
android:layout_height="@dimen/divider_medium"
android:background="@color/grey100"
app:layout_constraintTop_toBottomOf="@+id/tv_log_out"/>

Expand Down Expand Up @@ -52,7 +52,6 @@
android:layout_marginTop="2dp"
android:text="계정을 영구적으로 삭제합니다."
android:textColor="@color/grey300"
android:visibility="gone"
app:layout_constraintStart_toStartOf="@+id/tv_sign_out"
app:layout_constraintTop_toBottomOf="@+id/tv_sign_out"
tools:visibility="visible"/>
Expand All @@ -62,7 +61,7 @@
<View
android:id="@+id/accountManagementDivider"
android:layout_width="match_parent"
android:layout_height="@dimen/divider_small"
android:layout_height="@dimen/divider_medium"
android:background="@color/grey100"
app:layout_constraintTop_toBottomOf="@+id/sign_out_lay"/>

Expand Down
15 changes: 7 additions & 8 deletions presentation/src/main/res/layout/fragment_edit_user_name.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"/>

<EditText
<org.gdsc.presentation.view.custom.ClassicEditText
android:id="@+id/username_edit_text"
style="@style/text_large_medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
style="@style/text_large_medium"
android:layout_marginHorizontal="@dimen/default_spacing"
android:maxLength="10"
android:backgroundTint="@color/grey400"
android:drawableRight="@drawable/ic_cancel"
app:layout_constraintTop_toBottomOf="@+id/ask_nickname_text"/>

<LinearLayout
Expand All @@ -41,10 +39,11 @@

<ImageView
android:id="@+id/verify_icon"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:src="@drawable/check_icon"
android:contentDescription="@string/content_description_nickname_verify" />

<Space
android:layout_width="4dp"
android:layout_height="wrap_content"/>
Expand All @@ -67,7 +66,7 @@
app:layout_constraintBottom_toBottomOf="parent">
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/next_btn"
android:text="@string/next"
android:text="@string/change"
android:layout_width="0dp"
android:layout_height="62dp"
style="@style/JmtButtonMain"
Expand Down
Loading

0 comments on commit c905020

Please sign in to comment.