import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter_douban/config/Http_service.dart';
import 'package:flutter_douban/config/app_colors.dart';
import 'package:flutter_douban/main_page/home/detail/views/cook_detail_headerView.dart';
import 'package:flutter_douban/main_page/home/detail/views/nutrition_facts_view.dart';
import 'package:flutter_douban/main_page/home/h5_detail_page/activity_detail_page.dart';
import 'package:flutter_douban/main_page/home/notes/commit_cell.dart';
import 'package:flutter_douban/main_page/home/notes/note_detail_page.dart';
import 'package:flutter_douban/main_page/home/notes/note_list_page.dart';
import 'package:flutter_douban/main_page/home/video/window_video_page.dart';
import 'package:flutter_douban/model/content_model.dart';
import 'package:flutter_douban/model/note_content_model.dart';
import 'package:flutter_douban/model/note_model.dart';
import 'package:flutter_douban/model/recipe_big_model.dart';
import 'package:flutter_douban/tool_views/cached_network_Image.dart';
import 'package:flutter_douban/tool_views/photo_ViewScreen.dart';
import 'package:flutter_douban/tool_views/router.dart';
import 'package:flutter_douban/tool_views/stance_page.dart';
import 'package:sticky_headers/sticky_headers/widget.dart';
import '../../../../main.dart';
import 'cook_detail_navFooter.dart';
import 'cook_detail_navHeader.dart';
const APPBAR_SCROLL = 100; //设置滑动变化的偏移量
class CookDetailPage extends StatefulWidget {
final int id;
final String? imgUrl;
const CookDetailPage({Key? key, required this.id,this.imgUrl}) : super(key: key);
@override
_CookDetailPageState createState() => _CookDetailPageState();
}
class _CookDetailPageState extends State<CookDetailPage> {
RecipeBigModel? _model;
List<NoteContentModel> _commotList = NoteContentModellList([]).list;
List<NoteModel> _noteList = NoteModelList([]).list;
/// 滚动控制器
ScrollController? _controller;
/// 关闭键盘
FocusNode userFocusNode = FocusNode();
/// 输入框
late TextEditingController _textEditingController;
double appBarAlpha = 0;
double _offset = 0;
/// 作品数量
String _noteCount = '';
/// 请求主体数据
Future _getActiveData() async {
try {
/// 全部数据
Map<String, dynamic> result =
await HttpService.getCookDetailMianData(id: widget.id);
Map<String, dynamic> result02 = result['recipe'];
if (result02['nutrition_facts'] is List) {
} else {
result02['nutrition_facts'] = [];
}
/// 列表
RecipeBigModel model = RecipeBigModel.fromJson(result02);
setState(() {
_model = model;
_getDetailRecomomendData();
});
} catch (e) {
print(e);
setState(() {});
} finally {
setState(() {});
}
}
/// 请求评论和笔记数据
Future _getDetailRecomomendData() async {
try {
/// 全部数据
Map<String, dynamic> result =
await HttpService.getDetailCommentsData(id: widget.id);
NoteContentModellList commotList =
NoteContentModellList.fromJson(result['comments']);
NoteModelList noteList = NoteModelList.fromJson(result['notes']);
setState(() {
_commotList = commotList.list;
_noteList = noteList.list;
_noteCount = result['recommendation_tag'];
});
} catch (e) {
print(e);
setState(() {});
} finally {
setState(() {});
}
}
/// 监听列表偏移
_onScroll(offset) {
double alpha = offset / APPBAR_SCROLL;
if (alpha < 0) {
alpha = 0;
} else if (alpha > 1) {
alpha = 1;
}
setState(() {
appBarAlpha = alpha;
_offset = offset;
userFocusNode.unfocus();
});
}
@override
void initState() {
// TODO: implement initState
super.initState();
_getActiveData();
_textEditingController = TextEditingController();
_textEditingController.addListener(() {
setState(() {});
});
_controller = ScrollController();
}
@override
void dispose() {
super.dispose();
_textEditingController.dispose();
_controller!.dispose();
}
@override
Widget build(BuildContext context) {
if (_model?.title == null) {
return StancePage();
// return Container(
// height: MediaQuery.of(context).size.width*1.2,
// child: CachedImage(
// url: widget.imgUrl!,
// width: MediaQuery.of(context).size.width,
// height: MediaQuery.of(context).size.width*1.2,
// ),
// );
}
/// 高度数组
List<double> _headerList = [0, 40, 40];
/// 头部widget
List<Widget> _headerWidgetList = [
_header('食材清单', '加入采购清单'),
_header('食材清单', '加入采购清单'),
_header('营养分析', '查看详情'),
];
/// 内容widget
List<Widget> _contentWidgetList = [
CookDetailHeaderView(
model: _model!,
),
_cookNameWidget(),
_nutritionWidget(),
];
if (_model!.nutrition_facts?.length == 0) {
_headerList.removeAt(2);
_headerWidgetList.removeAt(2);
_contentWidgetList.removeAt(2);
}
for (int i = 0; i < _model!.cookstep!.length; i++) {
_headerList.add(35);
_headerWidgetList.add(_cookHeader(i == _model!.cookstep!.length - 1
? '最后一步'
: '步骤 ${i + 1}/${_model!.cookstep!.length}'));
_contentWidgetList.add(_cookProcessWidget(i));
}
if (_model!.tips!.length > 0) {
_headerList.add(40);
_headerWidgetList.add(
_header('小贴士', ''),
);
_contentWidgetList.add(_cookGuideWidget());
}
/// 评论数据
if (_commotList.length > 0) {
_headerList.add(40);
_headerWidgetList.add(
_header('热门评论', ''),
);
_contentWidgetList.add(_commitWidget());
}
/// 大家都在做
if (_noteList.length > 0) {
_headerList.add(40);
_headerWidgetList.add(
_header('大家做的这道菜', ' ' + _noteCount),
);
_contentWidgetList.add(_makeWidget());
}
/// 传学做
_headerList.add(0);
_headerWidgetList.add(
_header('', ''),
);
_contentWidgetList.add(_studentWidget());
return Scaffold(
body: Container(
color: Colors.white,
child: Stack(
children: <Widget>[
MediaQuery.removePadding(
removeTop: true,
context: context,
child: NotificationListener(
onNotification: (scrollNotification) {
if (scrollNotification is ScrollUpdateNotification &&
scrollNotification.depth == 0) {
//滚动且是列表滚动的时候
_onScroll(scrollNotification.metrics.pixels);
}
return true;
},
child: Container(
color: Colors.white,
padding: EdgeInsets.only(
top: appBarAlpha == 1
? kToolbarHeight -
5 +
MediaQuery.of(context).padding.top
: 0,
bottom: MediaQuery.of(context).padding.bottom),
child: ListView.builder(
primary: _controller == null,
controller: _controller,
itemCount: _headerList.length,
itemBuilder: (context, index) {
return StickyHeader(
// controller: _controller, // Optional
header: Container(
height: _headerList[index],
color: Colors.white,
padding: EdgeInsets.symmetric(horizontal: 16.0),
alignment: Alignment.centerLeft,
child: _headerWidgetList[index],
),
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
该项目是一款基于Flutter框架高仿豆果美食App的设计源码,包含425个文件,其中包括225个Dart源代码文件、125个PNG图片文件、18个JSON数据文件、10个XML配置文件、9个GIF图片文件、4个Git忽略文件、4个Gradle构建文件、4个iOS配置文件以及3个Markdown说明文件。支持多语言开发环境,包括Dart、Kotlin、C和Swift。
资源推荐
资源详情
资源评论
收起资源包目录
基于Flutter的豆果美食高仿设计源码 (424个子文件)
cook_detail_page.dart 26KB
app_dialog.dart 20KB
code_login_page.dart 19KB
login_page.dart 18KB
register_page.dart 14KB
class_detail_top_cell.dart 14KB
Http_service.dart 14KB
product_top_cell.dart 12KB
user_config_page.dart 9KB
me_page.dart 9KB
topic_detail_page.dart 9KB
note_list_view.dart 9KB
feed_back_page.dart 8KB
photo_ViewScreen.dart 8KB
window_video_page.dart 8KB
shopping_cell.dart 8KB
class_item_view.dart 8KB
home_card_view.dart 7KB
store_shop_page.dart 7KB
class_cell_view.dart 7KB
class_item_cell.dart 7KB
classroom_hasbuy_page.dart 7KB
home_mother_page.dart 7KB
address_picker_page.dart 7KB
home_recomend_page.dart 7KB
home_notes_page.dart 7KB
has_login_view.dart 6KB
note_detail_page.dart 6KB
classroom_page.dart 6KB
router.dart 6KB
cached_network_Image.dart 5KB
class_detail_bottow_view.dart 5KB
commit_cell.dart 5KB
commit_cell.dart 5KB
store_shop_cell.dart 5KB
ios_alert_dialog.dart 5KB
store_page.dart 5KB
home_activity_page.dart 5KB
class_detail_header_view.dart 5KB
classroom_detail_page.dart 5KB
home_image_page.dart 5KB
cook_detail_headerView.dart 5KB
author_collection.dart 4KB
collection_image.dart 4KB
setting_page.dart 4KB
stroe_product_cell.dart 4KB
author_page.dart 4KB
author_cook_page.dart 4KB
intro_view.dart 4KB
topic_list_page.dart 4KB
video_player.dart 4KB
cook_detail_navHeader.dart 4KB
note_list_page.dart 4KB
note_item_cell.dart 4KB
store_category_page.dart 4KB
text.dart 4KB
store_product_detail.dart 4KB
detail_header_topic_view.dart 4KB
cook_item_cell.dart 4KB
custom_text_page.dart 4KB
product_detail_bottow_view.dart 4KB
nutrition_facts_view.dart 4KB
home_video_page.dart 4KB
product_bottow_cell.dart 4KB
recipe_big_model.g.dart 4KB
anchor_baking_page.dart 4KB
my_custom_circle.dart 4KB
http_request.dart 4KB
stick_render.dart 4KB
my_underline_tabIndicator.dart 4KB
xuan.dart 4KB
video_page.dart 4KB
note_detail_centerView.dart 3KB
note_detail_header.dart 3KB
user_drawer_view.dart 3KB
note_db_provider.dart 3KB
nav_home_page.dart 3KB
note_model.g.dart 3KB
stroe_seckill_item_cell.dart 3KB
store_count_model.dart 3KB
classroom_category_son_page.dart 3KB
classroom_more_page.dart 3KB
avatar_role_name.dart 3KB
cook_recomend_view.dart 3KB
mother_knowledge_cell.dart 3KB
product_nav_view.dart 3KB
note_detail_headerView.dart 3KB
store_nav_view.dart 3KB
cook_info_model.g.dart 3KB
commit_all_page.dart 3KB
collection_note_page.dart 3KB
collection_cook_page.dart 3KB
shopping_bottow_view.dart 3KB
class_db_provider.dart 3KB
note_topic_view.dart 3KB
class_nav_view.dart 3KB
store_shop_header.dart 3KB
cook_db_provider.dart 3KB
transit_page.dart 3KB
code_login_view.dart 3KB
共 424 条
- 1
- 2
- 3
- 4
- 5
资源评论
wjs2024
- 粉丝: 2206
- 资源: 5449
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- [雷军]美妙的爱情......福的味道。.mp3
- 2023-04-06-项目笔记 - 第三百二十阶段 - 4.4.2.318全局变量的作用域-318 -2025.11.17
- 2023-04-06-项目笔记 - 第三百二十阶段 - 4.4.2.318全局变量的作用域-318 -2025.11.17
- java资源异步IO框架 Cindy
- java资源业务流程管理(BPM)和工作流系统 Activiti
- java资源高性能内存消息和事件驱动库 Chronicle
- 哋它亢技术应用2慕课自动化学习
- java资源高性能的JSON处理 Jackson
- java资源高性能的Java 3D引擎 Xith3D
- java资源WordNet的Java包 JWordNet
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功