Bläddra i källkod

1.钱包 - 构建基本页面

2.账单明细 - 构建基本页面
3.智能粘贴板 - 构建基本弹窗,编写基本监听逻辑
tags/0.0.1
杨华轩 4 år sedan
förälder
incheckning
ac4ba5c098
26 ändrade filer med 1908 tillägg och 55 borttagningar
  1. +115
    -0
      lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart
  2. +246
    -0
      lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart
  3. +183
    -0
      lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_no_goods_dialog.dart
  4. +50
    -0
      lib/dialog/global_dialog/intellect_search_goods_dialog/model/Intellect_search_set_model.dart
  5. +209
    -0
      lib/dialog/select_date_ym_dialog/select_date_ym_dialog.dart
  6. +134
    -0
      lib/pages/bil_detail_page/bil_detail_page.dart
  7. +53
    -0
      lib/pages/bil_detail_page/bil_detail_page_bloc.dart
  8. +5
    -0
      lib/pages/bil_detail_page/model/bil_detail_page_model.dart
  9. +1
    -0
      lib/pages/home_page/home_page.dart
  10. +17
    -1
      lib/pages/main_page/main_page.dart
  11. +97
    -27
      lib/pages/wallet_page/wallet_page.dart
  12. +17
    -7
      lib/pages/wallet_page/wallet_page_bloc.dart
  13. +18
    -6
      lib/register.dart
  14. +18
    -0
      lib/utils/contants.dart
  15. +1
    -1
      lib/widgets/home/home_slide_banner/home_slide_banner.dart
  16. +2
    -1
      lib/widgets/mine/mine_header/mine_header_container.dart
  17. +25
    -0
      lib/widgets/wallet/wallet_appbar/model/WalletAppbarModel.dart
  18. +34
    -0
      lib/widgets/wallet/wallet_appbar/wallet_appbar.dart
  19. +25
    -0
      lib/widgets/wallet/wallet_bil/model/wallet_bli_model.dart
  20. +46
    -0
      lib/widgets/wallet/wallet_bil/wallet_bil.dart
  21. +93
    -0
      lib/widgets/wallet/wallet_data/model/wallet_header_model.dart
  22. +111
    -1
      lib/widgets/wallet/wallet_data/wallet_data.dart
  23. +1
    -1
      lib/widgets/wallet/wallet_data/wallet_data_creater.dart
  24. +226
    -0
      lib/widgets/wallet/wallet_detail/model/wallet_detail_model.dart
  25. +174
    -8
      lib/widgets/wallet/wallet_detail/wallet_detail.dart
  26. +7
    -2
      pubspec.yaml

+ 115
- 0
lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart Visa fil

@@ -0,0 +1,115 @@
import 'dart:async';
import 'dart:convert';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:zhiying_base_widget/dialog/global_dialog/intellect_search_goods_dialog/model/Intellect_search_set_model.dart';
import 'package:zhiying_base_widget/utils/contants.dart';
import 'package:zhiying_comm/util/shared_prefe_util.dart';

import 'intellect_search_goods_dialog.dart';
import 'intellect_search_no_goods_dialog.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:string_validator/string_validator.dart';

class IntellectCreate {
static IntellectSearchSetModel _setModel;

///判断规则
static checkAndCreate(AppLifecycleState state, BuildContext context) async {
if (state == AppLifecycleState.resumed &&
!Constants.isShowIntellectDialog) {
_requestSetData(context);
}
}

///请求设置参数
static _requestSetData(BuildContext context) async {
if (_setModel == null) {
var param = {"webId": ""};

//请求参数
NetUtil.request('/api/v1/cfg/app_clipboard', params: param,
onSuccess: (data) async {
print("设置参数" + data.toString());

///检查是否已缓存过设置信息
String result = await SharedPreferencesUtil.getStringValue(
Constants.spIsCacheSetModel);
_setModel = IntellectSearchSetModel.fromJson(data);
if (result.isEmpty) {
validate(context, _setModel);
}
SharedPreferencesUtil.setNetCacheResult(
Constants.spIsCacheSetModel, json.encode(data));
});

///拿缓存数据
var cacheData = await SharedPreferencesUtil.getNetCacheResult(
Constants.spIsCacheSetModel);
///如果存在缓存直接进入验证阶段
if (cacheData.isNotEmpty) {
_setModel = IntellectSearchSetModel.fromJson(cacheData);
validate(context, _setModel);
}
} else {
validate(context, _setModel);
}
}

static checkAndCreateFirst(BuildContext context) async {
///检查规则
IntellectCreate.checkAndCreate(AppLifecycleState.resumed, context);
}

///请求数据打开弹窗
static requestDialog(BuildContext context, String content) async {
Constants.isShowIntellectDialog = true;
await showDialog(context: context, child: IntellectSearchGoodsDialog());
Constants.isShowIntellectDialog = false;
}

///检查字段是否被监听
static void validate(
BuildContext context, IntellectSearchSetModel setModel) async {
ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain);
String content = data.text;
//是否监听
if (setModel.state != "1") {
return;
}

///长度大小限制
if (setModel.keywordLimitState == "1" &&
(int.tryParse(setModel.keywordLimitMin) < content.length) ||
(int.tryParse(setModel.keywordLimitMax) > content.length)) {
return;
}

//是否纯数字
if (setModel.keywordNum == "1" && isNumeric(content)) {
return;
}

///是否纯字母
if (setModel.keywordAlpha == "1" && isAlpha(content)) {
return;
}

///是否仅包含数字和字母
if (setModel.keywordAlphanum == "1" && isAlphanumeric(content)) {
return;
}

///是否包含某个排除词
if (setModel.exclude.length > 0) {
for (var item in setModel.exclude) {
if (contains(content, item)) {
return;
}
}
}
requestDialog(context, content);
}
}

+ 246
- 0
lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart Visa fil

@@ -0,0 +1,246 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:zhiying_base_widget/widgets/home/home_quick_entry/cached_network_image_util.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class IntellectSearchGoodsDialog extends StatefulWidget {
@override
_IntellectSearchGoodsDialogState createState() =>
_IntellectSearchGoodsDialogState();
}

class _IntellectSearchGoodsDialogState
extends State<IntellectSearchGoodsDialog> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: InkWell(
onTap: () {
Navigator.of(context).pop();
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
GestureDetector(
onTap: () {},
child: Stack(
children: <Widget>[
Container(
margin: EdgeInsets.only(top: 38.h, left: 92.w, right: 92.w),
padding: EdgeInsets.only(
top: (38 + 38).h,
left: 30.w,
right: 30.w,
bottom: 48.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16)),
width: double.infinity,
child: Column(
children: <Widget>[_bulidTopItem(), _buildBottomItem()],
),
),
Container(
height: 76.h,
child: Center(
child: Container(
color: Colors.red,
height: 76.h,
width: 216.w,
child: CachedNetworkImage(
imageUrl: "",
),
)),
),
],
),
)
],
),
),
);
}

_bulidTopItem() {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
color: Colors.red,
width: 160.w,
height: 160.w,
),
SizedBox(
width: 19.w,
),
Expanded(
child: Container(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
children: <Widget>[
Text(
"2020新款春款波点连衣裙新短发dfasdfas短发时代发发呆发顺丰的打算萨阿啊",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: Colors.black, fontSize: 24.sp),
),
SizedBox(
height: 5.h,
),
Row(
children: <Widget>[
Container(
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(2)),
padding: EdgeInsets.all(2),
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
width: 30.w,
height: 30.w,
decoration: BoxDecoration(color: Colors.white),
child: Center(
child: Text(
"券",
style: TextStyle(
color: Colors.red, fontSize: 20.sp),
),
),
),
Padding(
padding: const EdgeInsets.only(left: 4, right: 4),
child: Text(
"¥100",
style: TextStyle(
color: Colors.white, fontSize: 20.sp),
),
)
],
),
),
SizedBox(
width: 12.w,
),
Container(
decoration: BoxDecoration(
color: HexColor.fromHex("#FFFFF6C1"),
borderRadius: BorderRadius.circular(2)),
padding: EdgeInsets.all(2),
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
height: 30.w,
),
Center(
child: Padding(
padding:
const EdgeInsets.only(left: 4, right: 4),
child: Text(
"预计返",
style: TextStyle(
color: Colors.deepOrangeAccent,
fontSize: 20.sp),
),
),
)
],
),
)
],
),
],
),
SizedBox(
height: 10.h,
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(bottom: 2),
child: Text(
"券后",
style: TextStyle(fontSize: 20.sp, color: Colors.red),
),
),
Padding(
padding:
const EdgeInsets.only(bottom: 2, left: 4, right: 4),
child: Text(
"¥",
style: TextStyle(fontSize: 20.sp, color: Colors.red),
),
),
Text(
"999",
style: TextStyle(
fontSize: 32.sp,
color: Colors.red,
),
)
],
)
],
),
))
],
);
}

_buildBottomItem() {
return Column(
children: <Widget>[
SizedBox(
height: 24,
),
Row(
children: <Widget>[
Expanded(
child: Container(
margin: EdgeInsets.only(left: 20.w, right: 20.w),
decoration: BoxDecoration(
color: Colors.red, borderRadius: BorderRadius.circular(50)),
child: Center(
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Text(
"合法化 ",
style: TextStyle(color: Colors.white, fontSize: 24.sp),
),
)),
))
],
),
SizedBox(
height: 16,
),
Row(
children: <Widget>[
Expanded(
child: Container(
margin: EdgeInsets.only(left: 20.w, right: 20.w),
decoration: BoxDecoration(
color: Colors.red, borderRadius: BorderRadius.circular(50)),
child: Center(
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Text(
"合法化 ",
style: TextStyle(color: Colors.white, fontSize: 24.sp),
),
)),
))
],
)
],
);
}
}

+ 183
- 0
lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_no_goods_dialog.dart Visa fil

@@ -0,0 +1,183 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:zhiying_base_widget/widgets/home/home_quick_entry/cached_network_image_util.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class IntellectSearchNoGoodsDialog extends StatefulWidget {
@override
_IntellectSearchNoGoodsDialogState createState() =>
_IntellectSearchNoGoodsDialogState();
}

class _IntellectSearchNoGoodsDialogState
extends State<IntellectSearchNoGoodsDialog> {
TextEditingController _textEditingController;

@override
void initState() {
_textEditingController = TextEditingController();
_getClipBoardData();
super.initState();
}

///获取粘贴板内容
_getClipBoardData() async {
ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain);
_textEditingController.text = data.text;
setState(() {});
}

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Stack(
children: <Widget>[
Container(
margin: EdgeInsets.only(top: 38.h, left: 92.w, right: 92.w),
padding: EdgeInsets.only(
top: (38 + 15).h, left: 30.w, right: 30.w, bottom: 48.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16)),
width: double.infinity,
child: Column(
children: <Widget>[_buildTopItem(), _buildBottomItem()],
),
),
Container(
height: 76.h,
child: Center(
child: Container(
color: Colors.red,
height: 76.h,
width: 216.w,
child: CachedNetworkImage(
imageUrl: "",
),
)),
),
],
)
],
),
);
}

_buildTopItem() {
return Container(
decoration: BoxDecoration(),
child: Column(
children: <Widget>[
Text(
"猜你要搜索以下商品",
style: TextStyle(color: Colors.red, fontSize: 30.sp),
),
Container(
margin: EdgeInsets.only(top: 12),
decoration: BoxDecoration(
color: Colors.deepOrangeAccent,
borderRadius: BorderRadius.circular(10)),
child: TextField(
controller: _textEditingController,
textAlign: TextAlign.start,
decoration: InputDecoration(
contentPadding: EdgeInsets.only(left: 10, top: 10, bottom: 4),
border: InputBorder.none,
),
maxLines: 5,
),
)
],
),
);
}

_buildBottomItem() {
return Column(
children: <Widget>[
SizedBox(
height: 24,
),
Row(
children: <Widget>[
Expanded(
child: Container(
decoration: BoxDecoration(
color: Colors.red, borderRadius: BorderRadius.circular(50)),
child: Center(
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Text(
"立即搜索 ",
style: TextStyle(color: Colors.white, fontSize: 24.sp),
),
)),
))
],
),
SizedBox(
height: 16,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Container(
height: 1,
width: 137.w,
color: Colors.deepOrange,
),
Text("搜索平台"),
Container(
height: 1,
width: 137.w,
color: Colors.deepOrange,
),
],
),
SizedBox(
height: 24,
),
Container(
height: 100.w,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: 10,
itemBuilder: _buildBottomListItem),
)
],
);
}

Widget _buildBottomListItem(BuildContext context, int index) {
return Container(
margin: EdgeInsets.only(left: 11,right: 11),
child: Column(
children: <Widget>[
Container(
color: Colors.deepOrange,
child: Image.network(
"",
width: 60.w,
height: 60.w,
fit: BoxFit.fill,
),
),
SizedBox(
height: 2,
),
Text(
"淘宝",
style: TextStyle(fontSize: 22.sp),
)
],
),
);
}
}

+ 50
- 0
lib/dialog/global_dialog/intellect_search_goods_dialog/model/Intellect_search_set_model.dart Visa fil

@@ -0,0 +1,50 @@
///智能粘贴板设置参数
///杨华轩
class IntellectSearchSetModel {
List<String> exclude;
String keywordAlpha;
String keywordAlphanum;
String keywordLimitMax;
String keywordLimitMin;
String keywordLimitState;
String keywordNum;
List<String> pvd;
String state;

IntellectSearchSetModel(
{this.exclude,
this.keywordAlpha,
this.keywordAlphanum,
this.keywordLimitMax,
this.keywordLimitMin,
this.keywordLimitState,
this.keywordNum,
this.pvd,
this.state});

IntellectSearchSetModel.fromJson(Map<String, dynamic> json) {
exclude = json['exclude'].cast<String>();
keywordAlpha = json['keyword_alpha'].toString();
keywordAlphanum = json['keyword_alphanum'].toString();
keywordLimitMax = json['keyword_limit_max'].toString();
keywordLimitMin = json['keyword_limit_min'].toString();
keywordLimitState = json['keyword_limit_state'].toString();
keywordNum = json['keyword_num'].toString();
pvd = json['pvd'].cast<String>();
state = json['state'].toString();
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['exclude'] = this.exclude;
data['keyword_alpha'] = this.keywordAlpha;
data['keyword_alphanum'] = this.keywordAlphanum;
data['keyword_limit_max'] = this.keywordLimitMax;
data['keyword_limit_min'] = this.keywordLimitMin;
data['keyword_limit_state'] = this.keywordLimitState;
data['keyword_num'] = this.keywordNum;
data['pvd'] = this.pvd;
data['state'] = this.state;
return data;
}
}

+ 209
- 0
lib/dialog/select_date_ym_dialog/select_date_ym_dialog.dart Visa fil

@@ -0,0 +1,209 @@
import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_comm/util/extension/color.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class SelectDateYMDialog extends StatefulWidget {
int currentYear;

int currentMonth;

SelectDateYMDialog({Key key, this.currentYear = 0, this.currentMonth = 0})
: super(key: key) {
var date = DateTime.now();
if (currentYear == 0) {
currentYear = date.year;
}
if (currentMonth == 0) {
currentMonth = date.month;
}
}

@override
_SelectDateYMDialogState createState() => _SelectDateYMDialogState();
}

class _SelectDateYMDialogState extends State<SelectDateYMDialog>
with TickerProviderStateMixin {
List<int> yearDate = List();
List<int> monthDate = List();

int selectYearIndex = 0;

int selectMonthIndex = 0;

ScrollController _yearScrollController;

ScrollController _monthScrollController;

double _containerHeight = 0;
AnimationController _animationController;
Animation _animation;

@override
void initState() {
_monthScrollController = FixedExtentScrollController();
for (int index = 0; index < 200; index++) {
yearDate.add(index + 1900);
if (index + 1900 == widget.currentYear) {
selectYearIndex = index;
}
}

for (int index = 0; index < 12; index++) {
monthDate.add(index + 1);
if (index + 1 == widget.currentMonth) {
selectMonthIndex = index;
}
}
_yearScrollController =
FixedExtentScrollController(initialItem: selectYearIndex);

_monthScrollController =
FixedExtentScrollController(initialItem: selectMonthIndex);

_animationController = new AnimationController(
duration: const Duration(milliseconds: 500), vsync: this);
final CurvedAnimation curve =
new CurvedAnimation(parent: _animationController, curve: Curves.ease);
_animation = new Tween(begin: 0.0, end: 250.0).animate(curve);
_animation.addListener(() {
setState(() {});
});
_animationController.forward();

super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
height: 56,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20))),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
GestureDetector(
child: Padding(
padding: const EdgeInsets.only(
left: 16, top: 8, bottom: 8, right: 16),
child: Text(
"取消",
style: TextStyle(
color: HexColor.fromHex("#FF999999"),
fontSize: 35.sp),
),
),
onTap: () {
Navigator.pop(context);
},
),
Text("选择日期"),
GestureDetector(
child: Padding(
padding: const EdgeInsets.only(
right: 16, left: 16, bottom: 8, top: 8),
child: Text(
"确定",
style: TextStyle(
color: HexColor.fromHex("#FFFF4242"),
fontSize: 35.sp),
),
),
onTap: () {
Navigator.of(context).pop({
"year": yearDate[selectYearIndex].toString(),
"month": monthDate[selectMonthIndex].toString()
});
},
)
],
),
),
Container(
height: _animation.value,
color: Colors.white,
child: Row(
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: CupertinoPicker(
scrollController: _yearScrollController,
backgroundColor: Colors.white,
itemExtent: 40,
onSelectedItemChanged: (index) {
selectYearIndex = index;
setState(() {});
},
children: _buildItem(context))),
flex: 1,
),
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: CupertinoPicker(
scrollController: _monthScrollController,
backgroundColor: Colors.white,
itemExtent: 40,
onSelectedItemChanged: (index) {
selectMonthIndex = index;
setState(() {});
},
children: _buildItem2(context),
)),
flex: 1,
)
],
),
)
],
),
);
}

_buildItem(BuildContext context) {
List<Widget> listWidget = List();

for (int index = 0; index < yearDate.length; index++) {
listWidget.add(Container(
height: 40,
child: Center(
child: Text(
yearDate[index].toString() + "",
style: TextStyle(
color:
index == selectYearIndex ? Colors.redAccent : Colors.black26),
)),
));
}
return listWidget;
}

_buildItem2(BuildContext context) {
List<Widget> listWidget = List();

for (int index = 0; index < monthDate.length; index++) {
listWidget.add(Container(
height: 40,
child: Center(
child: Text(monthDate[index].toString() + "月",
style: TextStyle(
color: index == selectMonthIndex
? Colors.redAccent
: Colors.black26)))));
}
return listWidget;
}
}

+ 134
- 0
lib/pages/bil_detail_page/bil_detail_page.dart Visa fil

@@ -0,0 +1,134 @@
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:zhiying_base_widget/dialog/select_date_ym_dialog/select_date_ym_dialog.dart';
import 'package:zhiying_base_widget/pages/bil_detail_page/bil_detail_page_bloc.dart';
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart';
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart';
import 'package:zhiying_base_widget/utils/contants.dart';
import 'package:zhiying_base_widget/widgets/others/mine_header_bg_widget.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:zhiying_comm/util/base_bloc.dart';
import 'package:zhiying_comm/util/custom_sliver_persistent_header_delegate.dart';

class BilDetailPage extends StatefulWidget {
final Map<String, dynamic> data;

const BilDetailPage(this.data, {Key key}) : super(key: key);

@override
_BilDetailPageState createState() => _BilDetailPageState();
}

class _BilDetailPageState extends State<BilDetailPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xfff9f9f9),
body: MultiProvider(
providers: [
ChangeNotifierProvider.value(value: MainPageNotifier()),
ChangeNotifierProvider.value(value: MainPageBgNotifier()),
],
child: BlocProvider<BilDetailPageBloc>(
bloc: BilDetailPageBloc(),
child: BilDetailPageContainer(data: widget.data),
),
),
);
}
}

class BilDetailPageContainer extends StatefulWidget {
final Map<String, dynamic> data;

const BilDetailPageContainer({Key key, this.data}) : super(key: key);

@override
_BilDetailPageContainerState createState() => _BilDetailPageContainerState();
}

class _BilDetailPageContainerState extends State<BilDetailPageContainer> {
BilDetailPageBloc _bloc;

String showDate;

@override
void initState() {
_bloc = BlocProvider.of<BilDetailPageBloc>(context);
showDate=DateForm DateTime.now()
super.initState();
}

@override
Widget build(BuildContext context) {
return StreamBuilder(
builder: (context, sny) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text("明细"),
),
body: Container(
child: ListView(
shrinkWrap: true,
children: <Widget>[
_buildType(),
],
),
),
);
},
);
}

_buildType() {
return Row(
children: <Widget>[
SizedBox(width: 12.5),
InkWell(
onTap: (){
///显示日期选择弹窗
_selectDate();
},
child: Padding(
padding: const EdgeInsets.only(top: 8,bottom: 8),
child: Text("2020-08"),
),
),
Icon(Icons.arrow_drop_down),
Expanded(
child: Container(
height: 50,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: 3,
itemBuilder: (context, index) {
return Container(
margin:
EdgeInsets.only(top: 10, left: 8, right: 8, bottom: 10),
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(50)),
child: Padding(
padding: const EdgeInsets.only(left: 16, right: 16),
child: Center(
child: Text(
"推广",
style: TextStyle(color: Colors.grey),
)),
),
);
}),
))
],
);
}

void _selectDate() {
showDialog(context: context, builder: (context)=>SelectDateYMDialog());
}
}

+ 53
- 0
lib/pages/bil_detail_page/bil_detail_page_bloc.dart Visa fil

@@ -0,0 +1,53 @@
import 'dart:async';

import 'package:zhiying_comm/util/base_bloc.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class BilDetailPageBloc extends BlocBase {
List<Map<String, dynamic>> _tabs = List();

StreamController<List<Map<String, dynamic>>> _tabController =
StreamController<List<Map<String, dynamic>>>();

Stream<List<Map<String, dynamic>>> get outData => _tabController.stream;



@override
void dispose() {
_tabController.close();
_tabController = null;
}

loadData(String skipIdentifier) {

NetUtil.request('/api/v1/mod/${skipIdentifier}', method: NetMethod.GET,
onCache: (data) {
_loadData(data);
}, onSuccess: (data) {
_loadData(data);
});
}

void refresh() {}

///处理加载的数据
void _loadData(data) {
print(data["mod_lis"]);
var list = List.from(data["mod_list"]).map((v) {
return Map<String, dynamic>.from(v);
}).toList();
_tabController.add(list);
}

void dateChange(DateChangeEvent dateChangeEvent){
///日期变更后
}

}

class DateChangeEvent{
String date;
DateChangeEvent(this.date);
}

+ 5
- 0
lib/pages/bil_detail_page/model/bil_detail_page_model.dart Visa fil

@@ -0,0 +1,5 @@


class BilDetailPageModel{

}

+ 1
- 0
lib/pages/home_page/home_page.dart Visa fil

@@ -36,6 +36,7 @@ class _HomePageState extends State<HomePage> {

@override
Widget build(BuildContext context) {
ScreenUtil.init(context, width: 750, height: 1334);
print('home_page build');
List<Map<String, dynamic>> tabs = _data;
if (tabs == null || tabs.length == 0) {


+ 17
- 1
lib/pages/main_page/main_page.dart Visa fil

@@ -2,9 +2,13 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:zhiying_base_widget/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart';
import 'package:zhiying_base_widget/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart';
import 'package:zhiying_base_widget/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_no_goods_dialog.dart';
import 'package:zhiying_base_widget/pages/main_page/main_page_bloc.dart';
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart';
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart';
import 'package:zhiying_base_widget/utils/contants.dart';
import 'package:zhiying_base_widget/widgets/home/home_auth/home_auth.dart';
import 'package:zhiying_base_widget/widgets/others/mine_header_bg_widget.dart';
import 'package:zhiying_comm/util/base_bloc.dart';
@@ -47,7 +51,8 @@ class _MainPageContainer extends StatefulWidget {
_MainPageContainerState createState() => _MainPageContainerState();
}

class _MainPageContainerState extends State<_MainPageContainer> {
class _MainPageContainerState extends State<_MainPageContainer>
with WidgetsBindingObserver {
bool _isEnded = false;
ScrollController _controller = ScrollController();
MainPageBloc _bloc;
@@ -62,9 +67,17 @@ class _MainPageContainerState extends State<_MainPageContainer> {
// _refreshController.loadComplete();
}

@override
void didChangeAppLifecycleState(AppLifecycleState state) async {
///智能粘贴板
// IntellectCreate.checkAndCreate(state, context);
super.didChangeAppLifecycleState(state);
}

@override
void dispose() {
_controller.dispose();
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}

@@ -88,6 +101,9 @@ class _MainPageContainerState extends State<_MainPageContainer> {
Provider.of<MainPageNotifier>(context, listen: false).reset();
}
});
///监听app生命周期变化
// WidgetsBinding.instance.addObserver(this);
IntellectCreate.checkAndCreateFirst(context);
super.initState();
}



+ 97
- 27
lib/pages/wallet_page/wallet_page.dart Visa fil

@@ -4,10 +4,20 @@ import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart';
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart';
import 'package:zhiying_base_widget/utils/contants.dart';
import 'package:zhiying_base_widget/widgets/others/mine_header_bg_widget.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:zhiying_comm/util/base_bloc.dart';
import 'package:zhiying_comm/util/custom_sliver_persistent_header_delegate.dart';

import 'wallet_page_bloc.dart';
import 'wallet_page_bloc.dart';

class WalletPage extends StatefulWidget {
final Map<String, dynamic> data;

const WalletPage({Key key, this.data}) : super(key: key);

@override
_WalletPageState createState() => _WalletPageState();
}
@@ -22,14 +32,19 @@ class _WalletPageState extends State<WalletPage> {
ChangeNotifierProvider.value(value: MainPageNotifier()),
ChangeNotifierProvider.value(value: MainPageBgNotifier()),
],
child: _WalletPageContainer(),
child: BlocProvider<WalletPageBloc>(
bloc: WalletPageBloc(),
child: _WalletPageContainer(data: widget.data),
),
),
);
}
}

class _WalletPageContainer extends StatefulWidget {
_WalletPageContainer({Key key}) : super(key: key);
_WalletPageContainer({Key key, this.data}) : super(key: key);

final Map<String, dynamic> data;

@override
_WalletPageContainerState createState() => _WalletPageContainerState();
@@ -40,8 +55,14 @@ class _WalletPageContainerState extends State<_WalletPageContainer> {
final RefreshController _refreshController =
RefreshController(initialRefresh: false);

WalletPageBloc _pageBloc;

@override
void initState() {
_pageBloc = BlocProvider.of<WalletPageBloc>(context);
if (widget.data.containsKey(Constants.SkipIdentifierName)) {
_pageBloc.loadData(widget.data[Constants.SkipIdentifierName]);
}
super.initState();
}

@@ -53,6 +74,7 @@ class _WalletPageContainerState extends State<_WalletPageContainer> {

@override
Widget build(BuildContext context) {
ScreenUtil.init(context, width: 750, height: 1334);
return SmartRefresher(
controller: _refreshController,
enablePullDown: false,
@@ -67,39 +89,87 @@ class _WalletPageContainerState extends State<_WalletPageContainer> {
MineHeaderBgWidget(
controller: _controller,
),
CustomScrollView(
slivers: _createContent(context),
),
StreamBuilder(
stream: _pageBloc.outData,
builder: (context, asyncSnapshot) {
var model = asyncSnapshot.data;
return CustomScrollView(
slivers: _createContent(context, model),
);
},
)
],
),
),
);
}

List<Widget> _createContent(BuildContext context) {
List<Widget> _createContent(
BuildContext context, List<Map<String, dynamic>> model) {
List<Widget> list = List();
if (model == null) {
list.addAll(WidgetFactory.create(
'normal_nav',
isSliver: true,
model: Map(),
));
list.addAll(WidgetFactory.create(
'wallet_data',
isSliver: true,
model: Map(),
));
list.addAll(WidgetFactory.create(
'wallet_detail',
isSliver: true,
model: Map(),
));

list.addAll(WidgetFactory.create(
'normal_nav',
isSliver: true,
model: Map(),
));
list.addAll(WidgetFactory.create(
'wallet_data',
isSliver: true,
model: Map(),
));
list.addAll(WidgetFactory.create(
'wallet_detail',
isSliver: true,
model: Map(),
));

list.addAll(WidgetFactory.create(
'wallet_income',
isSliver: true,
model: Map(),
));
list.addAll(WidgetFactory.create(
'wallet_income',
isSliver: true,
model: Map(),
));
} else {
for (var item in model) {
WidgetModel widgetModel =
WidgetModel.fromJson(Map<String, dynamic>.from(item));
if (item.containsKey("mod_name")&&item['mod_name']=="my_wallet_appbar") {
list.add(SliverPersistentHeader(
delegate: _SilverAppBarDelegate(context,
WidgetFactory.create(widgetModel.modName,
isSliver: false, model: item)[0]),pinned: true,));
continue;
}
list.addAll(WidgetFactory.create(widgetModel.modName,
isSliver: true, model: item));
}
}
return list;
}
}

class _SilverAppBarDelegate extends SliverPersistentHeaderDelegate {
_SilverAppBarDelegate(BuildContext context,this.child){
this.context=context;
}
BuildContext context;
final Widget child;

@override
double get minExtent => MediaQuery.of(context).padding.top+44;

@override
double get maxExtent => MediaQuery.of(context).padding.top+44;

@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return child;

}

@override
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) {
return false;
}
}

+ 17
- 7
lib/pages/wallet_page/wallet_page_bloc.dart Visa fil

@@ -17,13 +17,23 @@ class WalletPageBloc extends BlocBase {
_tabController = null;
}

void refresh() {
NetUtil.request('/api/v1/config.json', onSuccess: (data) {
List list = data;
_tabs = list.map((item) {
return Map<String, dynamic>.from(item);
}).toList();
_tabController.add(_tabs);
loadData(String skipIdentifier) {
NetUtil.request('/api/v1/mod/${skipIdentifier}', method: NetMethod.GET,
onCache: (data) {
_loadData(data);
}, onSuccess: (data) {
_loadData(data);
});
}

void refresh() {}

///处理加载的数据
void _loadData(data) {
print(data["mod_lis"]);
var list = List.from(data["mod_list"]).map((v) {
return Map<String, dynamic>.from(v);
}).toList();
_tabController.add(list);
}
}

+ 18
- 6
lib/register.dart Visa fil

@@ -1,5 +1,7 @@
import 'package:sharesdk_plugin/sharesdk_plugin.dart';
import 'package:zhiying_base_widget/pages/bil_detail_page/bil_detail_page.dart';
import 'package:zhiying_base_widget/pages/favorite_page/favorite_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:zhiying_base_widget/pages/goods_details_page/goods_details_page.dart';
import 'package:zhiying_base_widget/pages/invited_friends/invited_friends.dart';
import 'package:zhiying_base_widget/pages/launch_page/launch_page.dart';
@@ -34,6 +36,8 @@ import 'package:zhiying_base_widget/widgets/others/normal_nav/normal_nav_creater
import 'package:zhiying_base_widget/widgets/search/appbar/search_appbar_creater.dart';
import 'package:zhiying_base_widget/widgets/search/input/search_input_creater.dart';
import 'package:zhiying_base_widget/widgets/search/tabbar/search_tab_creater.dart';
import 'package:zhiying_base_widget/widgets/wallet/wallet_appbar/wallet_appbar.dart';
import 'package:zhiying_base_widget/widgets/wallet/wallet_bil/wallet_bil.dart';
import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data.dart';
import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/wallet_detail.dart';
import 'package:zhiying_base_widget/widgets/wallet/wallet_income/wallet_income.dart';
@@ -79,7 +83,8 @@ class BaseWidgetRegister {
PageFactory.regist('homePage', (model) => LaunchPage());
PageFactory.regist('pub.flutter.index', (model) => MainPage(model));
PageFactory.regist('pub.flutter.profile', (model) => MainPage(model));
PageFactory.regist('pub.flutter.my_wallet', (model) => WalletPage());
PageFactory.regist(
'pub.flutter.my_wallet', (model) => BilDetailPage(model));
PageFactory.regist('goods_details', (model) => GoodsDetailsPage(model));
PageFactory.regist('sreach', (model) => SearchPage(model));
PageFactory.regist('sreach_result', (model) => SreachResultPage());
@@ -206,16 +211,23 @@ class BaseWidgetRegister {

// ==================== 钱包
WidgetFactory.regist(
'wallet_data', DefaultWidgetCreater((model) => WalletData()));
'my_wallet_appbar',
DefaultWidgetCreater((model) => WalletAppbar(
data: model,
)));
WidgetFactory.regist(
'my_wallet_header', DefaultWidgetCreater((model) => WalletData(model)));
WidgetFactory.regist(
'my_wallet_bil', DefaultWidgetCreater((model) => WalletBil(model)));
// WidgetFactory.regist(
// 'wallet_detail', DefaultWidgetCreater((model) => WalletDetail()));
// WidgetFactory.regist('wallet_detail', HomeAuthCreater());
WidgetFactory.regist(
'wallet_data', DefaultWidgetCreater((model) => WalletData()));
WidgetFactory.regist(
'wallet_detail', DefaultWidgetCreater((model) => WalletDetail()));
WidgetFactory.regist('my_wallet_providers',
DefaultWidgetCreater((model) => WalletDetail(model)));

WidgetFactory.regist(
'wallet_income', DefaultWidgetCreater((model) => WalletIncome()));

//======================= 账单明细
}
}

+ 18
- 0
lib/utils/contants.dart Visa fil

@@ -0,0 +1,18 @@
import 'package:flutter/material.dart';

///通用配置,避免一些多次重复的字符串被写在代码中
class Constants {
///获取模块类型
static const String SkipIdentifierName = "skip_identifier";
///全局context

//==============================智能粘贴版===================================start
static BuildContext context;
///智能搜索版是否弹起
static bool isShowIntellectDialog=false;
///是否缓存设置信息
static String spIsCacheSetModel="spIsCacheSetModel";

//==============================智能粘贴版===================================end

}

+ 1
- 1
lib/widgets/home/home_slide_banner/home_slide_banner.dart Visa fil

@@ -100,7 +100,7 @@ class _HomeSlideBannerContainerState extends State<HomeSlideBannerContainer> {
onTap: (index) => _itemOnClick(datas.index_carousel_list[index]),
pagination: _getSwiperStyleByType(datas, datas?.index_carousel_list?.length ?? 0),
onIndexChanged: (index) {
print('切换下一页');
//print('切换下一页');
Provider.of<MainPageBgNotifier>(context, listen: false).switchBg(Container(
width: double.infinity,
height: 200,


+ 2
- 1
lib/widgets/mine/mine_header/mine_header_container.dart Visa fil

@@ -64,7 +64,8 @@ class _MineHeaderContainerState extends State<MineHeaderContainer> {
),
),
onTap: () async {
await RouterUtil.route(SkipModel.fromJson(widget.json), widget.json, context);
await RouterUtil.route(SkipModel.fromJson(widget.json),
widget.json, context);
_bloc.loadData();
},
),


+ 25
- 0
lib/widgets/wallet/wallet_appbar/model/WalletAppbarModel.dart Visa fil

@@ -0,0 +1,25 @@
class WalletAppbarModel {
String appBarName;
String appBarNameColor;
String appBarBgColor;
String bgImg;

WalletAppbarModel(
{this.appBarName, this.appBarNameColor, this.appBarBgColor, this.bgImg});

WalletAppbarModel.fromJson(Map<String, dynamic> json) {
appBarName = json['app_bar_name'];
appBarNameColor = json['app_bar_name_color'];
appBarBgColor = json['app_bar_bg_color'];
bgImg = json['bg_img'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['app_bar_name'] = this.appBarName;
data['app_bar_name_color'] = this.appBarNameColor;
data['app_bar_bg_color'] = this.appBarBgColor;
data['bg_img'] = this.bgImg;
return data;
}
}

+ 34
- 0
lib/widgets/wallet/wallet_appbar/wallet_appbar.dart Visa fil

@@ -0,0 +1,34 @@
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/widgets/wallet/wallet_appbar/model/WalletAppbarModel.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class WalletAppbar extends StatelessWidget {
final Map<String, dynamic> data;

const WalletAppbar({Key key, this.data}) : super(key: key);

@override
Widget build(BuildContext context) {
var model = WalletAppbarModel.fromJson(json.decode(data['data']));
return Container(
height: MediaQuery.of(context).padding.top + 56,
child: AppBar(
leading: Navigator.canPop(context)
? IconButton(
icon: Icon(Icons.arrow_back_ios),
onPressed: () {
Navigator.of(context).pop();
})
: Container(),
backgroundColor: HexColor.fromHex(model.appBarBgColor),
centerTitle: true,
title: Text(
model.appBarName,
style: TextStyle(color: HexColor.fromHex(model.appBarNameColor)),
),
),
);
}
}

+ 25
- 0
lib/widgets/wallet/wallet_bil/model/wallet_bli_model.dart Visa fil

@@ -0,0 +1,25 @@
class WalletBilModel {
String bilText;
String bilIcon;
String skipText;
String skipIdentifier;

WalletBilModel(
{this.bilText, this.bilIcon, this.skipText, this.skipIdentifier});

WalletBilModel.fromJson(Map<String, dynamic> json) {
bilText = json['bil_text'];
bilIcon = json['bil_icon'];
skipText = json['skip_text'];
skipIdentifier = json['skip_identifier'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['bil_text'] = this.bilText;
data['bil_icon'] = this.bilIcon;
data['skip_text'] = this.skipText;
data['skip_identifier'] = this.skipIdentifier;
return data;
}
}

+ 46
- 0
lib/widgets/wallet/wallet_bil/wallet_bil.dart Visa fil

@@ -0,0 +1,46 @@
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/widgets/home/home_quick_entry/cached_network_image_util.dart';
import 'package:zhiying_base_widget/widgets/wallet/wallet_bil/model/wallet_bli_model.dart';
import 'package:zhiying_base_widget/widgets/wallet/wallet_income/wallet_income_sk.dart';

import 'package:zhiying_comm/zhiying_comm.dart';

///查看明细部件
class WalletBil extends StatelessWidget {
Map<String, dynamic> data;

WalletBil(this.data, {Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
WalletBilModel model;
if (data != null) {
model = WalletBilModel.fromJson(json.decode(data['data']));
}
return data == null
? WalletIncomeSkeleton()
: Container(
decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.circular(8)),
margin: EdgeInsets.only(left: 12.5, right: 12.5,top: 10),
child: ListTile(
title: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
CachedNetworkImage(
imageUrl: model.bilIcon,
width: 36.w,
height: 36.w,
fit: BoxFit.fill,
),
SizedBox(width: 15.w,),
Text(model.bilText,style: TextStyle(fontSize: 24.sp),),
],
),
trailing: InkWell(child: Text(model.skipText,style: TextStyle(color: Colors.grey),),onTap: (){
///跳转???
},),
));
}
}

+ 93
- 0
lib/widgets/wallet/wallet_data/model/wallet_header_model.dart Visa fil

@@ -0,0 +1,93 @@
class WalletHeaderModel {
String headerImg;
String headerAvatar;
String headerCashOutText;
String headerCashOutTextColor;
String headerCashOutBtnImg;
List<HeaderBottomList> headerBottomList;

WalletHeaderModel(
{this.headerImg,
this.headerAvatar,
this.headerCashOutText,
this.headerCashOutTextColor,
this.headerCashOutBtnImg,
this.headerBottomList});

WalletHeaderModel.fromJson(Map<String, dynamic> json) {
headerImg = json['header_img'];
headerAvatar = json['header_avatar'];
headerCashOutText = json['header_cash_out_text'];
headerCashOutTextColor = json['header_cash_out_text_color'];
headerCashOutBtnImg = json['header_cash_out_btn_img'];
if (json['header_bottom_list'] != null) {
headerBottomList = new List<HeaderBottomList>();
json['header_bottom_list'].forEach((v) {
headerBottomList.add(new HeaderBottomList.fromJson(v));
});
}
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['header_img'] = this.headerImg;
data['header_avatar'] = this.headerAvatar;
data['header_cash_out_text'] = this.headerCashOutText;
data['header_cash_out_text_color'] = this.headerCashOutTextColor;
data['header_cash_out_btn_img'] = this.headerCashOutBtnImg;
if (this.headerBottomList != null) {
data['header_bottom_list'] =
this.headerBottomList.map((v) => v.toJson()).toList();
}
return data;
}
}

class HeaderBottomList {
String totalText;
String totalTextColor;
String totalValueColor;
String cashOutText;
String cashOutTextColor;
String cashOutValueColor;
String unfinalText;
String unfinalTextColor;
String unfinalValueColor;

HeaderBottomList(
{this.totalText,
this.totalTextColor,
this.totalValueColor,
this.cashOutText,
this.cashOutTextColor,
this.cashOutValueColor,
this.unfinalText,
this.unfinalTextColor,
this.unfinalValueColor});

HeaderBottomList.fromJson(Map<String, dynamic> json) {
totalText = json['total_text'];
totalTextColor = json['total_text_color'];
totalValueColor = json['total_value_color'];
cashOutText = json['cash_out_text'];
cashOutTextColor = json['cash_out_text_color'];
cashOutValueColor = json['cash_out_value_color'];
unfinalText = json['unfinal_text'];
unfinalTextColor = json['unfinal_text_color'];
unfinalValueColor = json['unfinal_value_color'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['total_text'] = this.totalText;
data['total_text_color'] = this.totalTextColor;
data['total_value_color'] = this.totalValueColor;
data['cash_out_text'] = this.cashOutText;
data['cash_out_text_color'] = this.cashOutTextColor;
data['cash_out_value_color'] = this.cashOutValueColor;
data['unfinal_text'] = this.unfinalText;
data['unfinal_text_color'] = this.unfinalTextColor;
data['unfinal_value_color'] = this.unfinalValueColor;
return data;
}
}

+ 111
- 1
lib/widgets/wallet/wallet_data/wallet_data.dart Visa fil

@@ -1,13 +1,123 @@
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/widgets/wallet/wallet_data/model/wallet_header_model.dart';
import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_sk.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class WalletData extends StatelessWidget {
final Map<String, dynamic> data;

const WalletData(this.data, {Key key}) : super(key: key);

@override
Widget build(BuildContext context) {

print(data);
Map<String, dynamic> temp = json.decode(data['data']);
var model = WalletHeaderModel.fromJson(temp);
return Container(
width: double.infinity,
child: WalletDataSkeleton(),
child: data == null
? WalletDataSkeleton()
: Container(
margin: EdgeInsets.only(left: 12.5, right: 12.5,top: 10),
padding: EdgeInsets.only(left: 36.w, right: 26.w),
decoration: BoxDecoration(
image: DecorationImage(
image: CachedNetworkImageProvider(model.headerImg),fit: BoxFit.fill)),
height: 290.h,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: <Widget>[
CachedNetworkImage(
imageUrl: model.headerAvatar,
height: 66.h,
width: 52.w,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
model.headerCashOutText,
style: TextStyle(
fontSize: 25.sp,
color: HexColor.fromHex(
model.headerCashOutTextColor)),
),
Text(
"没数据",
style: TextStyle(
fontSize: 25.sp,
color: HexColor.fromHex(
model.headerCashOutTextColor)),
),
],
),
)
],
),
GestureDetector(
child: Container(
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(10),
image: DecorationImage(
image: CachedNetworkImageProvider(""),
fit: BoxFit.fill)),
child: Padding(
padding: EdgeInsets.only(
left: 29.w,
right: 29.w,
top: 20.w,
bottom: 20.w),
child: Text(
"提现",
style: TextStyle(color: Colors.white),
),
),
),
)
],
),
Divider(
height: 1,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: _buildTopListItem(model?.headerBottomList))
],
),
),
);
}

///构建顶部Item
_buildTopListItem(List<HeaderBottomList> list) {
List<Widget> listWidget = List();
for (var item in list) {
listWidget.add(Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
"9999",
style: TextStyle(color: Colors.red, fontSize: 30.sp),
),
Text(
"累计到账(元)",
style: TextStyle(color: Colors.grey, fontSize: 22.sp),
),
],
));
}
return listWidget;
}
}

+ 1
- 1
lib/widgets/wallet/wallet_data/wallet_data_creater.dart Visa fil

@@ -6,7 +6,7 @@ class WalletDataCreater extends WidgetCreater {
@override
List<Widget> createWidgets(Map<String, dynamic> model) {
return [
WalletData(),
WalletData(model),
];
}
}

+ 226
- 0
lib/widgets/wallet/wallet_detail/model/wallet_detail_model.dart Visa fil

@@ -0,0 +1,226 @@
class WalletDetailModel {
List<Providers> providers;
List<DateList> dateList;
ProviderDashbord providerDashbord;

WalletDetailModel({this.providers, this.dateList, this.providerDashbord});

WalletDetailModel.fromJson(Map<String, dynamic> json) {
if (json['providers'] != null) {
providers = new List<Providers>();
json['providers'].forEach((v) {
providers.add(new Providers.fromJson(v));
});
}
if (json['date_list'] != null) {
dateList = new List<DateList>();
json['date_list'].forEach((v) {
dateList.add(new DateList.fromJson(v));
});
}
providerDashbord = json['provider_dashbord'] != null
? new ProviderDashbord.fromJson(json['provider_dashbord'])
: null;
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.providers != null) {
data['providers'] = this.providers.map((v) => v.toJson()).toList();
}
if (this.dateList != null) {
data['date_list'] = this.dateList.map((v) => v.toJson()).toList();
}
if (this.providerDashbord != null) {
data['provider_dashbord'] = this.providerDashbord.toJson();
}
return data;
}
}

class Providers {
String type;
String name;
String unselectColor;
String selectColor;
String lineColor;

Providers(
{this.type,
this.name,
this.unselectColor,
this.selectColor,
this.lineColor});

Providers.fromJson(Map<String, dynamic> json) {
type = json['type'];
name = json['name'];
unselectColor = json['unselect_color'];
selectColor = json['select_color'];
lineColor = json['line_color'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['type'] = this.type;
data['name'] = this.name;
data['unselect_color'] = this.unselectColor;
data['select_color'] = this.selectColor;
data['line_color'] = this.lineColor;
return data;
}
}

class DateList {
String text;
String textSelectColor;
String textUnselectColor;
String btnImg;

DateList(
{this.text, this.textSelectColor, this.textUnselectColor, this.btnImg});

DateList.fromJson(Map<String, dynamic> json) {
text = json['text'];
textSelectColor = json['text_select_color'];
textUnselectColor = json['text_unselect_color'];
btnImg = json['btn_img'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['text'] = this.text;
data['text_select_color'] = this.textSelectColor;
data['text_unselect_color'] = this.textUnselectColor;
data['btn_img'] = this.btnImg;
return data;
}
}

class ProviderDashbord {
Finish finish;
SelfBuy selfBuy;
SelfBuy directPromote;
SelfBuy indirectPromote;

ProviderDashbord(
{this.finish, this.selfBuy, this.directPromote, this.indirectPromote});

ProviderDashbord.fromJson(Map<String, dynamic> json) {
finish =
json['finish'] != null ? new Finish.fromJson(json['finish']) : null;
selfBuy = json['self_buy'] != null
? new SelfBuy.fromJson(json['self_buy'])
: null;
directPromote = json['direct_promote'] != null
? new SelfBuy.fromJson(json['direct_promote'])
: null;
indirectPromote = json['indirect_promote'] != null
? new SelfBuy.fromJson(json['indirect_promote'])
: null;
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.finish != null) {
data['finish'] = this.finish.toJson();
}
if (this.selfBuy != null) {
data['self_buy'] = this.selfBuy.toJson();
}
if (this.directPromote != null) {
data['direct_promote'] = this.directPromote.toJson();
}
if (this.indirectPromote != null) {
data['indirect_promote'] = this.indirectPromote.toJson();
}
return data;
}
}

class Finish {
String text;
String textColor;
String valueColor;
String bgImg;

Finish({this.text, this.textColor, this.valueColor, this.bgImg});

Finish.fromJson(Map<String, dynamic> json) {
text = json['text'];
textColor = json['text_color'];
valueColor = json['value_color'];
bgImg = json['bg_img'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['text'] = this.text;
data['text_color'] = this.textColor;
data['value_color'] = this.valueColor;
data['bg_img'] = this.bgImg;
return data;
}
}

class SelfBuy {
String title;
String titleColor;
String leftBgImg;
String rightBgImg;
List<ItemList> itemList;

SelfBuy(
{this.title,
this.titleColor,
this.leftBgImg,
this.rightBgImg,
this.itemList});

SelfBuy.fromJson(Map<String, dynamic> json) {
title = json['title'];
titleColor = json['title_color'];
leftBgImg = json['left_bg_img'];
rightBgImg = json['right_bg_img'];
if (json['list'] != null) {
itemList = new List<ItemList>();
json['list'].forEach((v) {
itemList.add(new ItemList.fromJson(v));
});
}
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['title'] = this.title;
data['title_color'] = this.titleColor;
data['left_bg_img'] = this.leftBgImg;
data['right_bg_img'] = this.rightBgImg;
if (this.itemList != null) {
data['list'] = this.itemList.map((v) => v.toJson()).toList();
}
return data;
}
}

class ItemList {
String text;
String textColor;
String valueColor;

ItemList({this.text, this.textColor, this.valueColor});

ItemList.fromJson(Map<String, dynamic> json) {
text = json['text'];
textColor = json['text_color'];
valueColor = json['value_color'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['text'] = this.text;
data['text_color'] = this.textColor;
data['value_color'] = this.valueColor;
return data;
}
}

+ 174
- 8
lib/widgets/wallet/wallet_detail/wallet_detail.dart Visa fil

@@ -1,18 +1,184 @@
import 'dart:convert';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/pages/withdraw_page/withdraw_page.dart';
import 'package:zhiying_base_widget/widgets/home/home_quick_entry/cached_network_image_util.dart';
import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/model/wallet_detail_model.dart';
import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/wallet_detail_sk.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class WalletDetail extends StatefulWidget {
final Map<String, dynamic> data;

const WalletDetail(
this.data, {
Key key,
}) : super(key: key);

@override
_WalletDetailState createState() => _WalletDetailState();
}

class _WalletDetailState extends State<WalletDetail>
with TickerProviderStateMixin {
WalletDetailModel _model;
TabController _tabController;
@override
void initState() {
if (widget.data != null) {
_model = WalletDetailModel.fromJson(json.decode(widget.data['data']));
_tabController =
TabController(length: _model.providers.length, vsync: this);
}
super.initState();
}

class WalletDetail extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GestureDetector(
child: WalletDetailSkeleton(),
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) {
return WithdrawPage();
}));
},
return Container(
margin: EdgeInsets.only(left: 12.5, right: 12.5),
child: Column(
children: <Widget>[
Container(
child: TabBar(
// isScrollable: true,
controller: _tabController,
tabs: _buildTabs()),
),
Container(
height: 75.h,
child: ListView.builder(
padding: EdgeInsets.only(top: 16),
itemCount: _model.dateList.length,
scrollDirection: Axis.horizontal,
itemBuilder: _buildTimeItem),
),
Container(
height: 126.h,
margin: EdgeInsets.only(top: 16),
width: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
image: CachedNetworkImageProvider(
_model.providerDashbord.finish.bgImg),
fit: BoxFit.fill)),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"已结算",
style: TextStyle(color: Colors.black, fontSize: 22.sp),
),
InkWell(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: CachedNetworkImage(
imageUrl: "",
width: 20.h,
height: 20.h,
fit: BoxFit.fill,
),
),
onTap: () {
///问好
})
],
),
Text(
"158",
style: TextStyle(color: Colors.red, fontSize: 40.sp),
)
],
),
),
Container(
child: ListView.builder(
itemCount: 3,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
return _buildBottomItem(
context, index, _model.providerDashbord);
}),
)
],
),
);
}

_buildTabs() {
List<Widget> listWidget = List();
for (var item in _model.providers) {
listWidget.add(Tab(
child: Text(
item.name,
style: TextStyle(color: Colors.grey),
),
));
}
return listWidget;
}

Widget _buildTimeItem(BuildContext context, int index) {
var item = _model.dateList[index];
return Container(
margin: EdgeInsets.only(top: 0, left: 8, right: 8),
decoration: BoxDecoration(
color: Colors.grey[200], borderRadius: BorderRadius.circular(50)),
child: Padding(
padding: const EdgeInsets.only(left: 16, right: 16),
child: Center(
child: Text(
item.text,
style: TextStyle(color: Colors.grey),
)),
),
);
}

Widget _buildBottomItem(
BuildContext context, int index, ProviderDashbord dashbord) {
var item = dashbord.selfBuy;
return Container(
child: Column(
children: <Widget>[
Text(
item.title,
style: TextStyle(color: HexColor.fromHex(item.titleColor)),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: Container(
height: 123.h,
margin: EdgeInsets.only(right: 8),
decoration: BoxDecoration(
image: DecorationImage(
image: CachedNetworkImageProvider(item.leftBgImg),
fit: BoxFit.fill)),
child: Center(child: Text("ddd")),
),
),
Expanded(
child: Container(
height: 123.h,
margin: EdgeInsets.only(left: 8),
decoration: BoxDecoration(
image: DecorationImage(
image: CachedNetworkImageProvider(item.rightBgImg))),
child: Center(child: Text("dddd")),
))
],
)
],
),
);
}
}

+ 7
- 2
pubspec.yaml Visa fil

@@ -26,13 +26,18 @@ dependencies:
ref: '1.2.3+1'
# mob 分享sdk
sharesdk_plugin: ^1.2.8
flutter_native_image: ^0.0.5
#字符检测
string_validator: 0.1.4
intl: 0.15.7

zhiying_comm:
path: ../zhiying_comm

dev_dependencies:
flutter_test:
sdk: flutter

zhiying_comm:
path: ../zhiying_comm

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec


Laddar…
Avbryt
Spara