Skip to content

Commit

Permalink
Merge pull request #53 from Next-Room/NextRoom-Android-40
Browse files Browse the repository at this point in the history
#40 feat: 결제 관련 코드 주석
  • Loading branch information
juhwankim-dev authored Dec 7, 2023
2 parents 847b3a9 + 820c9ea commit ac041a3
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ object RepositoryModule {
)
}

@Singleton
@Provides
fun provideBillingDataSource(): BillingDataSource = BillingDataSource()
// @Singleton
// @Provides
// fun provideBillingDataSource(): BillingDataSource = BillingDataSource()

@Singleton
@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,24 @@ import com.nextroom.nextroom.presentation.common.NRDialog
import com.nextroom.nextroom.presentation.databinding.ActivityMainBinding
import com.nextroom.nextroom.presentation.extension.repeatOn
import com.nextroom.nextroom.presentation.extension.repeatOnStarted
import com.nextroom.nextroom.presentation.ui.billing.BillingViewModel
import com.nextroom.nextroom.presentation.util.BillingClientLifecycle
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding

private val viewModel: MainViewModel by viewModels()
private val billingViewModel: BillingViewModel by viewModels()
// private val billingViewModel: BillingViewModel by viewModels()

@Inject
lateinit var billingClientLifecycle: BillingClientLifecycle
// @Inject
// lateinit var billingClientLifecycle: BillingClientLifecycle

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)

lifecycle.addObserver(billingClientLifecycle)
// lifecycle.addObserver(billingClientLifecycle)

binding.fcvNavHost.apply {
systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
Expand All @@ -49,11 +46,11 @@ class MainActivity : AppCompatActivity() {
if (!loggedIn) viewModel.logout()
}
}
repeatOnStarted {
billingViewModel.buyEvent.collect {
billingClientLifecycle.launchBillingFlow(this@MainActivity, it)
}
}
// repeatOnStarted {
// billingViewModel.buyEvent.collect {
// billingClientLifecycle.launchBillingFlow(this@MainActivity, it)
// }
// }
}

private fun observe(event: MainEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@ import android.content.Context
import android.os.Bundle
import android.view.View
import androidx.activity.OnBackPressedCallback
import androidx.core.view.isVisible
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import com.nextroom.nextroom.domain.model.SubscribeStatus
import com.nextroom.nextroom.domain.repository.StatisticsRepository
import com.nextroom.nextroom.presentation.R
import com.nextroom.nextroom.presentation.base.BaseFragment
import com.nextroom.nextroom.presentation.common.NRImageDialog
import com.nextroom.nextroom.presentation.databinding.FragmentAdminMainBinding
import com.nextroom.nextroom.presentation.extension.addMargin
import com.nextroom.nextroom.presentation.extension.safeNavigate
import com.nextroom.nextroom.presentation.extension.statusBarHeight
import dagger.hilt.android.AndroidEntryPoint
import org.orbitmvi.orbit.viewmodel.observe
import javax.inject.Inject
Expand Down Expand Up @@ -72,41 +66,45 @@ class AdminMainFragment : BaseFragment<FragmentAdminMainBinding>(FragmentAdminMa
}

private fun initViews() = with(binding) {
ivMyButton.addMargin(top = requireContext().statusBarHeight)
// ivMyButton.addMargin(top = requireContext().statusBarHeight)
rvThemes.adapter = adapter
tvPurchaseTicketButton.setOnClickListener {
goToPurchase()
}
ivMyButton.setOnClickListener {
goToMyPage()
}
// tvPurchaseTicketButton.setOnClickListener {
// goToPurchase()
// }
// ivMyButton.setOnClickListener {
// goToMyPage()
// }
// tvLogoutButton.apply {
// addMargin(top = requireContext().statusBarHeight)
// setOnClickListener { logout() }
// }
}

private fun render(state: AdminMainState) = with(binding) {
if (state.loading) return@with

tvPurchaseTicketButton.isVisible = state.userSubscribeStatus.subscribeStatus != SubscribeStatus.Subscription
when (state.userSubscribeStatus.subscribeStatus) {
SubscribeStatus.Expiration -> logout()
SubscribeStatus.Hold, SubscribeStatus.SubscriptionExpiration -> goToPurchase(state.userSubscribeStatus.subscribeStatus)
SubscribeStatus.Free -> {
if (viewModel.isFirstLaunchOfDay) { // 하루 최초 한 번 다이얼로그 표시
state.calculateDday().let { dday ->
if (dday >= 0) showDialog(dday)
}
}
}

SubscribeStatus.None, SubscribeStatus.Subscription -> Unit
}
// tvPurchaseTicketButton.isVisible = state.userSubscribeStatus.subscribeStatus != SubscribeStatus.Subscription
// when (state.userSubscribeStatus.subscribeStatus) {
// SubscribeStatus.Expiration -> logout()
// SubscribeStatus.Hold, SubscribeStatus.SubscriptionExpiration -> goToPurchase(state.userSubscribeStatus.subscribeStatus)
// SubscribeStatus.Free -> {
// if (viewModel.isFirstLaunchOfDay) { // 하루 최초 한 번 다이얼로그 표시
// state.calculateDday().let { dday ->
// if (dday >= 0) showDialog(dday)
// }
// }
// }
//
// SubscribeStatus.None, SubscribeStatus.Subscription -> Unit
// }
tvShopName.text = state.showName
adapter.submitList(state.themes)
}

private fun goToPurchase(subscribeStatus: SubscribeStatus = state.userSubscribeStatus.subscribeStatus) {
/*private fun goToPurchase(subscribeStatus: SubscribeStatus = state.userSubscribeStatus.subscribeStatus) {
val action = AdminMainFragmentDirections.actionAdminMainFragmentToPurchaseFragment(subscribeStatus)
findNavController().safeNavigate(action)
}
}*/

private fun goToMyPage() {
val action = AdminMainFragmentDirections.actionAdminMainFragmentToMypageFragment()
Expand All @@ -118,7 +116,7 @@ class AdminMainFragment : BaseFragment<FragmentAdminMainBinding>(FragmentAdminMa
findNavController().safeNavigate(action)
}

private fun showDialog(dDay: Int) {
/*private fun showDialog(dDay: Int) {
NRImageDialog.Builder(requireContext())
.setTitle(getString(R.string.dialog_free_plan_title, dDay))
.setMessage(getString(R.string.dialog_free_plan_message))
Expand All @@ -130,7 +128,7 @@ class AdminMainFragment : BaseFragment<FragmentAdminMainBinding>(FragmentAdminMa
goToPurchase()
}
.show(childFragmentManager)
}
}*/

private fun logout() {
viewModel.logout()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
package com.nextroom.nextroom.presentation.ui.adminmain

import com.mangbaam.commonutil.DateTimeUtil
import com.nextroom.nextroom.domain.model.SubscribeStatus
import com.nextroom.nextroom.domain.model.UserSubscribeStatus
import com.nextroom.nextroom.presentation.extension.calculateDday
import com.nextroom.nextroom.presentation.model.ThemeInfoPresentation

data class AdminMainState(
val loading: Boolean = false,
val userSubscribeStatus: UserSubscribeStatus = UserSubscribeStatus(),
// val userSubscribeStatus: UserSubscribeStatus = UserSubscribeStatus(),
val showName: String = "",
val themes: List<ThemeInfoPresentation> = emptyList(),
) {
private val dateTimeUtil = DateTimeUtil()
/*private val dateTimeUtil = DateTimeUtil()
fun calculateDday(): Int {
return when (userSubscribeStatus.subscribeStatus) {
SubscribeStatus.Free -> dateTimeUtil.stringToDate(userSubscribeStatus.expiryDate, "yyyy.MM.dd")?.calculateDday() ?: -1
else -> -1
}
}
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.nextroom.nextroom.presentation.ui.adminmain

import androidx.lifecycle.viewModelScope
import com.nextroom.nextroom.domain.model.onSuccess
import com.nextroom.nextroom.domain.model.suspendOnSuccess
import com.nextroom.nextroom.domain.repository.AdminRepository
import com.nextroom.nextroom.domain.repository.DataStoreRepository
import com.nextroom.nextroom.domain.repository.HintRepository
Expand Down Expand Up @@ -67,7 +66,7 @@ class AdminMainViewModel @Inject constructor(

private fun loadData() = intent {
reduce { state.copy(loading = true) }
adminRepository.getUserSubscribeStatus().suspendOnSuccess {
/*adminRepository.getUserSubscribeStatus().suspendOnSuccess {
reduce { state.copy(userSubscribeStatus = it) }
themeRepository.getThemes().onSuccess {
updateThemes(
Expand All @@ -77,6 +76,14 @@ class AdminMainViewModel @Inject constructor(
},
)
}
}*/
themeRepository.getThemes().onSuccess {
updateThemes(
it.map { themeInfo ->
val updatedAt = themeRepository.getUpdatedInfo(themeInfo.id)
themeInfo.toPresentation(updatedAt)
},
)
}
reduce { state.copy(loading = false) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class OnboardingFragment : BaseFragment<FragmentOnboardingBinding>(FragmentOnboa
private fun initViews() {
binding.tvApplyFreeTrial.setOnClickListener {
val action =
OnboardingFragmentDirections.actionGlobalWebViewFragment("https://m.naver.com/") // TODO: 홈페이지 주소 확정시 변경
OnboardingFragmentDirections.actionGlobalWebViewFragment("https://nextroom-escape.vercel.app/")
findNavController().safeNavigate(action)
}
binding.tvExistingUserGuide.setOnClickListener {
Expand Down
73 changes: 45 additions & 28 deletions presentation/src/main/res/layout/fragment_admin_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,46 +30,63 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!-- 결제 관련 -->
<!-- <TextView-->
<!-- android:id="@+id/tv_purchase_ticket_button"-->
<!-- style="@style/Pretendard.14.SemiBold"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginEnd="16dp"-->
<!-- android:background="@drawable/bg_secondary_button"-->
<!-- android:paddingHorizontal="16dp"-->
<!-- android:paddingVertical="6dp"-->
<!-- android:text="@string/purchase_ticket"-->
<!-- android:textColor="@color/White"-->
<!-- android:visibility="gone"-->
<!-- app:layout_constraintBottom_toBottomOf="@id/iv_my_button"-->
<!-- app:layout_constraintEnd_toStartOf="@id/iv_my_button"-->
<!-- app:layout_constraintTop_toTopOf="@id/iv_my_button"-->
<!-- tools:visibility="visible" />-->

<TextView
android:id="@+id/tv_purchase_ticket_button"
style="@style/Pretendard.14.SemiBold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:background="@drawable/bg_secondary_button"
android:paddingHorizontal="16dp"
android:paddingVertical="6dp"
android:text="@string/purchase_ticket"
android:textColor="@color/White"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/iv_my_button"
app:layout_constraintEnd_toStartOf="@id/iv_my_button"
app:layout_constraintTop_toTopOf="@id/iv_my_button"
tools:visibility="visible" />
<!-- <TextView-->
<!-- android:id="@+id/tv_logout_button"-->
<!-- style="@style/Pretendard.14.SemiBold"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginEnd="16dp"-->
<!-- android:background="@drawable/bg_secondary_button"-->
<!-- android:paddingHorizontal="16dp"-->
<!-- android:paddingVertical="6dp"-->
<!-- android:text="@string/logout_button"-->
<!-- android:textColor="@color/White"-->
<!-- app:layout_constraintBottom_toBottomOf="@id/iv_my_button"-->
<!-- app:layout_constraintEnd_toStartOf="@id/iv_my_button"-->
<!-- app:layout_constraintTop_toTopOf="@id/iv_my_button"-->
<!-- tools:visibility="visible" />-->

<ImageView
android:id="@+id/iv_my_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="20dp"
android:contentDescription="@string/mypage_button_description"
android:src="@drawable/ic_my"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!-- <ImageView-->
<!-- android:id="@+id/iv_my_button"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="12dp"-->
<!-- android:layout_marginEnd="20dp"-->
<!-- android:contentDescription="@string/mypage_button_description"-->
<!-- android:src="@drawable/ic_my"-->
<!-- android:visibility="gone"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent" />-->

<TextView
android:id="@+id/tv_shop_name_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="46dp"
android:layout_marginTop="142dp"
android:includeFontPadding="false"
android:text="@string/admin_main_shop_name_label"
android:textAppearance="@style/Pretendard.32"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_purchase_ticket_button" />
app:layout_constraintTop_toTopOf="parent"/>

<TextView
android:id="@+id/tv_shop_name"
Expand Down
3 changes: 2 additions & 1 deletion presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
<string name="game_backspace_description">지우기</string>

<string name="onboarding_title">힌트폰 서비스 넥스트룸</string>
<string name="onboarding_apply_free_trial">첫 달 무료 체험 신청하기</string>
<!-- <string name="onboarding_apply_free_trial">첫 달 무료 체험 신청하기</string>-->
<string name="onboarding_apply_free_trial">계정 신청하기</string>
<string name="onboarding_existing_user_guide">이미 기존 회원이라면? <font color='#FFFFFF'><b>로그인</b></font></string>

<string name="purchase_ticket">이용권 구매</string>
Expand Down

0 comments on commit ac041a3

Please sign in to comment.