添加了注释,完善了参数校验及空值处理
This commit is contained in:
@@ -91,6 +91,9 @@ fun AppScreen(
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航
|
||||
*/
|
||||
@Composable
|
||||
private fun NavHost(
|
||||
padding: PaddingValues,
|
||||
|
||||
@@ -30,6 +30,9 @@ import com.sw.inbound.ui.weight.TopTitleBar
|
||||
import com.sw.inbound.viewmodel.UserViewModel
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* 首页
|
||||
*/
|
||||
@Composable
|
||||
fun HomeScreen(
|
||||
modifier: Modifier = Modifier,
|
||||
|
||||
@@ -49,18 +49,21 @@ import com.sw.inbound.ui.theme.AppTypography.blackTextStyle
|
||||
import com.sw.inbound.ui.theme.AppTypography.grayTextStyle
|
||||
import com.sw.inbound.ui.weight.BottomActionBar
|
||||
import com.sw.inbound.ui.weight.TopTitleBar
|
||||
import com.sw.inbound.viewmodel.ProductViewModel
|
||||
import com.sw.inbound.viewmodel.PurchaseOrderViewModel
|
||||
|
||||
@Preview(
|
||||
widthDp = 1920,
|
||||
heightDp = 1080,
|
||||
showBackground = true
|
||||
)
|
||||
/**
|
||||
* 采购订单-供应商列表
|
||||
*/
|
||||
@Composable
|
||||
fun PurchaseOrderScreen(
|
||||
modifier: Modifier = Modifier,
|
||||
navController: NavHostController = rememberNavController(),
|
||||
viewModel: ProductViewModel = hiltViewModel<ProductViewModel>()
|
||||
viewModel: PurchaseOrderViewModel = hiltViewModel<PurchaseOrderViewModel>()
|
||||
) {
|
||||
val products by viewModel.supplierList.collectAsState()
|
||||
|
||||
@@ -97,12 +100,6 @@ fun PurchaseOrderScreen(
|
||||
} else {
|
||||
LazyRow(
|
||||
modifier = modifier
|
||||
// .paint(painterResource(R.mipmap.bg_listview))
|
||||
// .fillMaxSize()
|
||||
// .background(
|
||||
// color = Color(0x80FFFFFF),
|
||||
// shape = RoundedCornerShape(12.dp) // 圆角背景
|
||||
// )
|
||||
.padding(10.dp),
|
||||
contentPadding = PaddingValues(16.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(30.dp)
|
||||
@@ -131,6 +128,9 @@ fun PurchaseOrderScreen(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 采购单缺省
|
||||
*/
|
||||
@Composable
|
||||
fun PurchaseEmptyItem() {
|
||||
Column(
|
||||
@@ -149,6 +149,9 @@ fun PurchaseEmptyItem() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表item
|
||||
*/
|
||||
@Composable
|
||||
fun PurchaseOrderItem(product: SupplierInfo, onItemClick: (SupplierInfo) -> Unit) {
|
||||
|
||||
@@ -235,7 +238,7 @@ fun PurchaseOrderItem(product: SupplierInfo, onItemClick: (SupplierInfo) -> Unit
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Text(text = "采购日期", style = grayTextStyle)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Text(text = product.purchaseDate ?: "", style = blackTextStyle)
|
||||
Text(text = product.purchaseDate ?: "-", style = blackTextStyle)
|
||||
}
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Text(text = "到货日期", style = grayTextStyle)
|
||||
|
||||
@@ -48,6 +48,7 @@ import com.sw.inbound.ext.withSize
|
||||
import com.sw.inbound.model.request.UploadInfo
|
||||
import com.sw.inbound.model.response.DictType
|
||||
import com.sw.inbound.model.response.GoodsInfo
|
||||
import com.sw.inbound.sdk.SensorScaleUtils
|
||||
import com.sw.inbound.ui.theme.AppTypography
|
||||
import com.sw.inbound.ui.theme.AppTypography.black141428TextStyle
|
||||
import com.sw.inbound.ui.theme.AppTypography.gray96a0aaTextStyle
|
||||
@@ -57,13 +58,18 @@ import com.sw.inbound.ui.weight.CustomSpinner
|
||||
import com.sw.inbound.ui.weight.CustomTextField
|
||||
import com.sw.inbound.ui.weight.IdentityView
|
||||
import com.sw.inbound.ui.weight.InputType
|
||||
import com.sw.inbound.ui.weight.ProductListView
|
||||
import com.sw.inbound.ui.weight.ReceiptUnadjustedListView
|
||||
import com.sw.inbound.ui.weight.RowInputLayout
|
||||
import com.sw.inbound.ui.weight.TopTitleBar
|
||||
import com.sw.inbound.ui.weight.dialog.ReceiptTipDialog
|
||||
import com.sw.inbound.utils.InteractionUtils
|
||||
import com.sw.inbound.utils.ToastUtils
|
||||
import com.sw.inbound.viewmodel.ReceiptViewModel
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* 收货界面
|
||||
*/
|
||||
@Composable
|
||||
fun ReceiptProductScreen(
|
||||
modifier: Modifier = Modifier,
|
||||
@@ -79,6 +85,7 @@ fun ReceiptProductScreen(
|
||||
|
||||
LaunchedEffect(receiptResult) {
|
||||
if (receiptResult) {
|
||||
ToastUtils.showToast("收货成功")
|
||||
controller.popBackStack()
|
||||
}
|
||||
}
|
||||
@@ -94,7 +101,7 @@ fun ReceiptProductScreen(
|
||||
modifier = modifier
|
||||
.background(
|
||||
color = Color(0x80FFFFFF),
|
||||
shape = RoundedCornerShape(12.dp)
|
||||
shape = RoundedCornerShape(10.dp)
|
||||
)
|
||||
.fillMaxWidth()
|
||||
.padding(30.dp)
|
||||
@@ -140,6 +147,9 @@ fun ReceiptProductScreen(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 左侧列表
|
||||
*/
|
||||
@Composable
|
||||
fun ReceiptLeftView(
|
||||
modifier: Modifier,
|
||||
@@ -161,18 +171,18 @@ fun ReceiptLeftView(
|
||||
) {
|
||||
Column {
|
||||
Text(
|
||||
"供应商:${currentPurchaseInfo?.supplierName}",
|
||||
"供应商:${currentPurchaseInfo?.supplierName ?: "-"}",
|
||||
style = black141428TextStyle.bold()
|
||||
)
|
||||
Spacer(modifier = Modifier.height(18.dp))
|
||||
Row {
|
||||
Text(
|
||||
"采购单号:${currentPurchaseInfo?.purCode}",
|
||||
"采购单号:${currentPurchaseInfo?.purCode ?: "-"}",
|
||||
style = gray96a0aaTextStyle.copy(fontSize = 20.sp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(120.dp))
|
||||
Text(
|
||||
"收货单号:${currentPurchaseInfo?.receiveCode}",
|
||||
"收货单号:${currentPurchaseInfo?.receiveCode ?: "-"}",
|
||||
style = gray96a0aaTextStyle.copy(fontSize = 20.sp)
|
||||
)
|
||||
}
|
||||
@@ -181,22 +191,15 @@ fun ReceiptLeftView(
|
||||
items = warehouseTypeList,
|
||||
selectedItem = currentPurchaseInfo!!.warehouseName,
|
||||
onItemSelected = { value ->
|
||||
val currentPurchaseInfo1 = currentPurchaseInfo!!.copy()
|
||||
currentPurchaseInfo1.warehouseName = value.value
|
||||
val currentPurchaseInfo1 =
|
||||
currentPurchaseInfo!!.copy(warehouseName = value.value)
|
||||
viewModel.updateCurrentPurchaseInfo(currentPurchaseInfo1)
|
||||
viewModel.updateAllPurchaseStore(store = value)
|
||||
viewModel.updateAllPurchaseStore(warehouse = value)
|
||||
})
|
||||
}
|
||||
Spacer(modifier = Modifier.height(30.dp))
|
||||
|
||||
TabScreen(viewModel)
|
||||
// LazyColumn(
|
||||
// verticalArrangement = Arrangement.spacedBy(30.dp)
|
||||
// ) {
|
||||
// items(items = purchaseOrderList, key = { it.id }) {
|
||||
// ReceiptItem(it, modifier)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -275,7 +278,7 @@ fun TabScreen(viewModel: ReceiptViewModel) {
|
||||
fun UnadjustedView(purchaseOrderList: List<GoodsInfo>, viewModel: ReceiptViewModel) {
|
||||
val checkedItem by viewModel.selectedItem.collectAsState()
|
||||
// 未调整view
|
||||
ProductListView(
|
||||
ReceiptUnadjustedListView(
|
||||
modifier = Modifier.padding(horizontal = 30.dp),
|
||||
productList = purchaseOrderList,
|
||||
checkedItem = checkedItem,
|
||||
@@ -343,10 +346,11 @@ private fun AdjustedViewItem(purchaseOrder: GoodsInfo, viewModel: ReceiptViewMod
|
||||
Text(text = "x", style = AppTypography.black141428TextStyle.bold())
|
||||
Spacer(modifier = Modifier.width(50.dp))
|
||||
AdjustedRowInputLayout(
|
||||
label = "实收", value = purchaseOrder.receivedNumStr,
|
||||
label = "实收", value = purchaseOrder.receivedNumTemp,
|
||||
onValueChange = {
|
||||
viewModel.updatePurchaseItem(
|
||||
purchaseOrder = purchaseOrder.copy(
|
||||
receivedNumTemp = it,
|
||||
receivedNum = it.toSafeFloat()
|
||||
)
|
||||
)
|
||||
@@ -532,11 +536,16 @@ private fun ReceiptProductEditView(
|
||||
|
||||
RowInputLayout(
|
||||
label = "收货数量",
|
||||
value = selectedItem!!.receivedNumStr,
|
||||
value = selectedItem!!.receivedNumTemp,
|
||||
onValueChange = { value ->
|
||||
viewModel.updateCountInputState(value.isNotEmpty())
|
||||
selectedItem?.let {
|
||||
viewModel.updateSelectedItem(selectedItem!!.copy(receivedNum = value.toSafeFloat()))
|
||||
viewModel.updateSelectedItem(
|
||||
selectedItem!!.copy(
|
||||
receivedNumTemp = value,
|
||||
receivedNum = value.toSafeFloat()
|
||||
)
|
||||
)
|
||||
}
|
||||
},
|
||||
trailingLabel = selectedItem?.unitName,
|
||||
@@ -582,7 +591,11 @@ private fun ReceiptProductEditView(
|
||||
isInitUpdate = true,
|
||||
textAlign = TextAlign.End,
|
||||
trailingLabel = selectedItem!!.goodsWeightUnitStr,
|
||||
inputType = InputType.Decimal
|
||||
inputType = InputType.Decimal,
|
||||
onClick = InteractionUtils.rememberDoubleClickDetector {
|
||||
Timber.d("物品重量 双击")
|
||||
SensorScaleUtils.tare()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -593,7 +606,7 @@ private fun ReceiptProductEditView(
|
||||
thickness = 1.dp,
|
||||
color = colorResource(R.color.divider)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(30.dp))
|
||||
Spacer(modifier = Modifier.height(20.dp))
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.SpaceAround,
|
||||
modifier = Modifier
|
||||
@@ -604,6 +617,11 @@ private fun ReceiptProductEditView(
|
||||
viewModel.updateSelectedItem(null)
|
||||
}, painter = painterResource(R.mipmap.ic_btn_back), contentDescription = "返回")
|
||||
Image(modifier = Modifier.clickable {
|
||||
val errorInfo = selectedItem!!.hasNullField()
|
||||
if (errorInfo != null) {
|
||||
ToastUtils.showToast(errorInfo)
|
||||
return@clickable
|
||||
}
|
||||
viewModel.updatePurchaseItem(purchaseOrder = selectedItem!!.copy(isAdjusted = true))
|
||||
viewModel.updateSelectedItem(null)
|
||||
}, painter = painterResource(R.mipmap.ic_btn_confirm), contentDescription = "确定")
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.sw.inbound.ui.page
|
||||
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
@@ -19,8 +18,6 @@ import androidx.compose.foundation.layout.wrapContentSize
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
@@ -60,6 +57,7 @@ import com.sw.inbound.ext.withColor
|
||||
import com.sw.inbound.ext.withSize
|
||||
import com.sw.inbound.model.request.PurchaseWarehouseParam
|
||||
import com.sw.inbound.model.response.DictType
|
||||
import com.sw.inbound.sdk.SensorScaleUtils
|
||||
import com.sw.inbound.ui.theme.AppTypography
|
||||
import com.sw.inbound.ui.theme.Black_141428
|
||||
import com.sw.inbound.ui.weight.BottomActionBar
|
||||
@@ -74,6 +72,7 @@ import com.sw.inbound.ui.weight.InputType
|
||||
import com.sw.inbound.ui.weight.RowInputLayout
|
||||
import com.sw.inbound.ui.weight.SelfProcurementListItem
|
||||
import com.sw.inbound.ui.weight.TopTitleBar
|
||||
import com.sw.inbound.utils.InteractionUtils
|
||||
import com.sw.inbound.utils.ToastUtils
|
||||
import com.sw.inbound.viewmodel.SelfProcurementViewModel
|
||||
import timber.log.Timber
|
||||
@@ -83,6 +82,9 @@ import timber.log.Timber
|
||||
heightDp = 1080,
|
||||
showBackground = true
|
||||
)
|
||||
/**
|
||||
* 自采购
|
||||
*/
|
||||
@Composable
|
||||
fun SelfProcurementScreen(
|
||||
modifier: Modifier = Modifier,
|
||||
@@ -94,6 +96,7 @@ fun SelfProcurementScreen(
|
||||
|
||||
LaunchedEffect(addToWarehouseResult) {
|
||||
if (addToWarehouseResult) {
|
||||
ToastUtils.showToast("提交入库成功")
|
||||
controller.popBackStack()
|
||||
}
|
||||
}
|
||||
@@ -120,6 +123,7 @@ fun SelfProcurementScreen(
|
||||
controller.popBackStack()
|
||||
}, showRight1Button = true, right1ButtonText = "清空物品", onRight1ButtonClick = {
|
||||
viewModel.clearPurchaseOrders()
|
||||
ToastUtils.showToast("物品清空成功")
|
||||
}, right2ButtonText = "提交入库", onRight2ButtonClick = {
|
||||
viewModel.addToWarehouse()
|
||||
})
|
||||
@@ -288,11 +292,7 @@ private fun DialogContentView(
|
||||
Spacer(modifier = Modifier.height(58.dp))
|
||||
Row(modifier = Modifier.fillMaxWidth()) {
|
||||
// 采集窗口
|
||||
CameraCaptureLayout(modifier = Modifier.width(428.dp), onCancelClick = {
|
||||
|
||||
}, onConfirmClick = {
|
||||
|
||||
})
|
||||
CameraCaptureLayout(modifier = Modifier.width(428.dp))
|
||||
Spacer(modifier = Modifier.width(60.dp))
|
||||
// 右侧输入窗口
|
||||
|
||||
@@ -331,8 +331,9 @@ private fun DialogRightEditView(viewModel: SelfProcurementViewModel) {
|
||||
})
|
||||
ColumnInputText(
|
||||
modifier = Modifier.width(474.dp),
|
||||
label = "物品编码(服务生成)",
|
||||
label = "物品编码(系统生成)",
|
||||
value = "",
|
||||
enabled = false,
|
||||
onValueChange = {
|
||||
// viewModel.updateFormState(formState.copy(goodCode = it))
|
||||
})
|
||||
@@ -470,7 +471,8 @@ fun ColumnInputText(
|
||||
value: String,
|
||||
onValueChange: (String) -> Unit = {},
|
||||
dropdownItems: List<DictType> = emptyList(),
|
||||
trailingLabel: String? = null, inputType: InputType = InputType.Text
|
||||
trailingLabel: String? = null, inputType: InputType = InputType.Text,
|
||||
enabled: Boolean = true
|
||||
) {
|
||||
val placeholder = if (dropdownItems.isEmpty()) "请录入" else "请选择"
|
||||
Column(modifier = modifier) {
|
||||
@@ -482,7 +484,8 @@ fun ColumnInputText(
|
||||
onValueChange = onValueChange,
|
||||
placeholderValue = placeholder,
|
||||
trailingLabel = trailingLabel,
|
||||
inputType = inputType
|
||||
inputType = inputType,
|
||||
enabled = enabled
|
||||
)
|
||||
} else {
|
||||
CustomDropdownTextField(
|
||||
@@ -647,14 +650,19 @@ private fun SelfProductEditView(
|
||||
|
||||
RowInputLayout(
|
||||
label = "采购数量",
|
||||
value = selectedItem!!.goodsCountStr,
|
||||
value = selectedItem!!.goodsCountTemp,
|
||||
inputType = InputType.Decimal,
|
||||
isInitUpdate = true,
|
||||
onValueChange = { value ->
|
||||
Timber.d("采购数量 onValueChange value = $value")
|
||||
viewModel.updateCountInputState(value.isNotEmpty())
|
||||
selectedItem.let {
|
||||
viewModel.updateSelectedItem(selectedItem!!.copy(goodsCount = value.toSafeDouble()))
|
||||
viewModel.updateSelectedItem(
|
||||
selectedItem!!.copy(
|
||||
goodsCountTemp = value,
|
||||
goodsCount = value.toSafeDouble()
|
||||
)
|
||||
)
|
||||
}
|
||||
},
|
||||
trailingLabel = selectedItem!!.unitName,
|
||||
@@ -699,19 +707,23 @@ private fun SelfProductEditView(
|
||||
isInitUpdate = true,
|
||||
textAlign = TextAlign.End,
|
||||
trailingLabel = selectedItem!!.goodsWeightUnitStr,
|
||||
onClick = InteractionUtils.rememberDoubleClickDetector {
|
||||
Timber.d("物品重量 双击")
|
||||
SensorScaleUtils.tare()
|
||||
},
|
||||
leadingIcon = {
|
||||
Button(
|
||||
onClick = {},
|
||||
modifier = Modifier
|
||||
.padding(0.dp)
|
||||
.fillMaxHeight(),
|
||||
shape = RoundedCornerShape(10.dp),
|
||||
border = BorderStroke(2.dp, color = Color.White),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = Color.White,
|
||||
contentColor = Black_141428
|
||||
),
|
||||
) { Text(text = "累计", style = AppTypography.black141428TextStyle) }
|
||||
// Button(
|
||||
// onClick = {},
|
||||
// modifier = Modifier
|
||||
// .padding(0.dp)
|
||||
// .fillMaxHeight(),
|
||||
// shape = RoundedCornerShape(10.dp),
|
||||
// border = BorderStroke(2.dp, color = Color.White),
|
||||
// colors = ButtonDefaults.buttonColors(
|
||||
// containerColor = Color.White,
|
||||
// contentColor = Black_141428
|
||||
// ),
|
||||
// ) { Text(text = "累计", style = AppTypography.black141428TextStyle) }
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -748,6 +760,7 @@ private fun SelfProductEditView(
|
||||
ToastUtils.showToast(errInfo)
|
||||
return@CustomButton
|
||||
}
|
||||
|
||||
viewModel.addPurchaseItem(selectedItem!!)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -50,11 +50,12 @@ import com.sw.inbound.utils.ToastUtils
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* 相机预览 -默认不预览,支持拍照
|
||||
*/
|
||||
@Composable
|
||||
fun CameraCaptureLayout(
|
||||
modifier: Modifier = Modifier,
|
||||
onCancelClick: () -> Unit = {},
|
||||
onConfirmClick: () -> Unit = {}
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
var showCamera by remember { mutableStateOf(false) }
|
||||
@@ -79,7 +80,6 @@ fun CameraCaptureLayout(
|
||||
verticalArrangement = Arrangement.spacedBy(24.dp)
|
||||
) {
|
||||
if (showCamera) {
|
||||
// CameraPreview()
|
||||
// 摄像头预览
|
||||
CameraPreview(
|
||||
modifier = Modifier
|
||||
@@ -183,7 +183,7 @@ fun CameraCaptureLayout(
|
||||
val savedUri = outputFileResults.savedUri ?: Uri.fromFile(photoFile)
|
||||
photoUri = savedUri
|
||||
Timber.d("photoUri = $photoUri")
|
||||
Toast.makeText(context, "照片已保存", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, "图片已保存", Toast.LENGTH_SHORT).show()
|
||||
showCamera = false
|
||||
GlobalData.imageUri = photoUri
|
||||
}
|
||||
@@ -208,7 +208,7 @@ fun CameraCaptureLayout(
|
||||
|
||||
// 生命周期管理
|
||||
DisposableEffect(lifecycleOwner) {
|
||||
Timber.d("cameraController 释放")
|
||||
Timber.d("cameraController")
|
||||
cameraController.bindToLifecycle(lifecycleOwner)
|
||||
onDispose { }
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import com.sw.inbound.R
|
||||
|
||||
/**
|
||||
* 相机预览
|
||||
*/
|
||||
@Composable
|
||||
fun CameraPreview(
|
||||
controller: LifecycleCameraController,
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
package com.sw.inbound.ui.weight
|
||||
|
||||
import android.Manifest
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.google.accompanist.permissions.ExperimentalPermissionsApi
|
||||
import com.google.accompanist.permissions.PermissionState
|
||||
import com.google.accompanist.permissions.isGranted
|
||||
import com.google.accompanist.permissions.rememberPermissionState
|
||||
import com.google.accompanist.permissions.shouldShowRationale
|
||||
|
||||
@OptIn(ExperimentalPermissionsApi::class)
|
||||
@Preview
|
||||
@Composable
|
||||
fun CameraScreen() {
|
||||
val cameraPermissionState =
|
||||
rememberPermissionState(permission = Manifest.permission.CAMERA)
|
||||
LaunchedEffect(key1 = Unit) {
|
||||
if (!cameraPermissionState.status.isGranted && !cameraPermissionState.status.shouldShowRationale) {
|
||||
cameraPermissionState.launchPermissionRequest()
|
||||
}
|
||||
}
|
||||
|
||||
if (cameraPermissionState.status.isGranted) {
|
||||
//接受拍照的授权
|
||||
// CameraContent()
|
||||
} else {
|
||||
//未授权,显示未授权的界面
|
||||
NoPermissionScreen(cameraPermissionState)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalPermissionsApi::class)
|
||||
@Composable
|
||||
fun NoPermissionScreen(cameraPermissionState: PermissionState) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
val message = if (cameraPermissionState.status.shouldShowRationale) {
|
||||
"未获取照相机权限导致无法使用照相机功能"
|
||||
} else {
|
||||
"请授权照相机的权限"
|
||||
}
|
||||
Text(message)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Button(onClick = {
|
||||
cameraPermissionState.launchPermissionRequest()
|
||||
}) {
|
||||
Text("请求授权")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ import com.sw.inbound.model.response.DictType
|
||||
import com.sw.inbound.ui.theme.AppTypography
|
||||
import com.sw.inbound.ui.theme.Black_141428
|
||||
|
||||
/**
|
||||
* 表单中的下拉菜单
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun CustomDropdownTextField(
|
||||
|
||||
@@ -30,6 +30,9 @@ import com.sw.inbound.R
|
||||
import com.sw.inbound.ui.theme.AppTypography
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* 搜索框
|
||||
*/
|
||||
@Composable
|
||||
fun CustomSearchView(onValueChange: (String) -> Unit = {}, onSearchClick: (String) -> Unit) {
|
||||
var searchText by remember { mutableStateOf("") }
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sw.inbound.ui.weight
|
||||
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import com.sw.inbound.ui.theme.AppTypography
|
||||
|
||||
/**
|
||||
* 自定义单行文本
|
||||
*/
|
||||
@Composable
|
||||
fun CustomSingleRightText(
|
||||
modifier: Modifier,
|
||||
text: String,
|
||||
style: TextStyle = AppTypography.blackTextStyle,
|
||||
textAlign: TextAlign = TextAlign.End
|
||||
) {
|
||||
Text(
|
||||
modifier = modifier,
|
||||
text = text,
|
||||
textAlign = textAlign,
|
||||
style = style,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
@@ -24,6 +24,9 @@ import androidx.compose.ui.unit.sp
|
||||
import com.sw.inbound.R
|
||||
import com.sw.inbound.model.response.DictType
|
||||
|
||||
/**
|
||||
* 自定义顶部仓库下拉
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun CustomSpinner(
|
||||
|
||||
@@ -2,10 +2,12 @@ package com.sw.inbound.ui.weight
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
@@ -84,22 +86,26 @@ enum class InputType {
|
||||
Decimal // 浮点
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义输入框
|
||||
*/
|
||||
@Composable
|
||||
fun CustomTextField(
|
||||
value: String,
|
||||
onValueChange: (String) -> Unit,
|
||||
modifier: Modifier = Modifier.height(60.dp),
|
||||
placeholderValue: String = "请录入",
|
||||
trailingLabel: String? = null,
|
||||
placeholderValue: String = "请录入", // 占位文本
|
||||
trailingLabel: String? = null, // 右侧文字
|
||||
textAlign: TextAlign = TextAlign.Start,
|
||||
textStyle: TextStyle? = null,
|
||||
leadingIcon: @Composable (() -> Unit)? = null,
|
||||
leadingIcon: @Composable (() -> Unit)? = null, // 左侧布局
|
||||
enabled: Boolean = true,
|
||||
inputType: InputType = InputType.Text,
|
||||
hasNext: Boolean = true,
|
||||
isInitUpdate: Boolean = false,
|
||||
inputType: InputType = InputType.Text, // 输入类型
|
||||
hasNext: Boolean = true, // 键盘显示下一个
|
||||
isInitUpdate: Boolean = false, // 是否需要根据原始数据变动
|
||||
keyboardOptions: KeyboardOptions? = null,
|
||||
keyboardActions: KeyboardActions? = null
|
||||
keyboardActions: KeyboardActions? = null,
|
||||
onClick: () -> Unit = {}, // 点击
|
||||
) {
|
||||
val containerColor = if (enabled) Color.Transparent else Gray_DCDCF0
|
||||
// var inputValue by remember { mutableStateOf(value) }
|
||||
@@ -109,8 +115,8 @@ fun CustomTextField(
|
||||
}
|
||||
val focusManager = LocalFocusManager.current
|
||||
|
||||
fun onEditingComplete() {
|
||||
Timber.d("onEditingComplete inputValue = $inputValue")
|
||||
fun onEditingComplete(isFocus: Boolean) {
|
||||
Timber.d("onEditingComplete inputValue = $inputValue, isFocus = $isFocus")
|
||||
onValueChange(inputValue)
|
||||
}
|
||||
|
||||
@@ -133,20 +139,20 @@ fun CustomTextField(
|
||||
InputType.Number -> {
|
||||
if (newValue.isEmpty() || newValue.isValidNumber()) {
|
||||
inputValue = newValue
|
||||
onEditingComplete()
|
||||
onEditingComplete(true)
|
||||
}
|
||||
}
|
||||
|
||||
InputType.Decimal -> {
|
||||
if (newValue.isEmpty() || newValue.isValidFloat()) {
|
||||
inputValue = newValue
|
||||
onEditingComplete()
|
||||
onEditingComplete(true)
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
inputValue = newValue
|
||||
onEditingComplete()
|
||||
onEditingComplete(true)
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -159,9 +165,11 @@ fun CustomTextField(
|
||||
color = Gray_DCDCF0,
|
||||
shape = RoundedCornerShape(10.dp)
|
||||
)
|
||||
.clickable(onClick = onClick)
|
||||
// .focusable()
|
||||
.onFocusChanged(onFocusChanged = { focusState ->
|
||||
{
|
||||
onEditingComplete()
|
||||
onEditingComplete(focusState.isFocused)
|
||||
}
|
||||
}),
|
||||
colors = TextFieldDefaults.colors(
|
||||
@@ -187,23 +195,25 @@ fun CustomTextField(
|
||||
leadingIcon = leadingIcon,
|
||||
trailingIcon = trailingLabel?.let { label ->
|
||||
{
|
||||
Text(
|
||||
text = trailingLabel,
|
||||
modifier = Modifier
|
||||
.fillMaxHeight()
|
||||
.wrapContentHeight(Alignment.CenterVertically),
|
||||
style = AppTypography.gray96a0aaTextStyle
|
||||
)
|
||||
Box(modifier = Modifier.padding(start = 10.dp, end = 20.dp)) {
|
||||
Text(
|
||||
text = trailingLabel,
|
||||
modifier = Modifier
|
||||
.fillMaxHeight()
|
||||
.wrapContentHeight(Alignment.CenterVertically),
|
||||
style = AppTypography.gray96a0aaTextStyle
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
keyboardOptions = keyboardOptions
|
||||
?: KeyboardOptions.Default.copy(imeAction = if (hasNext) ImeAction.Next else ImeAction.Done),
|
||||
keyboardActions = keyboardActions ?: KeyboardActions(onNext = {
|
||||
focusManager.moveFocus(focusDirection = FocusDirection.Next)
|
||||
onEditingComplete()
|
||||
onEditingComplete(false)
|
||||
}, onDone = {
|
||||
focusManager.clearFocus()
|
||||
onEditingComplete()
|
||||
onEditingComplete(false)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
package com.sw.inbound.ui.weight
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import com.sw.inbound.ext.withColor
|
||||
import com.sw.inbound.network.LoadingState
|
||||
import com.sw.inbound.ui.theme.AppTypography
|
||||
|
||||
@Composable
|
||||
fun GlobalLoading() {
|
||||
@@ -22,10 +27,16 @@ fun GlobalLoading() {
|
||||
dismissOnClickOutside = false
|
||||
)
|
||||
) {
|
||||
Column {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
CircularProgressIndicator(modifier = Modifier)
|
||||
Spacer(modifier = Modifier.height(20.dp))
|
||||
Text(text = "请稍等...")
|
||||
Text(
|
||||
text = "请稍等...",
|
||||
style = AppTypography.grayTextStyle.withColor(color = Color.White)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-22
@@ -13,16 +13,13 @@ import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.sw.inbound.R
|
||||
import com.sw.inbound.ext.bold
|
||||
@@ -30,9 +27,11 @@ import com.sw.inbound.model.response.GoodsInfo
|
||||
import com.sw.inbound.ui.theme.AppTypography
|
||||
import com.sw.inbound.ui.theme.Gray_DCDCF0
|
||||
|
||||
|
||||
/**
|
||||
* 收货-未调整列表
|
||||
*/
|
||||
@Composable
|
||||
fun ProductListView(
|
||||
fun ReceiptUnadjustedListView(
|
||||
modifier: Modifier = Modifier,
|
||||
productList: List<GoodsInfo>,
|
||||
checkedItem: GoodsInfo? = null,
|
||||
@@ -141,21 +140,4 @@ fun ProductListView(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CustomSingleRightText(
|
||||
modifier: Modifier,
|
||||
text: String,
|
||||
style: TextStyle = AppTypography.blackTextStyle,
|
||||
textAlign: TextAlign = TextAlign.End
|
||||
) {
|
||||
Text(
|
||||
modifier = modifier,
|
||||
text = text,
|
||||
textAlign = textAlign,
|
||||
style = style,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
+5
-5
@@ -23,16 +23,16 @@ import com.sw.inbound.ui.theme.AppTypography
|
||||
*/
|
||||
@Composable
|
||||
fun RowInputLayout(
|
||||
label: String,
|
||||
label: String, // 左侧文字
|
||||
value: String,
|
||||
onValueChange: (String) -> Unit,
|
||||
dropdownItems: List<DictType>? = null,
|
||||
hasNext: Boolean = true,
|
||||
dropdownItems: List<DictType>? = null, // 下拉列表
|
||||
hasNext: Boolean = true, // 键盘显示下一步
|
||||
inputType: InputType = InputType.Text,
|
||||
trailingLabel: String? = null,
|
||||
trailingLabel: String? = null, // 尾部文字
|
||||
keyboardOptions: KeyboardOptions? = null,
|
||||
keyboardActions: KeyboardActions? = null,
|
||||
isInitUpdate: Boolean = false
|
||||
isInitUpdate: Boolean = false // 是否根据原始数据更新
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
@@ -13,16 +13,13 @@ import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.sw.inbound.R
|
||||
import com.sw.inbound.ext.bold
|
||||
@@ -30,7 +27,9 @@ import com.sw.inbound.model.request.PurchaseWarehouseParam
|
||||
import com.sw.inbound.ui.theme.AppTypography
|
||||
import com.sw.inbound.ui.theme.Gray_DCDCF0
|
||||
|
||||
|
||||
/**
|
||||
* 自采购 左侧列表
|
||||
*/
|
||||
@Composable
|
||||
fun SelfProcurementListItem(
|
||||
modifier: Modifier = Modifier,
|
||||
@@ -141,21 +140,4 @@ fun SelfProcurementListItem(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CustomSingleRightText(
|
||||
modifier: Modifier,
|
||||
text: String,
|
||||
style: TextStyle = AppTypography.blackTextStyle,
|
||||
textAlign: TextAlign = TextAlign.End
|
||||
) {
|
||||
Text(
|
||||
modifier = modifier,
|
||||
text = text,
|
||||
textAlign = textAlign,
|
||||
style = style,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
@@ -52,6 +52,9 @@ fun testSingleGroup() {
|
||||
// SingleSelectButtonGroup(list)
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索结果列表,可选中
|
||||
*/
|
||||
@Composable
|
||||
fun SingleSelectButtonGroup(
|
||||
options: List<SearchGoodsInfo.Record>,
|
||||
@@ -65,15 +68,15 @@ fun SingleSelectButtonGroup(
|
||||
var selectedOption by remember { mutableStateOf(options.firstOrNull() ?: "") }
|
||||
|
||||
// 定义颜色
|
||||
val selectedColor = Color(0xFFD9E3F9) // 选中颜色 #D9E3F9
|
||||
val unselectedColor = Color(0xFFDCDCF0) // 未选中颜色 #DCDCF0
|
||||
val selectedColor = Color(0xFFD9E3F9)
|
||||
val unselectedColor = Color(0xFFDCDCF0)
|
||||
|
||||
LazyVerticalGrid(
|
||||
columns = GridCells.Fixed(2), // 每行2列
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(horizontalSpacing), // 水平间距13dp
|
||||
verticalArrangement = Arrangement.spacedBy(verticalSpacing) // 垂直间距13dp
|
||||
horizontalArrangement = Arrangement.spacedBy(horizontalSpacing),
|
||||
verticalArrangement = Arrangement.spacedBy(verticalSpacing)
|
||||
) {
|
||||
items(items = options) { option ->
|
||||
Box(
|
||||
@@ -90,7 +93,7 @@ fun SingleSelectButtonGroup(
|
||||
onOptionSelected(option)
|
||||
},
|
||||
contentAlignment = Alignment.Center
|
||||
// .padding(vertical = 20.dp) // 垂直内边距
|
||||
// .padding(vertical = 20.dp)
|
||||
) {
|
||||
Text(
|
||||
text = option.goodsNameStr,
|
||||
|
||||
@@ -42,6 +42,9 @@ import kotlinx.coroutines.delay
|
||||
heightDp = 1080,
|
||||
showBackground = true
|
||||
)
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@Composable
|
||||
fun TopTitleBar(
|
||||
modifier: Modifier = Modifier,
|
||||
|
||||
@@ -33,6 +33,9 @@ import com.sw.inbound.ui.theme.AppTypography
|
||||
import com.sw.inbound.ui.weight.CustomButton
|
||||
import com.sw.inbound.ui.weight.CustomOutlinedButton
|
||||
|
||||
/**
|
||||
* 收货确认弹窗
|
||||
*/
|
||||
@Composable
|
||||
fun ReceiptTipDialog(
|
||||
modifier: Modifier = Modifier,
|
||||
|
||||
Reference in New Issue
Block a user