feat embalajes #refs 4021
This commit is contained in:
parent
f695dbdda3
commit
fcf91a18d8
|
@ -10,12 +10,16 @@ import androidx.datastore.preferences.core.longPreferencesKey
|
|||
import androidx.datastore.preferences.core.stringPreferencesKey
|
||||
import androidx.datastore.preferences.preferencesDataStore
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import es.verdnatura.MobileApplication
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.domain.ConstAndValues.BASEURLLILIUM
|
||||
import es.verdnatura.domain.ConstAndValues.BASEURLSALIX
|
||||
import es.verdnatura.domain.ConstAndValues.BASE_URL_LILIUM
|
||||
import es.verdnatura.domain.ConstAndValues.BASE_URL_SALIX
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYID
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYOBSERVATIONORIGINAL
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYOBSERVATIONS
|
||||
import es.verdnatura.domain.ConstAndValues.NUMBEROFWAGONS
|
||||
import es.verdnatura.domain.ConstAndValues.PRINTERFK
|
||||
import es.verdnatura.domain.ConstAndValues.PRINTERFKDEFAULT
|
||||
|
@ -23,12 +27,15 @@ import es.verdnatura.domain.ConstAndValues.PRINTERNAME
|
|||
import es.verdnatura.domain.ConstAndValues.SECTORDESCRIP
|
||||
import es.verdnatura.domain.ConstAndValues.SECTORFK
|
||||
import es.verdnatura.domain.ConstAndValues.SECTORFKDEFAULT
|
||||
import es.verdnatura.domain.ConstAndValues.SUPPLIERID
|
||||
import es.verdnatura.domain.ConstAndValues.SUPPLIERNAME
|
||||
import es.verdnatura.domain.ConstAndValues.TRAINNAME
|
||||
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
|
||||
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFKDEFAULT
|
||||
import es.verdnatura.domain.ConstAndValues.WORKFORMSELECTED
|
||||
import es.verdnatura.presentation.view.feature.login.model.OperatorSalix
|
||||
import es.verdnatura.presentation.view.feature.login.model.WorkForms
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
@ -39,6 +46,7 @@ val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "se
|
|||
val Context.dataStoreWork: DataStore<Preferences> by preferencesDataStore(name = "workForm")
|
||||
|
||||
class DataStoreLocal(var mobileApplication: MobileApplication) {
|
||||
val IMAGES_KEY = stringPreferencesKey("images_key")
|
||||
|
||||
suspend fun saveDataOperator(operator: OperatorSalix) {
|
||||
|
||||
|
@ -144,6 +152,38 @@ class DataStoreLocal(var mobileApplication: MobileApplication) {
|
|||
|
||||
}
|
||||
|
||||
suspend fun saveImages(images: MutableList<com.esafirm.imagepicker.model.Image>?) {
|
||||
val gson = Gson()
|
||||
val imagesJson = gson.toJson(images)
|
||||
mobileApplication.dataStore.edit { preferences ->
|
||||
preferences[IMAGES_KEY] = imagesJson
|
||||
}
|
||||
}
|
||||
|
||||
fun getImages(): Flow<List<com.esafirm.imagepicker.model.Image>> {
|
||||
val gson = Gson()
|
||||
return mobileApplication.dataStore.data.map { preferences ->
|
||||
val imagesJson = preferences[IMAGES_KEY] ?: return@map emptyList<com.esafirm.imagepicker.model.Image>()
|
||||
val type = object : TypeToken<List<com.esafirm.imagepicker.model.Image>>() {}.type
|
||||
gson.fromJson(imagesJson, type)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
suspend fun deleteEntryPackaging(){
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(ENTRYID,"")
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(SUPPLIERID,"")
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(SUPPLIERNAME,"")
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(ENTRYOBSERVATIONORIGINAL,"")
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(ENTRYOBSERVATIONS,"")
|
||||
|
||||
|
||||
}
|
||||
suspend fun deleteImages(){
|
||||
mobileApplication.dataStore.edit { preferences ->
|
||||
preferences.remove(IMAGES_KEY)
|
||||
}
|
||||
}
|
||||
suspend fun deleteWorkForm(nameWorkForm: Preferences.Key<String>) {
|
||||
|
||||
if (nameWorkForm.name == "all") {
|
||||
|
|
|
@ -16,6 +16,12 @@ class CustomDialogInput(context: Context) : Dialog(context, R.style.DialogTheme)
|
|||
init {
|
||||
|
||||
setContentView(binding.root)
|
||||
binding.btOne.setOnClickListener { view -> plusTextButton(view) }
|
||||
binding.btTwo.setOnClickListener { view -> plusTextButton(view) }
|
||||
binding.btThree.setOnClickListener { view -> plusTextButton(view) }
|
||||
binding.btFour.setOnClickListener { view -> plusTextButton(view) }
|
||||
binding.btFive.setOnClickListener { view -> plusTextButton(view) }
|
||||
|
||||
}
|
||||
|
||||
fun getEditText(): TextInputEditText {
|
||||
|
@ -94,4 +100,20 @@ class CustomDialogInput(context: Context) : Dialog(context, R.style.DialogTheme)
|
|||
fun setFocusText() {
|
||||
binding.customDialogValue.requestFocus()
|
||||
}
|
||||
|
||||
fun plusTextButton(view: View) {
|
||||
|
||||
var sum = 0
|
||||
try {
|
||||
sum = getValue().toInt() + Integer.parseInt(view.tag.toString())
|
||||
setValue(sum.toString())
|
||||
} catch (ex: Exception) {
|
||||
setValue(view.tag.toString())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun setVisibilityPlusButtons(visibility: Int) {
|
||||
binding.layoutButtons.visibility = visibility
|
||||
}
|
||||
}
|
|
@ -32,51 +32,92 @@
|
|||
android:id="@+id/custom_dialog_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/layout_margin_1"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:layout_marginBottom="@dimen/layout_margin_1"
|
||||
android:textSize="@dimen/body1"
|
||||
android:visibility="gone"
|
||||
tools:text="Este cambio no podrá deshacerse a no ser que vuelvas a vincular el dispositivo"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_buttons"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btOne"
|
||||
style="@style/plusButton"
|
||||
android:tag="1"
|
||||
android:text="+1" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btTwo"
|
||||
style="@style/plusButton"
|
||||
android:tag="5"
|
||||
android:text="+5" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btThree"
|
||||
style="@style/plusButton"
|
||||
android:tag="10"
|
||||
android:text="+10" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btFour"
|
||||
android:tag="18"
|
||||
style="@style/plusButton"
|
||||
android:text="+18" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btFive"
|
||||
style="@style/plusButton"
|
||||
android:tag="30"
|
||||
android:text="+30" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/textinputlayout_username"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColorHint="@android:color/darker_gray"
|
||||
android:layout_marginTop="@dimen/default_layout_margin">
|
||||
android:layout_marginTop="@dimen/default_layout_margin"
|
||||
android:textColorHint="@android:color/darker_gray">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/custom_dialog_value"
|
||||
style="@style/DefaultButton.NormalButton"
|
||||
style="@style/DefaultButton.NormalButton"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@drawable/background_round"
|
||||
android:inputType="text"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:background="@drawable/background_round"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textColorHint="@android:color/darker_gray" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/textinputlayout_two"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:layout_marginTop="@dimen/default_layout_margin"
|
||||
android:textColorHint="@android:color/darker_gray"
|
||||
android:layout_marginTop="@dimen/default_layout_margin">
|
||||
android:visibility="gone">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/custom_dialog_value_two"
|
||||
style="@style/DefaultButton.NormalButton"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@drawable/background_round"
|
||||
android:inputType="text"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:background="@drawable/background_round"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textColorHint="@android:color/darker_gray" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/custom_dialog_button_ok"
|
||||
style="@style/DefaultButton.NormalButton"
|
||||
|
|
Loading…
Reference in New Issue