添加位置浮动层测试,使用Airtest测试框架验证
This commit is contained in:
@@ -147,6 +147,9 @@ fun CameraScreen(
|
||||
Log.d("CameraScreen", "Getting location...")
|
||||
locationText = locationHelper.getLocationInfo()
|
||||
Log.d("CameraScreen", "Location result: $locationText")
|
||||
if (locationText.isEmpty()) {
|
||||
locationText = "定位失败"
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("CameraScreen", "Location error", e)
|
||||
locationText = "定位失败"
|
||||
@@ -154,7 +157,7 @@ fun CameraScreen(
|
||||
} else if (manualAddress.isNotBlank()) {
|
||||
locationText = manualAddress
|
||||
} else {
|
||||
locationText = ""
|
||||
locationText = "请授予定位权限"
|
||||
}
|
||||
isLocationLoading = false
|
||||
}
|
||||
@@ -198,6 +201,44 @@ fun CameraScreen(
|
||||
onDismissDialog = { showPermissionDeniedDialog = false }
|
||||
)
|
||||
}
|
||||
|
||||
// 位置信息浮动层(在外层显示,不受权限影响)
|
||||
if (isLocationLoading || locationText.isNotBlank()) {
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.align(Alignment.BottomCenter)
|
||||
.padding(bottom = 120.dp, start = 16.dp, end = 16.dp),
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = Color.Black.copy(alpha = 0.6f)
|
||||
)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
if (isLocationLoading) {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier.size(16.dp),
|
||||
color = Color.White,
|
||||
strokeWidth = 2.dp
|
||||
)
|
||||
} else {
|
||||
Icon(
|
||||
imageVector = Icons.Default.LocationOn,
|
||||
contentDescription = null,
|
||||
tint = Color.White,
|
||||
modifier = Modifier.size(16.dp)
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Text(
|
||||
text = if (isLocationLoading) "正在定位..." else locationText,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = Color.White
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,44 +326,6 @@ private fun CameraContent(
|
||||
isCapturing = isCapturing,
|
||||
modifier = Modifier.align(Alignment.BottomCenter)
|
||||
)
|
||||
|
||||
// 位置信息浮动层
|
||||
if (isLocationLoading || locationText.isNotBlank()) {
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.align(Alignment.BottomCenter)
|
||||
.padding(bottom = 120.dp, start = 16.dp, end = 16.dp),
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = Color.Black.copy(alpha = 0.6f)
|
||||
)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
if (isLocationLoading) {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier.size(16.dp),
|
||||
color = Color.White,
|
||||
strokeWidth = 2.dp
|
||||
)
|
||||
} else {
|
||||
Icon(
|
||||
imageVector = Icons.Default.LocationOn,
|
||||
contentDescription = null,
|
||||
tint = Color.White,
|
||||
modifier = Modifier.size(16.dp)
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Text(
|
||||
text = if (isLocationLoading) "正在定位..." else locationText,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = Color.White
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user