fix: 食物识别编辑框删除bug + VLM相关代码回滚
- 修复饮食识别结果编辑框一次只能删一个字的bug(控制器缓存) - 回滚VLM图片压缩代码到原始状态 - 保持原有显示逻辑不变
This commit is contained in:
@@ -593,6 +593,7 @@ class _DietCapturePageState extends ConsumerState<DietCapturePage> {
|
||||
(v) => ref
|
||||
.read(dietProvider.notifier)
|
||||
.updateFoodName(food.id, v),
|
||||
fieldKey: '${food.id}_name',
|
||||
style: const TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -608,6 +609,7 @@ class _DietCapturePageState extends ConsumerState<DietCapturePage> {
|
||||
(v) => ref
|
||||
.read(dietProvider.notifier)
|
||||
.updateFoodPortion(food.id, v),
|
||||
fieldKey: '${food.id}_portion',
|
||||
hint: '份量',
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
@@ -629,6 +631,7 @@ class _DietCapturePageState extends ConsumerState<DietCapturePage> {
|
||||
food.id,
|
||||
int.tryParse(v) ?? 0,
|
||||
),
|
||||
fieldKey: '${food.id}_cal',
|
||||
hint: '0',
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
@@ -664,16 +667,26 @@ class _DietCapturePageState extends ConsumerState<DietCapturePage> {
|
||||
);
|
||||
}
|
||||
|
||||
final Map<String, TextEditingController> _fieldCtrls = {};
|
||||
|
||||
TextEditingController _ctrlFor(String key, String value) {
|
||||
if (_fieldCtrls.containsKey(key)) return _fieldCtrls[key]!;
|
||||
final c = TextEditingController(text: value);
|
||||
_fieldCtrls[key] = c;
|
||||
return c;
|
||||
}
|
||||
|
||||
Widget _compactField(
|
||||
String value,
|
||||
ValueChanged<String> cb, {
|
||||
required String fieldKey,
|
||||
String? hint,
|
||||
TextStyle? style,
|
||||
TextAlign align = TextAlign.start,
|
||||
TextInputType? keyboardType,
|
||||
}) {
|
||||
return TextField(
|
||||
controller: TextEditingController(text: value),
|
||||
controller: _ctrlFor(fieldKey, value),
|
||||
onChanged: cb,
|
||||
keyboardType: keyboardType,
|
||||
textAlign: align,
|
||||
|
||||
Reference in New Issue
Block a user