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