添加了副屏显示逻辑控制
This commit is contained in:
@@ -27,16 +27,12 @@ class UserViewModel : BaseViewModel() {
|
||||
private val faceApi: FaceApi = FaceApi()
|
||||
|
||||
// 识别出的列表
|
||||
private val _identifiedFoodInfoList = MutableStateFlow<List<FoodInfo>?>(null)
|
||||
val identifiedFoodInfoList: StateFlow<List<FoodInfo>?> = _identifiedFoodInfoList
|
||||
private val _identifiedFoodInfoList = MutableStateFlow<List<FoodInfo>>(emptyList())
|
||||
val identifiedFoodInfoList: StateFlow<List<FoodInfo>> = _identifiedFoodInfoList
|
||||
|
||||
// 搜索出的食物列表
|
||||
private val _foodInfoList = MutableStateFlow<List<FoodInfo>?>(null)
|
||||
val foodInfoList: StateFlow<List<FoodInfo>?> = _foodInfoList
|
||||
|
||||
// 当前食物信息
|
||||
private val _currentFoodInfo = MutableStateFlow<FoodInfo?>(null)
|
||||
val currentFoodInfo: StateFlow<FoodInfo?> = _currentFoodInfo
|
||||
private val _searchFoodInfoList = MutableStateFlow<List<FoodInfo>>(emptyList())
|
||||
val searchFoodInfoList: StateFlow<List<FoodInfo>> = _searchFoodInfoList
|
||||
|
||||
// 就餐数据
|
||||
private val _nutritionData = MutableStateFlow<NutritionData?>(null)
|
||||
@@ -46,6 +42,7 @@ class UserViewModel : BaseViewModel() {
|
||||
* 获取token
|
||||
*/
|
||||
fun getEquipmentToken(qrcodeId: String = "3ea47dc0-3cf0-3c2f-909c-265a9a65572e") {
|
||||
Timber.d("getEquipmentToken")
|
||||
launchWithLoading {
|
||||
val response = repository.getEquipmentToken(qrcodeId)
|
||||
if (parseResponse(response)) {
|
||||
@@ -131,35 +128,49 @@ class UserViewModel : BaseViewModel() {
|
||||
Timber.d("resetUserInfo")
|
||||
}
|
||||
|
||||
fun identifiedFoodList() {
|
||||
fun getIdentifiedFoodList() {
|
||||
Timber.d("identifiedFoodList")
|
||||
launchWithLoading {
|
||||
delay(5000)
|
||||
_identifiedFoodInfoList.value = List(6) {
|
||||
FoodInfo(
|
||||
id = "185225109358109491${it}",
|
||||
foodName = "豆芽炒粉条$it",
|
||||
imgUrl = "http://101.201.149.156:9002/temp/20221119/62dc2d17-6853-4277-96ed-a4ef4c8654ea_1668840050258.png"
|
||||
imgUrl = "http://101.201.149.156:9002/temp/20230912/f54b2d76-45e1-4c6b-a7a0-5fd1eace99d1_1694484601879.png"
|
||||
)
|
||||
}
|
||||
// _currentFoodInfo.value = _identifiedFoodInfoList.value[0]
|
||||
}
|
||||
}
|
||||
|
||||
fun cleanIdentifiedFoodInfoList() {
|
||||
Timber.d("cleanIdentifiedFoodInfoList")
|
||||
_identifiedFoodInfoList.value = emptyList<FoodInfo>()
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索食物
|
||||
*/
|
||||
fun searchByFoodName(foodName: String) {
|
||||
Timber.d("searchByFoodName foodName = $foodName")
|
||||
launchWithLoading {
|
||||
val response = repository.getRestInfoFoodsByType(foodName = foodName)
|
||||
if (parseResponse(response)) {
|
||||
_foodInfoList.value = response.result
|
||||
_searchFoodInfoList.value = response.result ?: emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun cleanSearchFoodInfoList() {
|
||||
Timber.d("cleanSearchFoodInfoList")
|
||||
_searchFoodInfoList.value = emptyList<FoodInfo>()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户就餐数据
|
||||
*/
|
||||
fun getUserNutritionData(userId: String, foodId: String) {
|
||||
Timber.d("getUserNutritionData userId = ${userId}, foodId = $foodId")
|
||||
launchWithLoading {
|
||||
val response = repository.getUserNutritionData(userId = userId, foodId = foodId)
|
||||
if (parseResponse(response)) {
|
||||
@@ -172,6 +183,7 @@ class UserViewModel : BaseViewModel() {
|
||||
* 提交就餐数据
|
||||
*/
|
||||
fun postUserNutritionData(param: UserNutritionParam) {
|
||||
Timber.d("postUserNutritionData param = $param")
|
||||
launchWithLoading {
|
||||
val response = repository.postUserNutritionData(param)
|
||||
if (parseResponse(response)) {
|
||||
|
||||
Reference in New Issue
Block a user