Commit 80cd9bc6a18cfa9b33ecf3253f2b636e5007423d

Authored by wdn127929
1 parent 662bac04

预订联系人部分

import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/provider/contant_show_model.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
class ContantLeftPage extends StatefulWidget {
ContantLeftPage({Key key}) : super(key: key);
@override
_ContantLeftPageState createState() => _ContantLeftPageState();
}
class _ContantLeftPageState extends State<ContantLeftPage> {
EasyRefreshController _controller;
ContantShowModel contantShowModel;
@override
void initState() {
super.initState();
_controller = EasyRefreshController();
WidgetsBinding.instance.addPostFrameCallback((_) {
_getContantData();
});
}
_getContantData() async {
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
await contantShowModel.getUserHistorys(context, params);
}
@override
Widget build(BuildContext context) {
contantShowModel = Provider.of<ContantShowModel>(context, listen: true);
return Expanded(
child: Consumer<ContantShowModel>(
builder: (context, model, _) {
if (model.pageStateLeft != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateLeft,
callback: () {
// offset = 0;
// getMessages();
_getContantData();
},
emptyMsg: "暂时没有联系人哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return EasyRefresh.custom(
controller: _controller,
slivers: [
SliverList(delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(30)),
height: ScreenUtil().setWidth(74 * 2),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: ScreenUtil().setWidth(2),
color: MyColours.color_E0E0E0))),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(model.userHistorys[index].rname,
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(32))),
VEmptyView(10),
Text(model.userHistorys[index].phone,
style: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(30)))
],
),
);
}))
],
// onRefresh: () async {
// // offset = 0;
// // getMessages(showLoading: false);
// },
// onLoad: () async {
// // offset++;
// // getMessages(showLoading: false);
// },
);
}
},
),
);
}
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:contacts_service/contacts_service.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:intl/intl.dart';
import 'package:one_key/pages/my/contant_left_page.dart';
import 'package:one_key/provider/contant_show_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/widgets/custom_tab_indicator.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:provider/provider.dart';
class ContactListPage extends StatefulWidget {
@override
_ContactListPageState createState() => _ContactListPageState();
}
class _ContactListPageState extends State<ContactListPage> {
List<Contact> _contacts;
List _tabBarTitle;
@override
void initState() {
_tabBarTitle = ['预订联系人', '手机联系人'];
super.initState();
refreshContacts();
}
Future<void> refreshContacts() async {
// Load without thumbnails initially.
var contacts = (await ContactsService.getContacts(
withThumbnails: false, iOSLocalizedLabels: false))
.toList();
// var contacts = (await ContactsService.getContactsForPhone("8554964652"))
// .toList();
setState(() {
_contacts = contacts;
});
// Lazy load thumbnails after rendering initial contacts.
for (final contact in contacts) {
ContactsService.getAvatar(contact).then((avatar) {
if (avatar == null) return; // Don't redraw if no change.
setState(() => contact.avatar = avatar);
});
}
}
void updateContact() async {
Contact ninja = _contacts
.toList()
.firstWhere((contact) => contact.familyName.startsWith("Ninja"));
ninja.avatar = null;
await ContactsService.updateContact(ninja);
refreshContacts();
}
_openContactForm() async {
try {
var contact =
await ContactsService.openContactForm(iOSLocalizedLabels: false);
refreshContacts();
} on FormOperationException catch (e) {
switch (e.errorCode) {
case FormOperationErrorCode.FORM_OPERATION_CANCELED:
case FormOperationErrorCode.FORM_COULD_NOT_BE_OPEN:
case FormOperationErrorCode.FORM_OPERATION_UNKNOWN_ERROR:
default:
print(e.errorCode);
}
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar('联系人'),
body: SafeArea(
child: DefaultTabController(
length: 2,
child: Stack(
children: <Widget>[
TabBarView(
physics: NeverScrollableScrollPhysics(),
children: <Widget>[
ChangeNotifierProvider<ContantShowModel>(
create: (_) => ContantShowModel(),
child: ContantLeftPage()),
Container()
],
),
Positioned(
child: Container(
padding:
EdgeInsets.only(bottom: ScreenUtil().setWidth(10)),
margin: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(30)),
child: TabBar(
indicator: CustomTabIndicator(
radius: 0,
),
indicatorColor: MyColours.color_199095,
indicatorSize: TabBarIndicatorSize.tab,
// indicatorPadding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(12)),
labelColor: MyColours.color_199095,
labelStyle: TextStyle(
fontSize: ScreenUtil().setSp(32),
fontWeight: FontWeight.bold),
labelPadding: EdgeInsets.zero,
unselectedLabelStyle:
TextStyle(fontWeight: FontWeight.normal),
unselectedLabelColor: MyColours.color_999999,
tabs: _tabBarTitle.map((value) {
return Tab(
child: Text(value),
);
}).toList()),
))
],
))));
}
}
... ...
... ... @@ -268,20 +268,6 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
// ],
// ),
VEmptyView(40),
// MyItem(
// title: "我的员工",
// content: "",
// callback: () {
// Utils.goMiniProgramZm(context, "roomtype/roomtype");
// },
// ),
// MyDivider(
// double.infinity,
// ScreenUtil().setHeight(1),
// color: MyColours.color_f3f3f3,
// ),
MyItem(
title: "线上券创建",
content: '',
... ... @@ -289,11 +275,23 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
NavigatorUtil.goCouponPage(context);
},
),
MyDivider(
double.infinity,
ScreenUtil().setHeight(1),
color: MyColours.color_f3f3f3,
),
MyItem(
title: "联系人",
content: "",
callback: () {
// Utils.goMiniProgramZm(context, "roomtype/roomtype");
NavigatorUtil.goMyContantPage(context);
},
),
VEmptyView(40),
MyItem(
title: "短信管理",
content:
... ...
import 'package:flutter/material.dart';
import 'package:one_key/constant/constant.dart';
import 'package:one_key/constant/error.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/user_history_entity.dart';
import 'package:one_key/net/base_resp.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/net/http_url.dart';
class ContantShowModel extends ChangeNotifier {
PageState pageStateLeft = PageState.Loading;
List<UserHistoryEntity> userHistorys = []; //历史录入
//获取历史录入
getUserHistorys(BuildContext context, Map<String, String> params) async {
BaseResp<List> baseResp = await DioUtil()
.request<List>(context, Method.get, HttpUrl.get_reserve_user,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
case 1:
pageStateLeft = PageState.ConnectivityError;
break;
case 2:
pageStateLeft = PageState.ConnectivityTimeOut;
break;
default:
pageStateLeft = PageState.ConnectivityError;
break;
}
}
notifyListeners();
});
if (baseResp != null && baseResp.code == Constant.status_success) {
userHistorys = baseResp.data.map<UserHistoryEntity>((value) {
return UserHistoryEntity.fromJson(value);
}).toList();
if (userHistorys.length == 0) {
pageStateLeft = PageState.Empty;
} else {
pageStateLeft = PageState.Success;
}
notifyListeners();
}
}
}
... ...
... ... @@ -301,4 +301,10 @@ class NavigatorUtil {
"${Routes.my_integral_page}?sunModel=${FluroConvertUtils.object2string(sunModel)}",
replace: replace);
}
/// 我的联系人页面
static Future<dynamic> goMyContantPage(BuildContext context,
{replace = false, IntegralSunModel sunModel}) {
return _navigateTo(context, "${Routes.my_contant_page}", replace: replace);
}
}
... ...
... ... @@ -34,6 +34,7 @@ import 'package:one_key/pages/login/web_page.dart';
import 'package:one_key/pages/message/message_order_menu.dart';
import 'package:one_key/pages/my/base_info.dart';
import 'package:one_key/pages/my/book_time_set.dart';
import 'package:one_key/pages/my/contant_page.dart';
import 'package:one_key/pages/my/my_integral_page.dart';
import 'package:one_key/pages/my/receive_orders_time_set.dart';
import 'package:one_key/pages/my/remark_manager_page.dart';
... ... @@ -436,3 +437,13 @@ var myIntegralPageHandler = new Handler(
return ChangeNotifierProvider<MyModel>(
create: (_) => MyModel(), child: MyIntegralPage(sunModel: sunModel));
});
///我的联系人
var myContantPageHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
// IntegralSunModel sunModel = IntegralSunModel.fromJson(json
// .decode(FluroConvertUtils.fluroCnParamsDecode(params["sunModel"].first)));
// String urlStr = FluroConvertUtils.fluroCnParamsDecode(params["urlStr"].first);
return ContactListPage();
});
... ...
... ... @@ -42,6 +42,8 @@ class Routes {
static String enter_store_environment = "/enter_store_environment"; //店铺环境
static String complete_create_store = "/complete_create_store"; //创建店铺完成
static String my_integral_page = "/my_integral_page"; //我的积分
static String my_contant_page = "/my_contant_page"; //我的联系人
static void configureRoutes(FluroRouter router) {
router.notFoundHandler = new Handler(
... ... @@ -92,6 +94,9 @@ class Routes {
handler: completeCreateStorePageHandler);
router.define(my_integral_page,
handler: myIntegralPageHandler);
router.define(my_contant_page,
handler: myContantPageHandler);
}
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/res/colors.dart';
class CustomTabIndicator extends Decoration {
/// Create an underline style selected tab indicator.
///
/// The [borderSide] and [insets] arguments must not be null.
const CustomTabIndicator(
{this.borderSide = const BorderSide(width: 2.0, color: Colors.white),
this.insets = EdgeInsets.zero,
this.width,
this.radius,
this.color})
: assert(borderSide != null),
assert(insets != null);
/// The color and weight of the horizontal line drawn below the selected tab.
final BorderSide borderSide;
final double radius;
final double width;
final Color color;
/// Locates the selected tab's underline relative to the tab's boundary.
///
/// The [TabBar.indicatorSize] property can be used to define the
/// tab indicator's bounds in terms of its (centered) tab widget with
/// [TabIndicatorSize.label], or the entire tab with [TabIndicatorSize.tab].
final EdgeInsetsGeometry insets;
@override
Decoration lerpFrom(Decoration a, double t) {
if (a is CustomTabIndicator) {
return CustomTabIndicator(
borderSide: BorderSide.lerp(a.borderSide, borderSide, t),
insets: EdgeInsetsGeometry.lerp(a.insets, insets, t),
);
}
return super.lerpFrom(a, t);
}
@override
Decoration lerpTo(Decoration b, double t) {
if (b is CustomTabIndicator) {
return CustomTabIndicator(
borderSide: BorderSide.lerp(borderSide, b.borderSide, t),
insets: EdgeInsetsGeometry.lerp(insets, b.insets, t),
);
}
return super.lerpTo(b, t);
}
@override
_UnderlinePainter createBoxPainter([VoidCallback onChanged]) {
return _UnderlinePainter(this, onChanged);
}
}
class _UnderlinePainter extends BoxPainter {
_UnderlinePainter(this.decoration, VoidCallback onChanged)
: assert(decoration != null),
super(onChanged);
final CustomTabIndicator decoration;
BorderSide get borderSide => decoration.borderSide;
EdgeInsetsGeometry get insets => decoration.insets;
// Rect _indicatorRectFor(Rect rect, TextDirection textDirection) {
// assert(rect != null);
// assert(textDirection != null);
// final Rect indicator = insets.resolve(textDirection).deflateRect(rect);
// //取中间坐标
// double cw = (indicator.left + indicator.right) / 2;
// return Rect.fromLTWH(
// cw - decoration.width / 2,
// indicator.bottom - borderSide.width,
// decoration.width,
// borderSide.width);
// }
Rect _indicatorRectFor(Rect rect, TextDirection textDirection) {
assert(rect != null);
assert(textDirection != null);
final Rect indicator = insets.resolve(textDirection).deflateRect(rect);
return Rect.fromLTWH(
indicator.left,
indicator.bottom - borderSide.width,
indicator.width,
borderSide.width,
);
}
// @override
// void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
// assert(configuration != null);
// assert(configuration.size != null);
// final Rect rect = offset & configuration.size;
// final TextDirection textDirection = configuration.textDirection;
// final Rect indicator =
// _indicatorRectFor(rect, textDirection).deflate(borderSide.width / 2.0);
// final RRect rrect =
// RRect.fromRectAndRadius(indicator, Radius.circular(40.0));
// Gradient gradient = LinearGradient(colors: [
// MyColours.color_3BBFF5,
// MyColours.color_57a0ff,
// ]);
// final Paint paint = borderSide.toPaint()..strokeCap = StrokeCap.square;
// canvas.drawLine(Offset(rrect.left, rrect.bottom),
// Offset(rrect.right, rrect.bottom), paint);
// canvas.drawRRect(
// rrect,
// Paint()
// ..style = PaintingStyle.fill
// ..shader = gradient.createShader(rect));
// // Gradient gradient =
// // LinearGradient(colors: [Colors.red[200], Colors.red[800]]);
// Gradient gradient = LinearGradient(colors: [
// MyColours.color_3BBFF5,
// MyColours.color_57a0ff,
// ]);
// canvas.drawLine(rect.left, p2, paint)
// canvas.drawRRect(
// rrect,
// Paint()
// ..style = PaintingStyle.fill
// ..shader = gradient.createShader(rect));
// }
// void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
// assert(configuration != null);
// assert(configuration.size != null);
// final Rect rect = offset & configuration.size;
// final TextDirection textDirection = configuration.textDirection;
// Gradient gradient = LinearGradient(colors: [
// MyColours.color_3BBFF5,
// MyColours.color_57a0ff,
// ]);
// final Rect indicator = _indicatorRectFor(rect, textDirection).deflate(borderSide.width / 2.0);
// final Paint paint = borderSide.toPaint()..strokeCap = StrokeCap.square ..shader = gradient.createShader(rect);
// canvas.drawLine(indicator.bottomLeft, indicator.bottomRight, paint);
// }
@override
void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
assert(configuration != null);
assert(configuration.size != null);
final Rect rect = offset & configuration.size;
final RRect rRect = RRect.fromRectAndRadius(
Rect.fromLTWH(rect.left + (rect.width - ScreenUtil().setWidth(48*2)) / 2,
rect.top + rect.height - ScreenUtil().setWidth(20), ScreenUtil().setWidth(48*2), ScreenUtil().setWidth(6)),
Radius.circular(decoration.radius));
Gradient gradient = LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
MyColours.color_199095,
MyColours.color_199095,
],
);
canvas.drawRRect(
rRect,
Paint()
..style = PaintingStyle.fill
..shader = gradient.createShader(rect));
}
}
... ...
... ... @@ -116,6 +116,8 @@ dependencies:
dotted_border: ^1.0.7
scroll_to_index: ^2.0.0
#通讯录
... ...