|
@@ -5,12 +5,14 @@ import android.os.Bundle
|
|
|
import android.view.LayoutInflater
|
|
|
import android.view.ViewGroup
|
|
|
import androidx.lifecycle.MutableLiveData
|
|
|
+import com.develop.auth.R
|
|
|
import com.develop.auth.databinding.FragmentMemberProfileBinding
|
|
|
import com.develop.auth.viewmodel.MemberViewModel
|
|
|
import com.develop.base.ext.navigateTo
|
|
|
import com.develop.base.ext.resId2Dimension
|
|
|
import com.develop.base.ext.setVisible
|
|
|
import com.develop.base.mvvm.BaseBVMFragment
|
|
|
+import com.develop.base.util.MMkvUtils
|
|
|
import com.develop.base.util.ThreadUtils
|
|
|
import com.develop.common.data_repo.FoodDataProvider
|
|
|
import com.develop.common.data_repo.db.entity.UserInfo
|
|
@@ -18,6 +20,8 @@ import com.develop.common.data_repo.net.model.response.User
|
|
|
import com.develop.common.dialog.AgeSelectDialog
|
|
|
import com.develop.common.dialog.GenderSelectDialog
|
|
|
import com.develop.common.router.Screens
|
|
|
+import com.develop.common.tag.API_TOKEN
|
|
|
+import com.develop.common.tag.LOGIN_TAG
|
|
|
import com.develop.common.ui.CommonBVMFragment
|
|
|
|
|
|
class MemberProfileFragment : CommonBVMFragment<FragmentMemberProfileBinding, MemberViewModel>() {
|
|
@@ -42,7 +46,9 @@ class MemberProfileFragment : CommonBVMFragment<FragmentMemberProfileBinding, Me
|
|
|
binding.tvChooseAge.setTextColor(Color.BLACK)
|
|
|
}.show()
|
|
|
}
|
|
|
-
|
|
|
+ binding.ivMember.setOnClickListener {
|
|
|
+ UserIconSelectDialog(viewModel).show(childFragmentManager, "UserIcon")
|
|
|
+ }
|
|
|
binding.tvChooseSex.setOnClickListener {
|
|
|
GenderSelectDialog {
|
|
|
selectGender = if (it) 2 else 1
|
|
@@ -63,32 +69,16 @@ class MemberProfileFragment : CommonBVMFragment<FragmentMemberProfileBinding, Me
|
|
|
)
|
|
|
}
|
|
|
binding.tvSkipForNow.setOnClickListener {
|
|
|
+ if (viewModel.enterFromHome) {
|
|
|
+ val saveToken: String? = null
|
|
|
+ MMkvUtils.save(API_TOKEN, saveToken)
|
|
|
+ MMkvUtils.save(LOGIN_TAG, false)
|
|
|
+ }
|
|
|
navigateTo(Screens.Main.ENTRANCE_CHOSEN)
|
|
|
}
|
|
|
-// binding.tvDestroyAccount.setOnClickListener {
|
|
|
-//
|
|
|
-// }
|
|
|
-
|
|
|
if (viewModel.enterFromHome) {
|
|
|
- (binding.tvTitle.layoutParams as ViewGroup.MarginLayoutParams).let {
|
|
|
- it.topMargin = dp53
|
|
|
- binding.tvTitle.requestLayout()
|
|
|
- }
|
|
|
- (binding.tvSave.layoutParams as ViewGroup.MarginLayoutParams).let {
|
|
|
- it.topMargin = dp101
|
|
|
- binding.tvSave.requestLayout()
|
|
|
- }
|
|
|
- (binding.tvSkipForNow.layoutParams as ViewGroup.MarginLayoutParams).let {
|
|
|
- it.topMargin = dp16
|
|
|
- binding.tvSkipForNow.requestLayout()
|
|
|
- }
|
|
|
binding.tvSkipForNow.text = "Sign out"
|
|
|
-// binding.tvDestroyAccount.setVisible()
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
- super.onCreate(savedInstanceState)
|
|
|
viewModel.apply {
|
|
|
userInfoLiveData.observe(viewLifecycleOwner) {
|
|
|
it?.apply {
|
|
@@ -104,6 +94,18 @@ class MemberProfileFragment : CommonBVMFragment<FragmentMemberProfileBinding, Me
|
|
|
showToast(this)
|
|
|
}
|
|
|
}
|
|
|
+ viewModel.chooseAvatar.observe(viewLifecycleOwner) {
|
|
|
+ val icons = listOf(
|
|
|
+ com.develop.common.R.drawable.ic_icon1,
|
|
|
+ com.develop.common.R.drawable.ic_icon2,
|
|
|
+ com.develop.common.R.drawable.ic_icon3,
|
|
|
+ com.develop.common.R.drawable.ic_icon4,
|
|
|
+ com.develop.common.R.drawable.ic_icon5,
|
|
|
+ com.develop.common.R.drawable.ic_icon6
|
|
|
+ )
|
|
|
+ val chooseIcon = icons.getOrNull(it ?: 0) ?: com.develop.common.R.drawable.ic_icon1
|
|
|
+ binding.ivMember.setImageResource(chooseIcon)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|