forked from lxm_flutter/FlutterUnit
✨ 支持拷贝代码
This commit is contained in:
@@ -8,9 +8,9 @@ class Cons {
|
||||
static const MENU_INFO = <String>["关于", "帮助", "问题反馈"]; //菜单栏
|
||||
static const ICONS_MAP = {
|
||||
//底栏图标
|
||||
"图鉴": TolyIcon.icon_layout, "收藏": TolyIcon.icon_star,
|
||||
// "喜欢": Icons.favorite, "手册": Icons.class_,
|
||||
// "我的": Icons.account_circle,
|
||||
"组件集录": TolyIcon.icon_layout, "收藏集录": TolyIcon.icon_star,
|
||||
"绘制集录": Icons.palette, "布局集录": Icons.widgets,
|
||||
"要点集录": TolyIcon.icon_bug,
|
||||
};
|
||||
|
||||
static const rainbow = <int>[
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:flutter_unit_mac/app/style/TolyIcon.dart';
|
||||
import 'package:flutter_unit_mac/app/utils/Toast.dart';
|
||||
|
||||
import 'package:flutter_unit_mac/components/permanent/circle.dart';
|
||||
import 'package:flutter_unit_mac/components/permanent/code/code_widget.dart';
|
||||
@@ -109,13 +111,13 @@ class _WidgetNodePanelState extends State<WidgetNodePanel> {
|
||||
Widget _buildShareButton() => FeedbackWidget(
|
||||
mode: FeedMode.fade,
|
||||
a: 0.4,
|
||||
onPressed: _doShare,
|
||||
onPressed: _doCopy,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
right: 10,
|
||||
),
|
||||
child: Icon(
|
||||
TolyIcon.icon_share,
|
||||
Icons.content_copy,
|
||||
size: 20,
|
||||
color: themeColor,
|
||||
),
|
||||
@@ -140,8 +142,10 @@ class _WidgetNodePanelState extends State<WidgetNodePanel> {
|
||||
);
|
||||
|
||||
//执行分享
|
||||
_doShare() {
|
||||
Share.share(widget.code);
|
||||
_doCopy() async{
|
||||
await Clipboard.setData(ClipboardData(text: widget.code));
|
||||
Toast.toast(context, '复制成功!',duration: Duration(seconds: 10));
|
||||
// Share.share(widget.code);
|
||||
}
|
||||
|
||||
// 折叠代码面板
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_unit_mac/app/res/cons.dart';
|
||||
import 'package:flutter_unit_mac/app/router.dart';
|
||||
import 'package:flutter_unit_mac/app/style/TolyIcon.dart';
|
||||
import 'package:flutter_unit_mac/blocs/bloc_exp.dart';
|
||||
import 'package:flutter_unit_mac/components/permanent/circle_image.dart';
|
||||
import 'package:flutter_unit_mac/components/permanent/feedback_widget.dart';
|
||||
import 'package:flutter_unit_mac/views/app/navigation/unit_bottom_bar.dart';
|
||||
import 'package:flutter_unit_mac/views/pages/category/collect_page.dart';
|
||||
import 'package:flutter_unit_mac/views/pages/category/home_right_drawer.dart';
|
||||
import 'package:flutter_unit_mac/views/pages/home/home_drawer.dart';
|
||||
import 'package:flutter_unit_mac/views/pages/home/home_page.dart';
|
||||
|
||||
import 'package:flutter_unit_mac/views/pages/unit_todo/bug_unit_page.dart';
|
||||
import 'package:flutter_unit_mac/views/pages/unit_todo/layout_unit_page.dart';
|
||||
import 'package:flutter_unit_mac/views/pages/unit_todo/paint_unit_page.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class UnitNavigation extends StatefulWidget {
|
||||
@override
|
||||
@@ -34,26 +41,35 @@ class _UnitNavigationState extends State<UnitNavigation> {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<HomeBloc, HomeState>(
|
||||
builder: (_, state) => Scaffold(
|
||||
drawer: HomeDrawer(color:state.homeColor),
|
||||
//左滑页
|
||||
endDrawer: HomeRightDrawer(color: state.homeColor,),
|
||||
//右滑页
|
||||
floatingActionButtonLocation:
|
||||
FloatingActionButtonLocation.centerDocked,
|
||||
floatingActionButton: _buildSearchButton(state.homeColor),
|
||||
body: PageView(
|
||||
physics:const NeverScrollableScrollPhysics(),
|
||||
//使用PageView实现页面的切换
|
||||
controller: _controller,
|
||||
children: <Widget>[
|
||||
HomePage(),
|
||||
CollectPage(),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: UnitBottomBar(
|
||||
drawer: HomeDrawer(color: state.homeColor),
|
||||
//左滑页
|
||||
endDrawer: HomeRightDrawer(
|
||||
color: state.homeColor,
|
||||
itemData: Cons.ICONS_MAP,
|
||||
onItemClick: _onTapNav)));
|
||||
),
|
||||
//右滑页
|
||||
floatingActionButton: _buildSearchButton(state.homeColor),
|
||||
body: Row(
|
||||
children: [
|
||||
_buildLeftNav(),
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: PageView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
//使用PageView实现页面的切换
|
||||
controller: _controller,
|
||||
children: <Widget>[
|
||||
HomePage(),
|
||||
CollectPage(),
|
||||
PaintUnitPage(),
|
||||
LayoutUnitPage(),
|
||||
BugUnitPage(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
Widget _buildSearchButton(Color color) {
|
||||
@@ -66,10 +82,204 @@ class _UnitNavigationState extends State<UnitNavigation> {
|
||||
}
|
||||
|
||||
_onTapNav(int index) {
|
||||
_controller.animateToPage(index,
|
||||
duration:const Duration(milliseconds: 200), curve: Curves.linear);
|
||||
_controller.jumpToPage(index);
|
||||
if (index == 1) {
|
||||
BlocProvider.of<CollectBloc>(context).add(EventSetCollectData());
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildLeftNav() {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 20),
|
||||
alignment: Alignment.topCenter,
|
||||
margin: EdgeInsets.only(right: 1),
|
||||
width: 120,
|
||||
decoration: BoxDecoration(color: Color(0xff2C3036), boxShadow: [
|
||||
BoxShadow(color: Colors.grey, offset: Offset(1, 0), blurRadius: 2)
|
||||
]),
|
||||
child: Column(
|
||||
children: [
|
||||
Wrap(
|
||||
direction: Axis.vertical,
|
||||
spacing: 10,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
CircleImage(
|
||||
image: AssetImage('assets/images/icon_head.png'),
|
||||
size: 60,
|
||||
),
|
||||
Text(
|
||||
'张风捷特烈',
|
||||
style: TextStyle(color: Colors.white70),
|
||||
)
|
||||
],
|
||||
),
|
||||
buildIcons(),
|
||||
Divider(
|
||||
color: Colors.white,
|
||||
height: 1,
|
||||
endIndent: 20,
|
||||
),
|
||||
// SizedBox(height: 60,),
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Center(
|
||||
child: RightNavBar(
|
||||
itemData: Cons.ICONS_MAP,
|
||||
onItemClick: _onTapNav,
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: Container(),
|
||||
flex: 1,
|
||||
),
|
||||
Divider(
|
||||
indent: 20,
|
||||
color: Colors.white,
|
||||
height: 1,
|
||||
),
|
||||
Builder(
|
||||
builder: (ctx) => FeedbackWidget(
|
||||
onPressed: () => Scaffold.of(ctx).openDrawer(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20, top: 20),
|
||||
child: Icon(
|
||||
Icons.settings,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildIcons() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20, top: 20),
|
||||
child: Wrap(
|
||||
spacing: 5,
|
||||
children: [
|
||||
FeedbackWidget(
|
||||
onPressed: () => _launchURL("http://blog.toly1994.com"),
|
||||
child: Icon(
|
||||
TolyIcon.icon_item,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
FeedbackWidget(
|
||||
onPressed: () =>
|
||||
_launchURL("https://github.com/toly1994328/FlutterUnit"),
|
||||
child: Icon(
|
||||
TolyIcon.icon_github,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
FeedbackWidget(
|
||||
onPressed: () =>
|
||||
_launchURL("https://juejin.im/user/5b42c0656fb9a04fe727eb37"),
|
||||
child: Icon(
|
||||
TolyIcon.icon_juejin,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_launchURL(String url) async {
|
||||
if (await canLaunch(url)) {
|
||||
await launch(url);
|
||||
} else {
|
||||
debugPrint('Could not launch $url');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class RightNavBar extends StatefulWidget {
|
||||
final Color color;
|
||||
final Map<String, IconData> itemData;
|
||||
final Function(int) onItemClick;
|
||||
final Size itemSize;
|
||||
|
||||
RightNavBar(
|
||||
{this.color = Colors.blue,
|
||||
this.itemData,
|
||||
this.onItemClick,
|
||||
this.itemSize = const Size(120, 35)});
|
||||
|
||||
@override
|
||||
_RightNavBarState createState() => _RightNavBarState();
|
||||
}
|
||||
|
||||
class _RightNavBarState extends State<RightNavBar> {
|
||||
int _position = 0;
|
||||
|
||||
List<String> get info => widget.itemData.keys.toList();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: info
|
||||
.map((e) => _buildChild(context, info.indexOf(e), widget.color))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildChild(BuildContext context, int i, Color color) {
|
||||
var active = i == _position;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => _tapTab(i),
|
||||
child: Container(
|
||||
alignment: Alignment.topLeft,
|
||||
margin: EdgeInsets.only(top: 10),
|
||||
width: widget.itemSize.width,
|
||||
child: UnconstrainedBox(
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: active ? widget.color : Colors.white.withAlpha(33),
|
||||
borderRadius: BorderRadius.only(
|
||||
topRight: Radius.circular(20),
|
||||
bottomRight: Radius.circular(20))),
|
||||
width:
|
||||
active ? widget.itemSize.width*0.95 : widget.itemSize.width * 0.85,
|
||||
height: widget.itemSize.height,
|
||||
child: Wrap(
|
||||
spacing: 10,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
widget.itemData[info[i]],
|
||||
size: active ? 24 : 20,
|
||||
color: active ? Colors.white:Colors.white70,
|
||||
),
|
||||
Text(
|
||||
info[i],
|
||||
style: TextStyle(
|
||||
color: active ? Colors.white:Colors.white70,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
_tapTab(int i) {
|
||||
setState(() {
|
||||
_position = i;
|
||||
if (widget.onItemClick != null) {
|
||||
widget.onItemClick(_position);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class CollectWidgetListItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 5,
|
||||
bottom: 20,
|
||||
right: 5,
|
||||
child: FeedbackWidget(
|
||||
onPressed: () {
|
||||
|
||||
@@ -27,7 +27,7 @@ class CouponWidgetListItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
|
||||
// margin: const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
isClip
|
||||
|
||||
@@ -20,7 +20,6 @@ class TechnoWidgetListItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
Material(
|
||||
|
||||
@@ -16,10 +16,10 @@ import 'edit_category_panel.dart';
|
||||
|
||||
class CategoryPage extends StatelessWidget {
|
||||
final gridDelegate = const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 4,
|
||||
mainAxisSpacing: 10,
|
||||
crossAxisSpacing: 10,
|
||||
childAspectRatio: 0.8,
|
||||
crossAxisCount: 3,
|
||||
mainAxisSpacing: 25,
|
||||
crossAxisSpacing: 25,
|
||||
childAspectRatio: 0.9,
|
||||
);
|
||||
|
||||
@override
|
||||
@@ -27,7 +27,7 @@ class CategoryPage extends StatelessWidget {
|
||||
return BlocBuilder<CategoryBloc, CategoryState>(builder: (_, state) {
|
||||
if (state is CategoryLoadedState) {
|
||||
return GridView.builder(
|
||||
padding: EdgeInsets.all(10),
|
||||
padding: EdgeInsets.only(right: 20,left: 20,bottom: 20,top: 0),
|
||||
itemCount: state.categories.length,
|
||||
itemBuilder: (_, index) => Container(
|
||||
child: GestureDetector(
|
||||
@@ -70,40 +70,46 @@ class CategoryPage extends StatelessWidget {
|
||||
_editCollect(BuildContext context, CategoryModel model) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => Dialog(
|
||||
backgroundColor:Color(0xFFF2F2F2),
|
||||
elevation: 5,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10))),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Row(
|
||||
builder: (ctx) => UnconstrainedBox(
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
width: 400,
|
||||
child: Dialog(
|
||||
backgroundColor:Color(0xFFF2F2F2),
|
||||
elevation: 5,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10))),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20, right: 10),
|
||||
child: Circle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'修改收藏集',
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
Spacer(),
|
||||
CloseButton()
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20, right: 10),
|
||||
child: Circle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: EditCategoryPanel(model: model,type: EditType.update,),
|
||||
),
|
||||
Text(
|
||||
'修改收藏集',
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
Spacer(),
|
||||
CloseButton()
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: EditCategoryPanel(model: model,type: EditType.update,),
|
||||
),
|
||||
],
|
||||
),
|
||||
));
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
_toDetailPage(BuildContext context, CategoryModel model) {
|
||||
|
||||
@@ -12,10 +12,10 @@ import 'category_page.dart';
|
||||
class CollectPage extends StatelessWidget {
|
||||
|
||||
final gridDelegate = const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 4,
|
||||
mainAxisSpacing: 10,
|
||||
crossAxisSpacing: 10,
|
||||
childAspectRatio: 1 / 0.5,
|
||||
crossAxisCount: 3,
|
||||
mainAxisSpacing: 20,
|
||||
crossAxisSpacing: 20,
|
||||
childAspectRatio: 2,
|
||||
);
|
||||
|
||||
final _tabs = ['收藏集录','默认收藏', ];
|
||||
@@ -104,21 +104,22 @@ class CollectPage extends StatelessWidget {
|
||||
|
||||
Widget _buildContent(BuildContext context, CollectState state) {
|
||||
return SliverPadding(
|
||||
padding: EdgeInsets.only(top:10, left: 10, right: 10, bottom: 40),
|
||||
padding: EdgeInsets.only(left: 20,right: 20),
|
||||
sliver: SliverGrid(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(_, index) => Container(
|
||||
child: GestureDetector(
|
||||
onTap: () =>
|
||||
_toDetailPage(context, state.widgets[index]),
|
||||
child: CollectWidgetListItem(
|
||||
data: state.widgets[index],
|
||||
onDelectItemClick: (model) =>
|
||||
_deleteCollect(context, model),
|
||||
)),
|
||||
),
|
||||
childCount: state.widgets.length),
|
||||
gridDelegate: gridDelegate),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(_, index) => Container(
|
||||
child: GestureDetector(
|
||||
onTap: () =>
|
||||
_toDetailPage(context, state.widgets[index]),
|
||||
child: CollectWidgetListItem(
|
||||
data: state.widgets[index],
|
||||
onDelectItemClick: (model) =>
|
||||
_deleteCollect(context, model),
|
||||
)),
|
||||
),
|
||||
childCount: state.widgets.length),
|
||||
gridDelegate: gridDelegate
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ class _HomePageState extends State<HomePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var color = BlocProvider.of<HomeBloc>(context).state.homeColor;
|
||||
var showBg = BlocProvider.of<GlobalBloc>(context).state.showBackGround;
|
||||
return Scaffold(
|
||||
appBar: TolyAppBar(
|
||||
selectIndex: Cons.tabColors.indexOf(color.value),
|
||||
@@ -41,27 +40,34 @@ class _HomePageState extends State<HomePage> {
|
||||
),
|
||||
body: Stack(
|
||||
children: <Widget>[
|
||||
if (showBg) Background(),
|
||||
BlocBuilder<GlobalBloc, GlobalState>(builder: (_, state) {
|
||||
if (state.showBackGround) {
|
||||
return Background();
|
||||
}
|
||||
return Container();
|
||||
}),
|
||||
BlocBuilder<HomeBloc, HomeState>(builder: _buildContent)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final gridDelegate = const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 10,
|
||||
crossAxisSpacing: 10,
|
||||
childAspectRatio: 3.5,
|
||||
crossAxisSpacing: 20,
|
||||
childAspectRatio: 3.0,
|
||||
);
|
||||
|
||||
Widget _buildContent(BuildContext context, HomeState state) {
|
||||
if (state is WidgetsLoaded) {
|
||||
var items = state.widgets;
|
||||
print(items.length);
|
||||
if (items.isEmpty) return EmptyPage();
|
||||
return GridView.builder(
|
||||
padding: EdgeInsets.all(10),
|
||||
controller: _ctrl,
|
||||
padding: EdgeInsets.all(20),
|
||||
itemCount: items.length,
|
||||
itemBuilder: (_, index) =>_buildHomeItem(items[index]),
|
||||
itemBuilder: (_, index) => _buildHomeItem(items[index]),
|
||||
gridDelegate: gridDelegate,
|
||||
);
|
||||
}
|
||||
@@ -76,11 +82,16 @@ class _HomePageState extends State<HomePage> {
|
||||
Widget _buildHomeItem(
|
||||
WidgetModel model,
|
||||
) =>
|
||||
FeedbackWidget(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
onPressed: () => _toDetailPage(model),
|
||||
child: HomeItemSupport.get(model,
|
||||
BlocProvider.of<GlobalBloc>(context).state.itemStyleIndex));
|
||||
BlocBuilder<GlobalBloc, GlobalState>(
|
||||
condition: (p, c) => (p.itemStyleIndex != c.itemStyleIndex),
|
||||
builder: (_, state) {
|
||||
return
|
||||
FeedbackWidget(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
onPressed: () => _toDetailPage(model),
|
||||
child: HomeItemSupport.get(model, state.itemStyleIndex));
|
||||
},
|
||||
);
|
||||
|
||||
_updateAppBarHeight() {
|
||||
if (_ctrl.offset < _limitY * 4) {
|
||||
|
||||
@@ -31,6 +31,7 @@ class _TolyAppBarState extends State<TolyAppBar>
|
||||
double _width = 0;
|
||||
int _selectIndex = 0;
|
||||
double factor = 1.0;
|
||||
final navWidth =120;
|
||||
|
||||
List<int> colors = Cons.tabColors;
|
||||
List info = Cons.tabs;
|
||||
@@ -55,7 +56,7 @@ class _TolyAppBarState extends State<TolyAppBar>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_width = MediaQuery.of(context).size.width / colors.length;
|
||||
_width = (MediaQuery.of(context).size.width-navWidth) / colors.length;
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
child: Flow(
|
||||
|
||||
@@ -2,13 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_unit_mac/app/router.dart';
|
||||
import 'package:flutter_unit_mac/app/style/TolyIcon.dart';
|
||||
import 'package:flutter_unit_mac/blocs/collect/collect_bloc.dart';
|
||||
import 'package:flutter_unit_mac/blocs/collect/collect_event.dart';
|
||||
import 'package:flutter_unit_mac/blocs/detail/detail_bloc.dart';
|
||||
import 'package:flutter_unit_mac/blocs/detail/detail_event.dart';
|
||||
import 'package:flutter_unit_mac/blocs/search/search_bloc.dart';
|
||||
import 'package:flutter_unit_mac/blocs/search/search_event.dart';
|
||||
import 'package:flutter_unit_mac/blocs/search/search_state.dart';
|
||||
import 'package:flutter_unit_mac/blocs/bloc_exp.dart';
|
||||
import 'package:flutter_unit_mac/components/permanent/circle.dart';
|
||||
import 'package:flutter_unit_mac/storage/dao/widget_dao.dart';
|
||||
import 'package:flutter_unit_mac/model/widget_model.dart';
|
||||
@@ -21,7 +15,6 @@ import 'package:flutter_unit_mac/views/pages/search/start_filter.dart';
|
||||
|
||||
import 'empty_page.dart';
|
||||
|
||||
|
||||
class SearchPage extends StatefulWidget {
|
||||
@override
|
||||
_SearchPageState createState() => _SearchPageState();
|
||||
@@ -34,14 +27,16 @@ class _SearchPageState extends State<SearchPage> {
|
||||
body: WillPopScope(
|
||||
onWillPop: () async {
|
||||
//返回时 情空搜索
|
||||
BlocProvider.of<SearchBloc>(context).add(EventTextChanged(args: SearchArgs()));
|
||||
BlocProvider.of<SearchBloc>(context)
|
||||
.add(EventTextChanged(args: SearchArgs()));
|
||||
return true;
|
||||
},
|
||||
child: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
_buildSliverAppBar(),
|
||||
_buildSliverAppBar(),
|
||||
SliverToBoxAdapter(child: _buildStarFilter()),
|
||||
BlocBuilder<SearchBloc, SearchState>(builder: (_, state) => _buildBodyByState(state))
|
||||
BlocBuilder<SearchBloc, SearchState>(
|
||||
builder: (_, state) => _buildBodyByState(state))
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -50,15 +45,15 @@ class _SearchPageState extends State<SearchPage> {
|
||||
|
||||
Widget _buildSliverAppBar() {
|
||||
return SliverAppBar(
|
||||
pinned: true,
|
||||
title: AppSearchBar(),
|
||||
actions: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 15.0),
|
||||
child: Icon(TolyIcon.icon_sound),
|
||||
)
|
||||
],
|
||||
);
|
||||
pinned: true,
|
||||
title: AppSearchBar(),
|
||||
actions: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 15.0),
|
||||
child: Icon(TolyIcon.icon_sound),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStarFilter() => Column(
|
||||
@@ -99,28 +94,56 @@ class _SearchPageState extends State<SearchPage> {
|
||||
);
|
||||
|
||||
Widget _buildBodyByState(SearchState state) {
|
||||
if (state is SearchStateNoSearch) return SliverToBoxAdapter(child: NotSearchPage(),);
|
||||
if (state is SearchStateLoading) return SliverToBoxAdapter(child: LoadingPage());
|
||||
if (state is SearchStateError) return SliverToBoxAdapter(child: ErrorPage());
|
||||
if (state is SearchStateNoSearch)
|
||||
return SliverToBoxAdapter(
|
||||
child: NotSearchPage(),
|
||||
);
|
||||
if (state is SearchStateLoading)
|
||||
return SliverToBoxAdapter(child: LoadingPage());
|
||||
if (state is SearchStateError)
|
||||
return SliverToBoxAdapter(child: ErrorPage());
|
||||
if (state is SearchStateSuccess) return _buildSliverList(state.result);
|
||||
if (state is SearchStateEmpty) return SliverToBoxAdapter(child: EmptyPage());
|
||||
if (state is SearchStateEmpty)
|
||||
return SliverToBoxAdapter(child: EmptyPage());
|
||||
return NotSearchPage();
|
||||
}
|
||||
|
||||
Widget _buildSliverList(List<WidgetModel> models) => SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(_, int index) => Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 15, vertical: 5),
|
||||
Widget _buildSliverList(List<WidgetModel> models) => SliverPadding(
|
||||
padding: EdgeInsets.all(20),
|
||||
sliver: SliverGrid.count(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 10,
|
||||
crossAxisSpacing: 20,
|
||||
childAspectRatio: 3.5,
|
||||
children: models
|
||||
.asMap()
|
||||
.keys
|
||||
.map((index) => Container(
|
||||
// margin: EdgeInsets.symmetric(horizontal: 15, vertical: 5),
|
||||
child: InkWell(
|
||||
onTap: () => _toDetailPage(models[index]),
|
||||
child: TechnoWidgetListItem(
|
||||
data: models[index],
|
||||
))),
|
||||
childCount: models.length),
|
||||
);
|
||||
)),
|
||||
))
|
||||
.toList(),
|
||||
// delegate: SliverChildBuilderDelegate(
|
||||
// (_, int index) =>
|
||||
// Container(
|
||||
// margin: EdgeInsets.symmetric(horizontal: 15, vertical: 5),
|
||||
// child:
|
||||
// InkWell(
|
||||
// onTap: () => _toDetailPage(models[index]),
|
||||
// child: TechnoWidgetListItem(
|
||||
// data: models[index],
|
||||
// ))
|
||||
// ),
|
||||
// childCount: models.length),
|
||||
),
|
||||
);
|
||||
|
||||
_doSelectStart(List<int> select) {
|
||||
var temp = select.map((e)=>e+1).toList();
|
||||
var temp = select.map((e) => e + 1).toList();
|
||||
if (temp.length < 5) {
|
||||
temp.addAll(List.generate(5 - temp.length, (e) => -1));
|
||||
}
|
||||
@@ -130,6 +153,6 @@ class _SearchPageState extends State<SearchPage> {
|
||||
|
||||
_toDetailPage(WidgetModel model) {
|
||||
BlocProvider.of<DetailBloc>(context).add(FetchWidgetDetail(model));
|
||||
Navigator.pushNamed(context, Router.widget_detail,arguments: model);
|
||||
Navigator.pushNamed(context, Router.widget_detail, arguments: model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,14 @@ class Hello {
|
||||
});
|
||||
}""";
|
||||
|
||||
|
||||
final gridDelegate = const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 10,
|
||||
crossAxisSpacing: 20,
|
||||
childAspectRatio: 1.5,
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -43,9 +51,11 @@ class Hello {
|
||||
|
||||
Widget _buildFontCell(
|
||||
BuildContext context, List<HighlighterStyle> styles, int index) {
|
||||
return ListView.builder(
|
||||
itemCount: styles.length,
|
||||
itemBuilder: (_ctx, i) => FeedbackWidget(
|
||||
return GridView.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
padding: EdgeInsets.all(20),
|
||||
itemCount: styles.length,
|
||||
itemBuilder: (_, i) => FeedbackWidget(
|
||||
a: 0.95,
|
||||
duration: Duration(milliseconds: 200),
|
||||
onPressed: (){
|
||||
|
||||
@@ -30,7 +30,7 @@ class FontSettingPage extends StatelessWidget {
|
||||
return GridView.count(
|
||||
padding: EdgeInsets.only(top: 20, left: 10, right: 10),
|
||||
shrinkWrap: true,
|
||||
crossAxisCount: 2,
|
||||
crossAxisCount: 3,
|
||||
mainAxisSpacing: 10,
|
||||
crossAxisSpacing: 10,
|
||||
childAspectRatio: 1.5,
|
||||
|
||||
@@ -15,6 +15,15 @@ import 'package:flutter_unit_mac/views/items/home_item_support.dart';
|
||||
/// 说明: item样式切换支持
|
||||
|
||||
class ItemStyleSettingPage extends StatelessWidget {
|
||||
|
||||
final gridDelegate = const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 10,
|
||||
crossAxisSpacing: 20,
|
||||
childAspectRatio: 3.5,
|
||||
);
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -31,33 +40,37 @@ class ItemStyleSettingPage extends StatelessWidget {
|
||||
get items=> HomeItemSupport.itemSimples();
|
||||
|
||||
Widget _buildFontCell(BuildContext context, int index) {
|
||||
return ListView.builder(
|
||||
itemCount: items.length,
|
||||
itemBuilder: (_, i) => FeedbackWidget(
|
||||
a: 0.95,
|
||||
duration: Duration(milliseconds: 200),
|
||||
onPressed: () {
|
||||
BlocProvider.of<GlobalBloc>(context)
|
||||
.add(EventChangeItemStyle(i));
|
||||
},
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
items[i],
|
||||
if (index == i)
|
||||
Positioned(
|
||||
left: 25,
|
||||
top: 15,
|
||||
child: Circle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
radius: 10,
|
||||
child: Icon(
|
||||
Icons.check,
|
||||
color: Colors.white,
|
||||
size: 15,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)));
|
||||
return GridView.builder(
|
||||
padding: EdgeInsets.all(20),
|
||||
itemCount: items.length,
|
||||
itemBuilder: (_, i) => FeedbackWidget(
|
||||
a: 0.95,
|
||||
duration: Duration(milliseconds: 200),
|
||||
onPressed: () {
|
||||
BlocProvider.of<GlobalBloc>(context)
|
||||
.add(EventChangeItemStyle(i));
|
||||
},
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
items[i],
|
||||
if (index == i)
|
||||
Positioned(
|
||||
left: 25,
|
||||
top: 15,
|
||||
child: Circle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
radius: 10,
|
||||
child: Icon(
|
||||
Icons.check,
|
||||
color: Colors.white,
|
||||
size: 15,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)),
|
||||
gridDelegate: gridDelegate,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_unit_mac/app/res/cons.dart';
|
||||
import 'package:flutter_unit_mac/app/router.dart';
|
||||
import 'package:flutter_unit_mac/app/style/TolyIcon.dart';
|
||||
import 'package:flutter_unit_mac/blocs/global/global_bloc.dart';
|
||||
import 'package:flutter_unit_mac/blocs/global/global_event.dart';
|
||||
import 'package:flutter_unit_mac/blocs/global/global_state.dart';
|
||||
import 'package:flutter_unit_mac/components/permanent/feedback_widget.dart';
|
||||
import 'package:flutter_unit_mac/components/permanent/circle.dart';
|
||||
|
||||
|
||||
class SettingPage extends StatelessWidget {
|
||||
@override
|
||||
@@ -73,10 +71,7 @@ class SettingPage extends StatelessWidget {
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
title: Text('显示背景'),
|
||||
onChanged: (show) {
|
||||
BlocProvider.of<GlobalBloc>(context)
|
||||
.add(EventSwitchShowBg(show));
|
||||
},
|
||||
onChanged: (show) => BlocProvider.of<GlobalBloc>(context).add(EventSwitchShowBg(show)),
|
||||
));
|
||||
|
||||
Widget _nextIcon(BuildContext context) =>
|
||||
|
||||
@@ -13,6 +13,8 @@ import 'package:flutter_unit_mac/components/permanent/circle.dart';
|
||||
|
||||
class ThemeColorSettingPage extends StatelessWidget {
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -30,7 +32,7 @@ class ThemeColorSettingPage extends StatelessWidget {
|
||||
return GridView.count(
|
||||
padding: EdgeInsets.only(top: 20, left: 10, right: 10),
|
||||
shrinkWrap: true,
|
||||
crossAxisCount: 2,
|
||||
crossAxisCount: 4,
|
||||
mainAxisSpacing: 10,
|
||||
crossAxisSpacing: 10,
|
||||
childAspectRatio: 1.5,
|
||||
|
||||
Reference in New Issue
Block a user