提交 d94d3a81 authored 作者: yueweilu's avatar yueweilu

笔记详情基本布局

上级 feb8d22d
......@@ -13,6 +13,12 @@ class UserNoteController extends GetxController {
int _page = 1;
bool _noMore = false;
@override
void onReady() {
onRefresh();
super.onReady();
}
@override
void onClose() {
refreshController.dispose();
......@@ -29,7 +35,7 @@ class UserNoteController extends GetxController {
);
// 如果是刷新 清理数据
if (isRefresh) notes.clear();
notes.addAll(_test());
// notes.addAll(_test());
notes.addAll(result);
_page ++;
_noMore = result.length < _limit;
......
......@@ -8,8 +8,10 @@ import 'package:flutter_book/theme.dart';
import 'package:flutter_book/widgets/index.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
import '../../models/index.dart';
import '../../routes/index.dart';
import '../../utils/index.dart';
......
......@@ -19,7 +19,7 @@ class _UserNotePageState extends State<UserNotePage> {
),
body: CustomPullScrollView(
controller: controller.refreshController,
onRefresh: controller.onRefresh,
// onRefresh: controller.onRefresh,
onLoading: controller.onLoading,
child:SingleChildScrollView(
child: Container(
......@@ -40,7 +40,12 @@ class _UserNotePageState extends State<UserNotePage> {
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (BuildContext context, int index){
return BuildItem(model: controller.notes[index],index: index,num: controller.notes.length,);
return GestureDetector(
onTap: (){
context.pushNamed(Routes.noteDes,extra: controller.notes[index]);
},
child: BuildItem(model: controller.notes[index],index: index,num: controller.notes.length,)
);
},
itemCount: controller.notes.length,
),
......
......@@ -14,6 +14,7 @@ class BuildItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
// margin: const EdgeInsets.symmetric(horizontal: 10),
padding: const EdgeInsets.symmetric(horizontal: 10),
// margin: const EdgeInsets.all(10),
......
part of user_notes_des;
class UserNotesDesController extends GetxController {
final String tag;
UserNotesDesController(this.tag);
}
\ No newline at end of file
library user_notes_des;
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../models/index.dart';
import '../../theme.dart';
import '../../utils/index.dart';
part 'view.dart';
part 'controller.dart';
part 'widgets/item.dart';
part 'widgets/list.dart';
\ No newline at end of file
part of user_notes_des;
class UserNotesDesPage extends StatefulWidget {
final CourseModel model;
const UserNotesDesPage({
Key? key,
required this.model
}) : super(key: key);
@override
State<UserNotesDesPage> createState() => _UserNotesDesPageState();
}
class _UserNotesDesPageState extends State<UserNotesDesPage> {
List<Tab> tabs = [
const Tab(text: '全部',),
const Tab(text: '划线',),
const Tab(text: '高亮',),
const Tab(text: '笔记',),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('笔记详情'),
),
body: DefaultTabController(
length: tabs.length,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
BuildItem(model: widget.model),
ClipRRect(
borderRadius:const BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5)),
child: Container(
width: double.infinity,
color: Colors.white,
height: 35,
child: TabBar(
indicator: UnderlineTabIndicator(
borderRadius: BorderRadius.circular(0.75),
borderSide: const BorderSide(width: 1.5,color: AppTheme.primary),
insets: const EdgeInsets.symmetric(horizontal: 22), // 设置标签下面指示器的水平内边距
),
labelPadding: const EdgeInsets.symmetric(horizontal: 20),
indicatorSize: TabBarIndicatorSize.label,
indicatorColor: AppTheme.primary,
indicatorWeight: 1.5,
labelStyle: const TextStyle(color: AppTheme.primary,fontSize: 15,height: 1.5,fontWeight: Fonts.medium),
unselectedLabelColor: Colours.c9,
unselectedLabelStyle: const TextStyle(color: Colours.c9,fontSize: 15,height: 1.5),
isScrollable: true,
tabs: tabs
),
),
),
Expanded(
child: TabBarView(
children: List.generate(tabs.length, (index){
return BuildListPage(tag:'$index');
})
),
)
],
)
),
);
}
}
part of user_notes_des;
class BuildItem extends StatelessWidget {
final CourseModel model;
const BuildItem({
Key? key,
required this.model,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.white,
boxShadow: [
BoxShadow(
color: const Color(0xFFC7C7C7).withOpacity(0.5),
offset: const Offset(3, 0),
blurRadius: 10.w,
spreadRadius: 0.w,
),
],
),
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Column(
children: [
Container(
padding: const EdgeInsets.only(top: 12,bottom: 15),
// color: Colors.red,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 87,
width: 73,
color: Colors.cyan,
),
Container(
height: 87,
margin: const EdgeInsets.only(left: 13),
// color: Colors.green,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(model.bookName??'',style: const TextStyle(fontSize: 14,height: 1.5,fontWeight: Fonts.medium,color: Colours.c3),),
Text(model.authors??'',style: const TextStyle(fontSize: 12,height: 1.5,color: Colours.c6),),
],
),
Text('${model.notesNum.toString()}个笔记',style: const TextStyle(fontSize: 11,height: 1.5,color: AppTheme.primary)),
],
),
)
],
),
)
],
),
);
}
}
part of user_notes_des;
class BuildListPage extends StatefulWidget {
final String tag;
const BuildListPage({
Key? key,
required this.tag
}) : super(key: key);
@override
State<BuildListPage> createState() => _BuildListPageState();
}
class _BuildListPageState extends State<BuildListPage> {
@override
Widget build(BuildContext context) {
return GetBuilder<UserNotesDesController>(
tag: widget.tag,
init: UserNotesDesController(widget.tag),
builder: (controller) =>ListView.builder(
itemBuilder: (BuildContext context,int index){
return Container(
height: 20,
color: Colors.red,
);
},
itemCount: 3,
),
);
}
}
......@@ -27,6 +27,7 @@ import 'package:flutter_book/pages/user_love/index.dart';
import 'package:flutter_book/pages/user_msg/index.dart';
import 'package:flutter_book/pages/user_nick/index.dart';
import 'package:flutter_book/pages/user_notes/index.dart';
import 'package:flutter_book/pages/user_notes_des/index.dart';
import 'package:flutter_book/pages/user_point/index.dart';
import 'package:flutter_book/pages/user_security/index.dart';
import 'package:flutter_book/pages/user_set/index.dart';
......
......@@ -74,6 +74,8 @@ abstract class Routes {
static const love = 'love';
// 笔记
static const note = 'note';
// 笔记详情
static const noteDes = 'note_des';
// 错题
static const wrong = 'wrong';
// 讨论
......@@ -412,6 +414,15 @@ abstract class Routes {
child: const UserFeedbackPage()
)
),
GoRoute(
path: '/$noteDes',
name: noteDes,
pageBuilder: (context, state) =>CupertinoPage(
name: state.uri.toString(),
key: state.pageKey,
child: UserNotesDesPage(model: state.extra as CourseModel,)
)
),
]
);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论