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();
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter_common/utils/toast_util.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:food_hub_app/apis/session.dart';
|
||||
import 'package:food_hub_app/models/session.dart';
|
||||
import 'package:food_hub_app/widgets/common/form.dart';
|
||||
import 'package:food_hub_app/widgets/common/index.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
|
||||
@@ -85,7 +86,6 @@ class _LoginPage extends State<LoginPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey[100],
|
||||
body: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
@@ -145,7 +145,8 @@ class _LoginPage extends State<LoginPage> {
|
||||
name: 'username',
|
||||
initialValue: _username,
|
||||
keyboardType: TextInputType.text,
|
||||
decoration: formInputDecoration(
|
||||
decoration: buildInputDecoration(
|
||||
context: context,
|
||||
hintText: "请输入账号",
|
||||
prefixIcon: Icons.person,
|
||||
),
|
||||
@@ -169,22 +170,18 @@ class _LoginPage extends State<LoginPage> {
|
||||
obscureText: _isObscure,
|
||||
onSaved: (v) => _password = v!,
|
||||
validator: FormBuilderValidators.required(),
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: Icon(Icons.lock),
|
||||
decoration: buildInputDecoration(
|
||||
context: context,
|
||||
hintText: "请输入密码",
|
||||
hintStyle: TextStyle(color: Colors.grey),
|
||||
border: OutlineInputBorder(),
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
prefixIcon: Icons.lock,
|
||||
).copyWith(
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(Icons.remove_red_eye, color: _eyeColor),
|
||||
onPressed: () {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
setState(() {
|
||||
_isObscure = !_isObscure;
|
||||
_eyeColor =
|
||||
(_isObscure
|
||||
? Colors.grey
|
||||
: Theme.of(context).iconTheme.color)!;
|
||||
_eyeColor = (_isObscure ? Colors.grey : colors.surface);
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
@@ -52,7 +52,11 @@ class _MomentFormPageState extends State<MomentFormPage> {
|
||||
provider.momentFormItem.content = value!;
|
||||
});
|
||||
},
|
||||
decoration: buildInputDecoration(context: context, hintText: '请输入朋友圈内容'),
|
||||
decoration: buildInputDecoration(
|
||||
context: context,
|
||||
hintText: '请输入朋友圈内容',
|
||||
prefixIcon: Icons.article,
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return '请输入朋友圈内容';
|
||||
@@ -90,7 +94,10 @@ class _MomentFormPageState extends State<MomentFormPage> {
|
||||
}
|
||||
// 上传按钮(最后一个)
|
||||
else {
|
||||
return buildImageUploadButton(onTap: () => _pickImages(provider));
|
||||
return buildImageUploadButton(
|
||||
context: context,
|
||||
onTap: () => _pickImages(provider),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -104,19 +111,21 @@ class _MomentFormPageState extends State<MomentFormPage> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
buildFormLabel('朋友圈内容', required: true),
|
||||
buildFormLabel(context: context, text: '朋友圈内容', isRequired: true),
|
||||
const SizedBox(height: 8),
|
||||
_buildContentField(provider),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
buildFormLabel('上传图片', required: true),
|
||||
buildFormLabel(context: context, text: '上传图片', isRequired: true),
|
||||
const SizedBox(height: 8),
|
||||
_buildImageField(provider),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
buildFormButtonGroup(
|
||||
context: context,
|
||||
isShowDelete: provider.isEditing,
|
||||
onConfirm: () => _submitForm(provider),
|
||||
onDelete: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_common/utils/minio_utils.dart';
|
||||
import 'package:flutter_common/utils/toast_util.dart';
|
||||
import 'package:flutter_common/widget/common_widget.dart';
|
||||
import 'package:flutter_common/widget/dialog_widget.dart';
|
||||
import 'package:flutter_common/widget/loading_widget.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:food_hub_app/apis/recipe.dart';
|
||||
import 'package:food_hub_app/config/app_config.dart';
|
||||
@@ -40,32 +42,32 @@ class _RecordFormPageState extends State<RecordFormPage> {
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildFormBuilder() {
|
||||
final provider = context.watch<FoodProvider>();
|
||||
|
||||
Widget _buildFormBuilder(FoodProvider provider) {
|
||||
return FormBuilder(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
buildFormLabel('菜谱名称', required: true),
|
||||
buildFormLabel(context: context, text: '菜谱名称', isRequired: true),
|
||||
const SizedBox(height: 8),
|
||||
_buildRecipeField(provider),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
buildFormLabel('完成时间', required: true),
|
||||
buildFormLabel(context: context, text: '完成时间', isRequired: true),
|
||||
const SizedBox(height: 8),
|
||||
_buildDateField(provider),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
buildFormLabel('上传图片', required: true),
|
||||
buildFormLabel(context: context, text: '上传图片', isRequired: true),
|
||||
const SizedBox(height: 8),
|
||||
_buildImageField(provider),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
buildFormButtonGroup(
|
||||
context: context,
|
||||
isShowDelete: provider.isEditing,
|
||||
onConfirm: () => _submitForm(provider),
|
||||
onDelete: () => _deleteForm(provider),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -87,7 +89,7 @@ class _RecordFormPageState extends State<RecordFormPage> {
|
||||
},
|
||||
|
||||
onSelected: (String value) {
|
||||
provider.recordFormItem.name = value;
|
||||
provider.updateRecordFormItem(name: value);
|
||||
},
|
||||
|
||||
optionsViewBuilder: (
|
||||
@@ -114,6 +116,7 @@ class _RecordFormPageState extends State<RecordFormPage> {
|
||||
elevation: 2,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Container(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: 200,
|
||||
maxWidth: MediaQuery.of(context).size.width - 58,
|
||||
@@ -146,7 +149,7 @@ class _RecordFormPageState extends State<RecordFormPage> {
|
||||
|
||||
void onClearRecipeName() {
|
||||
controller.clear();
|
||||
provider.recordFormItem.name = '';
|
||||
provider.updateRecordFormItem(name: '');
|
||||
}
|
||||
|
||||
Widget? buildSuffixIcon() {
|
||||
@@ -166,16 +169,12 @@ class _RecordFormPageState extends State<RecordFormPage> {
|
||||
focusNode: focusNode,
|
||||
enabled: !provider.isEditing,
|
||||
onChanged: (value) {
|
||||
provider.recordFormItem.name = value ?? '';
|
||||
provider.updateRecordFormItem(name: value ?? '');
|
||||
},
|
||||
decoration: buildInputDecoration(
|
||||
context: context,
|
||||
hintText: '请输入菜谱名称',
|
||||
prefixIcon: const Icon(
|
||||
Icons.restaurant_menu,
|
||||
size: 20,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
prefixIcon: Icons.restaurant_menu,
|
||||
).copyWith(suffixIcon: buildSuffixIcon()),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
@@ -196,11 +195,7 @@ class _RecordFormPageState extends State<RecordFormPage> {
|
||||
decoration: buildInputDecoration(
|
||||
context: context,
|
||||
hintText: '请选择完成时间',
|
||||
prefixIcon: const Icon(
|
||||
Icons.calendar_month,
|
||||
size: 20,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
prefixIcon: Icons.calendar_month,
|
||||
),
|
||||
onTap: () => _onSelectDate(provider),
|
||||
validator: (value) {
|
||||
@@ -224,7 +219,7 @@ class _RecordFormPageState extends State<RecordFormPage> {
|
||||
if (picked != null) {
|
||||
final String date = DateFormat('yyyy-MM-dd').format(picked);
|
||||
_formKey.currentState?.fields[_dateField]?.didChange(date);
|
||||
provider.recordFormItem.date = date;
|
||||
provider.updateRecordFormItem(date: date);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +228,10 @@ class _RecordFormPageState extends State<RecordFormPage> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (provider.recordFormItem.imageUrl.isEmpty)
|
||||
buildImageUploadButton(onTap: () => _pickImage(provider))
|
||||
buildImageUploadButton(
|
||||
context: context,
|
||||
onTap: () => _pickImage(provider),
|
||||
)
|
||||
else
|
||||
ImagePreview(
|
||||
imageUrls: [provider.recordFormItem.imageUrl],
|
||||
@@ -254,22 +252,21 @@ class _RecordFormPageState extends State<RecordFormPage> {
|
||||
|
||||
if (result != null) {
|
||||
PlatformFile file = result.files.first;
|
||||
LoadingDialog.show(context, message: '上传中');
|
||||
|
||||
final fileName = await MinIOHelper().uploadFile(
|
||||
bucketName: AppConfig.bucketName,
|
||||
file: file,
|
||||
);
|
||||
|
||||
setState(() {
|
||||
provider.recordFormItem.imageUrl = fileName;
|
||||
});
|
||||
LoadingDialog.hide(context);
|
||||
provider.updateRecordFormItem(imageUrl: fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/// 移除图片
|
||||
void _removeImage(FoodProvider provider) {
|
||||
setState(() {
|
||||
provider.recordFormItem.imageUrl = '';
|
||||
});
|
||||
provider.updateRecordFormItem(imageUrl: '');
|
||||
}
|
||||
|
||||
/// 提交表单
|
||||
@@ -280,10 +277,44 @@ class _RecordFormPageState extends State<RecordFormPage> {
|
||||
return;
|
||||
}
|
||||
|
||||
await provider.handleRecord();
|
||||
LoadingDialog.show(context, message: '提交中');
|
||||
final result = await provider.handleRecord();
|
||||
if (result == true) {
|
||||
await provider.onRecordTabChange();
|
||||
LoadingDialog.hide(context);
|
||||
|
||||
if (provider.isEditing) {
|
||||
showSuccessTip(context, '更新记录成功');
|
||||
} else {
|
||||
showSuccessTip(context, '新增记录成功');
|
||||
}
|
||||
|
||||
Future.delayed(Duration(milliseconds: 1500), () {
|
||||
if (mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _deleteForm(FoodProvider provider) async {
|
||||
final result = await showConfirmDialog(context, '确认删除该记录?');
|
||||
if (result == true) {
|
||||
LoadingDialog.show(context, message: '删除中');
|
||||
final isDelete = await provider.deleteRecord();
|
||||
if (isDelete) {
|
||||
await provider.onRecordTabChange();
|
||||
LoadingDialog.hide(context);
|
||||
showSuccessTip(context, '删除记录成功');
|
||||
|
||||
Future.delayed(Duration(milliseconds: 1500), () {
|
||||
if (mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -305,7 +336,7 @@ class _RecordFormPageState extends State<RecordFormPage> {
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: CommonCard(child: _buildFormBuilder()),
|
||||
child: CommonCard(child: _buildFormBuilder(provider)),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -4,50 +4,54 @@ import 'package:flutter/material.dart';
|
||||
InputDecoration buildInputDecoration({
|
||||
required BuildContext context,
|
||||
required String hintText,
|
||||
Widget? prefixIcon,
|
||||
required IconData prefixIcon,
|
||||
}) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return InputDecoration(
|
||||
hintText: hintText,
|
||||
hintStyle: const TextStyle(
|
||||
color: Color(0xFF999999),
|
||||
fontSize: 15,
|
||||
height: 1.2,
|
||||
),
|
||||
hintStyle: TextStyle(color: colors.onSurface.withAlpha(100)),
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
fillColor: colors.surface,
|
||||
border: OutlineInputBorder(
|
||||
borderSide: const BorderSide(color: Color(0xFFE5E7EB)),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Theme.of(context).primaryColor, width: 1.5),
|
||||
borderSide: BorderSide(color: colors.primary, width: 2),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderSide: const BorderSide(color: Colors.red, width: 1.5),
|
||||
borderSide: const BorderSide(color: Colors.red, width: 2),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 15, vertical: 14),
|
||||
errorStyle: const TextStyle(fontSize: 12, height: 1, color: Colors.red),
|
||||
prefixIcon: prefixIcon,
|
||||
prefixIcon: Icon(prefixIcon, size: 20, color: Color(0xFF86909C)),
|
||||
prefixIconConstraints: const BoxConstraints(minWidth: 40),
|
||||
isDense: true,
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildFormLabel(String text, {bool required = false}) {
|
||||
Widget buildFormLabel({
|
||||
required BuildContext context,
|
||||
required String text,
|
||||
required bool isRequired,
|
||||
}) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return RichText(
|
||||
text: TextSpan(
|
||||
text: text,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF1D2129),
|
||||
style: TextStyle(
|
||||
color: colors.onSurface,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontFamily: 'CustomFont',
|
||||
height: 1.2,
|
||||
),
|
||||
children: [
|
||||
if (required)
|
||||
if (isRequired)
|
||||
const TextSpan(
|
||||
text: ' *',
|
||||
style: TextStyle(color: Colors.red, fontSize: 16),
|
||||
@@ -60,12 +64,19 @@ Widget buildFormLabel(String text, {bool required = false}) {
|
||||
/// 表单底部按钮组组件
|
||||
Widget buildFormButtonGroup({
|
||||
required BuildContext context,
|
||||
required bool isShowDelete,
|
||||
required VoidCallback onConfirm,
|
||||
required VoidCallback onDelete,
|
||||
}) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: _buildCancelButton(context)),
|
||||
const SizedBox(width: 16),
|
||||
if (isShowDelete) ...[
|
||||
SizedBox(width: 16),
|
||||
Expanded(child: _buildDeleteButton(context, onDelete)),
|
||||
],
|
||||
SizedBox(width: 16),
|
||||
Expanded(child: _buildSubmitButton(context, onConfirm)),
|
||||
],
|
||||
);
|
||||
@@ -76,9 +87,8 @@ Widget _buildCancelButton(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
onPressed: () => Navigator.pop(context), // 直接使用传入的context返回
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
foregroundColor: const Color(0xFF4E5969),
|
||||
side: const BorderSide(color: Color(0xFFDCDFE6)),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
elevation: 0,
|
||||
),
|
||||
@@ -98,3 +108,16 @@ Widget _buildSubmitButton(BuildContext context, VoidCallback onConfirm) {
|
||||
child: const Text('提交', style: TextStyle(color: Colors.white)),
|
||||
);
|
||||
}
|
||||
|
||||
/// 删除按钮
|
||||
Widget _buildDeleteButton(BuildContext context, VoidCallback onDelete) {
|
||||
return ElevatedButton(
|
||||
onPressed: () => onDelete(),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
elevation: 0,
|
||||
),
|
||||
child: const Text('删除', style: TextStyle(color: Colors.white)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -203,7 +203,12 @@ class ImagePreview extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
Widget buildImageUploadButton({required VoidCallback onTap}) {
|
||||
Widget buildImageUploadButton({
|
||||
required BuildContext context,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
@@ -211,16 +216,16 @@ Widget buildImageUploadButton({required VoidCallback onTap}) {
|
||||
width: 96,
|
||||
height: 96,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: colors.surface,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: Colors.black),
|
||||
),
|
||||
child: const Column(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.add, color: Color(0xFF86909C)),
|
||||
Icon(Icons.add, color: colors.onSurface.withAlpha(100)),
|
||||
SizedBox(height: 6),
|
||||
Text('添加图片', style: TextStyle(color: Color(0xFF86909C))),
|
||||
Text('添加图片', style: TextStyle(color: colors.onSurface.withAlpha(100))),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -146,37 +146,41 @@ class _RecipeCalendarState extends State<RecipeCalendar> {
|
||||
bool isToday,
|
||||
FoodProvider provider,
|
||||
) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
// 检查当前日期是否在需要显示红点的列表中
|
||||
bool shouldShowRedDot = provider.recordList.any(
|
||||
(item) => item.date == formatDateTime(day),
|
||||
);
|
||||
|
||||
late Color boxColor;
|
||||
if (isSelected) {
|
||||
boxColor = colors.secondary;
|
||||
} else {
|
||||
boxColor = isToday ? colors.primary : Colors.transparent;
|
||||
}
|
||||
|
||||
late Color textColor;
|
||||
if (isSelected) {
|
||||
textColor = colors.surface;
|
||||
} else {
|
||||
textColor = isToday ? colors.surface : colors.onSurface;
|
||||
}
|
||||
|
||||
return Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
margin: EdgeInsets.all(2),
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
isSelected
|
||||
? Theme.of(context).primaryColor
|
||||
: isToday
|
||||
? Colors.grey[300]
|
||||
: Colors.transparent,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
decoration: BoxDecoration(color: boxColor, shape: BoxShape.circle),
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
// 日期数字
|
||||
Text(
|
||||
day.day.toString(),
|
||||
style: TextStyle(color: isSelected ? Colors.white : Colors.black),
|
||||
),
|
||||
// 底部红点 - 只在指定日期显示
|
||||
// 日期数字始终居中
|
||||
Text(day.day.toString(), style: TextStyle(color: textColor)),
|
||||
|
||||
// 红点
|
||||
if (shouldShowRedDot)
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 2),
|
||||
Align(
|
||||
alignment: Alignment(0, 0.8),
|
||||
child: Container(
|
||||
width: 6,
|
||||
height: 6,
|
||||
decoration: BoxDecoration(
|
||||
@@ -184,6 +188,7 @@ class _RecipeCalendarState extends State<RecipeCalendar> {
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -31,7 +31,6 @@ class _RecipeListState extends State<RecipeList> {
|
||||
decoration: BoxDecoration(
|
||||
color: colors.surfaceContainer,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.grey[200]!),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
child: DropdownButton<String>(
|
||||
@@ -64,15 +63,28 @@ class _RecipeListState extends State<RecipeList> {
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
provider.queryCategory = value!;
|
||||
provider.refreshRecipeList();
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRecipeList(FoodProvider provider) {
|
||||
return GridView.builder(
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
crossAxisSpacing: 8,
|
||||
mainAxisSpacing: 8,
|
||||
childAspectRatio: 0.9,
|
||||
),
|
||||
itemCount: provider.recipeSummaryList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return RecipeCard(recipe: provider.recipeSummaryList[index]);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContent(FoodProvider provider) {
|
||||
if (provider.recipeSummaryList.isEmpty) {
|
||||
return buildEmptyData();
|
||||
@@ -81,20 +93,7 @@ class _RecipeListState extends State<RecipeList> {
|
||||
children: [
|
||||
_buildSelectCategory(provider),
|
||||
SizedBox(height: 5),
|
||||
Expanded(
|
||||
child: GridView.builder(
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2, // 每行2个
|
||||
crossAxisSpacing: 8, // 水平间距
|
||||
mainAxisSpacing: 8, // 垂直间距
|
||||
childAspectRatio: 0.9,
|
||||
),
|
||||
itemCount: provider.recipeSummaryList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return RecipeCard(recipe: provider.recipeSummaryList[index]);
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(child: _buildRecipeList(provider)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -56,20 +56,17 @@ class _RecipeTimeline extends State<RecipeTimeline> {
|
||||
if (recordList.isEmpty) {
|
||||
return buildEmptyData();
|
||||
} else {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return Timeline.tileBuilder(
|
||||
theme: TimelineThemeData(nodePosition: 0, indicatorPosition: 0),
|
||||
builder: TimelineTileBuilder.connected(
|
||||
itemCount: recordList.length,
|
||||
connectorBuilder:
|
||||
(context, index, type) => Connector.solidLine(
|
||||
thickness: 2,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
(context, index, type) =>
|
||||
Connector.solidLine(thickness: 2, color: colors.primary),
|
||||
indicatorBuilder: (context, index) {
|
||||
return Indicator.dot(
|
||||
size: 12.0,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
);
|
||||
return Indicator.dot(size: 12.0, color: colors.primary);
|
||||
},
|
||||
contentsBuilder: (context, index) {
|
||||
return Padding(
|
||||
|
||||
@@ -7,12 +7,16 @@
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <file_selector_linux/file_selector_plugin.h>
|
||||
#include <rive_native/rive_native_plugin.h>
|
||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
|
||||
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
|
||||
g_autoptr(FlPluginRegistrar) rive_native_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "RiveNativePlugin");
|
||||
rive_native_plugin_register_with_registrar(rive_native_registrar);
|
||||
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
||||
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
file_selector_linux
|
||||
rive_native
|
||||
url_launcher_linux
|
||||
)
|
||||
|
||||
|
||||
@@ -7,14 +7,18 @@ import Foundation
|
||||
|
||||
import file_picker
|
||||
import file_selector_macos
|
||||
import flutter_image_compress_macos
|
||||
import path_provider_foundation
|
||||
import rive_native
|
||||
import share_plus
|
||||
import shared_preferences_foundation
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
|
||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
||||
FlutterImageCompressMacosPlugin.register(with: registry.registrar(forPlugin: "FlutterImageCompressMacosPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
RiveNativePlugin.register(with: registry.registrar(forPlugin: "RiveNativePlugin"))
|
||||
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
}
|
||||
|
||||
72
pubspec.lock
72
pubspec.lock
@@ -33,6 +33,14 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.12.0"
|
||||
awesome_dialog:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: awesome_dialog
|
||||
sha256: "4c5821a0a637ceee022084e78c1b8237dd4b8bfca4dd24ac2484662a56707338"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.3.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -325,6 +333,54 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "10.0.1"
|
||||
flutter_image_compress:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_image_compress
|
||||
sha256: "51d23be39efc2185e72e290042a0da41aed70b14ef97db362a6b5368d0523b27"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.4.0"
|
||||
flutter_image_compress_common:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_image_compress_common
|
||||
sha256: c5c5d50c15e97dd7dc72ff96bd7077b9f791932f2076c5c5b6c43f2c88607bfb
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.6"
|
||||
flutter_image_compress_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_image_compress_macos
|
||||
sha256: "20019719b71b743aba0ef874ed29c50747461e5e8438980dfa5c2031898f7337"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.3"
|
||||
flutter_image_compress_ohos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_image_compress_ohos
|
||||
sha256: e76b92bbc830ee08f5b05962fc78a532011fcd2041f620b5400a593e96da3f51
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.0.3"
|
||||
flutter_image_compress_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_image_compress_platform_interface
|
||||
sha256: "579cb3947fd4309103afe6442a01ca01e1e6f93dc53bb4cbd090e8ce34a41889"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
flutter_image_compress_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_image_compress_web
|
||||
sha256: b9b141ac7c686a2ce7bb9a98176321e1182c9074650e47bb140741a44b6f5a96
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.1.5"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@@ -780,6 +836,22 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.5.0"
|
||||
rive:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: rive
|
||||
sha256: fc0abf65d03d1c9afaeb35be9e71c7cf04d2d1f76e94e69d2af1b3ba413cddf9
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.14.0-dev.14"
|
||||
rive_native:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: rive_native
|
||||
sha256: e9c7d36f19eb6d32f563825d4e9d5032b19a36d3ca3341641431035bca022d19
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.0.17"
|
||||
share_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
@@ -7,12 +7,15 @@
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <file_selector_windows/file_selector_windows.h>
|
||||
#include <rive_native/rive_native_plugin.h>
|
||||
#include <share_plus/share_plus_windows_plugin_c_api.h>
|
||||
#include <url_launcher_windows/url_launcher_windows.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
FileSelectorWindowsRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FileSelectorWindows"));
|
||||
RiveNativePluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("RiveNativePlugin"));
|
||||
SharePlusWindowsPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
|
||||
UrlLauncherWindowsRegisterWithRegistrar(
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
file_selector_windows
|
||||
rive_native
|
||||
share_plus
|
||||
url_launcher_windows
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user