Browse Source

1.优化首页公告栏、轮播图、多眼导航

tags/0.0.3+2
“yanghuaxuan” 4 years ago
parent
commit
7d4e6a970b
4 changed files with 46 additions and 32 deletions
  1. +33
    -28
      lib/widgets/custom/multi_nav/custom_quick_entry.dart
  2. +5
    -2
      lib/widgets/custom/notice/custom_notice_widget.dart
  3. +2
    -2
      lib/widgets/custom/slide_banner/custom_slide_banner.dart
  4. +6
    -0
      lib/widgets/custom/slide_banner/model/custom_slide_banner_model.dart

+ 33
- 28
lib/widgets/custom/multi_nav/custom_quick_entry.dart View File

@@ -19,7 +19,9 @@ class CustomQuickEntry extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocProvider<CustomQuickEntryBloc>( return BlocProvider<CustomQuickEntryBloc>(
create: (_) => CustomQuickEntryBloc(repository: CustomQuickEntryRepository())..add(CustomQuickEntryInitEvent(model: model)), create: (_) =>
CustomQuickEntryBloc(repository: CustomQuickEntryRepository())
..add(CustomQuickEntryInitEvent(model: model)),
child: _CustomQuickEntryContainer(model), child: _CustomQuickEntryContainer(model),
); );
} }
@@ -27,7 +29,9 @@ class CustomQuickEntry extends StatelessWidget {


class _CustomQuickEntryContainer extends StatefulWidget { class _CustomQuickEntryContainer extends StatefulWidget {
final Map<String, dynamic> model; final Map<String, dynamic> model;

_CustomQuickEntryContainer(this.model); _CustomQuickEntryContainer(this.model);

@override @override
__CustomQuickEntryContainerState createState() => __CustomQuickEntryContainerState(); __CustomQuickEntryContainerState createState() => __CustomQuickEntryContainerState();
} }
@@ -57,8 +61,7 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocConsumer<CustomQuickEntryBloc, CustomQuickEntryState>( return BlocConsumer<CustomQuickEntryBloc, CustomQuickEntryState>(
listener: (context, state) { listener: (context, state) {},
},
buildWhen: (prev, current) { buildWhen: (prev, current) {
return true; return true;
}, },
@@ -69,14 +72,14 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer>
if (state is CustomQuickEntryLoadedState) { if (state is CustomQuickEntryLoadedState) {
return _getMainWidget(state.model); return _getMainWidget(state.model);
} }
if(state is CustomQuickEntryErrorState){ if (state is CustomQuickEntryErrorState) {
return Container(); return Container();
} }
return CustomQuickEntrySkeleton(); return CustomQuickEntrySkeleton();
}, },
); );
} }
Widget _getMainWidget(CustomQuickEntryModel model) { Widget _getMainWidget(CustomQuickEntryModel model) {
// 数据总数 // 数据总数
int totalDataSize = model?.listStyle?.length ?? 0; int totalDataSize = model?.listStyle?.length ?? 0;
@@ -128,16 +131,18 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer>
// } // }


return Container( return Container(
margin: EdgeInsets.only(top: ParseUtil.stringParseDouble(model?.topMargin)), margin: EdgeInsets.only(top: double.tryParse(model?.topMargin),
left: ParseUtil.stringParseDouble(model?.leftRightMargin),
right: ParseUtil.stringParseDouble(model?.leftRightMargin)),
decoration: BoxDecoration( decoration: BoxDecoration(
color: HexColor.fromHex(model?.bgColor ?? ''), color: HexColor.fromHex(model?.bgColor ?? ''),
// color: Colors.green, //color: Colors.green,
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
topRight: Radius.circular(ParseUtil.stringParseDouble(model?.topRightRadius)), topRight: Radius.circular(ParseUtil.stringParseDouble(model?.topRightRadius)),
topLeft: Radius.circular(ParseUtil.stringParseDouble(model?.topLeftRadius)), topLeft: Radius.circular(ParseUtil.stringParseDouble(model?.topLeftRadius)),
bottomLeft: Radius.circular(ParseUtil.stringParseDouble(model?.bottomLeftRadius)), bottomLeft: Radius.circular(ParseUtil.stringParseDouble(model?.bottomLeftRadius)),
bottomRight: Radius.circular(ParseUtil.stringParseDouble(model?.bottomRightRadius)), bottomRight: Radius.circular(ParseUtil.stringParseDouble(model?.bottomRightRadius)),
) )
), ),
child: Container( child: Container(
margin: EdgeInsets.only(top: !hasCategory ? 15 : 0, bottom: totalPage > 1 ? 15 : 0), margin: EdgeInsets.only(top: !hasCategory ? 15 : 0, bottom: totalPage > 1 ? 15 : 0),
@@ -150,7 +155,7 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer>


Container( Container(
width: double.infinity, width: double.infinity,
height: hasCategory ? totalHeight - categoryHeight - categoryBottomMargin : totalHeight , height: hasCategory ? totalHeight - categoryHeight - categoryBottomMargin : totalHeight,
child: Swiper( child: Swiper(
controller: _controller, controller: _controller,
itemCount: totalPage, itemCount: totalPage,
@@ -274,17 +279,16 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer>
} }


/// 行的数据 /// 行的数据
Widget _getRowWidget( Widget _getRowWidget({double titleHeight,
{double titleHeight, double iconHeight,
double iconHeight, int totalPage,
int totalPage, int currentPage,
int currentPage, int columSize,
int columSize, int totalRowSize,
int totalRowSize, int totalDataSize,
int totalDataSize, CustomQuickEntryModel model,
CustomQuickEntryModel model, int currentRow,
int currentRow, double itemHeight}) {
double itemHeight}) {
List itemList = []; List itemList = [];
for (int i = 0; i < columSize; i++) { for (int i = 0; i < columSize; i++) {
itemList.add(i); itemList.add(i);
@@ -353,6 +357,7 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer>
// color: Colors.red, // color: Colors.red,
child: Column( child: Column(
children: <Widget>[ children: <Widget>[

/// 图标 /// 图标
MyNetWorkImage(item.img), MyNetWorkImage(item.img),


@@ -404,7 +409,8 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer>
SwiperPagination _swiperPaginationDot(CustomQuickEntryModel model) { SwiperPagination _swiperPaginationDot(CustomQuickEntryModel model) {
return SwiperPagination( return SwiperPagination(
margin: const EdgeInsets.only(), margin: const EdgeInsets.only(),
builder: DotSwiperPaginationBuilder(color: HexColor.fromHex(model?.paginationUnselectColor), activeColor: HexColor.fromHex(model?.paginationSelectColor), size: 8, activeSize: 8)); builder: DotSwiperPaginationBuilder(
color: HexColor.fromHex(model?.paginationUnselectColor), activeColor: HexColor.fromHex(model?.paginationSelectColor), size: 8, activeSize: 8));
} }


// 自定义进度条 条形 // 自定义进度条 条形
@@ -465,7 +471,6 @@ class MyNetWorkImage extends StatelessWidget {
} }





// Widget _getMainWidget(CustomQuickEntryModel model) { // Widget _getMainWidget(CustomQuickEntryModel model) {
// // 数据总数 // // 数据总数
// int totalDataSize = model?.listStyle?.length ?? 0; // int totalDataSize = model?.listStyle?.length ?? 0;


+ 5
- 2
lib/widgets/custom/notice/custom_notice_widget.dart View File

@@ -68,14 +68,17 @@ class _CustomNoticeWidgetContainerState extends State<_CustomNoticeWidgetContain
width: double.infinity, width: double.infinity,
decoration: BoxDecoration( decoration: BoxDecoration(
color: HexColor.fromHex(model?.bgColor), color: HexColor.fromHex(model?.bgColor),
// color: Colors.orangeAccent, //color: Colors.orangeAccent,
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
topRight: Radius.circular(ParseUtil.stringParseDouble(model?.topRightRadius, defVal: 7.5)), topRight: Radius.circular(ParseUtil.stringParseDouble(model?.topRightRadius, defVal: 7.5)),
topLeft: Radius.circular(ParseUtil.stringParseDouble(model?.topLeftRadius, defVal: 7.5)), topLeft: Radius.circular(ParseUtil.stringParseDouble(model?.topLeftRadius, defVal: 7.5)),
bottomLeft: Radius.circular(ParseUtil.stringParseDouble(model?.bottomLeftRadius, defVal: 7.5)), bottomLeft: Radius.circular(ParseUtil.stringParseDouble(model?.bottomLeftRadius, defVal: 7.5)),
bottomRight: Radius.circular(ParseUtil.stringParseDouble(model?.bottomRightRadius, defVal: 7.5)), bottomRight: Radius.circular(ParseUtil.stringParseDouble(model?.bottomRightRadius, defVal: 7.5)),
)), )),
margin: EdgeInsets.only(top: ParseUtil.stringParseDouble(model?.topMargin)), margin: EdgeInsets.only(
top: ParseUtil.stringParseDouble(model?.topMargin),
left: ParseUtil.stringParseDouble(model?.leftRightMargin),
right: ParseUtil.stringParseDouble(model?.leftRightMargin)),
padding: EdgeInsets.symmetric(horizontal: ParseUtil.stringParseDouble(model?.leftRightMargin, defVal: 12.5), vertical: 7.5), padding: EdgeInsets.symmetric(horizontal: ParseUtil.stringParseDouble(model?.leftRightMargin, defVal: 12.5), vertical: 7.5),
child: Container( child: Container(
decoration: BoxDecoration(borderRadius: BorderRadius.circular(7.5), color: HexColor.fromHex('#F6F6F6')), decoration: BoxDecoration(borderRadius: BorderRadius.circular(7.5), color: HexColor.fromHex('#F6F6F6')),


+ 2
- 2
lib/widgets/custom/slide_banner/custom_slide_banner.dart View File

@@ -123,7 +123,7 @@ class _CustomSlideBannerContainerState extends State<CustomSlideBannerContainer>
child: Container( child: Container(
width: double.infinity, width: double.infinity,
height: double.infinity, height: double.infinity,
color: size > 1 ? HexColor.fromHex('#FFFF4242') : Colors.transparent, color: size > 1 ? HexColor.fromHex(datas?.bgColor2??"#FFFF4242") : Colors.transparent,
// color: Colors.yellow, // color: Colors.yellow,
), ),
), ),
@@ -132,7 +132,7 @@ class _CustomSlideBannerContainerState extends State<CustomSlideBannerContainer>
child: Container( child: Container(
height: double.infinity, height: double.infinity,
width: double.infinity, width: double.infinity,
color: size > 1 ? Colors.white : Colors.transparent, color: size > 1 ? HexColor.fromHex(datas?.bgColor??"#FFFFFF") : Colors.transparent,
// color: Colors.yellow, // color: Colors.yellow,
), ),
) )


+ 6
- 0
lib/widgets/custom/slide_banner/model/custom_slide_banner_model.dart View File

@@ -17,6 +17,8 @@ class CustomSlideBannerModel {
String carouselTime; String carouselTime;
String topMargin; String topMargin;
String leftRightMargin; String leftRightMargin;
String bgColor;
String bgColor2;
List<IndexCarouselList> indexCarouselList; List<IndexCarouselList> indexCarouselList;
int moduleKeyId; int moduleKeyId;


@@ -39,6 +41,8 @@ class CustomSlideBannerModel {
this.leftRightMargin, this.leftRightMargin,
this.indexCarouselList, this.indexCarouselList,
this.moduleKeyId, this.moduleKeyId,
this.bgColor,
this.bgColor2
}); });


CustomSlideBannerModel.fromJson(Map<String, dynamic> json) { CustomSlideBannerModel.fromJson(Map<String, dynamic> json) {
@@ -58,6 +62,8 @@ class CustomSlideBannerModel {
carouselTime = json['carousel_time']; carouselTime = json['carousel_time'];
topMargin = json['top_margin']; topMargin = json['top_margin'];
leftRightMargin = json['left_right_margin']; leftRightMargin = json['left_right_margin'];
bgColor=json['bg_color'];
bgColor2=json['bg_color2'];
if (json['index_carousel_list'] != null) { if (json['index_carousel_list'] != null) {
indexCarouselList = new List<IndexCarouselList>(); indexCarouselList = new List<IndexCarouselList>();
json['index_carousel_list'].forEach((v) { json['index_carousel_list'].forEach((v) {


||||||
x
 
000:0
Loading…
Cancel
Save