books
This commit is contained in:
93
lib/components/toly_ui/decoration/title.dart
Normal file
93
lib/components/toly_ui/decoration/title.dart
Normal file
@@ -0,0 +1,93 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TolyTitle extends StatelessWidget {
|
||||
final Widget child;
|
||||
final Color? lineColor;
|
||||
final Color? color;
|
||||
const TolyTitle({
|
||||
super.key,
|
||||
required this.child,
|
||||
this.lineColor,
|
||||
this.color,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: TitleDecoration(
|
||||
color,lineColor,
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TitleDecoration extends Decoration {
|
||||
final Color? lineColor;
|
||||
final Color? color;
|
||||
|
||||
const TitleDecoration( this.color,this.lineColor,);
|
||||
|
||||
@override
|
||||
BoxPainter createBoxPainter([VoidCallback? onChanged]) =>
|
||||
TitlePainter(color: color, lineColor: lineColor);
|
||||
}
|
||||
|
||||
class TitlePainter extends BoxPainter {
|
||||
final Color? color;
|
||||
final Color? lineColor;
|
||||
|
||||
const TitlePainter({this.color, this.lineColor});
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
|
||||
canvas.save();
|
||||
canvas.translate(offset.dx, offset.dy);
|
||||
Size size = configuration.size ?? Size.zero;
|
||||
final Paint paint = Paint()
|
||||
// ..style = PaintingStyle.stroke
|
||||
..color = color??Colors.transparent
|
||||
..strokeWidth = 1;
|
||||
|
||||
|
||||
final Rect zone = Rect.fromCenter(
|
||||
center: Offset(size.width / 2, size.height / 2),
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
);
|
||||
|
||||
canvas.drawRect(zone, paint);
|
||||
final Paint paint2 = Paint()
|
||||
..strokeWidth = 1
|
||||
// ..style = PaintingStyle.stroke
|
||||
// ..color = const Color(0xffFFFAA7);
|
||||
..color = lineColor??Colors.transparent;
|
||||
|
||||
const double start = 4;
|
||||
canvas.drawLine(const Offset(0, start), Offset(size.width, start), paint2);
|
||||
double end = size.height - 4;
|
||||
canvas.drawLine(Offset(0, end), Offset(size.width, end), paint2);
|
||||
|
||||
canvas.drawCircle(Offset(10,size.height/2), 4, paint2);
|
||||
|
||||
//
|
||||
// canvas.translate(
|
||||
// offset.dx + (configuration.size?.width??0) / 2,
|
||||
// offset.dy + (configuration.size?.height??0) / 2,
|
||||
// );
|
||||
//
|
||||
// final Rect zone = Rect.fromCenter(
|
||||
// center: Offset.zero,
|
||||
// width: configuration.size.width,
|
||||
// height: configuration.size.height,
|
||||
// );
|
||||
//
|
||||
// path.addRRect(RRect.fromRectAndRadius(
|
||||
// zone,
|
||||
// Radius.circular(20),
|
||||
// ));
|
||||
//
|
||||
// const DashPainter(span: 4, step: 9).paint(canvas, path, paint);
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:idraw/idraw.dart';
|
||||
import 'package:iroute/pages/dashboard/chat_room.dart';
|
||||
|
||||
|
||||
final RouteBase drawRouters = GoRoute(
|
||||
path: '/draw',
|
||||
redirect: (_,state) {
|
||||
redirect: (_, state) {
|
||||
if (state.fullPath == '/draw') {
|
||||
return '/draw/chapter1';
|
||||
}
|
||||
@@ -37,11 +35,48 @@ final RouteBase drawRouters = GoRoute(
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return const P04Page();
|
||||
},
|
||||
), GoRoute(
|
||||
),
|
||||
GoRoute(
|
||||
path: 'chapter5',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return const P05Page();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'chapter6',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return const P06Page();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'chapter7',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return const P07Page();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'chapter8',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return const P08Page();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'chapter9',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return const P09Page();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'chapter10',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return const P10Page();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'chapter11',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return const P11Page();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -1,37 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../components/toly_ui/decoration/title.dart';
|
||||
|
||||
class TitleGroup extends StatelessWidget {
|
||||
final String title;
|
||||
const TitleGroup({super.key, required this.title});
|
||||
final Color? color;
|
||||
final Color? lineColor;
|
||||
|
||||
const TitleGroup({super.key, required this.title, this.color=const Color(0xff333333), this.lineColor});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
CircleAvatar(
|
||||
radius: 6,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
Text(
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 16),
|
||||
child: Center(
|
||||
child: TolyTitle(
|
||||
color: color,
|
||||
lineColor: lineColor,
|
||||
child:
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 24,vertical: 10),
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
|
||||
style: TextStyle(fontSize: 14,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
],
|
||||
), ),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,6 @@ List<BookInfo> kBooks = [
|
||||
cover: 'assets/images/anima.webp',
|
||||
price: '3.5',
|
||||
),
|
||||
|
||||
BookInfo(
|
||||
name: 'Flutter渲染机制·聚沙成塔',
|
||||
path: 'dream',
|
||||
@@ -102,7 +101,6 @@ List<BookInfo> projectBooks = [
|
||||
),
|
||||
];
|
||||
|
||||
|
||||
class ViewBooks extends StatelessWidget {
|
||||
const ViewBooks({super.key});
|
||||
|
||||
@@ -117,70 +115,43 @@ class ViewBooks extends StatelessWidget {
|
||||
);
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: TitleGroup(
|
||||
title: 'Flutter 七剑合璧',
|
||||
lineColor: const Color(0xff6EAFF9),
|
||||
),
|
||||
),
|
||||
_buildSliverSliverGrid(kBooks,gridDelegate),
|
||||
SliverToBoxAdapter(
|
||||
child: TitleGroup(
|
||||
title: 'Flutter 实战探索',
|
||||
lineColor: const Color(0xffFD983A),
|
||||
),
|
||||
),
|
||||
_buildSliverSliverGrid(projectBooks,gridDelegate),
|
||||
|
||||
|
||||
SliverToBoxAdapter(
|
||||
child: TitleGroup(title: 'Flutter 七剑合璧',),
|
||||
child: TitleGroup(
|
||||
title: 'Flutter 免费小册',
|
||||
lineColor: const Color(0xff7864E1),
|
||||
),
|
||||
),
|
||||
|
||||
SliverGrid(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(_, i) => BookCell(bookInfo:kBooks[i]),
|
||||
childCount: kBooks.length,
|
||||
),
|
||||
gridDelegate: gridDelegate),
|
||||
|
||||
SliverToBoxAdapter(
|
||||
child: TitleGroup(title: 'Flutter 实战探索',),
|
||||
),
|
||||
|
||||
|
||||
SliverGrid(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(_, i) => BookCell(bookInfo:projectBooks[i]),
|
||||
childCount: projectBooks.length,
|
||||
),
|
||||
gridDelegate: gridDelegate),
|
||||
|
||||
SliverToBoxAdapter(
|
||||
child: TitleGroup(title: 'Flutter 免费小册',),
|
||||
),
|
||||
SliverGrid(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(_, i) => BookCell(bookInfo:freeBooks[i]),
|
||||
childCount: freeBooks.length,
|
||||
),
|
||||
gridDelegate: gridDelegate),
|
||||
_buildSliverSliverGrid(freeBooks,gridDelegate),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// SliverGridDelegate gridDelegate = const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
// maxCrossAxisExtent: 240,
|
||||
// mainAxisSpacing: 10,
|
||||
// mainAxisExtent: 260,
|
||||
// crossAxisSpacing: 10,
|
||||
// );
|
||||
// return GridView.builder(
|
||||
// padding: EdgeInsets.all(10),
|
||||
// gridDelegate: gridDelegate,
|
||||
// itemBuilder: (_, i) {
|
||||
// BookInfo bookInfo = kBooks[i];
|
||||
// return Center(
|
||||
// child: Padding(
|
||||
// padding: EdgeInsets.symmetric(horizontal: 10,vertical: 6),
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Expanded(child: Center(child: Image.asset(bookInfo.cover))),
|
||||
// const SizedBox(height: 6,),
|
||||
// Text('${bookInfo.name}',style: TextStyle(fontSize: 14,fontWeight: FontWeight.bold),),
|
||||
// const SizedBox(height: 6,),
|
||||
// Text('${bookInfo.info}',style: TextStyle(fontSize: 12,color: Color(0xff515767)),),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// itemCount: kBooks.length,
|
||||
// );
|
||||
Widget _buildSliverSliverGrid(
|
||||
List<BookInfo> books, SliverGridDelegate gridDelegate) {
|
||||
return SliverPadding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
sliver: SliverGrid(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(_, i) => BookCell(bookInfo: books[i]),
|
||||
childCount: books.length,
|
||||
),
|
||||
gridDelegate: gridDelegate),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user