mirror of
https://github.com/shaulascr/ecommerce_serang.git
synced 2025-12-15 15:41:02 +00:00
fix UI
This commit is contained in:
@ -33,6 +33,7 @@ import com.alya.ecommerce_serang.utils.SessionManager
|
||||
import com.alya.ecommerce_serang.utils.setLightStatusBar
|
||||
import com.alya.ecommerce_serang.utils.viewmodel.HomeUiState
|
||||
import com.alya.ecommerce_serang.utils.viewmodel.HomeViewModel
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
//@AndroidEntryPoint
|
||||
@ -141,12 +142,13 @@ class HomeFragment : Fragment() {
|
||||
viewModel.uiState.collect { state ->
|
||||
when (state) {
|
||||
is HomeUiState.Loading -> {
|
||||
binding.loadingAll.visibility = View.VISIBLE
|
||||
binding.loadingAll.root.visibility = View.VISIBLE
|
||||
binding.error.root.isVisible = false
|
||||
binding.home.isVisible = false
|
||||
delay(3000)
|
||||
}
|
||||
is HomeUiState.Success -> {
|
||||
binding.loadingAll.visibility = View.GONE
|
||||
binding.loadingAll.root.visibility = View.GONE
|
||||
binding.error.root.isVisible = false
|
||||
binding.home.isVisible = true
|
||||
val products = state.products
|
||||
@ -155,7 +157,7 @@ class HomeFragment : Fragment() {
|
||||
productAdapter?.updateLimitedProducts(products)
|
||||
}
|
||||
is HomeUiState.Error -> {
|
||||
binding.loadingAll.visibility = View.GONE
|
||||
binding.loadingAll.root.visibility = View.GONE
|
||||
binding.error.root.isVisible = true
|
||||
binding.home.isVisible = false
|
||||
// binding.error.errorMessage.text = state.message
|
||||
|
||||
@ -270,16 +270,6 @@ class CheckoutActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun setupProductRecyclerView(checkoutData: CheckoutData) {
|
||||
if (checkoutData.cartItems.isEmpty()) {
|
||||
// Show empty products state
|
||||
binding.containerEmptyProducts.visibility = View.VISIBLE
|
||||
binding.rvProductItems.visibility = View.GONE
|
||||
return
|
||||
}
|
||||
|
||||
binding.containerEmptyProducts.visibility = View.GONE
|
||||
binding.rvProductItems.visibility = View.VISIBLE
|
||||
|
||||
val adapter = if (checkoutData.isBuyNow || checkoutData.cartItems.size <= 1) {
|
||||
CheckoutSellerAdapter(checkoutData)
|
||||
} else {
|
||||
@ -291,6 +281,16 @@ class CheckoutActivity : AppCompatActivity() {
|
||||
this.adapter = adapter
|
||||
isNestedScrollingEnabled = false
|
||||
}
|
||||
|
||||
if (checkoutData.cartItems.isEmpty()) {
|
||||
// Show empty products state
|
||||
binding.containerEmptyProducts.visibility = View.VISIBLE
|
||||
binding.rvProductItems.visibility = View.GONE
|
||||
return
|
||||
}
|
||||
|
||||
binding.containerEmptyProducts.visibility = View.GONE
|
||||
binding.rvProductItems.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
private fun updateOrderSummary() {
|
||||
|
||||
@ -52,12 +52,12 @@ class AddressActivity : AppCompatActivity() {
|
||||
windowInsets
|
||||
}
|
||||
|
||||
viewModel.fetchAddresses()
|
||||
|
||||
setupToolbar()
|
||||
setupRecyclerView()
|
||||
setupObservers()
|
||||
|
||||
viewModel.fetchAddresses()
|
||||
}
|
||||
|
||||
|
||||
@ -126,6 +126,11 @@ class AddressActivity : AppCompatActivity() {
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.fetchAddresses()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val EXTRA_ADDRESS_ID = "extra_address_id"
|
||||
}
|
||||
|
||||
@ -64,10 +64,9 @@ class StoreDetailActivity : AppCompatActivity() {
|
||||
)
|
||||
windowInsets
|
||||
}
|
||||
|
||||
loadData()
|
||||
setupUI()
|
||||
setupObservers()
|
||||
loadData()
|
||||
}
|
||||
|
||||
private fun setupUI() {
|
||||
|
||||
@ -95,12 +95,14 @@ class ProfileFragment : Fragment() {
|
||||
binding.cardLogout.visibility = View.GONE
|
||||
}
|
||||
|
||||
|
||||
viewModel.loadUserProfile()
|
||||
viewModel.checkStoreUser()
|
||||
|
||||
observeUserProfile()
|
||||
|
||||
observeStoreStatus()
|
||||
|
||||
viewModel.loadUserProfile()
|
||||
viewModel.checkStoreUser()
|
||||
|
||||
binding.cardBukaToko.setOnClickListener{
|
||||
// if (hasStore == true) startActivity(Intent(requireContext(), MyStoreActivity::class.java))
|
||||
|
||||
@ -500,7 +500,7 @@
|
||||
android:id="@+id/empty_other_products"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Belum ada ulasan"
|
||||
android:text="Belum ada produk lainnya"
|
||||
android:textSize="16sp"
|
||||
android:textColor="@color/black_200"
|
||||
android:gravity="center"
|
||||
|
||||
@ -167,15 +167,14 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/searchContainer" />
|
||||
|
||||
<ProgressBar
|
||||
<include
|
||||
android:id="@+id/loadingAll"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="8dp"
|
||||
layout="@layout/view_loading"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<include
|
||||
android:id="@+id/error"
|
||||
|
||||
@ -23,40 +23,53 @@
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity=""
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/courier_name_cost"
|
||||
android:fontFamily="@font/dmsans_semibold"
|
||||
android:textSize="14sp"
|
||||
android:paddingHorizontal="2dp"
|
||||
android:paddingTop="4dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="JNE"/>
|
||||
<TextView
|
||||
android:id="@+id/est_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="12sp"
|
||||
android:paddingHorizontal="4dp"
|
||||
android:text="Estimasi 3-4 hari"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/cost_price"
|
||||
android:textSize="14sp"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_margin="16dp"
|
||||
android:fontFamily="@font/dmsans_semibold"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Rp15.0000"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:weightSum="1">
|
||||
|
||||
<!-- Left Section -->
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.7"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/courier_name_cost"
|
||||
android:fontFamily="@font/dmsans_semibold"
|
||||
android:textSize="14sp"
|
||||
android:paddingHorizontal="2dp"
|
||||
android:paddingTop="4dp"
|
||||
android:ellipsize="end"
|
||||
android:scrollHorizontally="false"
|
||||
android:singleLine="false"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="2"
|
||||
android:text="JNE Express"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/est_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="12sp"
|
||||
android:paddingHorizontal="4dp"
|
||||
android:text="Estimasi 3-4 hari"/>
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Right Section -->
|
||||
<TextView
|
||||
android:id="@+id/cost_price"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3"
|
||||
android:textSize="14sp"
|
||||
android:gravity="start"
|
||||
android:fontFamily="@font/dmsans_semibold"
|
||||
android:text="Rp15.000"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@ -11,6 +11,8 @@
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user