mirror of
https://github.com/shaulascr/ecommerce_serang.git
synced 2025-08-10 09:22:21 +00:00
@ -29,6 +29,9 @@
|
|||||||
android:theme="@style/Theme.Ecommerce_serang"
|
android:theme="@style/Theme.Ecommerce_serang"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
tools:targetApi="31">
|
tools:targetApi="31">
|
||||||
|
<activity
|
||||||
|
android:name=".ui.profile.mystore.review.ReviewActivity"
|
||||||
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.product.listproduct.ListCategoryActivity"
|
android:name=".ui.product.listproduct.ListCategoryActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.alya.ecommerce_serang.data.api.dto
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class ReviewsItem(
|
||||||
|
|
||||||
|
@field:SerializedName("order_item_id")
|
||||||
|
val orderItemId: Int? = null,
|
||||||
|
|
||||||
|
@field:SerializedName("review_date")
|
||||||
|
val reviewDate: String? = null,
|
||||||
|
|
||||||
|
@field:SerializedName("user_image")
|
||||||
|
val userImage: String? = null,
|
||||||
|
|
||||||
|
@field:SerializedName("product_id")
|
||||||
|
val productId: Int? = null,
|
||||||
|
|
||||||
|
@field:SerializedName("rating")
|
||||||
|
val rating: Int? = null,
|
||||||
|
|
||||||
|
@field:SerializedName("review_text")
|
||||||
|
val reviewText: String? = null,
|
||||||
|
|
||||||
|
@field:SerializedName("product_name")
|
||||||
|
val productName: String? = null,
|
||||||
|
|
||||||
|
@field:SerializedName("username")
|
||||||
|
val username: String? = null
|
||||||
|
)
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.alya.ecommerce_serang.data.api.response.store.review
|
||||||
|
|
||||||
|
import com.alya.ecommerce_serang.data.api.dto.ReviewsItem
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class ProductReviewResponse(
|
||||||
|
|
||||||
|
@field:SerializedName("reviews")
|
||||||
|
val reviews: List<ReviewsItem?>? = null,
|
||||||
|
|
||||||
|
@field:SerializedName("message")
|
||||||
|
val message: String? = null
|
||||||
|
)
|
@ -75,6 +75,7 @@ import com.alya.ecommerce_serang.data.api.response.store.product.UpdateProductRe
|
|||||||
import com.alya.ecommerce_serang.data.api.response.store.product.ViewStoreProductsResponse
|
import com.alya.ecommerce_serang.data.api.response.store.product.ViewStoreProductsResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.store.GenericResponse
|
import com.alya.ecommerce_serang.data.api.response.store.GenericResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.store.profile.StoreDataResponse
|
import com.alya.ecommerce_serang.data.api.response.store.profile.StoreDataResponse
|
||||||
|
import com.alya.ecommerce_serang.data.api.response.store.review.ProductReviewResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.store.topup.BalanceTopUpResponse
|
import com.alya.ecommerce_serang.data.api.response.store.topup.BalanceTopUpResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.store.topup.TopUpResponse
|
import com.alya.ecommerce_serang.data.api.response.store.topup.TopUpResponse
|
||||||
import okhttp3.MultipartBody
|
import okhttp3.MultipartBody
|
||||||
@ -507,4 +508,8 @@ interface ApiService {
|
|||||||
@GET("mystore/notification")
|
@GET("mystore/notification")
|
||||||
suspend fun getNotifStore(
|
suspend fun getNotifStore(
|
||||||
): Response<ListStoreNotifResponse>
|
): Response<ListStoreNotifResponse>
|
||||||
|
|
||||||
|
@GET("store/reviews")
|
||||||
|
suspend fun getStoreProductReview(
|
||||||
|
): Response<ProductReviewResponse>
|
||||||
}
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.alya.ecommerce_serang.data.repository
|
||||||
|
|
||||||
|
import com.alya.ecommerce_serang.data.api.dto.ProductsItem
|
||||||
|
import com.alya.ecommerce_serang.data.api.response.customer.product.ProductResponse
|
||||||
|
import com.alya.ecommerce_serang.data.api.response.store.review.ProductReviewResponse
|
||||||
|
import com.alya.ecommerce_serang.data.api.retrofit.ApiService
|
||||||
|
|
||||||
|
class ReviewRepository(private val apiService: ApiService) {
|
||||||
|
suspend fun getReviewList(score: String): Result<ProductReviewResponse> {
|
||||||
|
return try {
|
||||||
|
val response = apiService.getStoreProductReview()
|
||||||
|
|
||||||
|
if (response.isSuccessful) {
|
||||||
|
val allReviews = response.body()
|
||||||
|
val filteredReviews = if (score == "all") {
|
||||||
|
allReviews
|
||||||
|
} else {
|
||||||
|
val targetScore = score.toIntOrNull()
|
||||||
|
allReviews?.copy(reviews = allReviews.reviews?.filter {
|
||||||
|
val rating = it?.rating ?: 0
|
||||||
|
when(targetScore) {
|
||||||
|
5 -> rating > 4
|
||||||
|
4 -> rating > 3 && rating <= 4
|
||||||
|
3 -> rating > 2 && rating <= 3
|
||||||
|
2 -> rating > 1 && rating <= 2
|
||||||
|
1 -> rating <= 1
|
||||||
|
else -> true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Result.Success(filteredReviews!!)
|
||||||
|
} else {
|
||||||
|
Result.Error(Exception("HTTP ${response.code()}: ${response.message()}"))
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Result.Error(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun getProductDetail(productId: Int): ProductResponse? {
|
||||||
|
return try {
|
||||||
|
val response = apiService.getDetailProduct(productId)
|
||||||
|
if (response.isSuccessful) {
|
||||||
|
response.body()
|
||||||
|
} else null
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,7 @@ import com.alya.ecommerce_serang.ui.profile.mystore.balance.BalanceActivity
|
|||||||
import com.alya.ecommerce_serang.ui.profile.mystore.chat.ChatListStoreActivity
|
import com.alya.ecommerce_serang.ui.profile.mystore.chat.ChatListStoreActivity
|
||||||
import com.alya.ecommerce_serang.ui.profile.mystore.product.ProductActivity
|
import com.alya.ecommerce_serang.ui.profile.mystore.product.ProductActivity
|
||||||
import com.alya.ecommerce_serang.ui.profile.mystore.profile.DetailStoreProfileActivity
|
import com.alya.ecommerce_serang.ui.profile.mystore.profile.DetailStoreProfileActivity
|
||||||
|
import com.alya.ecommerce_serang.ui.profile.mystore.review.ReviewActivity
|
||||||
import com.alya.ecommerce_serang.ui.profile.mystore.review.ReviewFragment
|
import com.alya.ecommerce_serang.ui.profile.mystore.review.ReviewFragment
|
||||||
import com.alya.ecommerce_serang.ui.profile.mystore.sells.SellsActivity
|
import com.alya.ecommerce_serang.ui.profile.mystore.sells.SellsActivity
|
||||||
import com.alya.ecommerce_serang.utils.BaseViewModelFactory
|
import com.alya.ecommerce_serang.utils.BaseViewModelFactory
|
||||||
@ -99,25 +100,21 @@ class MyStoreActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
binding.tvHistory.setOnClickListener {
|
binding.tvHistory.setOnClickListener {
|
||||||
val intent = Intent(this, SellsActivity::class.java)
|
startActivity(Intent(this, SellsActivity::class.java))
|
||||||
startActivity(intent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.layoutPerluTagihan.setOnClickListener {
|
binding.layoutPerluTagihan.setOnClickListener {
|
||||||
val intent = Intent(this, SellsActivity::class.java)
|
startActivity(Intent(this, SellsActivity::class.java))
|
||||||
startActivity(intent)
|
|
||||||
//navigateToSellsFragment("pending")
|
//navigateToSellsFragment("pending")
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.layoutPembayaran.setOnClickListener {
|
binding.layoutPembayaran.setOnClickListener {
|
||||||
val intent = Intent(this, SellsActivity::class.java)
|
startActivity(Intent(this, SellsActivity::class.java))
|
||||||
startActivity(intent)
|
|
||||||
//navigateToSellsFragment("paid")
|
//navigateToSellsFragment("paid")
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.layoutPerluDikirim.setOnClickListener {
|
binding.layoutPerluDikirim.setOnClickListener {
|
||||||
val intent = Intent(this, SellsActivity::class.java)
|
startActivity(Intent(this, SellsActivity::class.java))
|
||||||
startActivity(intent)
|
|
||||||
//navigateToSellsFragment("processed")
|
//navigateToSellsFragment("processed")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,15 +123,11 @@ class MyStoreActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
binding.layoutReview.setOnClickListener {
|
binding.layoutReview.setOnClickListener {
|
||||||
supportFragmentManager.beginTransaction()
|
startActivity(Intent(this, ReviewActivity::class.java))
|
||||||
.replace(android.R.id.content, ReviewFragment())
|
|
||||||
.addToBackStack(null)
|
|
||||||
.commit()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.layoutInbox.setOnClickListener {
|
binding.layoutInbox.setOnClickListener {
|
||||||
val intent = Intent(this, ChatListStoreActivity::class.java)
|
startActivity(Intent(this, ChatListStoreActivity::class.java))
|
||||||
startActivity(intent)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,74 @@
|
|||||||
|
package com.alya.ecommerce_serang.ui.profile.mystore.review
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.activity.viewModels
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import androidx.fragment.app.commit
|
||||||
|
import com.alya.ecommerce_serang.R
|
||||||
|
import com.alya.ecommerce_serang.data.api.retrofit.ApiConfig
|
||||||
|
import com.alya.ecommerce_serang.data.repository.ReviewRepository
|
||||||
|
import com.alya.ecommerce_serang.databinding.ActivityReviewBinding
|
||||||
|
import com.alya.ecommerce_serang.utils.BaseViewModelFactory
|
||||||
|
import com.alya.ecommerce_serang.utils.SessionManager
|
||||||
|
import com.alya.ecommerce_serang.utils.viewmodel.ReviewViewModel
|
||||||
|
|
||||||
|
class ReviewActivity : AppCompatActivity() {
|
||||||
|
private lateinit var binding: ActivityReviewBinding
|
||||||
|
private lateinit var sessionManager: SessionManager
|
||||||
|
|
||||||
|
private val viewModel: ReviewViewModel by viewModels {
|
||||||
|
BaseViewModelFactory {
|
||||||
|
val apiService = ApiConfig.getApiService(sessionManager)
|
||||||
|
val reviewRepository = ReviewRepository(apiService)
|
||||||
|
ReviewViewModel(reviewRepository)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
binding = ActivityReviewBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
|
||||||
|
sessionManager = SessionManager(this)
|
||||||
|
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { view, windowInsets ->
|
||||||
|
val systemBars = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
|
view.setPadding(
|
||||||
|
systemBars.left,
|
||||||
|
systemBars.top,
|
||||||
|
systemBars.right,
|
||||||
|
systemBars.bottom
|
||||||
|
)
|
||||||
|
windowInsets
|
||||||
|
}
|
||||||
|
|
||||||
|
setupHeader()
|
||||||
|
|
||||||
|
viewModel.getReview("all")
|
||||||
|
viewModel.averageScore.observe(this) { binding.tvReviewScore.text = it }
|
||||||
|
viewModel.totalReview.observe(this) { binding.tvTotalReview.text = "$it rating" }
|
||||||
|
viewModel.totalReviewWithDesc.observe(this) { binding.tvTotalReviewWithDesc.text = "$it ulasan" }
|
||||||
|
|
||||||
|
if (savedInstanceState == null) {
|
||||||
|
showReviewFragment()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupHeader() {
|
||||||
|
binding.header.headerTitle.text = "Ulasan Pembeli"
|
||||||
|
|
||||||
|
binding.header.headerLeftIcon.setOnClickListener {
|
||||||
|
onBackPressed()
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showReviewFragment() {
|
||||||
|
supportFragmentManager.commit {
|
||||||
|
replace(R.id.fragment_container_reviews, ReviewFragment())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
package com.alya.ecommerce_serang.ui.profile.mystore.review
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.alya.ecommerce_serang.R
|
||||||
|
import com.alya.ecommerce_serang.data.api.dto.ReviewsItem
|
||||||
|
import com.alya.ecommerce_serang.utils.viewmodel.ReviewViewModel
|
||||||
|
import com.bumptech.glide.Glide
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
class ReviewAdapter(
|
||||||
|
private val viewModel: ReviewViewModel
|
||||||
|
): RecyclerView.Adapter<ReviewAdapter.ReviewViewHolder>() {
|
||||||
|
|
||||||
|
private val reviews = mutableListOf<ReviewsItem>()
|
||||||
|
private var fragmentScore: String = "all"
|
||||||
|
|
||||||
|
fun setFragmentScore(score: String) {
|
||||||
|
fragmentScore = score
|
||||||
|
}
|
||||||
|
|
||||||
|
fun submitList(newReviews: List<ReviewsItem>) {
|
||||||
|
reviews.clear()
|
||||||
|
reviews.addAll(newReviews)
|
||||||
|
notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(
|
||||||
|
parent: ViewGroup,
|
||||||
|
viewType: Int
|
||||||
|
): ReviewAdapter.ReviewViewHolder {
|
||||||
|
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_store_product_review, parent, false)
|
||||||
|
return ReviewViewHolder(view)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ReviewViewHolder, position: Int) {
|
||||||
|
if (position < reviews.size) {
|
||||||
|
holder.bind(reviews[position])
|
||||||
|
} else {
|
||||||
|
Log.e("ReviewAdapter", "Position $position is out of bounds for size ${reviews.size}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount(): Int = reviews.size
|
||||||
|
|
||||||
|
inner class ReviewViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
|
private val ivProduct: ImageView = itemView.findViewById(R.id.iv_product)
|
||||||
|
private val tvProductName: TextView = itemView.findViewById(R.id.tv_product_name)
|
||||||
|
private val tvReviewScore: TextView = itemView.findViewById(R.id.tv_review_score)
|
||||||
|
private val tvReviewDate: TextView = itemView.findViewById(R.id.tv_review_date)
|
||||||
|
private val tvUsername: TextView = itemView.findViewById(R.id.tv_username)
|
||||||
|
private val tvReviewDesc: TextView = itemView.findViewById(R.id.tv_review_desc)
|
||||||
|
private val ivMenu: ImageView = itemView.findViewById(R.id.iv_menu)
|
||||||
|
|
||||||
|
fun bind(review: ReviewsItem) {
|
||||||
|
val actualScore =
|
||||||
|
if (fragmentScore == "all") review.rating.toString() else fragmentScore
|
||||||
|
|
||||||
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
|
val imageUrl = viewModel.getProductImage(review.productId ?: -1)
|
||||||
|
Glide.with(itemView.context)
|
||||||
|
.load(imageUrl)
|
||||||
|
.placeholder(R.drawable.placeholder_image)
|
||||||
|
.into(ivProduct)
|
||||||
|
}
|
||||||
|
|
||||||
|
tvProductName.text = review.productName
|
||||||
|
tvReviewScore.text = actualScore
|
||||||
|
tvReviewDate.text = review.reviewDate
|
||||||
|
tvUsername.text = review.username
|
||||||
|
tvReviewDesc.text = review.reviewText
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,32 +1,56 @@
|
|||||||
package com.alya.ecommerce_serang.ui.profile.mystore.review
|
package com.alya.ecommerce_serang.ui.profile.mystore.review
|
||||||
|
|
||||||
import androidx.fragment.app.viewModels
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.alya.ecommerce_serang.R
|
import com.alya.ecommerce_serang.databinding.FragmentReviewBinding
|
||||||
import com.alya.ecommerce_serang.utils.viewmodel.ReviewViewModel
|
import com.alya.ecommerce_serang.utils.SessionManager
|
||||||
|
import com.google.android.material.tabs.TabLayoutMediator
|
||||||
|
|
||||||
class ReviewFragment : Fragment() {
|
class ReviewFragment : Fragment() {
|
||||||
|
|
||||||
companion object {
|
private var _binding: FragmentReviewBinding? = null
|
||||||
fun newInstance() = ReviewFragment()
|
private val binding get() = _binding!!
|
||||||
}
|
private lateinit var sessionManager: SessionManager
|
||||||
|
|
||||||
private val viewModel: ReviewViewModel by viewModels()
|
private lateinit var viewPagerAdapter: ReviewViewPagerAdapter
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
|
|
||||||
// TODO: Use the ViewModel
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View {
|
): View {
|
||||||
return inflater.inflate(R.layout.fragment_review, container, false)
|
_binding = FragmentReviewBinding.inflate(inflater, container, false)
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
sessionManager = SessionManager(requireContext())
|
||||||
|
|
||||||
|
setupViewPager()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupViewPager() {
|
||||||
|
viewPagerAdapter = ReviewViewPagerAdapter(requireActivity())
|
||||||
|
binding.viewPagerReview.adapter = viewPagerAdapter
|
||||||
|
|
||||||
|
TabLayoutMediator(binding.tabLayoutReview, binding.viewPagerReview) { tab, position ->
|
||||||
|
tab.text = when (position) {
|
||||||
|
0 -> "Semua"
|
||||||
|
1 -> "5 Bintang"
|
||||||
|
2 -> "4 Bintang"
|
||||||
|
3 -> "3 Bintang"
|
||||||
|
4 -> "2 Bintang"
|
||||||
|
5 -> "1 Bintang"
|
||||||
|
else -> "Tab $position"
|
||||||
|
}
|
||||||
|
}.attach()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
super.onDestroyView()
|
||||||
|
_binding = null
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,123 @@
|
|||||||
|
package com.alya.ecommerce_serang.ui.profile.mystore.review
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.fragment.app.viewModels
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import com.alya.ecommerce_serang.R
|
||||||
|
import com.alya.ecommerce_serang.data.api.retrofit.ApiConfig
|
||||||
|
import com.alya.ecommerce_serang.data.repository.ReviewRepository
|
||||||
|
import com.alya.ecommerce_serang.databinding.FragmentReviewListBinding
|
||||||
|
import com.alya.ecommerce_serang.ui.order.address.ViewState
|
||||||
|
import com.alya.ecommerce_serang.utils.BaseViewModelFactory
|
||||||
|
import com.alya.ecommerce_serang.utils.SessionManager
|
||||||
|
import com.alya.ecommerce_serang.utils.viewmodel.ProductViewModel
|
||||||
|
import com.alya.ecommerce_serang.utils.viewmodel.ReviewViewModel
|
||||||
|
|
||||||
|
class ReviewListFragment : Fragment() {
|
||||||
|
|
||||||
|
private var _binding: FragmentReviewListBinding? = null
|
||||||
|
private val binding get() = _binding!!
|
||||||
|
private lateinit var sessionManager: SessionManager
|
||||||
|
|
||||||
|
private lateinit var reviewAdapter: ReviewAdapter
|
||||||
|
private val viewModel: ReviewViewModel by viewModels {
|
||||||
|
BaseViewModelFactory {
|
||||||
|
val apiService = ApiConfig.getApiService(SessionManager(requireContext()))
|
||||||
|
ReviewViewModel(ReviewRepository(apiService))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private var score: String = "all"
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val ARG_SCORE = "score"
|
||||||
|
|
||||||
|
fun newInstance(score: String): ReviewListFragment = ReviewListFragment().apply {
|
||||||
|
arguments = Bundle().apply {
|
||||||
|
putString(ARG_SCORE, score)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
sessionManager = SessionManager(requireContext())
|
||||||
|
score = arguments?.getString(ARG_SCORE) ?: "all"
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
_binding = FragmentReviewListBinding.inflate(inflater, container, false)
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
reviewAdapter = ReviewAdapter(viewModel)
|
||||||
|
binding.rvReview.apply {
|
||||||
|
layoutManager = LinearLayoutManager(requireContext())
|
||||||
|
adapter = reviewAdapter
|
||||||
|
}
|
||||||
|
|
||||||
|
observeReviewList()
|
||||||
|
fetchReviewByScore(score)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun fetchReviewByScore(score: String) {
|
||||||
|
val normalizedScore = when (score) {
|
||||||
|
"all" -> "all"
|
||||||
|
else -> {
|
||||||
|
val scoreValue = score.toDoubleOrNull() ?: 0.0
|
||||||
|
when {
|
||||||
|
scoreValue > 4.5 -> "5"
|
||||||
|
scoreValue > 3.5 -> "4"
|
||||||
|
scoreValue > 2.5 -> "3"
|
||||||
|
scoreValue > 1.5 -> "2"
|
||||||
|
else -> "1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
viewModel.getReview(normalizedScore)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun observeReviewList() {
|
||||||
|
viewModel.review.observe(viewLifecycleOwner) { result ->
|
||||||
|
when (result) {
|
||||||
|
is ViewState.Success -> {
|
||||||
|
val data = result.data.orEmpty().sortedByDescending { it.reviewDate }
|
||||||
|
binding.progressBar.visibility = View.GONE
|
||||||
|
|
||||||
|
if (data.isEmpty()) {
|
||||||
|
binding.tvEmptyState.visibility = View.VISIBLE
|
||||||
|
binding.rvReview.visibility = View.GONE
|
||||||
|
} else {
|
||||||
|
binding.tvEmptyState.visibility = View.GONE
|
||||||
|
binding.rvReview.visibility = View.VISIBLE
|
||||||
|
reviewAdapter.submitList(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
is ViewState.Loading -> binding.progressBar.visibility = View.VISIBLE
|
||||||
|
is ViewState.Error -> {
|
||||||
|
binding.progressBar.visibility = View.GONE
|
||||||
|
binding.tvEmptyState.visibility = View.VISIBLE
|
||||||
|
Toast.makeText(requireContext(), result.message, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
super.onDestroyView()
|
||||||
|
_binding = null
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.alya.ecommerce_serang.ui.profile.mystore.review
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||||
|
|
||||||
|
class ReviewViewPagerAdapter(
|
||||||
|
fragmentActivity: FragmentActivity
|
||||||
|
) : FragmentStateAdapter(fragmentActivity) {
|
||||||
|
private val reviewScore = listOf(
|
||||||
|
"all",
|
||||||
|
"5",
|
||||||
|
"4",
|
||||||
|
"3",
|
||||||
|
"2",
|
||||||
|
"1"
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun getItemCount(): Int = reviewScore.size
|
||||||
|
|
||||||
|
override fun createFragment(position: Int): Fragment {
|
||||||
|
return ReviewListFragment.newInstance(reviewScore[position])
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,71 @@
|
|||||||
package com.alya.ecommerce_serang.utils.viewmodel
|
package com.alya.ecommerce_serang.utils.viewmodel
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import com.alya.ecommerce_serang.BuildConfig.BASE_URL
|
||||||
|
import com.alya.ecommerce_serang.data.api.dto.ReviewsItem
|
||||||
|
import com.alya.ecommerce_serang.data.repository.Result
|
||||||
|
import com.alya.ecommerce_serang.data.repository.ReviewRepository
|
||||||
|
import com.alya.ecommerce_serang.ui.order.address.ViewState
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlin.getOrThrow
|
||||||
|
|
||||||
class ReviewViewModel : ViewModel() {
|
class ReviewViewModel(private val repository: ReviewRepository) : ViewModel() {
|
||||||
// TODO: Implement the ViewModel
|
|
||||||
|
private val _review = MutableLiveData<ViewState<List<ReviewsItem>>>()
|
||||||
|
val review: LiveData<ViewState<List<ReviewsItem>>> = _review
|
||||||
|
|
||||||
|
private val _averageScore = MutableLiveData<String>()
|
||||||
|
val averageScore: LiveData<String> = _averageScore
|
||||||
|
|
||||||
|
private val _totalReview = MutableLiveData<Int>()
|
||||||
|
val totalReview: LiveData<Int> = _totalReview
|
||||||
|
|
||||||
|
private val _totalReviewWithDesc = MutableLiveData<Int>()
|
||||||
|
val totalReviewWithDesc: LiveData<Int> = _totalReviewWithDesc
|
||||||
|
|
||||||
|
private val _isLoading = MutableLiveData<Boolean>()
|
||||||
|
val isLoading: LiveData<Boolean> = _isLoading
|
||||||
|
|
||||||
|
private val productImageCache = mutableMapOf<Int, String?>()
|
||||||
|
|
||||||
|
fun getReview(score: String) {
|
||||||
|
_review.value = ViewState.Loading
|
||||||
|
viewModelScope.launch {
|
||||||
|
try {
|
||||||
|
val response = repository.getReviewList(score)
|
||||||
|
if (response is Result.Success) {
|
||||||
|
val reviews = response.data.reviews?.filterNotNull().orEmpty()
|
||||||
|
_review.value = ViewState.Success(reviews)
|
||||||
|
|
||||||
|
if (score == "all") {
|
||||||
|
val avg = if (reviews.isNotEmpty()) {
|
||||||
|
reviews.mapNotNull { it.rating }.average()
|
||||||
|
} else 0.0
|
||||||
|
_averageScore.value = String.format("%.1f", avg)
|
||||||
|
_totalReview.value = reviews.size
|
||||||
|
_totalReviewWithDesc.value = reviews.count { !it.reviewText.isNullOrBlank() }
|
||||||
|
}
|
||||||
|
} else if (response is Result.Error) {
|
||||||
|
_review.value = ViewState.Error(response.exception.message ?: "Gagal memuat ulasan")
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
_review.value = ViewState.Error(e.message ?: "Terjadi kesalahan")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun getProductImage(productId: Int): String? {
|
||||||
|
if (productImageCache.containsKey(productId)) {
|
||||||
|
return productImageCache[productId]
|
||||||
|
}
|
||||||
|
val result = repository.getProductDetail(productId)
|
||||||
|
val imageUrl = if (result?.product?.image?.startsWith("/") == true) {
|
||||||
|
BASE_URL + result.product.image.removePrefix("/")
|
||||||
|
} else result?.product?.image
|
||||||
|
productImageCache[productId] = imageUrl.toString()
|
||||||
|
return imageUrl.toString()
|
||||||
|
}
|
||||||
}
|
}
|
85
app/src/main/res/layout/activity_review.xml
Normal file
85
app/src/main/res/layout/activity_review.xml
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
android:id="@+id/main"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:backgroundTint="@color/white"
|
||||||
|
tools:context=".ui.profile.mystore.review.ReviewActivity">
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/header"
|
||||||
|
layout="@layout/header" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="36dp"
|
||||||
|
android:src="@drawable/baseline_star_24" />
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_review_score"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="5.0"
|
||||||
|
style="@style/headline_small"
|
||||||
|
android:fontFamily="@font/dmsans_extrabold"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="/5.0"
|
||||||
|
style="@style/body_medium"
|
||||||
|
android:textColor="@color/black_300"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/tv_review_score"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/tv_review_score"/>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_total_review"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:text="318 rating"
|
||||||
|
style="@style/body_medium"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:text="•"
|
||||||
|
style="@style/body_medium"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_total_review_with_desc"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:text="108 ulasan"
|
||||||
|
style="@style/body_medium"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<androidx.fragment.app.FragmentContainerView
|
||||||
|
android:id="@+id/fragment_container_reviews"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -1,13 +1,32 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/reviews"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".ui.profile.mystore.review.ReviewFragment">
|
tools:context=".ui.profile.mystore.review.ReviewFragment">
|
||||||
|
|
||||||
<TextView
|
<com.google.android.material.tabs.TabLayout
|
||||||
|
android:id="@+id/tab_layout_review"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:text="Hello" />
|
app:tabMode="scrollable"
|
||||||
|
app:tabTextAppearance="@style/label_medium_prominent"
|
||||||
|
app:tabSelectedTextAppearance="@style/label_medium_prominent"
|
||||||
|
app:tabIndicatorColor="@color/blue_500"
|
||||||
|
app:tabSelectedTextColor="@color/blue_500"
|
||||||
|
app:tabTextColor="@color/black_300"
|
||||||
|
app:tabBackground="@color/white"
|
||||||
|
app:tabPadding="13dp"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
|
|
||||||
</FrameLayout>
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
|
android:id="@+id/view_pager_review"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/tab_layout_review"/>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
41
app/src/main/res/layout/fragment_review_list.xml
Normal file
41
app/src/main/res/layout/fragment_review_list.xml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".ui.profile.mystore.review.ReviewListFragment">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rv_review"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:padding="8dp"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
tools:listitem="@layout/item_review" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_empty_state"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Tidak ada penilaian"
|
||||||
|
style="@style/body_large"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_bar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -9,7 +9,7 @@
|
|||||||
tools:context=".ui.profile.mystore.sells.SellsFragment">
|
tools:context=".ui.profile.mystore.sells.SellsFragment">
|
||||||
|
|
||||||
<com.google.android.material.tabs.TabLayout
|
<com.google.android.material.tabs.TabLayout
|
||||||
android:id="@+id/tabLayoutSells"
|
android:id="@+id/tab_layout_sells"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:tabMode="scrollable"
|
app:tabMode="scrollable"
|
||||||
@ -23,10 +23,10 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent"/>
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
|
|
||||||
<androidx.viewpager2.widget.ViewPager2
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
android:id="@+id/viewPagerSells"
|
android:id="@+id/view_pager_sells"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tabLayoutSells" />
|
app:layout_constraintTop_toBottomOf="@+id/tab_layout_sells" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -7,7 +7,7 @@
|
|||||||
tools:context=".ui.profile.mystore.sells.SellsListFragment">
|
tools:context=".ui.profile.mystore.sells.SellsListFragment">
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/rvSells"
|
android:id="@+id/rv_sells"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
@ -16,11 +16,11 @@
|
|||||||
tools:listitem="@layout/item_sells" />
|
tools:listitem="@layout/item_sells" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvEmptyState"
|
android:id="@+id/tv_empty_state"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="TIdak ada penjualan"
|
android:text="Tidak ada penjualan"
|
||||||
android:textSize="16sp"
|
style="@style/body_large"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
@ -28,7 +28,7 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progress_bar"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -80,7 +82,9 @@
|
|||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:src="@drawable/ic_more_vertical"
|
android:src="@drawable/ic_more_vertical"
|
||||||
android:contentDescription="Menu"
|
android:contentDescription="Menu"
|
||||||
android:layout_marginStart="8dp" />
|
android:layout_marginStart="8dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
105
app/src/main/res/layout/item_store_product_review.xml
Normal file
105
app/src/main/res/layout/item_store_product_review.xml
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:backgroundTint="@color/white">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<com.google.android.material.imageview.ShapeableImageView
|
||||||
|
android:id="@+id/iv_product"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:src="@drawable/placeholder_image"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:contentDescription="Review Product Image"
|
||||||
|
app:shapeAppearanceOverlay="@style/store_product_image"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_product_name"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:text="Jaket Pink Fuschia"
|
||||||
|
style="@style/body_medium"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_menu"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:src="@drawable/ic_more_vertical"
|
||||||
|
android:contentDescription="Menu"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginTop="8dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="16dp"
|
||||||
|
android:layout_height="16dp"
|
||||||
|
android:src="@drawable/baseline_star_24" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_review_score"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="5.0"
|
||||||
|
style="@style/body_small" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_review_date"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:text="30-12-2025"
|
||||||
|
style="@style/body_small"
|
||||||
|
android:textColor="@color/black_300"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_username"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Gracia"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
style="@style/label_medium_prominent"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_review_desc"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Suka banget! Real pict dan pengirimannya juga cepat! Next bakal beli di sini sih, thank you!"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
style="@style/label_small"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Divider -->
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="8dp"
|
||||||
|
android:background="@color/black_50"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
Reference in New Issue
Block a user