forked from lxm_flutter/FlutterUnit
优化条目点击事件
This commit is contained in:
@@ -131,7 +131,6 @@ class CouponShapeBorder extends ShapeBorder {
|
||||
|
||||
@override
|
||||
ShapeBorder scale(double t) {
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,41 +20,44 @@ class ItemStyleSettingPage extends StatelessWidget {
|
||||
title: Text('item样式设置'),
|
||||
),
|
||||
body: BlocBuilder<GlobalBloc, GlobalState>(builder: (_, state) {
|
||||
return _buildFontCell(context, state.itemStyleIndex);
|
||||
return _buildCell(context, state.itemStyleIndex);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> get items=> HomeItemSupport.itemSimples();
|
||||
|
||||
Widget _buildFontCell(BuildContext context, int index) {
|
||||
Widget _buildCell(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,
|
||||
itemBuilder: (_, i) => Padding(
|
||||
padding: EdgeInsets.only(bottom: 8,left: 8,right: 8),
|
||||
child: 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,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)));
|
||||
)
|
||||
],
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_star/flutter_star.dart';
|
||||
import 'package:flutter_unit/app/res/cons.dart';
|
||||
import 'package:flutter_unit/app/res/style/shape/coupon_shape_border.dart';
|
||||
import 'package:flutter_unit/app/router/unit_router.dart';
|
||||
import 'package:flutter_unit/widget_system/blocs/widget_system_bloc.dart';
|
||||
|
||||
import 'package:flutter_unit/components/permanent/circle_image.dart';
|
||||
@@ -26,26 +27,24 @@ class CouponWidgetListItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 10,top:2,left: 10,right: 10),
|
||||
final CouponShapeBorder couponShapeBorder = CouponShapeBorder(
|
||||
hasTopHole: hasTopHole,
|
||||
hasBottomHole: hasBottomHole,
|
||||
hasLine: false,
|
||||
edgeRadius: 25,
|
||||
lineRate: 0.20);
|
||||
|
||||
child: Stack(
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
isClip
|
||||
? ClipPath(
|
||||
clipper: ShapeBorderClipper(
|
||||
shape: CouponShapeBorder(
|
||||
hasTopHole: hasTopHole,
|
||||
hasBottomHole: hasBottomHole,
|
||||
hasLine: false,
|
||||
edgeRadius: 25,
|
||||
lineRate: 0.20)),
|
||||
shape: couponShapeBorder),
|
||||
child: buildContent(),
|
||||
)
|
||||
: buildContent(),
|
||||
_buildCollectTag(Theme.of(context).primaryColor)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_unit/app/res/style/shape/coupon_shape_border.dart';
|
||||
import 'package:flutter_unit/app/res/style/shape/techno_shape.dart';
|
||||
import 'package:flutter_unit/widget_system/repositories/model/enums.dart';
|
||||
import 'package:flutter_unit/widget_system/repositories/model/widget_model.dart';
|
||||
import 'package:flutter_unit/components/project/items/widget/simple_widget_list_item.dart';
|
||||
@@ -13,6 +15,30 @@ import 'techno_widget_list_item.dart';
|
||||
/// 说明:
|
||||
|
||||
class HomeItemSupport {
|
||||
|
||||
static Map<int,ShapeBorder> shapeBorderMap={
|
||||
1: TechnoShapeBorder(),
|
||||
2: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6)),
|
||||
3: CouponShapeBorder(
|
||||
hasTopHole: true,
|
||||
hasBottomHole: false,
|
||||
hasLine: false,
|
||||
edgeRadius: 25,
|
||||
lineRate: 0.20),
|
||||
4: CouponShapeBorder(
|
||||
hasTopHole: false,
|
||||
hasBottomHole: false,
|
||||
hasLine: false,
|
||||
edgeRadius: 25,
|
||||
lineRate: 0.20),
|
||||
5: CouponShapeBorder(
|
||||
hasTopHole: true,
|
||||
hasBottomHole: false,
|
||||
hasLine: false,
|
||||
edgeRadius: 25,
|
||||
lineRate: 0.20),
|
||||
};
|
||||
|
||||
static Widget get(
|
||||
WidgetModel model,
|
||||
int index,
|
||||
|
||||
@@ -24,12 +24,11 @@ class SimpleWidgetListItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
|
||||
decoration: BoxDecoration(
|
||||
color: itemColor.withAlpha(66),
|
||||
borderRadius: BorderRadius.circular(6)
|
||||
),
|
||||
margin: const EdgeInsets.only(bottom: 10,top:2,left: 10,right: 10),
|
||||
// margin: const EdgeInsets.only(bottom: 10,top:2,left: 10,right: 10),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
|
||||
@@ -18,9 +18,7 @@ class TechnoWidgetListItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 10,top:2,left: 10,right: 10),
|
||||
child: Stack(
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
Material(
|
||||
color: itemColor.withAlpha(66),
|
||||
@@ -62,8 +60,7 @@ class TechnoWidgetListItem extends StatelessWidget {
|
||||
),
|
||||
_buildCollectTag(Theme.of(context).primaryColor)
|
||||
],
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCollectTag(Color color) {
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_unit/app/router/unit_router.dart';
|
||||
import 'package:flutter_unit/app/res/toly_icon.dart';
|
||||
import 'package:flutter_unit/components/project/items/widget/home_item_support.dart';
|
||||
import 'package:flutter_unit/widget_system/repositories/repositories.dart';
|
||||
|
||||
import 'package:flutter_unit/components/permanent/circle.dart';
|
||||
@@ -105,8 +106,11 @@ class _SearchPageState extends State<SearchPage> {
|
||||
|
||||
Widget _buildSliverList(List<WidgetModel> models) => SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(_, int index) => Container(
|
||||
(_, int index) => Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(bottom: 10, top: 2, left: 10, right: 10),
|
||||
child: InkWell(
|
||||
customBorder: HomeItemSupport.shapeBorderMap[index],
|
||||
onTap: () => _toDetailPage(models[index]),
|
||||
child: TechnoWidgetListItem(
|
||||
data: models[index],
|
||||
|
||||
@@ -3,26 +3,24 @@ import 'dart:math';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_unit/app/blocs/color_change_bloc.dart';
|
||||
import 'package:flutter_unit/app/blocs/global/global_bloc.dart';
|
||||
import 'package:flutter_unit/app/blocs/global/global_state.dart';
|
||||
import 'package:flutter_unit/app/res/cons.dart';
|
||||
import 'package:flutter_unit/app/router/unit_router.dart';
|
||||
import 'package:flutter_unit/app/utils/convert.dart';
|
||||
import 'package:flutter_unit/widget_system/repositories/model/enums.dart';
|
||||
import 'package:flutter_unit/widget_system/repositories/model/widget_model.dart';
|
||||
|
||||
import 'package:flutter_unit/components/permanent/feedback_widget.dart';
|
||||
import 'package:flutter_unit/components/project/default/empty_shower.dart';
|
||||
import 'package:flutter_unit/components/project/default/error_shower.dart';
|
||||
import 'package:flutter_unit/components/project/default/loading_shower.dart';
|
||||
import 'package:flutter_unit/components/project/items/widget/home_item_support.dart';
|
||||
import 'package:flutter_unit/components/project/no_more_widget.dart';
|
||||
import 'package:flutter_unit/components/project/overlay_tool_wrapper.dart';
|
||||
import 'package:flutter_unit/app/blocs/color_change_bloc.dart';
|
||||
import 'package:flutter_unit/widget_system/blocs/widget_system_bloc.dart';
|
||||
import 'toly_app_bar.dart';
|
||||
import 'package:flutter_unit/widget_system/repositories/model/enums.dart';
|
||||
import 'package:flutter_unit/widget_system/repositories/model/widget_model.dart';
|
||||
|
||||
import 'background.dart';
|
||||
import 'toly_app_bar.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
@override
|
||||
@@ -121,23 +119,32 @@ class _HomePageState extends State<HomePage>
|
||||
BlocBuilder<GlobalBloc, GlobalState>(
|
||||
buildWhen: (p, c) => (p.itemStyleIndex != c.itemStyleIndex),
|
||||
builder: (_, state) {
|
||||
return FeedbackWidget(
|
||||
a: 0.95,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
onEnd: () => _toDetailPage(model),
|
||||
child: HomeItemSupport.get(model, state.itemStyleIndex));
|
||||
int index = state.itemStyleIndex;
|
||||
ShapeBorder? shapeBorder = HomeItemSupport.shapeBorderMap[index];
|
||||
return Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(bottom: 10, top: 2, left: 10, right: 10),
|
||||
child: InkWell(
|
||||
customBorder: shapeBorder,
|
||||
onTap: ()=> _toDetail(model),
|
||||
child: HomeItemSupport.get(model, index)),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
_switchTab(int index) {
|
||||
void _switchTab(int index) {
|
||||
WidgetFamily widgetFamily = Convert.toFamily(index);
|
||||
context.read<ColorChangeCubit>().change(Cons.tabColors[index],family: widgetFamily);
|
||||
BlocProvider.of<WidgetsBloc>(context).add(EventTabTap(widgetFamily));
|
||||
}
|
||||
|
||||
_toDetailPage(WidgetModel model) {
|
||||
void _toDetail(WidgetModel model){
|
||||
BlocProvider.of<DetailBloc>(context).add(FetchWidgetDetail(model));
|
||||
Navigator.pushNamed(context, UnitRouter.widget_detail, arguments: model);
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
UnitRouter.widget_detail,
|
||||
arguments: model,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user