feat:更新主题色适配
This commit is contained in:
@@ -56,6 +56,13 @@ class FoodProvider with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void updateRecordFormItem({String? name, String? date, String? imageUrl}) {
|
||||
if (name != null) recordFormItem.name = name;
|
||||
if (date != null) recordFormItem.date = date;
|
||||
if (imageUrl != null) recordFormItem.imageUrl = imageUrl;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void resetMomentForm() {
|
||||
momentFormItem = Moment.getEmpty();
|
||||
notifyListeners();
|
||||
@@ -161,8 +168,8 @@ class FoodProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> handleRecord() async {
|
||||
if (isLoading) return;
|
||||
Future<bool> handleRecord() async {
|
||||
if (isLoading) return true;
|
||||
|
||||
try {
|
||||
isLoading = true;
|
||||
@@ -171,14 +178,34 @@ class FoodProvider with ChangeNotifier {
|
||||
|
||||
if (isEditing) {
|
||||
await updateRecordApi(recordFormItem.id!, recordFormItem);
|
||||
ToastUtil.success('更新记录成功');
|
||||
} else {
|
||||
await addRecordApi(recordFormItem);
|
||||
ToastUtil.success('上传记录成功');
|
||||
}
|
||||
return true;
|
||||
} catch (e) {
|
||||
error = '处理数据失败: $e';
|
||||
debugPrint('处理数据失败: $e');
|
||||
return false;
|
||||
} finally {
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> deleteRecord() async {
|
||||
if (isLoading) return true;
|
||||
|
||||
try {
|
||||
isLoading = true;
|
||||
error = null;
|
||||
notifyListeners();
|
||||
|
||||
await deleteRecordApi(recordFormItem.id!);
|
||||
return true;
|
||||
} catch (e) {
|
||||
error = '处理数据失败: $e';
|
||||
debugPrint('处理数据失败: $e');
|
||||
return false;
|
||||
} finally {
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
|
||||
Reference in New Issue
Block a user