diff --git a/lib/app.dart b/lib/app.dart index 866e175..3744ea7 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'layout/layout_scaffold.dart'; /// /// 应用页 @@ -14,11 +13,6 @@ class App extends StatefulWidget { class _AppState extends State { @override Widget build(BuildContext context) { - return LayoutScaffold( - appBar: AppBar( - title: const Text('满席'), - ), - body: null, - ); + return Container(); } } diff --git a/lib/layout/layout_scaffold.dart b/lib/layout/layout_scaffold.dart deleted file mode 100644 index 95a60e3..0000000 --- a/lib/layout/layout_scaffold.dart +++ /dev/null @@ -1,41 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; - -class LayoutScaffold extends StatelessWidget { - final AppBar appBar; - final Widget? body; - - const LayoutScaffold({ - Key? key, - required this.appBar, - this.body, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - Text title = appBar.title as Text; - - return Scaffold( - appBar: PreferredSize( - preferredSize: const Size.fromHeight(60), - child: AppBar( - actions: appBar.actions, - leading: appBar.leading, - title: Text( - title.data ?? '', - style: const TextStyle( - fontSize: 25, - ), - ), - centerTitle: true, - bottom: appBar.bottom, - systemOverlayStyle: const SystemUiOverlayStyle( - statusBarColor: Colors.transparent, //设置为透明 - statusBarIconBrightness: Brightness.dark, - ), - ), - ), - body: body, - ); - } -} diff --git a/lib/life.dart b/lib/life.dart index 8b51830..9182707 100644 --- a/lib/life.dart +++ b/lib/life.dart @@ -1,10 +1,9 @@ +import 'package:bistro/common/global.dart'; import 'package:flutter/material.dart'; -import 'package:bistro/layout/layout_scaffold.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; class Life extends StatefulWidget { const Life({Key? key}) : super(key: key); - final title = '途说'; @override State createState() => _LifeState(); @@ -85,7 +84,7 @@ class _LifeState extends State { { 'id': '10', 'thumbnail': 'res/assets/images/tiefutu.jpg', - 'title': '标题10', + 'title': '标题10标题10标题10标题10标题10标题10标题10标题10标题10标题10标题10标题10', 'author': '浅帅', 'hasLiked': true }, @@ -94,28 +93,14 @@ class _LifeState extends State { @override Widget build(BuildContext context) { - return LayoutScaffold( - appBar: AppBar( - title: Text(widget.title), - actions: [ - IconButton( - icon: Icon( - Icons.add, - color: Theme.of(context).primaryColor, - ), - onPressed: () {}, - ) - ], - ), - body: MasonryGridView.count( - shrinkWrap: true, - itemCount: _list.length, - crossAxisCount: 2, - itemBuilder: cardBuilder, - padding: const EdgeInsets.only(top: 8), - mainAxisSpacing: 12.0, - crossAxisSpacing: 6.0, - ), + return MasonryGridView.count( + shrinkWrap: true, + itemCount: _list.length, + crossAxisCount: 2, + itemBuilder: cardBuilder, + padding: const EdgeInsets.only(top: 8), + mainAxisSpacing: 6.0, + // crossAxisSpacing: 4.0, ); } @@ -123,70 +108,66 @@ class _LifeState extends State { var item = _list[index]; return Card( - key: ValueKey(item["id"]), - elevation: 8, - color: Theme.of(context).colorScheme.background, - child: Column( - children: [ - InkWell( - child: Image.asset( - item["thumbnail"], - ), - onTap: () {}, - ), - ListTile( - title: Text( - item["title"].toString(), - maxLines: 2, - style: const TextStyle( - fontSize: 13, + key: ValueKey(item["id"]), + clipBehavior: Clip.antiAlias, + elevation: 3, + color: Theme.of(context).colorScheme.tertiary, + child: GestureDetector( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + item['thumbnail'], + fit: BoxFit.fitWidth, ), - overflow: TextOverflow.ellipsis, - ), - isThreeLine: true, - subtitle: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - child: Row( - children: [ - // Icon( - // Icons.person_outline, - // color: Theme.of(context).primaryColor, - // ), - ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 100), - child: Text( - item['author'].toString(), - softWrap: true, - textAlign: TextAlign.left, - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: const TextStyle( - fontSize: 11, - ), + ListTile( + title: Text( + item["title"].toString(), + maxLines: 2, + style: const TextStyle( + fontSize: 13, + ), + overflow: TextOverflow.ellipsis, + ), + // isThreeLine: true, + subtitle: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 100), + child: Text( + item['author'].toString(), + softWrap: true, + textAlign: TextAlign.left, + overflow: TextOverflow.ellipsis, + maxLines: 1, + style: const TextStyle( + fontSize: 11, ), - ) - ], - ), - onTap: () {}, + ), + ), + GestureDetector( + excludeFromSemantics: true, + child: Icon( + item["hasLiked"] + ? Icons.favorite + : Icons.favorite_border, + color: Theme.of(context).primaryColor, + ), + onTap: () { + setState(() { + _list[index]["hasLiked"] = !item["hasLiked"]; + }); + }, + ), + ], ), - InkWell( - child: Icon( - item["hasLiked"] ? Icons.favorite : Icons.favorite_border, - color: Theme.of(context).primaryColor, - ), - onTap: () { - setState(() { - _list[index]["hasLiked"] = !item["hasLiked"]; - }); - }, - ), - ], - ), - ) - ], - ), - ); + ) + ], + ), + onTap: () { + printWhenDebug(123); + }, + )); } } diff --git a/lib/mine.dart b/lib/mine.dart index bcfdfdf..27f46b7 100644 --- a/lib/mine.dart +++ b/lib/mine.dart @@ -1,20 +1,20 @@ import 'package:flutter/material.dart'; -import 'layout/layout_scaffold.dart'; /// /// 【我的】页 /// -class Mine extends StatelessWidget { +class Mine extends StatefulWidget { const Mine({Key? key}) : super(key: key); @override - Widget build(BuildContext context) { - return LayoutScaffold( - appBar: AppBar( - title: const Text('在下'), - ), + State createState() => _MineState(); +} - ); +class _MineState extends State { + @override + Widget build(BuildContext context) { + return Container(); + // return Container(); } } diff --git a/lib/news.dart b/lib/news.dart index 1ea2324..ac0e882 100644 --- a/lib/news.dart +++ b/lib/news.dart @@ -1,17 +1,10 @@ import 'package:flutter/material.dart'; -import 'layout/layout_scaffold.dart'; - class News extends StatelessWidget { const News({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - return LayoutScaffold( - appBar: AppBar( - title: const Text('道听'), - ), - body: null, - ); + return Container(); } } diff --git a/pubspec.yaml b/pubspec.yaml index 7254efd..72d4512 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -175,7 +175,7 @@ flutter_native_splash: # platform. #android: false #ios: false - web: false + #web: false # The position of the splash image can be set with android_gravity, ios_content_mode, and # web_image_mode parameters. All default to center. diff --git a/web/index.html b/web/index.html index ea0f6d4..0d4b772 100644 --- a/web/index.html +++ b/web/index.html @@ -30,7 +30,6 @@ bistro -