feat: refs #7266 printItem
This commit is contained in:
parent
7bfd17d1f7
commit
f8a87de356
|
@ -5,13 +5,12 @@ import android.content.Context
|
|||
import android.text.InputType
|
||||
import android.view.View
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.view.component.CustomDialogList
|
||||
|
||||
class PrinterDialogManager(private val context: Context) {
|
||||
fun showPrintDialog(
|
||||
item: Long,
|
||||
itemName: String,
|
||||
onPrintClick: (Long, String, Int?, Int) -> Unit
|
||||
item: Long, itemName: String, onPrintClick: (Long, String, Int?, Int) -> Unit
|
||||
) {
|
||||
val customDialogList = CustomDialogList(context)
|
||||
customDialogList.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER)
|
||||
|
@ -20,17 +19,15 @@ class PrinterDialogManager(private val context: Context) {
|
|||
customDialogList.setTitle(context.getString(R.string.itemName, item, itemName))
|
||||
.setOkButton(context.getString(R.string.printQr)) {
|
||||
handlePrintClick(item, customDialogList, onPrintClick, "qr")
|
||||
}
|
||||
.setOkTwoButton(context.getString(R.string.printBarcode)) {
|
||||
handlePrintClick(item, customDialogList, onPrintClick, "barcode")
|
||||
|
||||
}
|
||||
.setKoButton(context.getString(R.string.cancel)) {
|
||||
customDialogList.dismiss()
|
||||
}
|
||||
.setHintValueThree(context.getString(R.string.labelNumber))
|
||||
.setHintValue(context.getString(R.string.optionalPacking))
|
||||
.setTextThree(View.VISIBLE)
|
||||
}.setOkTwoButton(context.getString(R.string.printBarcode)) {
|
||||
handlePrintClick(item, customDialogList, onPrintClick, "barcode")
|
||||
customDialogList.dismiss()
|
||||
|
||||
}.setKoButton(context.getString(R.string.cancel)) {
|
||||
customDialogList.dismiss()
|
||||
}.setHintValueThree(context.getString(R.string.labelNumber))
|
||||
.setHintValue(context.getString(R.string.optionalPacking)).setTextThree(View.VISIBLE)
|
||||
.show()
|
||||
customDialogList.getFocusThree()
|
||||
}
|
||||
|
@ -41,16 +38,21 @@ class PrinterDialogManager(private val context: Context) {
|
|||
onPrintClick: (Long, String, Int?, Int) -> Unit,
|
||||
labelType: String
|
||||
) {
|
||||
onPrintClick(
|
||||
item,
|
||||
labelType,
|
||||
if (customDialogList.getValue().isEmpty()) null else customDialogList.getValue()
|
||||
.toInt(),
|
||||
if (customDialogList.getValueOptional()
|
||||
.isEmpty()
|
||||
) 1 else customDialogList.getValueOptional().toInt()
|
||||
)
|
||||
customDialogList.dismiss()
|
||||
try {
|
||||
onPrintClick(
|
||||
item,
|
||||
labelType,
|
||||
if (customDialogList.getValue().isEmpty()) null else customDialogList.getValue()
|
||||
.toInt(),
|
||||
if (customDialogList.getValueOptional()
|
||||
.isEmpty()
|
||||
) 1 else customDialogList.getValueOptional().toInt()
|
||||
)
|
||||
customDialogList.dismiss()
|
||||
} catch (ex: Exception) {
|
||||
context.getString(R.string.errorInput).toast(context)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue