mirror of
https://github.com/shaulascr/ecommerce_serang.git
synced 2025-12-15 15:41:02 +00:00
fix register store and product
This commit is contained in:
@ -62,6 +62,9 @@ data class Product(
|
||||
@field:SerializedName("wholesale_min_item")
|
||||
val wholesaleMinItem: Int? = null,
|
||||
|
||||
@field:SerializedName("status")
|
||||
val status: String,
|
||||
|
||||
@field:SerializedName("min_order")
|
||||
val minOrder: Int,
|
||||
|
||||
|
||||
@ -51,7 +51,6 @@ class MyStoreActivity : AppCompatActivity() {
|
||||
|
||||
enableEdgeToEdge()
|
||||
|
||||
|
||||
binding.headerMyStore.headerTitle.text = "Toko Saya"
|
||||
|
||||
binding.headerMyStore.headerLeftIcon.setOnClickListener {
|
||||
|
||||
@ -42,6 +42,7 @@ import com.alya.ecommerce_serang.utils.ImageUtils
|
||||
import com.alya.ecommerce_serang.utils.PopUpDialog
|
||||
import com.alya.ecommerce_serang.utils.RegisterStoreViewModelFactory
|
||||
import com.alya.ecommerce_serang.utils.SessionManager
|
||||
import com.alya.ecommerce_serang.utils.applyLiveCounter
|
||||
import com.alya.ecommerce_serang.utils.viewmodel.MyStoreViewModel
|
||||
import com.alya.ecommerce_serang.utils.viewmodel.RegisterStoreViewModel
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
@ -102,6 +103,30 @@ class RegisterStoreActivity : AppCompatActivity() {
|
||||
binding = ActivityRegisterStoreBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
applyLiveCounter(
|
||||
binding.etStoreName,
|
||||
binding.tvCountName,
|
||||
binding.tvCountNameMax
|
||||
)
|
||||
|
||||
applyLiveCounter(
|
||||
binding.etStoreDescription,
|
||||
binding.tvCountDesc,
|
||||
binding.tvCountDescMax
|
||||
)
|
||||
|
||||
applyLiveCounter(
|
||||
binding.etStreet,
|
||||
binding.tvCountStreet,
|
||||
binding.tvCountStreetMax
|
||||
)
|
||||
|
||||
applyLiveCounter(
|
||||
binding.etAddressDetail,
|
||||
binding.tvCountAddressDetail,
|
||||
binding.tvCountAddressDetailMax
|
||||
)
|
||||
|
||||
sessionManager = SessionManager(this)
|
||||
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
|
||||
@ -31,6 +31,7 @@ import com.alya.ecommerce_serang.utils.CompressionResult
|
||||
import com.alya.ecommerce_serang.utils.FileUtils.compressFileToMax1MB
|
||||
import com.alya.ecommerce_serang.utils.ImageUtils.compressImage
|
||||
import com.alya.ecommerce_serang.utils.SessionManager
|
||||
import com.alya.ecommerce_serang.utils.applyLiveCounter
|
||||
import com.alya.ecommerce_serang.utils.viewmodel.ProductViewModel
|
||||
import com.bumptech.glide.Glide
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
@ -116,6 +117,18 @@ class DetailStoreProductActivity : AppCompatActivity() {
|
||||
binding = ActivityDetailStoreProductBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
applyLiveCounter(
|
||||
binding.edtNamaProduk,
|
||||
binding.tvCountName,
|
||||
binding.tvCountNameMax
|
||||
)
|
||||
|
||||
applyLiveCounter(
|
||||
binding.edtDeskripsiProduk,
|
||||
binding.tvCountDesc,
|
||||
binding.tvCountDescMax
|
||||
)
|
||||
|
||||
isEditing = intent.getBooleanExtra("is_editing", false)
|
||||
productId = intent.getIntExtra("product_id", -1)
|
||||
|
||||
@ -271,6 +284,9 @@ class DetailStoreProductActivity : AppCompatActivity() {
|
||||
binding.switcherHalal.showNext()
|
||||
}
|
||||
|
||||
binding.switchIsActive.isChecked = product.status == "active"
|
||||
binding.switchIsActive.jumpDrawablesToCurrentState()
|
||||
|
||||
validateForm()
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ import com.alya.ecommerce_serang.data.repository.Result
|
||||
import com.alya.ecommerce_serang.databinding.ActivityDetailStoreAddressBinding
|
||||
import com.alya.ecommerce_serang.utils.BaseViewModelFactory
|
||||
import com.alya.ecommerce_serang.utils.SessionManager
|
||||
import com.alya.ecommerce_serang.utils.applyLiveCounter
|
||||
import com.alya.ecommerce_serang.utils.viewmodel.AddressViewModel
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
|
||||
@ -55,6 +56,18 @@ class DetailStoreAddressActivity : AppCompatActivity() {
|
||||
binding = ActivityDetailStoreAddressBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
applyLiveCounter(
|
||||
binding.edtStreet,
|
||||
binding.tvCountStreet,
|
||||
binding.tvCountStreetMax
|
||||
)
|
||||
|
||||
applyLiveCounter(
|
||||
binding.edtDetailAddress,
|
||||
binding.tvCountDetail,
|
||||
binding.tvCountDetailMax
|
||||
)
|
||||
|
||||
sessionManager = SessionManager(this)
|
||||
apiService = ApiConfig.getApiService(sessionManager)
|
||||
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
package com.alya.ecommerce_serang.utils
|
||||
|
||||
import android.os.Build
|
||||
import android.text.InputFilter
|
||||
import android.view.View
|
||||
import android.view.WindowInsetsController
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
fun Fragment.setLightStatusBar(){
|
||||
@ -19,4 +23,27 @@ fun Fragment.setLightStatusBar(){
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public fun applyLiveCounter(
|
||||
editText: EditText,
|
||||
tvCount: TextView,
|
||||
tvMax: TextView
|
||||
) {
|
||||
val max = tvMax.text.toString().toIntOrNull() ?: Int.MAX_VALUE
|
||||
|
||||
// Replace any existing LengthFilter with the new max
|
||||
val current = editText.filters?.toMutableList() ?: mutableListOf()
|
||||
current.removeAll { it is InputFilter.LengthFilter }
|
||||
current.add(InputFilter.LengthFilter(max))
|
||||
editText.filters = current.toTypedArray()
|
||||
|
||||
// Set initial count (handles prefilled text / edit mode)
|
||||
tvCount.text = (editText.text?.length ?: 0).toString()
|
||||
|
||||
// Update on change
|
||||
editText.doAfterTextChanged {
|
||||
val len = it?.length ?: 0
|
||||
tvCount.text = len.toString()
|
||||
}
|
||||
}
|
||||
@ -205,7 +205,6 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<!-- Jalan -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -223,13 +222,49 @@
|
||||
<EditText
|
||||
android:id="@+id/edt_street"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="70dp"
|
||||
android:background="@drawable/bg_text_field"
|
||||
android:hint="Isi nama jalan di sini"
|
||||
android:padding="8dp"
|
||||
style="@style/body_small"
|
||||
android:hint="Isi nama jalan di sini"
|
||||
android:inputType="text|textMultiLine"
|
||||
android:gravity="top"
|
||||
android:layout_marginTop="10dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="4dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_count_street"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="0"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="/"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_count_street_max"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="255"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Kode Pos -->
|
||||
@ -254,6 +289,7 @@
|
||||
android:padding="8dp"
|
||||
style="@style/body_small"
|
||||
android:hint="Isi kode pos di sini"
|
||||
android:inputType="number"
|
||||
android:layout_marginTop="10dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
@ -275,15 +311,47 @@
|
||||
<EditText
|
||||
android:id="@+id/edt_detail_address"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="70dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_text_field"
|
||||
android:hint="Isi detail alamat di sini, contoh: Blok, No. Kavling, dsb."
|
||||
android:padding="8dp"
|
||||
style="@style/body_small"
|
||||
android:inputType="text|textMultiLine"
|
||||
android:gravity="top"
|
||||
android:hint="Isi detail alamat di sini, contoh: Blok, No. Kavling, dsb."
|
||||
android:layout_marginTop="10dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="4dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_count_detail"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="0"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="/"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_count_detail_max"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="100"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Pinpoint Lokasi -->
|
||||
|
||||
@ -167,6 +167,40 @@
|
||||
style="@style/body_small"
|
||||
android:layout_marginTop="10dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="4dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_count_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="0"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="/"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_count_name_max"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="50"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Kategori Produk -->
|
||||
@ -271,6 +305,40 @@
|
||||
android:gravity="top"
|
||||
android:layout_marginTop="10dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="4dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_count_desc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="0"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="/"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_count_desc_max"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="255"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Harga Produk -->
|
||||
|
||||
@ -138,6 +138,40 @@
|
||||
style="@style/body_small"
|
||||
android:layout_marginTop="10dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="4dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_count_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="0"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="/"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_count_name_max"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="30"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Deskripsi Toko -->
|
||||
@ -166,6 +200,40 @@
|
||||
android:gravity="top"
|
||||
android:layout_marginTop="10dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="4dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_count_desc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="0"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="/"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_count_desc_max"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="255"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Jenis UMKM -->
|
||||
@ -435,7 +503,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginBottom="24dp">
|
||||
android:layout_marginVertical="24dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -463,13 +531,49 @@
|
||||
<EditText
|
||||
android:id="@+id/et_street"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="70dp"
|
||||
android:background="@drawable/bg_text_field"
|
||||
android:hint="Isi jalan tempat toko Anda di sini"
|
||||
android:padding="8dp"
|
||||
style="@style/body_small"
|
||||
android:inputType="text|textMultiLine"
|
||||
android:gravity="top"
|
||||
android:layout_marginTop="10dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="4dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_count_street"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="0"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="/"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_count_street_max"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="255"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Kode Pos -->
|
||||
@ -532,15 +636,49 @@
|
||||
<EditText
|
||||
android:id="@+id/et_address_detail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="70dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_text_field"
|
||||
android:hint="Isi detail alamat toko Anda di sini"
|
||||
android:padding="8dp"
|
||||
style="@style/body_small"
|
||||
android:inputType="text|textMultiLine"
|
||||
android:inputType="text"
|
||||
android:gravity="top"
|
||||
android:layout_marginTop="10dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="4dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_count_address_detail"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="0"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="/"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_count_address_detail_max"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/label_small"
|
||||
android:text="100"
|
||||
android:textColor="@color/black_300"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Nama Bank-->
|
||||
@ -626,7 +764,7 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="12. Nama Pemilik Rekening"
|
||||
android:text="11. Nama Pemilik Rekening"
|
||||
style="@style/body_medium"
|
||||
android:layout_marginEnd="4dp"/>
|
||||
|
||||
@ -668,7 +806,7 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="11. Nomor Rekening"
|
||||
android:text="12. Nomor Rekening"
|
||||
style="@style/body_medium"
|
||||
android:layout_marginEnd="4dp"/>
|
||||
|
||||
@ -887,7 +1025,7 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="17. Dokumen NPWP"
|
||||
android:text="16. Dokumen NPWP"
|
||||
style="@style/body_medium"
|
||||
android:layout_marginEnd="4dp"/>
|
||||
|
||||
@ -954,7 +1092,7 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="16. Dokumen NIB"
|
||||
android:text="17. Dokumen NIB"
|
||||
style="@style/body_medium"
|
||||
android:layout_marginEnd="4dp"/>
|
||||
|
||||
@ -1015,7 +1153,7 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="17. Pilih Titik Lokasi Usaha"
|
||||
android:text="18. Pilih Titik Lokasi Usaha"
|
||||
style="@style/body_medium"
|
||||
android:layout_marginEnd="4dp"/>
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@
|
||||
android:background="@null"
|
||||
android:hint="Isi stok produk di sini"
|
||||
android:inputType="number"
|
||||
android:textAlignment="center"
|
||||
android:padding="8dp"
|
||||
style="@style/body_small" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user