feat:增加朋友圈组件
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:food_hub_app/api/moment.dart';
|
||||
import 'package:food_hub_app/models/moment.dart';
|
||||
import 'package:food_hub_app/widgets/moment/card.dart';
|
||||
import 'package:tdesign_flutter/tdesign_flutter.dart';
|
||||
|
||||
class MomentPage extends StatefulWidget {
|
||||
const MomentPage({super.key});
|
||||
@@ -7,9 +11,35 @@ class MomentPage extends StatefulWidget {
|
||||
State<MomentPage> createState() => _MomentPage();
|
||||
}
|
||||
|
||||
class _MomentPage extends State<MomentPage>{
|
||||
class _MomentPage extends State<MomentPage> {
|
||||
List<Moment> momentList = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
refreshRecipeList();
|
||||
}
|
||||
|
||||
Future<void> refreshRecipeList() async {
|
||||
final result = await queryMomentListApi();
|
||||
|
||||
setState(() {
|
||||
momentList = result;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Center(child: Text("朋友圈"));
|
||||
if (momentList.isEmpty) {
|
||||
return const TDEmpty(type: TDEmptyType.plain, emptyText: '暂无数据');
|
||||
} else {
|
||||
return ListView.builder(
|
||||
itemCount: momentList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return MomentCard(moment: momentList[index]);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:food_hub_app/widgets/recipe/recipe_calendar.dart';
|
||||
import 'package:food_hub_app/widgets/recipe/recipe_list.dart';
|
||||
import 'package:food_hub_app/widgets/recipe/recipe_timeline.dart';
|
||||
import 'package:food_hub_app/widgets/recipe/calendar.dart';
|
||||
import 'package:food_hub_app/widgets/recipe/list.dart';
|
||||
import 'package:food_hub_app/widgets/recipe/timeline.dart';
|
||||
import 'package:tdesign_flutter/tdesign_flutter.dart';
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user