Pārlūkot izejas kodu

1.优化钱包加载方式

tags/0.0.14+5
“yanghuaxuan” pirms 3 gadiem
vecāks
revīzija
9a8c6b4051
4 mainītis faili ar 58 papildinājumiem un 112 dzēšanām
  1. +4
    -2
      example/lib/main.dart
  2. +7
    -3
      example/pubspec.yaml
  3. +31
    -90
      lib/widgets/wallet/wallet_detail/wallet_detail.dart
  4. +16
    -17
      lib/widgets/wallet/wallet_detail/wallet_detail_bloc.dart

+ 4
- 2
example/lib/main.dart Parādīt failu

@@ -24,7 +24,8 @@ import 'package:zhiying_equity_card/zhiying_equity_card.dart';
import 'package:zhiying_official/register.dart';
import 'package:zhiying_base_widget/zhiying_base_widget.dart';
import 'package:zhiying_acquisition/register.dart';
//import 'package:zhiying_credit_card/register.dart';
import 'package:zhiying_shopping_mall/zhiying_shopping_mall.dart';
import 'package:zhiying_credit_card/register.dart';

void main() {
FlutterError.onError = (FlutterErrorDetails details) {
@@ -68,7 +69,8 @@ class _MyAppState extends State<MyApp> {
EquityCardRegister.init();
OfficialRegister.init();
AcquisitionRegister.init();
// CreditCardRegister.init();
ShoppingMallRegister.init();
CreditCardRegister.init();
// print('初始化百川');
FlutterAlibc.initAlibc(version: "", appName: "").then((result) {
print("百川" + '${result.errorCode} ${result.errorMessage}');


+ 7
- 3
example/pubspec.yaml Parādīt failu

@@ -34,8 +34,12 @@ dev_dependencies:
path: ../../zhiying_official
zhiying_acquisition:
path: ../../zhiying_acquisition
# zhiying_credit_card:
# path: ../../zhiying_credit_card
zhiying_shopping_mall:
git:
ref: 0.0.4
url: 'http://192.168.0.138:3000/FnuoOS_ZhiYing/zhiying_shopping_mall.git'
zhiying_credit_card:
path: ../../zhiying_credit_card
#微信导师
zhiying_wechat_teacher:
# path: ../../zhiying_wechat_teacher
@@ -46,7 +50,7 @@ dev_dependencies:
zhiying_moments:
# path: ../../zhiying_moments
git:
ref: 0.2.2
ref: 0.2.3
url: http://192.168.0.138:3000/FnuoOS_ZhiYing/zhiying_moments.git
#会员升级
zhiying_member_upgrade:


+ 31
- 90
lib/widgets/wallet/wallet_detail/wallet_detail.dart Parādīt failu

@@ -23,8 +23,7 @@ class WalletDetail extends StatefulWidget {
_WalletDetailState createState() => _WalletDetailState();
}

class _WalletDetailState extends State<WalletDetail>
with TickerProviderStateMixin {
class _WalletDetailState extends State<WalletDetail> with TickerProviderStateMixin {
WalletDetailModel _model;

TabController _tabController;
@@ -35,24 +34,22 @@ class _WalletDetailState extends State<WalletDetail>
void initState() {
if (widget.data != null) {
_model = WalletDetailModel.fromJson(json.decode(widget.data['data']));
_tabController =
TabController(length: _model.providers.length, vsync: this);
_tabController = TabController(length: _model.providers.length, vsync: this);
}
_bloc = new WalletDetailBloc();
_bloc.loadData(_model.providers[0].type);
_bloc.loadData(_model.providers[0].type, _bloc.selectDay);

super.initState();
}


@override
void didChangeDependencies() {
RefreshListener.listen(context, (event) {
if (event == "refresh") {
if (_bloc.currentType == null) {
_bloc.loadData(_model.providers[0].type);
_bloc.loadData(_model.providers[0].type, _bloc.selectDay);
} else {
_bloc.loadData(_bloc.currentType);
_bloc.loadData(_bloc.currentType, _bloc.selectDay);
}
}
});
@@ -69,15 +66,13 @@ class _WalletDetailState extends State<WalletDetail>
return StreamBuilder(
stream: _bloc.outData,
builder: (context, asyn) {
if (_bloc.listDataModel.length == 0) {
if (_bloc.currentWalletDetailDataModel == null) {
///骨架图
return WalletDetailSkeleton();
}
return Container(
decoration: BoxDecoration(
color: Colors.white, borderRadius: BorderRadius.circular(8)),
margin:
EdgeInsets.only(left: 12.5, right: 12.5, top: 7.5, bottom: 7.5),
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 7.5, bottom: 7.5),
padding: const EdgeInsets.only(bottom: 13),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -96,13 +91,10 @@ class _WalletDetailState extends State<WalletDetail>
color: HexColor.fromHex(_model.providers[0].selectColor),
),
isScrollable: true,
unselectedLabelColor:
HexColor.fromHex(_model.providers[0].unselectColor),
labelColor:
HexColor.fromHex(_model.providers[0].selectColor),
unselectedLabelColor: HexColor.fromHex(_model.providers[0].unselectColor),
labelColor: HexColor.fromHex(_model.providers[0].selectColor),
controller: _tabController,
indicatorColor:
HexColor.fromHex(_model.providers[0].selectColor),
indicatorColor: HexColor.fromHex(_model.providers[0].selectColor),
indicatorSize: TabBarIndicatorSize.label,
onTap: (index) {
///变更平台
@@ -128,11 +120,7 @@ class _WalletDetailState extends State<WalletDetail>
height: 63,
margin: EdgeInsets.only(top: 16, left: 15, right: 15),
width: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
image: CachedNetworkImageProvider(
_model.providerDashbord.finish.bgImg),
fit: BoxFit.fill)),
decoration: BoxDecoration(image: DecorationImage(image: CachedNetworkImageProvider(_model.providerDashbord.finish.bgImg), fit: BoxFit.fill)),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
@@ -142,10 +130,7 @@ class _WalletDetailState extends State<WalletDetail>
padding: const EdgeInsets.all(8.0),
child: Text(
_model.providerDashbord.finish.text,
style: TextStyle(
fontSize: 14,
color: HexColor.fromHex(_model
.providerDashbord.finish.textColor)),
style: TextStyle(fontSize: 14, color: HexColor.fromHex(_model.providerDashbord.finish.textColor)),
),
),
Row(
@@ -159,9 +144,7 @@ class _WalletDetailState extends State<WalletDetail>
child: Padding(
padding: const EdgeInsets.all(8.0),
child: CachedNetworkImage(
imageUrl:
_model.providerDashbord.finish.tipIcon ??
"",
imageUrl: _model.providerDashbord.finish.tipIcon ?? "",
width: 10,
height: 10,
fit: BoxFit.fill,
@@ -169,19 +152,13 @@ class _WalletDetailState extends State<WalletDetail>
),
onTap: () {
///显示弹窗
showTipDialog(
null, _model.providerDashbord.finish.tipText);
showTipDialog(null, _model.providerDashbord.finish.tipText);
})
],
),
Text(
_bloc.selectDateData.finish ?? "",
style: TextStyle(
color: Colors.red,
fontSize: 20,
fontFamily: 'Din',
package: 'zhiying_comm',
fontWeight: FontWeight.bold),
style: TextStyle(color: Colors.red, fontSize: 20, fontFamily: 'Din', package: 'zhiying_comm', fontWeight: FontWeight.bold),
)
],
),
@@ -193,8 +170,7 @@ class _WalletDetailState extends State<WalletDetail>
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
return _buildBottomItem(
context, index, _model.providerDashbord);
return _buildBottomItem(context, index, _model.providerDashbord);
}),
)
],
@@ -224,41 +200,26 @@ class _WalletDetailState extends State<WalletDetail>
child: Container(
margin: EdgeInsets.only(top: 0, left: 8, right: 8),
decoration: BoxDecoration(
image: DecorationImage(
image: CachedNetworkImageProvider(
item.type == _bloc.selectDateData.type
? item.btnImg ?? ""
: item.btnNoColorImg ?? ""),
fit: BoxFit.fitWidth),
image: DecorationImage(image: CachedNetworkImageProvider(item.type == _bloc.selectDateData.type ? item.btnImg ?? "" : item.btnNoColorImg ?? ""), fit: BoxFit.fitWidth),
),
child: Padding(
padding: const EdgeInsets.only(left: 16, right: 16),
child: Center(
child: Text(
item.text,
style: TextStyle(
fontSize: 11,
color: HexColor.fromHex(item.type == _bloc.selectDateData.type
? item.textSelectColor
: item.textUnselectColor)),
style: TextStyle(fontSize: 11, color: HexColor.fromHex(item.type == _bloc.selectDateData.type ? item.textSelectColor : item.textUnselectColor)),
)),
),
),
onTap: () {
for (var select in _bloc.listDataModel) {
if (select.type == item.type) {
_bloc.selectDay = item.type;
_bloc.refresh();
return;
}
}
_bloc.selectDay = item.type;
_bloc.loadData(_bloc.currentType, _bloc.selectDay);
},
);
}

///底部显示
Widget _buildBottomItem(
BuildContext context, int index, ProviderDashbord dashbord) {
Widget _buildBottomItem(BuildContext context, int index, ProviderDashbord dashbord) {
SelfBuy item;
if (index == 0) {
item = dashbord.selfBuy;
@@ -280,8 +241,7 @@ class _WalletDetailState extends State<WalletDetail>
? Container()
: Text(
item.title,
style: TextStyle(
color: HexColor.fromHex(item.titleColor), fontSize: 14),
style: TextStyle(color: HexColor.fromHex(item.titleColor), fontSize: 14),
),
SizedBox(
height: 7.5,
@@ -294,11 +254,7 @@ class _WalletDetailState extends State<WalletDetail>
height: 61.5,
margin: EdgeInsets.only(right: 8, left: 15),
padding: EdgeInsets.only(left: 10),
decoration: BoxDecoration(
image: DecorationImage(
image: CachedNetworkImageProvider(
item.itemList[0].bgImg ?? ""),
fit: BoxFit.fill)),
decoration: BoxDecoration(image: DecorationImage(image: CachedNetworkImageProvider(item.itemList[0].bgImg ?? ""), fit: BoxFit.fill)),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
@@ -307,10 +263,7 @@ class _WalletDetailState extends State<WalletDetail>
children: <Widget>[
Text(
item.itemList[0].text ?? "",
style: TextStyle(
fontSize: 11,
color: HexColor.fromHex(
item.itemList[0].textColor)),
style: TextStyle(fontSize: 11, color: HexColor.fromHex(item.itemList[0].textColor)),
),
InkWell(
child: Padding(
@@ -335,8 +288,7 @@ class _WalletDetailState extends State<WalletDetail>
package: 'zhiying_comm',
fontWeight: FontWeight.bold,
fontSize: 17,
color:
HexColor.fromHex(item.itemList[1].valueColor),
color: HexColor.fromHex(item.itemList[1].valueColor),
))
],
)),
@@ -349,11 +301,7 @@ class _WalletDetailState extends State<WalletDetail>
right: 15,
),
padding: EdgeInsets.only(left: 10),
decoration: BoxDecoration(
image: DecorationImage(
image: CachedNetworkImageProvider(
item.itemList[1].bgImg ?? ""),
fit: BoxFit.fill)),
decoration: BoxDecoration(image: DecorationImage(image: CachedNetworkImageProvider(item.itemList[1].bgImg ?? ""), fit: BoxFit.fill)),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
@@ -362,10 +310,7 @@ class _WalletDetailState extends State<WalletDetail>
children: <Widget>[
Text(
item.itemList[1].text ?? "",
style: TextStyle(
fontSize: 11,
color:
HexColor.fromHex(item.itemList[1].textColor)),
style: TextStyle(fontSize: 11, color: HexColor.fromHex(item.itemList[1].textColor)),
),
InkWell(
child: Padding(
@@ -386,12 +331,7 @@ class _WalletDetailState extends State<WalletDetail>
),
Text(
dataMap[item.itemList[1].vauleKey],
style: TextStyle(
fontSize: 17,
color: HexColor.fromHex(item.itemList[1].valueColor),
fontFamily: 'Din',
package: 'zhiying_comm',
fontWeight: FontWeight.bold),
style: TextStyle(fontSize: 17, color: HexColor.fromHex(item.itemList[1].valueColor), fontFamily: 'Din', package: 'zhiying_comm', fontWeight: FontWeight.bold),
)
],
),
@@ -405,7 +345,8 @@ class _WalletDetailState extends State<WalletDetail>

///变更平台
void changeProvider(String type) {
_bloc.loadData(type);
_bloc.currentType = type;
_bloc.loadData(type, _bloc.selectDay);
}

///显示提示框


+ 16
- 17
lib/widgets/wallet/wallet_detail/wallet_detail_bloc.dart Parādīt failu

@@ -7,8 +7,7 @@ import 'package:zhiying_comm/zhiying_comm.dart';
import 'model/wallet_detail_data_model.dart';

class WalletDetailBloc extends BlocBase {
StreamController<WalletDetailDataModel> _dataController =
StreamController<WalletDetailDataModel>();
StreamController<WalletDetailDataModel> _dataController = StreamController<WalletDetailDataModel>();

Stream<WalletDetailDataModel> get outData => _dataController.stream;

@@ -21,6 +20,8 @@ class WalletDetailBloc extends BlocBase {

String currentType;

WalletDetailDataModel currentWalletDetailDataModel;

@override
void dispose() {
_dataController.close();
@@ -30,25 +31,23 @@ class WalletDetailBloc extends BlocBase {
///
/// 加载头部数据
///
loadData(String type) async {
await NetUtil.request("/api/v1/user/wallet/" + type, onSuccess: (data) {
currentType = type;
listDataModel.clear();
listDataModel.addAll(List.from(data).map((v) {
return WalletDetailDataModel.fromJson(v);
}).toList());
refresh();
loadData(String type, String time) async {
currentType = type;
await NetUtil.request("/api/v1/user/wallet/" + type + "?time=" + time, onSuccess: (data) {
if (currentType == type) {
listDataModel.clear();
listDataModel.addAll(List.from(data).map((v) {
return WalletDetailDataModel.fromJson(v);
}).toList());
currentWalletDetailDataModel = listDataModel[0];
refresh();
}
});
}

///刷新页面
refresh() {
for (var item in listDataModel) {
if (selectDay == item.type) {
selectDateData = item;
_dataController.add(selectDateData);
return;
}
}
selectDateData = currentWalletDetailDataModel;
_dataController.add(selectDateData);
}
}

Notiek ielāde…
Atcelt
Saglabāt