books
This commit is contained in:
@@ -5,7 +5,8 @@ import '../view_books.dart';
|
||||
|
||||
class BookCell extends StatefulWidget {
|
||||
final BookInfo bookInfo;
|
||||
const BookCell({super.key, required this.bookInfo});
|
||||
final ValueChanged<BookInfo> onSelect;
|
||||
const BookCell({super.key, required this.bookInfo, required this.onSelect});
|
||||
|
||||
@override
|
||||
State<BookCell> createState() => _BookCellState();
|
||||
@@ -14,31 +15,34 @@ class BookCell extends StatefulWidget {
|
||||
class _BookCellState extends State<BookCell> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MouseRegion(
|
||||
onEnter: _onEnter,
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Center(child: ClipRRect(
|
||||
child: Image.asset(widget.bookInfo.cover),
|
||||
borderRadius:BorderRadius.circular(8)
|
||||
))),
|
||||
const SizedBox(height: 8),
|
||||
return GestureDetector(
|
||||
onTap: ()=> widget.onSelect(widget.bookInfo),
|
||||
child: MouseRegion(
|
||||
onEnter: _onEnter,
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Center(child: ClipRRect(
|
||||
child: Image.asset(widget.bookInfo.cover),
|
||||
borderRadius:BorderRadius.circular(8)
|
||||
))),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Text(
|
||||
'${widget.bookInfo.info}',
|
||||
style:
|
||||
TextStyle(fontSize: 12, color: Color(0xff515767)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Text(
|
||||
'${widget.bookInfo.info}',
|
||||
style:
|
||||
TextStyle(fontSize: 12, color: Color(0xff515767)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:components/toly_ui/decoration/title.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../components/toly_ui/decoration/title.dart';
|
||||
|
||||
class TitleGroup extends StatelessWidget {
|
||||
final String title;
|
||||
final Color? color;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:iroute/navigation/router/menus/menu_scope/menu_scope.dart';
|
||||
|
||||
import 'view_book/book_cell.dart';
|
||||
import 'view_book/title_group.dart';
|
||||
@@ -121,14 +123,14 @@ class ViewBooks extends StatelessWidget {
|
||||
lineColor: const Color(0xff6EAFF9),
|
||||
),
|
||||
),
|
||||
_buildSliverSliverGrid(kBooks,gridDelegate),
|
||||
_buildSliverSliverGrid(context,kBooks,gridDelegate),
|
||||
SliverToBoxAdapter(
|
||||
child: TitleGroup(
|
||||
title: 'Flutter 实战探索',
|
||||
lineColor: const Color(0xffFD983A),
|
||||
),
|
||||
),
|
||||
_buildSliverSliverGrid(projectBooks,gridDelegate),
|
||||
_buildSliverSliverGrid(context,projectBooks,gridDelegate),
|
||||
|
||||
|
||||
SliverToBoxAdapter(
|
||||
@@ -137,18 +139,22 @@ class ViewBooks extends StatelessWidget {
|
||||
lineColor: const Color(0xff7864E1),
|
||||
),
|
||||
),
|
||||
_buildSliverSliverGrid(freeBooks,gridDelegate),
|
||||
_buildSliverSliverGrid(context,freeBooks,gridDelegate),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSliverSliverGrid(
|
||||
Widget _buildSliverSliverGrid(BuildContext context,
|
||||
List<BookInfo> books, SliverGridDelegate gridDelegate) {
|
||||
return SliverPadding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
sliver: SliverGrid(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(_, i) => BookCell(bookInfo: books[i]),
|
||||
(_, i) => BookCell(bookInfo: books[i],onSelect: (b){
|
||||
if(b.path == 'draw'){
|
||||
context.go('/draw/chapter1');
|
||||
}
|
||||
},),
|
||||
childCount: books.length,
|
||||
),
|
||||
gridDelegate: gridDelegate),
|
||||
|
||||
30
lib/pages/empty/empty_panel.dart
Normal file
30
lib/pages/empty/empty_panel.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class EmptyPanel extends StatelessWidget {
|
||||
final String msg;
|
||||
const EmptyPanel({super.key, required this.msg});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
child: Center(
|
||||
child: Wrap(
|
||||
spacing: 16,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
direction: Axis.vertical,
|
||||
children: [
|
||||
Icon(Icons.nearby_error,size: 64, color: Colors.redAccent),
|
||||
Text(
|
||||
msg,
|
||||
style: TextStyle(fontSize: 24, color: Colors.grey),
|
||||
),
|
||||
ElevatedButton(onPressed: (){
|
||||
context.go('/dashboard/view');
|
||||
}, child: Text('返回首页'))
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user