ソースを参照

更新订单样式

tags/0.0.1
Weller 4年前
コミット
cdf3c59716
7個のファイルの変更226行の追加60行の削除
  1. +42
    -0
      lib/pages/orders_page/bloc/order_content_bloc.dart
  2. +36
    -12
      lib/pages/orders_page/models/order_filter_model.dart
  3. +36
    -0
      lib/pages/orders_page/models/order_model.dart
  4. +49
    -11
      lib/pages/orders_page/order_content_page.dart
  5. +13
    -9
      lib/pages/orders_page/orders_page.dart
  6. +34
    -23
      lib/pages/orders_page/views/order_filter.dart
  7. +16
    -5
      lib/pages/orders_page/views/order_tabbar_widget.dart

+ 42
- 0
lib/pages/orders_page/bloc/order_content_bloc.dart ファイルの表示

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

import 'package:zhiying_base_widget/pages/orders_page/models/order_filter_model.dart';
import 'package:zhiying_base_widget/pages/orders_page/models/order_model.dart';
import 'package:zhiying_comm/util/base_bloc.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class OrderContentBloc extends BlocBase {
List<OrderModel> _orders = List();

StreamController<List<OrderModel>> _ordersController =
StreamController<List<OrderModel>>();

Stream<List<OrderModel>> get outData => _ordersController.stream;

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

void loadData(OrderFilterModel filter) {
Map<String, dynamic> params = filter.toJson();
params.removeWhere((key, value) => value == null || value == '');
NetUtil.request('/api/v1/order', method: NetMethod.POST, params: params,
onCache: (data) {
_loadData(data);
}, onSuccess: (data) {
_loadData(data);
});
}

void _loadData(dynamic data) {
List list = data ?? [];

_orders = list.map((item) {
return OrderModel.fromJson(Map<String, dynamic>.from(item));
}).toList();

_ordersController.add(_orders);
}
}

+ 36
- 12
lib/pages/orders_page/models/order_filter_model.dart ファイルの表示

@@ -1,21 +1,45 @@
// 订单筛选条件
class OrderFilterModel {
final String state; // 否 string 订单状态0已付款,1已收货,2成功,3失效
final String keyword; // 否 string 关键字
final String start_time; // 否 string 开始时间
final String end_time; // 否 string 结束时间
final String type; // 否 string 订单类型self自购, share分享, fans粉丝
final String provider; // 否 string 供应商taobao, jd, pdd, vip, kaola,suning,own自营
final String page_no; // 否 string 页码
final String page_size;
String state;
String keyword;
String startTime;
String endTime;
String type;
String provider;
String pageNo;
String pageSize;

OrderFilterModel(
{this.state,
this.keyword,
this.start_time,
this.end_time,
this.startTime,
this.endTime,
this.type,
this.provider,
this.page_no,
this.page_size}); // 否 string 页数
this.pageNo,
this.pageSize});

OrderFilterModel.fromJson(Map<String, dynamic> json) {
state = json['state'];
keyword = json['keyword'];
startTime = json['start_time'];
endTime = json['end_time'];
type = json['type'];
provider = json['provider'];
pageNo = json['page_no'];
pageSize = json['page_size'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['state'] = this.state;
data['keyword'] = this.keyword;
data['start_time'] = this.startTime;
data['end_time'] = this.endTime;
data['type'] = this.type;
data['provider'] = this.provider;
data['page_no'] = this.pageNo;
data['page_size'] = this.pageSize;
return data;
}
}

+ 36
- 0
lib/pages/orders_page/models/order_model.dart ファイルの表示

@@ -0,0 +1,36 @@
class OrderModel {
String itemId;
String title;
String price;
String commission;
String commissionRate;
String imgUrl;

OrderModel(
{this.itemId,
this.title,
this.price,
this.commission,
this.commissionRate,
this.imgUrl});

OrderModel.fromJson(Map<String, dynamic> json) {
itemId = json['item_id'];
title = json['title'];
price = json['price'];
commission = json['commission'];
commissionRate = json['commission_rate'];
imgUrl = json['img_url'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['item_id'] = this.itemId;
data['title'] = this.title;
data['price'] = this.price;
data['commission'] = this.commission;
data['commission_rate'] = this.commissionRate;
data['img_url'] = this.imgUrl;
return data;
}
}

+ 49
- 11
lib/pages/orders_page/order_content_page.dart ファイルの表示

@@ -1,10 +1,13 @@
import 'package:event_bus/event_bus.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/pages/orders_page/bloc/order_content_bloc.dart';
import 'package:zhiying_base_widget/pages/orders_page/models/order_filter_model.dart';
import 'package:zhiying_base_widget/pages/orders_page/models/order_model.dart';
import 'package:zhiying_base_widget/pages/orders_page/views/order_item_widget.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:zhiying_base_widget/widgets/empty/empty_widget.dart';
import 'package:zhiying_comm/util/base_bloc.dart';

class OrderContentPage extends StatefulWidget {
final EventBus filter;
final OrderFilterModel filter;

const OrderContentPage({Key key, this.filter}) : super(key: key);

@@ -13,22 +16,57 @@ class OrderContentPage extends StatefulWidget {
}

class _OrderContentPageState extends State<OrderContentPage> {
@override
Widget build(BuildContext context) {
return BlocProvider<OrderContentBloc>(
bloc: OrderContentBloc(),
child: OrderContentContainer(widget.filter),
);
}
}

class OrderContentContainer extends StatefulWidget {
final OrderFilterModel filter;

const OrderContentContainer(this.filter, {Key key}) : super(key: key);

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

class _OrderContentContainerState extends State<OrderContentContainer> {
OrderContentBloc _bloc;

@override
void initState() {
// 每次滑动刷新数据
widget.filter?.streamController?.add((filter) {
Logger.debug(filter.toString());
});
_bloc = BlocProvider.of(context);
_bloc.loadData(widget.filter);

super.initState();
}

@override
Widget build(BuildContext context) {
print(context.toString());
return ListView.builder(
itemCount: 20,
itemBuilder: (context, index) {
return OrderItemWidget();
return StreamBuilder<List<OrderModel>>(
stream: _bloc.outData,
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.data == null) {
return Container();
}
List<OrderModel> orders = snapshot.data;
if (orders.length == 0) {
return Container(
child: Center(
child: EmptyWidget(tips: '暂无订单,快去下一单吧'),
),
);
}
return ListView.builder(
itemCount: 20,
itemBuilder: (context, index) {
return OrderItemWidget();
});
});
}
}

+ 13
- 9
lib/pages/orders_page/orders_page.dart ファイルの表示

@@ -1,4 +1,3 @@
import 'package:event_bus/event_bus.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/pages/orders_page/models/order_filter_model.dart';
@@ -80,7 +79,6 @@ class _OrdersContainerState extends State<_OrdersContainer>
TabController _tabController;
GlobalKey _tabKey = GlobalKey();

final EventBus _eventBus = EventBus();
final OrderFilterModel _filter = OrderFilterModel();

bool _isFilterShow = false;
@@ -99,22 +97,22 @@ class _OrdersContainerState extends State<_OrdersContainer>
_tabController = TabController(length: 6, vsync: this);
_contents = [
OrderContentPage(
filter: _eventBus,
filter: _filter,
),
OrderContentPage(
filter: _eventBus,
filter: _filter,
),
OrderContentPage(
filter: _eventBus,
filter: _filter,
),
OrderContentPage(
filter: _eventBus,
filter: _filter,
),
OrderContentPage(
filter: _eventBus,
filter: _filter,
),
OrderContentPage(
filter: _eventBus,
filter: _filter,
),
];
super.initState();
@@ -152,7 +150,13 @@ class _OrdersContainerState extends State<_OrdersContainer>
),
Visibility(
visible: _isFilterShow,
child: OrderFilterWidget(),
child: OrderFilterWidget(
onDismiss: () {
setState(() {
_isFilterShow = false;
});
},
),
)
],
),


+ 34
- 23
lib/pages/orders_page/views/order_filter.dart ファイルの表示

@@ -2,6 +2,10 @@ import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/widgets/others/action_date_alert/action_date_alert.dart';

class OrderFilterWidget extends StatefulWidget {
final VoidCallback onDismiss;

const OrderFilterWidget({Key key, this.onDismiss}) : super(key: key);

@override
_OrderFilterWidgetState createState() => _OrderFilterWidgetState();
}
@@ -9,26 +13,32 @@ class OrderFilterWidget extends StatefulWidget {
class _OrderFilterWidgetState extends State<OrderFilterWidget> {
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
height: double.infinity,
color: Color(0x55555555),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
_creteTitle('订单来源'),
_createTags(),
_creteTitle('订单类型'),
_createTags(),
_creteTitle('订单时间'),
_creteTime(),
Container(
width: double.infinity,
height: 0.5,
color: Color(0xffe3e3e3),
return GestureDetector(
onTap: widget.onDismiss,
child: Container(
width: double.infinity,
height: double.infinity,
color: Color(0x55555555),
child: GestureDetector(
onTap: () {},
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
_creteTitle('订单来源'),
_createTags(),
_creteTitle('订单类型'),
_createTags(),
_creteTitle('订单时间'),
_creteTime(),
Container(
width: double.infinity,
height: 0.5,
color: Color(0xffe3e3e3),
),
_createButtons(),
],
),
_createButtons(),
],
),
),
);
}
@@ -60,12 +70,13 @@ class _OrderFilterWidgetState extends State<OrderFilterWidget> {
runSpacing: 10,
children: List.generate(10, (index) {
return Container(
padding: EdgeInsets.only(left: 8, right: 8, top: 4, bottom: 4),
padding: EdgeInsets.only(left: 12, right: 12, top: 6, bottom: 6),
decoration: BoxDecoration(
color: Colors.blue, borderRadius: BorderRadius.circular(5)),
color: Color(0xfff1f1f1),
borderRadius: BorderRadius.circular(5)),
child: Text(
'aaaa',
style: TextStyle(fontSize: 12),
'全部',
style: TextStyle(fontSize: 12, color: Color(0xff999999)),
),
);
}).toList(),


+ 16
- 5
lib/pages/orders_page/views/order_tabbar_widget.dart ファイルの表示

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/widgets/search/widget/my_tab.dart';

class OrderTabbarWidget extends StatelessWidget {
final TabController controller;
@@ -25,9 +26,16 @@ class OrderTabbarWidget extends StatelessWidget {
controller: controller,
isScrollable: true,
indicatorSize: TabBarIndicatorSize.label,
tabs: titles
.map((title) => OrderTabbarItemWidget(title: title))
.toList(),
// tabs: widgets,
indicatorColor: Color(0xffff4242),
labelColor: Color(0xffff4242),
unselectedLabelColor: Color(0xff999999),
tabs: titles.map((item) {
return MyTab(
// icon: CachedNetworkImage(imageUrl: item?.with_icon_color ?? '', width: 14,),
text: item,
);
}).toList(),
),
),
GestureDetector(
@@ -52,8 +60,10 @@ class OrderTabbarWidget extends StatelessWidget {

class OrderTabbarItemWidget extends StatelessWidget {
final String title;
final bool isSelected;

const OrderTabbarItemWidget({Key key, this.title}) : super(key: key);
const OrderTabbarItemWidget({Key key, this.title, this.isSelected = false})
: super(key: key);

@override
Widget build(BuildContext context) {
@@ -61,7 +71,8 @@ class OrderTabbarItemWidget extends StatelessWidget {
height: 26,
child: Text(
title,
style: TextStyle(color: Color(0xFFFF4242)),
style: TextStyle(
color: isSelected ? Color(0xFFFF4242) : Color(0xff999999)),
),
);
}


読み込み中…
キャンセル
保存