diff --git a/android/app/build.gradle b/android/app/build.gradle index 1959c21..56f7b25 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -39,6 +39,7 @@ android { versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } buildTypes { diff --git a/assets/fonts/jindian.ttf b/assets/fonts/jindian.ttf new file mode 100644 index 0000000..b21ffe0 Binary files /dev/null and b/assets/fonts/jindian.ttf differ diff --git a/assets/images/banner1.jpg b/assets/images/banner1.jpg new file mode 100644 index 0000000..b440d9b Binary files /dev/null and b/assets/images/banner1.jpg differ diff --git a/assets/images/banner2.jpg b/assets/images/banner2.jpg new file mode 100644 index 0000000..feea84d Binary files /dev/null and b/assets/images/banner2.jpg differ diff --git a/assets/images/banner3.jpg b/assets/images/banner3.jpg new file mode 100644 index 0000000..1f51b66 Binary files /dev/null and b/assets/images/banner3.jpg differ diff --git a/assets/images/login_logo.png b/assets/images/login_logo.png new file mode 100644 index 0000000..0531be9 Binary files /dev/null and b/assets/images/login_logo.png differ diff --git a/lib/common/api.dart b/lib/common/api.dart new file mode 100644 index 0000000..a6b9192 --- /dev/null +++ b/lib/common/api.dart @@ -0,0 +1,36 @@ + +import 'dart:core'; + +/** + * + * api +**/ + +String BASE_URL = "http://192.168.1.106"; + +const String CODE_BASE_PORT = ":12223"; + +const String ROOM_BASE_PORT = ":12222"; + +const String HOTEL_BASE_PORT = ":12224"; + +const String ORDER_BASE_PORT = ":12225"; + +String CODE_URL = BASE_URL + CODE_BASE_PORT + "/auth/code/"; + +String TOKEN_URL = BASE_URL + CODE_BASE_PORT + "/auth/checkcode"; + +String HOTEL_URL = BASE_URL + HOTEL_BASE_PORT + "/hotel/info/0/1"; + +String ROOM_URL = BASE_URL + ROOM_BASE_PORT + "/room/detail/1"; + +String ROOM_COUNT_URL = BASE_URL + ROOM_BASE_PORT + "/room/count/1"; + +String SINGLE_ROOM_COUNT_URL = BASE_URL + ROOM_BASE_PORT + "/room/single/count/1"; + +String ORDER_URL = BASE_URL + ORDER_BASE_PORT + "/order/detail/"; + + +String COMMIT_ORDER_URL = BASE_URL + ORDER_BASE_PORT + "/order/commit/"; + +String CREATE_ORDER_URL = BASE_URL + ORDER_BASE_PORT + "/order/create/body"; \ No newline at end of file diff --git a/lib/common/constant.dart b/lib/common/constant.dart new file mode 100644 index 0000000..69f3a45 --- /dev/null +++ b/lib/common/constant.dart @@ -0,0 +1,18 @@ +import 'dart:core'; + +const String TOKEN_KEY = "TOKEN_KEY"; + +const String USER_NAME = "USER_NAME"; + +String gobalUserName = ""; + +String fontname = 'jindian'; + +DateTime selectDate = new DateTime.now(); + +int counttime = 100; + + + +DateTime secselectDate = new DateTime.now().add(Duration(days: 1)); + diff --git a/lib/common/tu_chong_repository.dart b/lib/common/tu_chong_repository.dart index ce3be8e..0f6976b 100644 --- a/lib/common/tu_chong_repository.dart +++ b/lib/common/tu_chong_repository.dart @@ -1,10 +1,15 @@ +import 'package:dio/dio.dart'; +import 'package:hotel/entity/hotelview.dart'; +import 'package:hotel/entity/roomview.dart'; import 'package:http_client_helper/http_client_helper.dart'; import '../ui/widget/loading_more/loading_more_list.dart'; import '../common/tu_chong_source.dart'; import 'dart:async'; import 'dart:convert'; -class TuChongRepository extends LoadingMoreBase { +import 'api.dart'; + +class TuChongRepository extends LoadingMoreBase { int pageindex = 1; @override @@ -40,31 +45,33 @@ class TuChongRepository extends LoadingMoreBase { Future loadData([bool isloadMoreAction = false]) async { // TODO: implement getData String url = ""; + Dio dio = new Dio(); if (this.length == 0) { - url = "https://api.tuchong.com/feed-app"; + url = HOTEL_URL; } else { - int lastPostId = this[this.length - 1].post_id; - url = "https://api.tuchong.com/feed-app?post_id=${lastPostId}&page=${pageindex}&type=loadmore"; + url = HOTEL_URL; } bool isSuccess = false; try { //to show loading more clearly, in your app,remove this - await Future.delayed(Duration(milliseconds: 500, seconds: 1)); +// await Future.delayed(Duration(milliseconds: 500, seconds: 1)); - var result = await HttpClientHelper.get(url); + var result = await dio.post(url); - var source = TuChongSource.fromJson(json.decode(result.body)); + var source = HotelView.fromJson(result.data); if (pageindex == 1) { this.clear(); } - source.feedList.forEach((item) { - if (item.hasImage && !this.contains(item) && hasMore) { - this.add(item); - } - }); + this.add(source); + +// source.feedList.forEach((item) { +// if (item.hasImage && !this.contains(item) && hasMore) { +// this.add(item); +// } +// }); - _hasMore = source.feedList.length != 0; + _hasMore = true; pageindex++; // this.clear(); // _hasMore=false; diff --git a/lib/config/application.dart b/lib/config/application.dart index 8fa3597..a921033 100644 --- a/lib/config/application.dart +++ b/lib/config/application.dart @@ -13,5 +13,6 @@ class Application { static navigateTo({ @required BuildContext context, @required String route, transition = TransitionType.inFromRight }) { router.navigateTo(context, route, transition: transition); } + } diff --git a/lib/entity/hotelview.dart b/lib/entity/hotelview.dart new file mode 100644 index 0000000..9381044 --- /dev/null +++ b/lib/entity/hotelview.dart @@ -0,0 +1,44 @@ + +class HotelView{ + + int id; + + String hotel_name; + + String hotel_location; + + String hotel_pic; + + String hotel_grade; + + String neighbor_location; + + String tap; + + String commuser_num; + + HotelView(); + + HotelView.fromJson(Map json) + : id = json['id'], + hotel_name = json['hotel_name'], + hotel_location = json['hotel_location'], + hotel_pic = json['hotel_pic'], + hotel_grade = json['hotel_grade'], + neighbor_location = json['neighbor_location'], + tap = json['tap'], + commuser_num = json['commuser_num']; + + Map toJson() => + { + 'id': id, + 'hotel_name': hotel_name, + 'hotel_location': hotel_location, + 'hotel_pic': hotel_pic, + 'hotel_grade': hotel_grade, + 'neighbor_location': neighbor_location, + 'tap': tap, + 'commuser_num': commuser_num, + + }; +} \ No newline at end of file diff --git a/lib/entity/mobile.dart b/lib/entity/mobile.dart new file mode 100644 index 0000000..2f2fd76 --- /dev/null +++ b/lib/entity/mobile.dart @@ -0,0 +1,12 @@ +//import 'package:json_annotation/json_annotation.dart'; +// +//@JsonSerializable(nullable: false) +//class Mobile{ +// +// String code; +// +// String mobilenum; +// +// Mobile({this.code,this.mobilenum}); +// +//} \ No newline at end of file diff --git a/lib/entity/orderdetail.dart b/lib/entity/orderdetail.dart new file mode 100644 index 0000000..8b83869 --- /dev/null +++ b/lib/entity/orderdetail.dart @@ -0,0 +1,41 @@ + +import 'dart:core'; + +class OrderDetail{ + + double collection_price; + + String user_id; + + String room_name; + + String hotel_name; + + int room_count; + + String room_in_time; + + String room_out_time; + + OrderDetail.fromJson(Map json) + : room_name = json['room_name'], + room_count = json['room_count'], + collection_price = json['collection_price'], + room_in_time = json['room_in_time'], + room_out_time = json['room_out_time'], + hotel_name = json['hotel_name'], + user_id = json['user_id']; + + Map toJson() => + { + 'room_name': room_name, + 'room_count': room_count, + 'collection_price': collection_price, + 'room_out_time': room_out_time, + 'room_in_time': room_in_time, + 'user_id': user_id, + 'hotel_name': hotel_name, + + }; + +} diff --git a/lib/entity/orderview.dart b/lib/entity/orderview.dart new file mode 100644 index 0000000..a461398 --- /dev/null +++ b/lib/entity/orderview.dart @@ -0,0 +1,59 @@ + +import 'dart:core'; + +import 'dart:core'; + +class OrderView{ + + int id; + + double collection_price; + + int order_id; + + String user_id; + + String room_name; + + int pay_status; + + String hotel_name; + + int room_count; + + String order_set_time; + + String room_in_time; + + String room_out_time; + + OrderView.fromJson(Map json) + : id = json['id'], + room_name = json['room_name'], + room_count = json['room_count'], + collection_price = json['collection_price'], + order_id = json['order_id'], + pay_status = json['pay_status'], + room_in_time = json['room_in_time'], + room_out_time = json['room_out_time'], + order_set_time = json['order_set_time'], + hotel_name = json['hotel_name'], + user_id = json['user_id']; + + Map toJson() => + { + 'id': id, + 'room_name': room_name, + 'room_count': room_count, + 'collection_price': collection_price, + 'order_id': order_id, + 'pay_status': pay_status, + 'room_out_time': room_out_time, + 'order_set_time': order_set_time, + 'room_in_time': room_in_time, + 'user_id': user_id, + 'hotel_name': hotel_name, + + }; + +} diff --git a/lib/entity/roomview.dart b/lib/entity/roomview.dart new file mode 100644 index 0000000..8c44ea1 --- /dev/null +++ b/lib/entity/roomview.dart @@ -0,0 +1,38 @@ + +class RoomView{ + + int id; + + int room_count; + + String room_name; + + double room_price; + + String room_detail; + + String room_pic; + + bool _cancel; + + RoomView.fromJson(Map json) + : id = json['id'], + room_name = json['room_name'], + room_count = json['room_count'], + room_price = json['room_price'], + room_detail = json['room_detail'], + room_pic = json['room_pic'], + _cancel = json['_cancel']; + + Map toJson() => + { + 'id': id, + 'room_name': room_name, + 'room_count': room_count, + 'room_price': room_price, + 'room_detail': room_detail, + 'room_pic': room_pic, + '_cancel': _cancel, + + }; +} \ No newline at end of file diff --git a/lib/entity/usertoken.dart b/lib/entity/usertoken.dart new file mode 100644 index 0000000..3efe645 --- /dev/null +++ b/lib/entity/usertoken.dart @@ -0,0 +1,20 @@ + +class UserToken{ + + String phone_num; + + String acesstoken; + + UserToken.fromJson(Map json) + :phone_num = json['phone_num'], + acesstoken = json['acesstoken']; + + + Map toJson() => + { + + 'phone_num': phone_num, + 'acesstoken': acesstoken + + }; +} \ No newline at end of file diff --git a/lib/http/service/NetService.dart b/lib/http/service/NetService.dart new file mode 100644 index 0000000..662b962 --- /dev/null +++ b/lib/http/service/NetService.dart @@ -0,0 +1,97 @@ +import 'dart:convert'; + +import 'package:dio/dio.dart'; +import 'package:hotel/common/api.dart'; +import 'package:hotel/common/constant.dart'; +import 'dart:io'; + +import 'package:shared_preferences/shared_preferences.dart'; + +class NetService { + + static const String GET = 'GET'; + static const String POST = 'POST'; + + static Map Headers = { + HttpHeaders.authorizationHeader : "" + }; + + //get请求 + static void get(String url, Function successCallBack, + {Map params, Function errorCallBack}) { + _request(url, successCallBack, + method: GET, params: params, errorCallBack: errorCallBack); + } + + //post请求 + static void post(String url, Function successCallBack, + {Map params, Map headers,Function errorCallBack}) { + print("post:${url}"); + _request(url, successCallBack, + method: POST, params: params, headers: headers, errorCallBack: errorCallBack); + } + + static Future getStorageString(key) async { + SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); + String token = sharedPreferences.get(key); + print("get token:${token}"); + if(token!=null) + { + Headers[HttpHeaders.authorizationHeader] ='Bearer '+ token; + } + + } + // 请求部分 + static void _request(String url, Function callBack, + {String method, Map params, Map headers, Function errorCallBack}) async { + String errorMsg = ""; + int statusCode; + + try { + Response response; + getStorageString(TOKEN_KEY); + print("headers:${Headers}"); + Options options= new Options( + // 15s 超时时间 + connectTimeout:1000, + receiveTimeout:1000, + baseUrl: BASE_URL, + headers: Headers + // dio库中默认将请求数据序列化为json,此处可根据后台情况自行修改 + //contentType: new ContentType('application', 'x-www-form-urlencoded',charset: 'utf-8') + ); + Dio dio = new Dio(options); + + if (method == GET) { + response = await dio.get(url,data: params); + + } else { + response = await dio.post(url,data: params); + } + statusCode = response.statusCode; + //处理错误部分 + if (statusCode < 0) { + errorMsg = "网络请求错误,状态码:" + statusCode.toString(); + _handError(errorCallBack, errorMsg); + return; + } + + if (callBack != null) { + callBack(response); + print(response.statusCode); + } + } catch (exception) { + _handError(errorCallBack, exception.toString()); + } + } + + //处理异常 + static void _handError(Function errorCallback, String errorMsg) { + if (errorCallback != null) { + errorCallback(errorMsg); + } + } + + + +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index d470310..2c437ed 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,11 +2,15 @@ import 'package:flutter/material.dart'; import 'package:fluro/fluro.dart'; import 'package:scoped_model/scoped_model.dart'; import 'package:event_bus/event_bus.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'route/routes.dart'; import 'models/state_model/main_state_model.dart'; import 'config/application.dart'; import 'ui/page/mainpage.dart'; -void main() => runApp(App()); + +void main() { + runApp(App()); +} class App extends StatefulWidget { @@ -21,6 +25,7 @@ class App extends StatefulWidget { class _AppState extends State with AutomaticKeepAliveClientMixin{ MainStateModel mainStateModel; + String token; @override bool get wantKeepAlive => true; @@ -33,11 +38,23 @@ class _AppState extends State with AutomaticKeepAliveClientMixin{ final Router router = Router(); Routes.configureRoutes(router); Application.router = router; + saveStorageString('18846086270','1111'); + + } + + Future saveStorageString(key,value) async { + print("save"); + SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); + sharedPreferences.setString( + key, value); } + + + + @override Widget build(BuildContext context) { // TODO: implement build - //状态管理 return ScopedModel( model: mainStateModel, diff --git a/lib/route/route_handlers.dart b/lib/route/route_handlers.dart index c331a81..7c69919 100644 --- a/lib/route/route_handlers.dart +++ b/lib/route/route_handlers.dart @@ -4,7 +4,15 @@ */ import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; -import 'package:hotel/ui/page/order/room_order_page.dart'; +import 'package:hotel/entity/hotelview.dart'; +import 'package:hotel/ui/page/login/codepage.dart'; +import 'package:hotel/ui/page/login/loginpage.dart'; +import 'package:hotel/ui/page/mainpage.dart'; +import 'package:hotel/ui/page/pay/successpage.dart'; +import 'package:hotel/ui/page/personal/ippage.dart'; +import 'package:hotel/ui/page/personal/settingpage.dart'; +import 'package:hotel/ui/page/room/room_order_page.dart'; +import 'package:hotel/ui/page/personal/personalpage.dart'; import '../ui/page/hotely/hotel_list_page.dart'; import '../ui/page/hotely/hotel_detail_page.dart'; import '../ui/page/order/order_detail_page.dart'; @@ -31,4 +39,57 @@ var roomorderpageRouteHandler = Handler( handlerFunc: (BuildContext context,Map> params){ return RoomOrderPage(); } +); + +var loginpageRouteHandler = Handler( + handlerFunc: (BuildContext context,Map> params){ + return LoginPage(); + } +); + +var codepageRouteHandler = Handler( + handlerFunc: (BuildContext context,Map> params){ + String phone_num = params["phone_num"]?.first; + String verifyCode = params["verifyCode"]?.first; + return CodePage( + phone_num:phone_num, + verifyCode:verifyCode, + ); + } +); + +var personpageRouteHandler = Handler( + handlerFunc: (BuildContext context,Map> params){ + String islogin = params["islogin"]?.first; + + return PersonPage( + + islogin: islogin == "true"?true:false, + ); + } +); + +var mainpageRouteHandler = Handler( + handlerFunc: (BuildContext context,Map> params){ + return MainPage(); + } +); + +var settingpageRouteHandler = Handler( + handlerFunc: (BuildContext context,Map> params){ + return SettingPage(); + } +); + + +var successpageRouteHandler = Handler( + handlerFunc: (BuildContext context,Map> params){ + return SuccessPage(); + } +); + +var ippageRouteHandler = Handler( + handlerFunc: (BuildContext context,Map> params){ + return IpPage(); + } ); \ No newline at end of file diff --git a/lib/route/routes.dart b/lib/route/routes.dart index 77e8bd6..3043085 100644 --- a/lib/route/routes.dart +++ b/lib/route/routes.dart @@ -13,6 +13,14 @@ class Routes { static String hoteldetailpage = "/hoteldetailpage"; static String orderdetailpage = "/orderdetailpage"; static String roomorderpage = "/roomorderpage"; + static String loginpage = "/loginpage"; + static String codepage = "/codepage"; + static String personpage = "/personpage"; + static String mainpage = "/mainpage"; + static String settingpage = "/settingpage"; + static String successpage = "/successpage"; + static String ippage = "/ippage"; + static void configureRoutes(Router router) { @@ -21,6 +29,13 @@ class Routes { router.define(hoteldetailpage, handler: hoteldetailpageRouteHandler); router.define(orderdetailpage, handler: orderdetailpageRouteHandler); router.define(roomorderpage, handler: roomorderpageRouteHandler); + router.define(loginpage, handler: loginpageRouteHandler); + router.define(codepage, handler: codepageRouteHandler); + router.define(personpage, handler: personpageRouteHandler); + router.define(mainpage, handler: mainpageRouteHandler); + router.define(settingpage, handler: settingpageRouteHandler); + router.define(successpage, handler: successpageRouteHandler); + router.define(ippage, handler: ippageRouteHandler); router.notFoundHandler = Handler( handlerFunc: (BuildContext context, Map> params) { print("ROUTE WAS NOT FOUND !!!"); diff --git a/lib/ui/page/find/findpage.dart b/lib/ui/page/find/findpage.dart index ae58892..3da9732 100644 --- a/lib/ui/page/find/findpage.dart +++ b/lib/ui/page/find/findpage.dart @@ -88,7 +88,9 @@ class _FindPageState extends State { child: BackdropFilter( filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), ///设置主题颜色 - child: Theme(data: new ThemeData(primaryColor: Colors.black54, hintColor: Colors.black54), child: TextField( + child: Theme( + data: new ThemeData(primaryColor: Colors.black54, hintColor: Colors.black54), + child: TextField( cursorColor: Colors.white, decoration: InputDecoration( fillColor: Colors.transparent.withOpacity(0.2), diff --git a/lib/ui/page/first/Internationalpage.dart b/lib/ui/page/first/Internationalpage.dart index 5627644..142cd26 100644 --- a/lib/ui/page/first/Internationalpage.dart +++ b/lib/ui/page/first/Internationalpage.dart @@ -1,4 +1,8 @@ +import 'package:city_pickers/city_pickers.dart'; import 'package:flutter/material.dart'; +import 'package:hotel/common/constant.dart'; +import 'package:hotel/config/application.dart'; +import 'package:hotel/route/routes.dart'; import 'package:hotel/ui/widget/bottom_pop/timebottompop.dart'; @@ -11,12 +15,28 @@ class InternationalPage extends StatefulWidget { } class _InternationalPageState extends State { + + Result result = new Result(); + @override Widget build(BuildContext context) { // TODO: implement build return _mainpage(context); } + + showMap() async { + result = await CityPickers.showCityPicker( + context: context, + ); + if(result == null){ + result = new Result(); + } + setState(() { + print(result); + }); + } + _mainpage(context){ final _media = MediaQuery.of(context).size; @@ -24,9 +44,7 @@ class _InternationalPageState extends State { children: [ InkWell( onTap: (){ - setState(() { - print(1); - }); + showMap(); }, child: Container( height: 65, @@ -47,9 +65,10 @@ class _InternationalPageState extends State { Container( alignment: Alignment.topLeft, child:Text( - '哈尔滨', + result.cityName == null ? "请选择城市" : result.cityName, style:TextStyle( - fontSize: 18, + fontSize: result.cityName == null ? 15 : 18, + color: result.cityName == null ? Colors.grey : Colors.black ), ), padding: EdgeInsets.only(left: 20,top: 5), @@ -79,12 +98,20 @@ class _InternationalPageState extends State { //showModalBottomSheet默认点击子widget收起,加一个GestureDetector并设置onTap为false阻断点击事件 return GestureDetector( onTap: () => false, - child: TimeBottomPop(), + child: TimeBottomPop( + onChange: (m){ + print(m); + }, + ), ); } - ); - setState(() { - print(1); + ).then((value){ + setState(() { + if(value!=null && !value.isEmpty){ + selectDate = value[0]; + secselectDate = value[1]; + } + }); }); }, child: Container( @@ -97,23 +124,26 @@ class _InternationalPageState extends State { children: [ Container( alignment: Alignment.centerLeft, - width: _media.width * 0.85 * 0.3, + width: _media.width * 0.85 * 0.4, child: Column( children: [ Container( - child: Text('今天入住', + alignment: Alignment.topLeft, + child: Text( + checksameday(selectDate,DateTime.now())? '今天入住' : '入住', style: TextStyle( fontSize: 13, color: Colors.red ), ), - padding: EdgeInsets.only(left: 10,top: 10), + padding: EdgeInsets.only(left: 20,top: 10), ), Container( + alignment: Alignment.topLeft, child: Text( - '5月8日 ', + selectDate.month.toString() + "月" + selectDate.day.toString() + "日", style:TextStyle( - fontSize: 20, + fontSize: 18, ), ), padding: EdgeInsets.only(left:20,top: 3), @@ -124,11 +154,13 @@ class _InternationalPageState extends State { ), Container( alignment: Alignment.centerLeft, - width:_media.width * 0.85 * 0.3, + width:_media.width * 0.85 * 0.4, child: Column( children: [ Container( - child: Text('明天入住', + alignment: Alignment.topLeft, + child: Text( + checksameday(secselectDate,DateTime.now().add(Duration(days: 1)))?'明天离店': '离店' , style: TextStyle( fontSize: 13, color: Colors.red @@ -137,13 +169,14 @@ class _InternationalPageState extends State { padding: EdgeInsets.only(left: 10,top: 10), ), Container( + alignment: Alignment.topLeft, child:Text( - '5月9日', + secselectDate.month.toString() + "月" + secselectDate.day.toString() + "日", style:TextStyle( - fontSize: 20, + fontSize: 18, ), ), - padding: EdgeInsets.only(left: 20,top: 3), + padding: EdgeInsets.only(left: 10,top: 3), ), ], @@ -153,7 +186,7 @@ class _InternationalPageState extends State { child: Container( alignment: Alignment.centerRight, child: Text( - '共'+'1'+'晚', + '共'+ secselectDate.difference(selectDate).inDays.toString() +'晚', style: TextStyle(color: Colors.black,fontSize: 11), ), ) @@ -303,24 +336,53 @@ class _InternationalPageState extends State { ), MyDivider(height: 0,indent: 400 / 30.0,endindent: 400 / 30.0,), Container( - height:80, - width: 480, - padding: EdgeInsets.only(left:10.0, right:10.0,top:30.0), + height:50, + width: 300, + margin: EdgeInsets.only(left:10.0,top: 30, right:10.0), child: new FlatButton( - color: Colors.red, child: new Padding( padding: EdgeInsets.all(8.0), child: new Text( "查找酒店", style: new TextStyle( - fontFamily: 'HanaleiFill', color: Colors.white, fontSize: 25.0), + fontFamily: 'jindian', + color: Colors.white, + fontSize: 25.0), ), ), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)), - onPressed: () {}, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)), //圆角大小 + onPressed: () { + Application.navigateTo(context:context, route : "${Routes.hotelpage}"); + }, + ), + decoration: new BoxDecoration( + //渐变色 + borderRadius: BorderRadius.all(Radius.circular(3)), + gradient: new LinearGradient( + colors: [ + Colors.deepOrangeAccent, + Colors.redAccent.withAlpha(220), + ], + begin: const FractionalOffset(0.2, 0.0), + end: const FractionalOffset(1.0, 1.0), + stops: [0.0, 1.0], + tileMode: TileMode.clamp + ) ) ), ], ); } + + bool checksameday(DateTime datetime,DateTime ct){ + + if(datetime.month == ct.month) { + if (datetime.day == ct.day){ + return true; + } + } + return false; + + } + } \ No newline at end of file diff --git a/lib/ui/page/first/babpage.dart b/lib/ui/page/first/babpage.dart index cf11998..4b6ddf7 100644 --- a/lib/ui/page/first/babpage.dart +++ b/lib/ui/page/first/babpage.dart @@ -1,4 +1,8 @@ +import 'package:city_pickers/city_pickers.dart'; import 'package:flutter/material.dart'; +import 'package:hotel/common/constant.dart'; +import 'package:hotel/config/application.dart'; +import 'package:hotel/route/routes.dart'; import 'package:hotel/ui/widget/bottom_pop/timebottompop.dart'; import '../../widget/MyDivider.dart'; @@ -10,11 +14,27 @@ class BabPage extends StatefulWidget { } class _BabPageState extends State { + + Result result = new Result(); + @override Widget build(BuildContext context) { // TODO: implement build return _mainpage(context); } + + showMap() async { + result = await CityPickers.showCityPicker( + context: context, + ); + if(result == null){ + result = new Result(); + } + setState(() { + print(result); + }); + } + _mainpage(context){ final _media = MediaQuery.of(context).size; @@ -22,9 +42,7 @@ class _BabPageState extends State { children: [ InkWell( onTap: (){ - setState(() { - print(1); - }); + showMap(); }, child: Container( height: 65, @@ -45,9 +63,10 @@ class _BabPageState extends State { Container( alignment: Alignment.topLeft, child:Text( - '哈尔滨', + result.cityName == null ? "请选择城市" : result.cityName, style:TextStyle( - fontSize: 18, + fontSize: result.cityName == null ? 15 : 18, + color: result.cityName == null ? Colors.grey : Colors.black ), ), padding: EdgeInsets.only(left: 20,top: 5), @@ -77,12 +96,20 @@ class _BabPageState extends State { //showModalBottomSheet默认点击子widget收起,加一个GestureDetector并设置onTap为false阻断点击事件 return GestureDetector( onTap: () => false, - child: TimeBottomPop(), + child: TimeBottomPop( + onChange: (m){ + print(m); + }, + ), ); } - ); - setState(() { - print(1); + ).then((value){ + setState(() { + if(value!=null && !value.isEmpty){ + selectDate = value[0]; + secselectDate = value[1]; + } + }); }); }, child: Container( @@ -95,23 +122,26 @@ class _BabPageState extends State { children: [ Container( alignment: Alignment.centerLeft, - width: _media.width * 0.85 * 0.3, + width: _media.width * 0.85 * 0.4, child: Column( children: [ Container( - child: Text('今天入住', + alignment: Alignment.topLeft, + child: Text( + checksameday(selectDate,DateTime.now())? '今天入住' : '入住', style: TextStyle( fontSize: 13, color: Colors.red ), ), - padding: EdgeInsets.only(left: 10,top: 10), + padding: EdgeInsets.only(left: 20,top: 10), ), Container( + alignment: Alignment.topLeft, child: Text( - '5月8日 ', + selectDate.month.toString() + "月" + selectDate.day.toString() + "日", style:TextStyle( - fontSize: 20, + fontSize: 18, ), ), padding: EdgeInsets.only(left:20,top: 3), @@ -122,11 +152,13 @@ class _BabPageState extends State { ), Container( alignment: Alignment.centerLeft, - width:_media.width * 0.85 * 0.3, + width:_media.width * 0.85 * 0.4, child: Column( children: [ Container( - child: Text('明天入住', + alignment: Alignment.topLeft, + child: Text( + checksameday(secselectDate,DateTime.now().add(Duration(days: 1)))?'明天离店': '离店' , style: TextStyle( fontSize: 13, color: Colors.red @@ -135,13 +167,14 @@ class _BabPageState extends State { padding: EdgeInsets.only(left: 10,top: 10), ), Container( + alignment: Alignment.topLeft, child:Text( - '5月9日', + secselectDate.month.toString() + "月" + secselectDate.day.toString() + "日", style:TextStyle( - fontSize: 20, + fontSize: 18, ), ), - padding: EdgeInsets.only(left: 20,top: 3), + padding: EdgeInsets.only(left: 10,top: 3), ), ], @@ -151,7 +184,7 @@ class _BabPageState extends State { child: Container( alignment: Alignment.centerRight, child: Text( - '共'+'1'+'晚', + '共'+ secselectDate.difference(selectDate).inDays.toString() +'晚', style: TextStyle(color: Colors.black,fontSize: 11), ), ) @@ -261,25 +294,53 @@ class _BabPageState extends State { ), MyDivider(height: 0,indent: 400 / 30.0,endindent: 400 / 30.0,), Container( - height:80, - width: 480, - padding: EdgeInsets.only(left:10.0, right:10.0,top:30.0), + height:50, + width: 300, + margin: EdgeInsets.only(left:10.0,top: 30, right:10.0), child: new FlatButton( - color: Colors.red, child: new Padding( padding: EdgeInsets.all(8.0), child: new Text( "查找酒店", style: new TextStyle( - fontFamily: 'HanaleiFill', color: Colors.white, fontSize: 25.0), + fontFamily: 'jindian', + color: Colors.white, + fontSize: 25.0), ), ), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)), - onPressed: () {}, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)), //圆角大小 + onPressed: () { + Application.navigateTo(context:context, route : "${Routes.hotelpage}"); + }, + ), + decoration: new BoxDecoration( + //渐变色 + borderRadius: BorderRadius.all(Radius.circular(3)), + gradient: new LinearGradient( + colors: [ + Colors.deepOrangeAccent, + Colors.redAccent.withAlpha(220), + ], + begin: const FractionalOffset(0.2, 0.0), + end: const FractionalOffset(1.0, 1.0), + stops: [0.0, 1.0], + tileMode: TileMode.clamp + ) ) ), ], ); } + bool checksameday(DateTime datetime,DateTime ct){ + + if(datetime.month == ct.month) { + if (datetime.day == ct.day){ + return true; + } + } + return false; + } + + } \ No newline at end of file diff --git a/lib/ui/page/first/bottompage.dart b/lib/ui/page/first/bottompage.dart index bdbe015..8945a34 100644 --- a/lib/ui/page/first/bottompage.dart +++ b/lib/ui/page/first/bottompage.dart @@ -1,5 +1,9 @@ +import 'dart:ui'; + import 'package:flutter/material.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; +import 'package:hotel/common/api.dart'; +import 'package:hotel/common/constant.dart'; import "package:pull_to_refresh/pull_to_refresh.dart"; import '../../widget/ad_swiper/swiper.dart'; @@ -14,6 +18,9 @@ class BottomPage extends StatefulWidget{ } class _BottomPageState extends State with SingleTickerProviderStateMixin{ + + List bannerlists = [BASE_URL + HOTEL_BASE_PORT + '/image/ad1.jpg',BASE_URL + HOTEL_BASE_PORT + '/image/ad2.jpg',BASE_URL + HOTEL_BASE_PORT + '/image/ad3.jpg']; + @override Widget build(BuildContext context) { // TODO: implement build @@ -21,18 +28,62 @@ class _BottomPageState extends State with SingleTickerProviderStateM } Widget _swiperBuilder(BuildContext context, int index) { - return ( - Image.asset( - "assets/images/2.jpg", - fit: BoxFit.fill, - )); + + final _media = MediaQuery.of(context).size; + return Stack( + children: [ + Container( + width: _media.width, + child: Image.network( + bannerlists[index], + fit: BoxFit.cover, + ), + ), + Container( + height: 80, + width: _media.width * 0.35, + margin: EdgeInsets.only(left: 10,top: 10), + child: Card( + elevation: 0, + color: Colors.white.withAlpha(20), + child: Column( + children: [ + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(left: 10,top: 10), + child: Text( + '限时抢', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.w500, + fontSize: 20 + ), + ), + ), + Container( + alignment: Alignment.bottomLeft, + margin: EdgeInsets.only(left: 10,top: 10), + child: Text( + '今夜尾房甩卖', + style: TextStyle( + color: Colors.white, + fontFamily: fontname, + fontSize: 15 + ), + ), + ) + ], + ), + ) + ), + ], + ); } Widget bottompage(BuildContext context) { final _media = MediaQuery.of(context).size; - List list = ['1','2','3']; - PageController pageController = PageController(initialPage: 0,viewportFraction: 0.3); + PageController pageController = PageController(initialPage: 0,viewportFraction: 0.35); return Container( child: Column( @@ -40,20 +91,22 @@ class _BottomPageState extends State with SingleTickerProviderStateM MySwiper(), Container( width: MediaQuery.of(context).size.width, - height: 200.0, + height: 230.0, padding: EdgeInsets.only(top: 20), child: Container( width: 300, child: Swiper( itemBuilder: _swiperBuilder, itemCount: 3, - pagination: new SwiperPagination( builder: DotSwiperPaginationBuilder( color: Colors.black54, activeColor: Colors.white, )), - control: new SwiperControl(), + control: new SwiperControl( + iconNext: null, + iconPrevious: null + ), scrollDirection: Axis.horizontal, autoplay: true, onTap: (index) => print('点击了第$index个'), @@ -61,14 +114,26 @@ class _BottomPageState extends State with SingleTickerProviderStateM ) ), Container( - margin: EdgeInsets.only(left: 10,bottom: 10,top: 40), - alignment: Alignment.centerLeft, - child: Text('特惠精选', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 23 - ), - ), + margin: EdgeInsets.only(left: 10,bottom: 10,top: 40), + alignment: Alignment.centerLeft, + child: Row( + children: [ + Padding( + child: Icon( + Icons.fiber_new, + color: Colors.deepOrange, + ), + padding: EdgeInsets.only(right: 5), + ), + Text('特惠精选', + style: TextStyle( + fontFamily: 'jindian', + fontWeight: FontWeight.w700, + fontSize: 23 + ), + ), + ], + ) ), Container( height: 100, @@ -78,16 +143,20 @@ class _BottomPageState extends State with SingleTickerProviderStateM Expanded( child: PageView.builder( controller: pageController, - itemCount: list.length, + itemCount: bannerlists.length, itemBuilder: (BuildContext context, int index){ return Container( margin: EdgeInsets.symmetric(horizontal: 10), padding: EdgeInsets.symmetric(horizontal: 10), decoration: BoxDecoration( - image: DecorationImage( fit: BoxFit.cover,image: AssetImage('assets/images/3.jpg')), + image: DecorationImage( + fit: BoxFit.cover, + image: NetworkImage(bannerlists[index]) + ), borderRadius: BorderRadius.circular(8.0) ), ); + } ) ) @@ -95,14 +164,26 @@ class _BottomPageState extends State with SingleTickerProviderStateM ) ), Container( - margin: EdgeInsets.only(left: 10,bottom: 10,top: 40), - alignment: Alignment.topLeft, - child: Text('推荐榜单', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 23 - ), - ), + margin: EdgeInsets.only(left: 10,bottom: 10,top: 40), + alignment: Alignment.topLeft, + child:Row( + children: [ + Padding( + child: Icon( + Icons.check_circle, + color: Colors.deepOrange, + ), + padding: EdgeInsets.only(right: 5), + ), Text( + '推荐榜单', + style: TextStyle( + fontFamily: 'jindian', + fontWeight: FontWeight.w700, + fontSize: 23 + ), + ), + ] + ) ), Container( child: Column( @@ -112,16 +193,27 @@ class _BottomPageState extends State with SingleTickerProviderStateM children: [ Container( height:160, - width: _media.width * 0.5, - child: Card( - color: Colors.redAccent, + width: _media.width * 0.48, + margin: EdgeInsets.only(left: 5), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(5)), + image: DecorationImage( + fit: BoxFit.cover, + image: NetworkImage(BASE_URL + HOTEL_BASE_PORT + '/image/ad4.jpg') + ), ), + ), Container( height:160, - width: _media.width * 0.5, - child: Card( - color: Colors.redAccent, + width: _media.width * 0.48, + margin: EdgeInsets.only(left: 5), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(5)), + image: DecorationImage( + fit: BoxFit.cover, + image: NetworkImage(BASE_URL + HOTEL_BASE_PORT + '/image/ad5.jpg') + ), ), ) ], @@ -131,25 +223,40 @@ class _BottomPageState extends State with SingleTickerProviderStateM child: Row( children: [ Container( - height:_media.width * 0.33, - width: _media.width * 0.33, - child: Card( - color: Colors.redAccent, + height:_media.width * 0.31, + width: _media.width * 0.31, + margin: EdgeInsets.only(left: 5,top: 5), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(5)), + image: DecorationImage( + fit: BoxFit.cover, + image: NetworkImage(BASE_URL + HOTEL_BASE_PORT + '/image/ad6.jpg') + ), ), ), Container( - height:_media.width * 0.33, - width: _media.width * 0.33, - child: Card( - color: Colors.redAccent, + height:_media.width * 0.31, + width: _media.width * 0.31, + margin: EdgeInsets.only(left: 5,top: 5), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(5)), + image: DecorationImage( + fit: BoxFit.cover, + image: NetworkImage(BASE_URL + HOTEL_BASE_PORT + '/image/ad7.jpg') + ), ), ), Container( - height:_media.width * 0.33, - width: _media.width * 0.33, - child: Card( - color: Colors.redAccent, - ), + height:_media.width * 0.31, + width: _media.width * 0.31, + margin: EdgeInsets.only(left: 5,top: 5), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(5)), + image: DecorationImage( + fit: BoxFit.cover, + image: NetworkImage(BASE_URL + HOTEL_BASE_PORT + '/image/ad1.jpg') + ), + ) ) ], ), @@ -158,18 +265,29 @@ class _BottomPageState extends State with SingleTickerProviderStateM ), ), Container( - margin: EdgeInsets.only(left: 10,bottom: 10,top: 40), - alignment: Alignment.centerLeft, - child: Text('猜你喜欢', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 23 - ), - ), + margin: EdgeInsets.only(left: 10,bottom: 10,top: 40), + alignment: Alignment.centerLeft, + child: Row( + children: [ + Padding( + child: Icon( + Icons.favorite, + color: Colors.deepOrange, + ), + padding: EdgeInsets.only(right: 5), + ),Text( + '猜你喜欢', + style: TextStyle( + fontFamily: 'jindian', + fontWeight: FontWeight.w700, + fontSize: 23 + ), + ), + ] + ) ), ], ), ); } - } \ No newline at end of file diff --git a/lib/ui/page/first/customtilebar.dart b/lib/ui/page/first/customtilebar.dart index f2eec9e..259ab07 100644 --- a/lib/ui/page/first/customtilebar.dart +++ b/lib/ui/page/first/customtilebar.dart @@ -32,20 +32,22 @@ class CustomTitleBarState extends State { final _media = MediaQuery.of(context).size; return Container( - padding: EdgeInsets.only(left: _media.width * 0.38,top: 15), + padding: EdgeInsets.only(left: _media.width * 0.35,top: 15), alignment: Alignment.center, child: Row( children: [ Container( child: Icon( - Icons.four_k, - color: _controller.value.alpha < 255/2 ? Colors.white.withAlpha(255 - _controller.value.alpha) : Colors.red.withAlpha(_controller.value.alpha), + Icons.spa, + color: _controller.value.alpha < 255/2 ? Colors.white.withAlpha(255 - _controller.value.alpha) : Colors.redAccent.withAlpha(_controller.value.alpha), ), ), Semantics( - child: Text('边度酒店', + child: Text( + '边度酒店', style: TextStyle( fontSize: 20, + fontFamily: 'jindian', color: _controller.value.alpha < 255/2 ? Colors.white.withAlpha(255 - _controller.value.alpha) :Colors.black.withAlpha(_controller.value.alpha), fontWeight: FontWeight.w600, ), @@ -67,9 +69,9 @@ class CustomTitleBarState extends State { color: Colors.white.withAlpha(_controller.value.alpha), border: Border( bottom: BorderSide( - color: Colors.black, - width: 0.1, - style: _controller.value.alpha < 255/2 ? BorderStyle.none :BorderStyle.solid + color: Colors.black, + width: 0.1, + style: _controller.value.alpha < 255/2 ? BorderStyle.none :BorderStyle.solid ) ) ), @@ -86,7 +88,7 @@ class CustomTitleBarState extends State { padding: EdgeInsets.only(left: 10,top: 15), child: new Icon( Icons.cloud, - color: _controller.value.alpha < 255/2 ? Colors.white.withAlpha(255 - _controller.value.alpha) : Colors.red.withAlpha(_controller.value.alpha), + color: _controller.value.alpha < 255/2 ? Colors.white.withAlpha(255 - _controller.value.alpha) : Colors.redAccent.withAlpha(_controller.value.alpha), ), ), ), @@ -94,24 +96,25 @@ class CustomTitleBarState extends State { new GestureDetector( onTap: widget.onMessageTap==null?(){}: widget.onMessageTap, child: new InkWell( - child: Container( - padding: EdgeInsets.only(top: 15,right: 15), - child: Column( - children: [ - Icon( - Icons.notifications, - color: _controller.value.alpha < 255/2 ? Colors.white.withAlpha(255 - _controller.value.alpha) : Colors.red.withAlpha(_controller.value.alpha), - ), - Text( - '客服', - style: TextStyle( - fontSize: 10, - color: _controller.value.alpha < 255/2 ? Colors.white.withAlpha(255 - _controller.value.alpha) : Colors.red.withAlpha(_controller.value.alpha) - ), + child: Container( + padding: EdgeInsets.only(top: 15,right: 15), + child: Column( + children: [ + Icon( + Icons.notifications, + color: _controller.value.alpha < 255/2 ? Colors.white.withAlpha(255 - _controller.value.alpha) : Colors.redAccent.withAlpha(_controller.value.alpha), + ), + Text( + '客服', + style: TextStyle( + fontSize: 10, + fontFamily: 'jindian', + color: _controller.value.alpha < 255/2 ? Colors.white.withAlpha(255 - _controller.value.alpha) : Colors.redAccent.withAlpha(_controller.value.alpha) + ), + ) + ], ) - ], ) - ) ), ), ], diff --git a/lib/ui/page/first/firstpage.dart b/lib/ui/page/first/firstpage.dart index cc4e869..4172af9 100644 --- a/lib/ui/page/first/firstpage.dart +++ b/lib/ui/page/first/firstpage.dart @@ -1,9 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:hotel/common/item_builder.dart'; -import 'package:hotel/common/tu_chong_source.dart'; -import "package:pull_to_refresh/pull_to_refresh.dart"; -import 'package:flutter_screenutil/flutter_screenutil.dart'; - +import 'package:hotel/entity/hotelview.dart'; import '../../widget/MyDivider.dart'; import '../hotely/hotel_item.dart'; import '../../widget/loading_more/loading_more_list.dart'; @@ -136,8 +132,20 @@ class _FirstPageState extends State with SingleTickerProviderStateMi Stack( children: [ Container( - height: 250, - color:Colors.red, + height: _media.height * 0.33, + decoration: new BoxDecoration( + //渐变色 + gradient: new LinearGradient( + colors: [ + Colors.red.withAlpha(230), + Colors.redAccent.withAlpha(220), + ], + begin: const FractionalOffset(0.2, 0.0), + end: const FractionalOffset(1.0, 1.0), + stops: [0.0, 1.0], + tileMode: TileMode.clamp + ) + ) ), Container( margin: EdgeInsets.only(top: 80, left: _media.width / 2 - cardwt / 2), @@ -158,11 +166,13 @@ class _FirstPageState extends State with SingleTickerProviderStateMi labelPadding: EdgeInsets.symmetric(horizontal: _media.width / 35), unselectedLabelColor: Color(0xff666666), unselectedLabelStyle: TextStyle( + fontFamily: 'jindian', fontSize: _media.width / 22, ), labelStyle: TextStyle( + fontFamily: 'jindian', fontSize: _media.width / 23, - fontWeight: FontWeight.w600, + fontWeight: FontWeight.w500, ), tabs: tablist.map((item) { return Tab( @@ -185,7 +195,7 @@ class _FirstPageState extends State with SingleTickerProviderStateMi ), ), LoadingMoreSliverList( - SliverListConfig( + SliverListConfig( itemBuilder: itemBuilder, sourceList: listSourceRepository, //isLastOne: false @@ -203,6 +213,6 @@ class _FirstPageState extends State with SingleTickerProviderStateMi ); } - Widget itemBuilder(BuildContext context,TuChongItem item, int index) => HotelItem(); + Widget itemBuilder(BuildContext context,HotelView item, int index) => HotelItem(hotelView: item,); } diff --git a/lib/ui/page/first/hourroompage.dart b/lib/ui/page/first/hourroompage.dart index 1b4d0dd..dfe0c79 100644 --- a/lib/ui/page/first/hourroompage.dart +++ b/lib/ui/page/first/hourroompage.dart @@ -1,4 +1,8 @@ +import 'package:city_pickers/city_pickers.dart'; import 'package:flutter/material.dart'; +import 'package:hotel/common/constant.dart'; +import 'package:hotel/config/application.dart'; +import 'package:hotel/route/routes.dart'; import 'package:hotel/ui/widget/bottom_pop/timebottompop.dart'; import '../../widget/bottom_pop/bottompop.dart'; @@ -10,22 +14,36 @@ class HourroomPage extends StatefulWidget { } class _HourroomPageState extends State { + + Result result = new Result(); + @override Widget build(BuildContext context) { // TODO: implement build return _mainpage(context); } + showMap() async { + result = await CityPickers.showCityPicker( + context: context, + ); + if(result == null){ + result = new Result(); + } + setState(() { + print(result); + }); + } + + _mainpage(context){ final _media = MediaQuery.of(context).size; return Column( children: [ InkWell( - onTap: (){ - setState(() { - print(1); - }); + onTap: (){ + showMap(); }, child: Container( height: 65, @@ -46,9 +64,10 @@ class _HourroomPageState extends State { Container( alignment: Alignment.topLeft, child:Text( - '哈尔滨', + result.cityName == null ? "请选择城市" : result.cityName, style:TextStyle( - fontSize: 18, + fontSize: result.cityName == null ? 15 : 18, + color: result.cityName == null ? Colors.grey : Colors.black ), ), padding: EdgeInsets.only(left: 20,top: 5), @@ -78,12 +97,20 @@ class _HourroomPageState extends State { //showModalBottomSheet默认点击子widget收起,加一个GestureDetector并设置onTap为false阻断点击事件 return GestureDetector( onTap: () => false, - child: TimeBottomPop(), + child: TimeBottomPop( + onChange: (m){ + print(m); + }, + ), ); } - ); - setState(() { - print(1); + ).then((value){ + setState(() { + if(value!=null && !value.isEmpty){ + selectDate = value[0]; + secselectDate = value[1]; + } + }); }); }, child: Container( @@ -96,23 +123,26 @@ class _HourroomPageState extends State { children: [ Container( alignment: Alignment.centerLeft, - width: _media.width * 0.85 * 0.3, + width: _media.width * 0.85 * 0.4, child: Column( children: [ Container( - child: Text('今天入住', + alignment: Alignment.topLeft, + child: Text( + checksameday(selectDate,DateTime.now())? '今天入住' : '入住', style: TextStyle( fontSize: 13, color: Colors.red ), ), - padding: EdgeInsets.only(left: 10,top: 10), + padding: EdgeInsets.only(left: 20,top: 10), ), Container( + alignment: Alignment.topLeft, child: Text( - '5月8日 ', + selectDate.month.toString() + "月" + selectDate.day.toString() + "日", style:TextStyle( - fontSize: 20, + fontSize: 18, ), ), padding: EdgeInsets.only(left:20,top: 3), @@ -123,11 +153,13 @@ class _HourroomPageState extends State { ), Container( alignment: Alignment.centerLeft, - width:_media.width * 0.85 * 0.3, + width:_media.width * 0.85 * 0.4, child: Column( children: [ Container( - child: Text('明天入住', + alignment: Alignment.topLeft, + child: Text( + checksameday(secselectDate,DateTime.now().add(Duration(days: 1)))?'明天离店': '离店' , style: TextStyle( fontSize: 13, color: Colors.red @@ -136,13 +168,14 @@ class _HourroomPageState extends State { padding: EdgeInsets.only(left: 10,top: 10), ), Container( + alignment: Alignment.topLeft, child:Text( - '5月9日', + secselectDate.month.toString() + "月" + secselectDate.day.toString() + "日", style:TextStyle( - fontSize: 20, + fontSize: 18, ), ), - padding: EdgeInsets.only(left: 20,top: 3), + padding: EdgeInsets.only(left: 10,top: 3), ), ], @@ -152,7 +185,7 @@ class _HourroomPageState extends State { child: Container( alignment: Alignment.centerRight, child: Text( - '共'+'1'+'晚', + '共'+ secselectDate.difference(selectDate).inDays.toString() +'晚', style: TextStyle(color: Colors.black,fontSize: 11), ), ) @@ -175,25 +208,52 @@ class _HourroomPageState extends State { ), MyDivider(height: 0,indent: 400 / 30.0,endindent: 400 / 30.0,), Container( - height:80, - width: 480, - padding: EdgeInsets.only(left:10.0, right:10.0,top:30.0), - child: new RaisedButton( - color: Colors.red, + height:50, + width: 300, + margin: EdgeInsets.only(left:10.0,top: 30, right:10.0), + child: new FlatButton( child: new Padding( padding: EdgeInsets.all(8.0), child: new Text( "查找酒店", style: new TextStyle( - fontFamily: 'HanaleiFill', color: Colors.white, fontSize: 25.0), + fontFamily: 'jindian', + color: Colors.white, + fontSize: 25.0), ), ), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)), - onPressed: () {}, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)), //圆角大小 + onPressed: () { + Application.navigateTo(context:context, route : "${Routes.hotelpage}"); + }, + ), + decoration: new BoxDecoration( + //渐变色 + borderRadius: BorderRadius.all(Radius.circular(3)), + gradient: new LinearGradient( + colors: [ + Colors.deepOrangeAccent, + Colors.redAccent.withAlpha(220), + ], + begin: const FractionalOffset(0.2, 0.0), + end: const FractionalOffset(1.0, 1.0), + stops: [0.0, 1.0], + tileMode: TileMode.clamp + ) ) ), ], ); } + bool checksameday(DateTime datetime,DateTime ct){ + + if(datetime.month == ct.month) { + if (datetime.day == ct.day){ + return true; + } + } + return false; + + } } diff --git a/lib/ui/page/first/inlandpage.dart b/lib/ui/page/first/inlandpage.dart index 0f45a86..03ed653 100644 --- a/lib/ui/page/first/inlandpage.dart +++ b/lib/ui/page/first/inlandpage.dart @@ -1,12 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:hotel/common/constant.dart'; import '../../widget/MyDivider.dart'; -import 'customtilebar.dart'; -import 'package:flutter/material.dart'; import '../../widget/bottom_pop/bottompop.dart'; import '../../widget/bottom_pop/timebottompop.dart'; -import '../../widget/MyDivider.dart'; import '../../../route/routes.dart'; import '../../../config/application.dart'; +import 'package:city_pickers/city_pickers.dart'; class InlandPage extends StatefulWidget { _InlandPageState createState() => _InlandPageState(); @@ -14,6 +13,9 @@ class InlandPage extends StatefulWidget { class _InlandPageState extends State { + bool _loading = false; + Result result = new Result(); +// List datelist = [DateTime.now(),DateTime.now().add(Duration(days: 1))]; @override Widget build(BuildContext context) { @@ -21,16 +23,27 @@ class _InlandPageState extends State { // TODO: implement build return _mainpage(context); } + + showMap() async { + result = await CityPickers.showCityPicker( + context: context, + ); + if(result == null){ + result = new Result(); + } + setState(() { + print(result); + }); + } _mainpage(context){ final _media = MediaQuery.of(context).size; + return Column( children: [ InkWell( onTap: (){ - setState(() { - print(1); - }); + showMap(); }, child: Container( height: 65, @@ -42,18 +55,24 @@ class _InlandPageState extends State { children: [ Container( alignment: Alignment.topLeft, - child: Text('目的地',style: TextStyle( - fontSize: 13, - color: Colors.grey), + child: Text( + '目的地', + style: TextStyle( + fontFamily: 'jindian', + fontSize: 13, + color: Colors.grey + ), ), padding: EdgeInsets.only(left: 20,top: 10), ), Container( alignment: Alignment.topLeft, child:Text( - '哈尔滨', + result.cityName == null ? "请选择城市" : result.cityName, style:TextStyle( - fontSize: 18, + fontFamily: 'jindian', + fontSize: result.cityName == null ? 15 : 18, + color: result.cityName == null ? Colors.grey : Colors.black ), ), padding: EdgeInsets.only(left: 20,top: 5), @@ -83,12 +102,20 @@ class _InlandPageState extends State { //showModalBottomSheet默认点击子widget收起,加一个GestureDetector并设置onTap为false阻断点击事件 return GestureDetector( onTap: () => false, - child: TimeBottomPop(), + child: TimeBottomPop( + onChange: (m){ + print(m); + }, + ), ); } - ); - setState(() { - print(1); + ).then((value){ + setState(() { + if(value!=null && !value.isEmpty){ + selectDate = value[0]; + secselectDate = value[1]; + } + }); }); }, child: Container( @@ -101,23 +128,28 @@ class _InlandPageState extends State { children: [ Container( alignment: Alignment.centerLeft, - width: _media.width * 0.85 * 0.3, + width: _media.width * 0.85 * 0.4, child: Column( children: [ Container( - child: Text('今天入住', + alignment: Alignment.topLeft, + child: Text( + checksameday(selectDate,DateTime.now())? '今天入住' : '入住', style: TextStyle( + fontFamily: 'jindian', fontSize: 13, color: Colors.red ), ), - padding: EdgeInsets.only(left: 10,top: 10), + padding: EdgeInsets.only(left: 20,top: 10), ), Container( + alignment: Alignment.topLeft, child: Text( - '5月8日 ', + selectDate.month.toString() + "月" + selectDate.day.toString() + "日", style:TextStyle( - fontSize: 20, + fontFamily: 'jindian', + fontSize: 18, ), ), padding: EdgeInsets.only(left:20,top: 3), @@ -128,26 +160,31 @@ class _InlandPageState extends State { ), Container( alignment: Alignment.centerLeft, - width:_media.width * 0.85 * 0.3, + width:_media.width * 0.85 * 0.4, child: Column( children: [ Container( - child: Text('明天入住', + alignment: Alignment.topLeft, + child: Text( + checksameday(secselectDate,DateTime.now().add(Duration(days: 1)))?'明天离店': '离店' , style: TextStyle( - fontSize: 13, + fontSize: 13, + fontFamily: 'jindian', color: Colors.red ), ), padding: EdgeInsets.only(left: 10,top: 10), ), Container( + alignment: Alignment.topLeft, child:Text( - '5月9日', + secselectDate.month.toString() + "月" + secselectDate.day.toString() + "日", style:TextStyle( - fontSize: 20, + fontSize: 18, + fontFamily: 'jindian', ), ), - padding: EdgeInsets.only(left: 20,top: 3), + padding: EdgeInsets.only(left: 10,top: 3), ), ], @@ -157,8 +194,12 @@ class _InlandPageState extends State { child: Container( alignment: Alignment.centerRight, child: Text( - '共'+'1'+'晚', - style: TextStyle(color: Colors.black,fontSize: 11), + '共'+ secselectDate.difference(selectDate).inDays.toString() +'晚', + style: TextStyle( + color: Colors.black, + fontSize: 11, + fontFamily: 'jindian', + ), ), ) ) @@ -197,6 +238,7 @@ class _InlandPageState extends State { child:Text( '搜索酒店/地名/关键字', style:TextStyle( + fontFamily: 'jindian', color: Colors.grey, fontSize: 16, ), @@ -242,6 +284,7 @@ class _InlandPageState extends State { child:Text( '设置我喜欢的星级/价格', style:TextStyle( + fontFamily: 'jindian', color: Colors.grey, fontSize: 16, ), @@ -264,29 +307,55 @@ class _InlandPageState extends State { ), MyDivider(height: 0,indent: 400 / 30.0,endindent: 400 / 30.0,), Container( - height:80, - width: 480, - padding: EdgeInsets.only(left:10.0, right:10.0,top: 30), - child: new RaisedButton( - color: Colors.red, + height:50, + width: 300, + margin: EdgeInsets.only(left:10.0,top: 30, right:10.0), + child: new FlatButton( child: new Padding( padding: EdgeInsets.all(8.0), child: new Text( "查找酒店", style: new TextStyle( - fontFamily: 'HanaleiFill', color: Colors.white, fontSize: 25.0), + fontFamily: 'jindian', + color: Colors.white, + fontSize: 25.0), ), ), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)), //圆角大小 onPressed: () { _navigate(context, "${Routes.hotelpage}"); }, + ), + decoration: new BoxDecoration( + //渐变色 + borderRadius: BorderRadius.all(Radius.circular(3)), + gradient: new LinearGradient( + colors: [ + Colors.deepOrangeAccent, + Colors.redAccent.withAlpha(220), + ], + begin: const FractionalOffset(0.2, 0.0), + end: const FractionalOffset(1.0, 1.0), + stops: [0.0, 1.0], + tileMode: TileMode.clamp + ) ) ), ], ); } + bool checksameday(DateTime datetime,DateTime ct){ + + if(datetime.month == ct.month) { + if (datetime.day == ct.day){ + return true; + } + } + return false; + + } + _navigate(BuildContext context, String route) { Application.navigateTo(context: context, route: route); } diff --git a/lib/ui/page/hotely/hotel_detail_page.dart b/lib/ui/page/hotely/hotel_detail_page.dart index 2fc3345..e3d1d11 100644 --- a/lib/ui/page/hotely/hotel_detail_page.dart +++ b/lib/ui/page/hotely/hotel_detail_page.dart @@ -1,22 +1,30 @@ +import 'dart:collection'; +import 'dart:convert'; + import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:hotel/common/api.dart'; +import 'package:hotel/common/constant.dart'; import 'package:hotel/common/tu_chong_repository.dart'; import 'package:hotel/common/tu_chong_source.dart'; -import 'package:hotel/ui/page/first/customtilebar.dart'; +import 'package:hotel/entity/hotelview.dart'; +import 'package:hotel/entity/roomview.dart'; +import 'package:hotel/http/service/NetService.dart'; import 'package:hotel/ui/widget/bottom_pop/timebottompop.dart'; +import 'package:hotel/ui/widget/progress/CustomProgressIndicator.dart'; +import 'package:hotel/ui/widget/progress/progressdialog.dart'; import 'package:hotel/ui/widget/stack_appbar/hotel_appbar.dart'; import '../../widget/MyDivider.dart'; import '../../widget/loading_more/loading_more_list.dart'; import 'hotel_item.dart'; -import '../order/room_order_item.dart'; +import '../room/room_order_item.dart'; class HotelDetailPage extends StatefulWidget{ - final String hotel_name; - final String hotel_location; + HotelView hotelView; HotelDetailPage({ - this.hotel_location, - this.hotel_name, + @required this.hotelView }); @override @@ -33,13 +41,17 @@ class _HotelDetailPageState extends State{ HotelBarController _hotelbarcontroller = new HotelBarController(); bool _isNeedSetAlpha = false; GlobalKey_mTitleKey = new GlobalKey(); - List list = ['1','2','3']; + List room_list = []; + bool _loading = true; + String token = null; + Map Headers = new HashMap(); @override void initState() { // TODO: implement initState super.initState(); + _hotelbarcontroller.value.alpha = 0; _scrollcontroller.addListener(() { @@ -59,16 +71,60 @@ class _HotelDetailPageState extends State{ listSourceRepository = new TuChongRepository(); } + @override + void dispose() { + //注意这里关闭 + super.dispose(); + } + + @override + void didChangeDependencies() { + _loading = true; + // TODO: implement didChangeDependencies + super.didChangeDependencies(); + print('didChangeDependencies'); + NetService.post(ROOM_URL, (response){ + print(response); + setState(() { + room_list.clear(); + _loading = false; + for(var s in response.data['result']){ + room_list.add(new RoomView.fromJson(s)); + } + }); + },errorCallBack: (errorMsg){ + print(errorMsg); + setState(() { + _loading = !_loading; + }); + Fluttertoast.showToast( + msg: "网络请求异常,获取不到酒店信息", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.BOTTOM, + timeInSecForIos: 1, + backgroundColor: Colors.black54, + textColor: Colors.white70, + fontSize: 16.0 + ); + }); + + } + @override Widget build(BuildContext context) { + + final _media = MediaQuery.of(context).size; // TODO: implement build return Scaffold( - body: _mainpage(), + backgroundColor: Colors.white, + body: ProgressDialog( + loading: _loading, + progress: CustomProgressIndicator.HeartBeat(_media), + child: _mainpage(_media), + ) ); } - _mainpage(){ - - final _media = MediaQuery.of(context).size; + _mainpage(_media){ return Stack( children: [ @@ -102,21 +158,36 @@ class _HotelDetailPageState extends State{ child: Row( children: [ Container( - margin: EdgeInsets.only(left: 5), + margin: EdgeInsets.only(left: 8), child: Text( - '5.0', + widget.hotelView.hotel_grade??"", style: TextStyle( color: Colors.orangeAccent, fontSize: 30, fontWeight: FontWeight.w700 ), ), + ), + Container( + height: 40, + margin: EdgeInsets.symmetric(vertical: 5,horizontal: 10), + alignment: Alignment.center, + padding: EdgeInsets.only(left: 8), + decoration: BoxDecoration( + border: Border(left: BorderSide(color: Colors.white30,width: 0.5)) + ), + child: Text( + "哈尔滨情侣必去", + style: TextStyle( + fontFamily: fontname, + color: Colors.orangeAccent, + ), + ), ) ], ), ), Container( - height: 300, margin: EdgeInsets.only(top: 280), decoration: BoxDecoration( color: Colors.white, @@ -125,43 +196,62 @@ class _HotelDetailPageState extends State{ child: Column( children: [ Container( + margin: EdgeInsets.only(top: 20,left: 20), + alignment: Alignment.topLeft, child: Text( - '七彩假日旅馆(东北林业大学)', + widget.hotelView.hotel_name??"", style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 30 + fontFamily: fontname, + fontWeight: FontWeight.w600, + fontSize: _media.width / 15 ), ), ), Container( - child: Text( - '秋林果戈里大街附近', - softWrap: true, - ), - ), - MyDivider(height: 0,width: 0.5,endindent: 30,indent: 30,), - GestureDetector( + margin: EdgeInsets.only(top: 10,left: 20,bottom: 10), + alignment: Alignment.topLeft, child: Row( children: [ Container( - width: _media.width/2, - height: 60, + width: _media.width * 0.7, child: Text( - '专享抵用卷' + widget.hotelView.hotel_location??"", + softWrap: true, + style: TextStyle( + fontFamily: fontname, + fontWeight: FontWeight.w200, + fontSize: _media.width / 20 + ), ), - ) , - Container( - width: _media.width/2, - alignment: Alignment.centerRight, - height: 60, - child: Text( - '已领取' + ), + GestureDetector( + onTap: (){ + }, + child: Container( + width: _media.width * 0.15, + child: Column( + children: [ + Icon( + Icons.location_on, + color: Colors.blueAccent, + size: _media.width / 20, + ), + Text( + "地图/导航", + style: TextStyle( + fontWeight: FontWeight.w200, + fontSize: _media.width / 30, + color: Colors.blueAccent + ), + ), + ], + ) ), - ) , + ), ], ) ), - MyDivider(height: 0,width: 0.5,), + MyDivider(height: 0,width: 0.5,endindent: 30,indent: 30,), InkWell( onTap: (){ showModalBottomSheet( @@ -170,45 +260,109 @@ class _HotelDetailPageState extends State{ //showModalBottomSheet默认点击子widget收起,加一个GestureDetector并设置onTap为false阻断点击事件 return GestureDetector( onTap: () => false, - child: TimeBottomPop(), + child: TimeBottomPop( + onChange: (m){ + print(m); + }, + ), ); } - ); - setState(() { - print(1); + ).then((value){ + setState(() { + if(value!=null && !value.isEmpty){ + selectDate = value[0]; + secselectDate = value[1]; + } + }); }); }, child: Container( - height: 30, + height: 65, child:Row( children: [ Container( - child: Text( - '5月8日 ', - style:TextStyle( - fontSize: 20, - ), - ), - padding: EdgeInsets.only(left:20,top: 3), - ), + width:_media.width * 0.85, + child: Row( + children: [ + Container( + alignment: Alignment.centerLeft, + width: _media.width * 0.85 * 0.4, + child: Column( + children: [ + Container( + alignment: Alignment.topLeft, + child: Text( + checksameday(selectDate,DateTime.now())? '今天入住' : '入住', + style: TextStyle( + fontFamily: fontname, + fontSize: 13, + color: Colors.red + ), + ), + padding: EdgeInsets.only(left: 20,top: 10), + ), + Container( + alignment: Alignment.topLeft, + child: Text( + selectDate.month.toString() + "月" + selectDate.day.toString() + "日", + style:TextStyle( + fontFamily: fontname, + fontSize: 18, + ), + ), + padding: EdgeInsets.only(left:20,top: 3), + ), - Container( - child:Text( - '5月9日', - style:TextStyle( - fontSize: 20, - ), - ), - padding: EdgeInsets.only(left: 20,top: 3), - ), - Expanded( - child: Container( - alignment: Alignment.centerRight, - child: Text( - '共'+'1'+'晚', - style: TextStyle(color: Colors.black,fontSize: 11), + ], + ), ), - ) + Container( + alignment: Alignment.centerLeft, + width:_media.width * 0.85 * 0.4, + child: Column( + children: [ + Container( + alignment: Alignment.topLeft, + child: Text( + checksameday(secselectDate,DateTime.now().add(Duration(days: 1)))?'明天离店': '离店' , + style: TextStyle( + fontFamily: fontname, + fontSize: 13, + color: Colors.red + ), + ), + padding: EdgeInsets.only(left: 10,top: 10), + ), + Container( + alignment: Alignment.topLeft, + child:Text( + secselectDate.month.toString() + "月" + secselectDate.day.toString() + "日", + style:TextStyle( + fontFamily: fontname, + fontSize: 18, + ), + ), + padding: EdgeInsets.only(left: 10,top: 3), + ), + + ], + ), + ), + Expanded( + child: Container( + alignment: Alignment.centerRight, + child: Text( + '共'+ secselectDate.difference(selectDate).inDays.toString() +'晚', + style: TextStyle( + fontFamily: fontname, + color: Colors.black, + fontSize: 11 + ), + ), + ) + ) + ], + ) , ), Expanded( child: Padding( @@ -219,7 +373,6 @@ class _HotelDetailPageState extends State{ color: Colors.grey), ) ), - ], ), ) @@ -235,9 +388,12 @@ class _HotelDetailPageState extends State{ SliverList( delegate: SliverChildBuilderDelegate( (context,int index){ - return RoomItem(); + return RoomItem( + roomView : room_list[index], + hotelView : widget.hotelView, + ); }, - childCount: 4 + childCount: room_list.length ), ) // LoadingMoreSliverList( @@ -254,9 +410,23 @@ class _HotelDetailPageState extends State{ height: 80.0, controller: _hotelbarcontroller, key: _mTitleKey, + hotelTitle: widget.hotelView.hotel_name??"", ) ] ); } + Widget itemBuilder(BuildContext context,TuChongItem item, int index) => HotelItem(); + + bool checksameday(DateTime datetime,DateTime ct){ + + if(datetime.month == ct.month) { + if (datetime.day == ct.day){ + return true; + } + } + return false; + + } + } diff --git a/lib/ui/page/hotely/hotel_item.dart b/lib/ui/page/hotely/hotel_item.dart index d3b2636..f5bdc0d 100644 --- a/lib/ui/page/hotely/hotel_item.dart +++ b/lib/ui/page/hotely/hotel_item.dart @@ -1,23 +1,31 @@ import 'package:flutter/material.dart'; -import 'package:hotel/config/application.dart'; -import 'package:hotel/route/routes.dart'; +import 'package:hotel/common/constant.dart'; +import 'package:hotel/entity/hotelview.dart'; + +import 'hotel_detail_page.dart'; class HotelItem extends StatelessWidget{ + + HotelView hotelView; + HotelItem({@required this.hotelView}); + String hotelname = ""; + @override Widget build(BuildContext context) { // TODO: implement build return _itemwidget(context); } - _navigate(BuildContext context, String route) { - Application.navigateTo(context: context, route: route); - } _itemwidget(context){ + final _media = MediaQuery.of(context).size; + return InkWell( onTap: (){ - _navigate(context, '${Routes.hoteldetailpage}'); + Navigator.push(context, new MaterialPageRoute(builder: (BuildContext context){ + return HotelDetailPage(hotelView: hotelView); + })); }, child: Container( child: Row( @@ -43,9 +51,10 @@ class HotelItem extends StatelessWidget{ alignment: Alignment.topLeft, margin: EdgeInsets.only(bottom: 5,left: 10), child: Text( - '七彩假日旅馆(东北林业大学)', + hotelView.hotel_name??"", style: TextStyle( fontSize: 18, + fontFamily: fontname, fontWeight: FontWeight.w500 ), ), @@ -68,6 +77,7 @@ class HotelItem extends StatelessWidget{ child: Text( '好房价干净温度合适', style: TextStyle( + fontFamily: fontname, color: Colors.blueAccent, fontSize: 13 ), @@ -93,7 +103,8 @@ class HotelItem extends StatelessWidget{ child: Text( '秋林果戈里大街附近', style: TextStyle( - fontSize: 13 + fontSize: 13, + fontFamily: fontname, ), ), ), @@ -154,7 +165,7 @@ class HotelItem extends StatelessWidget{ alignment: Alignment.bottomRight, padding: EdgeInsets.only(bottom: 0,right: 10), child: Text( - '\$88', + '¥' + '88', style: TextStyle( color: Colors.red, fontSize: 23 diff --git a/lib/ui/page/hotely/hotel_list_page.dart b/lib/ui/page/hotely/hotel_list_page.dart index c5c3d67..df006cb 100644 --- a/lib/ui/page/hotely/hotel_list_page.dart +++ b/lib/ui/page/hotely/hotel_list_page.dart @@ -1,4 +1,12 @@ import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:hotel/common/api.dart'; +import 'package:hotel/common/constant.dart'; +import 'package:hotel/entity/hotelview.dart'; +import 'package:hotel/http/service/NetService.dart'; +import 'package:hotel/ui/widget/MyDivider.dart'; +import 'package:hotel/ui/widget/progress/CustomProgressIndicator.dart'; +import 'package:hotel/ui/widget/progress/progressdialog.dart'; import 'hotel_item.dart'; class HotelPage extends StatefulWidget{ @@ -11,35 +19,149 @@ class HotelPage extends StatefulWidget{ class _HotelState extends State{ - List list = ['1','2','3']; + List hotel_list = []; + List titlelist = ["酒店品牌","酒店品牌","酒店品牌","酒店品牌","酒店品牌"]; + List> _dropDownMenuItems; + String _selectedFruit; + bool _loading = true; + + @override + void initState() { + // TODO: implement initState + super.initState(); + NetService.post(HOTEL_URL, (response){ + print(response.data['result']); + setState(() { + _loading = false; + hotel_list.add(new HotelView.fromJson(response.data['result'])); + print(new HotelView.fromJson(response.data['result']).hotel_name); + }); + },errorCallBack: (errorMsg){ + print(errorMsg); + setState(() { + _loading = false; + }); + Fluttertoast.showToast( + msg: "网络请求异常,获取不到酒店信息", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.BOTTOM, + timeInSecForIos: 1, + backgroundColor: Colors.black54, + textColor: Colors.white70, + fontSize: 16.0 + ); + }); + _dropDownMenuItems = buildAndGetDropDownMenuItems(titlelist); + _selectedFruit = _dropDownMenuItems[0].value; + } + @override Widget build(BuildContext context) { + + PageController pageController = PageController(initialPage: 2,viewportFraction: 0.20); + final _media = MediaQuery.of(context).size; // TODO: implement build return Scaffold( - appBar: AppBar( - leading: IconButton( - icon: Icon( - Icons.arrow_back, - color: Colors.black, - ), - onPressed: ()=>Navigator.pop(context), + appBar: AppBar( + leading: IconButton( + icon: Icon( + Icons.arrow_back_ios, + color: Colors.black, + ), + onPressed: ()=>Navigator.pop(context), + ), + elevation: 0.5, + backgroundColor: Colors.white, + bottom: PreferredSize( + child:Column( + children: [ + Container( + margin: EdgeInsets.only(bottom: 5), + child: Row( + children: [ + _appbartitle("位置区域"), + _appbartitle("价格星级"), + _appbartitle("智能排序"), + _appbartitle("筛选") + ], + ), + ), + Container( + height: 25, + width: _media.width, + margin: EdgeInsets.only(bottom: 10,top: 10), + child: PageView.builder( + controller: pageController, + itemCount: titlelist.length, + itemBuilder: (BuildContext context, int index){ + return Container( + margin: EdgeInsets.symmetric(horizontal: 5), + padding: EdgeInsets.symmetric(horizontal: 10,vertical: 5), + child: new DropdownButton( + + items: _dropDownMenuItems, + onChanged: changedDropDownItem, + ), + decoration: BoxDecoration( + color: Colors.grey.withAlpha(50), + borderRadius: BorderRadius.circular(4.0) + ), + ); + } + ) + ), + + ], + ) , + preferredSize: Size.fromHeight(60) + ) + ), + body: ProgressDialog( + loading: _loading, + progress: CustomProgressIndicator.HeartBeat(_media), + child:_mainbody(), + ) + ); + } + + _appbartitle(String text){ + + return Container( + margin: EdgeInsets.only(left: 30), + child: Text( + text, + style: TextStyle( + fontFamily: fontname ), - elevation: 0.0, - backgroundColor: Colors.white, ), - body: _mainbody(), ); } _mainbody(){ + return Container( child: ListView.builder( - itemCount: list.length, + itemCount: hotel_list.length, itemBuilder: (BuildContext context,int index){ - return HotelItem(); + return HotelItem(hotelView: hotel_list[index],); } ), ); } + List> buildAndGetDropDownMenuItems(List fruits) { + List> items = List(); + for (String fruit in fruits) { + items.add(DropdownMenuItem(value: fruit, child: Text(fruit))); + } + return items; + } + + void changedDropDownItem(String selectedFruit) { + setState(() { + _selectedFruit = selectedFruit; + }); + } + + } \ No newline at end of file diff --git a/lib/ui/page/login/codepage.dart b/lib/ui/page/login/codepage.dart new file mode 100644 index 0000000..26b2f47 --- /dev/null +++ b/lib/ui/page/login/codepage.dart @@ -0,0 +1,210 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:hotel/common/api.dart'; +import 'package:hotel/common/constant.dart'; +import 'package:hotel/entity/usertoken.dart'; +import 'package:hotel/route/routes.dart'; +import 'package:hotel/ui/page/login/verification_code_view.dart'; +import 'package:hotel/http/service/NetService.dart'; +import 'package:hotel/ui/widget/progress/progressdialog.dart'; +import 'package:hotel/utils/storage.dart'; + + +class CodePage extends StatefulWidget { + String phone_num; + String verifyCode; + CodePage({@required this.phone_num,this.verifyCode}); + @override + _CodePageState createState() => new _CodePageState(); +} + +class _CodePageState extends State { + + + TextEditingController _textEditingController = TextEditingController(); + bool _loading = false; + + @override + void initState() { + // TODO: implement initState + super.initState(); + _textEditingController.addListener((){ + if(_textEditingController.text.length == 4){ + setState(() { + _loading = true; + }); + print(widget.phone_num); + print(_textEditingController.text); + print(TOKEN_URL); + NetService.post(TOKEN_URL, (response){ + print(response); + UserToken userToken = new UserToken.fromJson(response.data['result']); + setState(() { + _loading = !_loading; + }); + saveStorageString(USER_NAME,userToken.phone_num); + saveStorageString(TOKEN_KEY,userToken.acesstoken); + Navigator.of(context).pushNamedAndRemoveUntil('${Routes.mainpage}', (Route route) => false); + },params: {'phone_num':widget.phone_num,'verifyCode':_textEditingController.text}, + errorCallBack: (errorMsg){ + print(errorMsg); + setState(() { + _loading = !_loading; + _textEditingController.text = ""; + + }); + Fluttertoast.showToast( + msg: errorMsg, + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.BOTTOM, + timeInSecForIos: 1, + backgroundColor: Colors.black54, + textColor: Colors.white70, + fontSize: 16.0 + ); + } + ); + + } + }); + } + + @override + Widget build(BuildContext context) { + // TODO: implement build + return ProgressDialog( + loading: _loading, + child:Scaffold( + resizeToAvoidBottomPadding: false, + appBar: AppBar( + elevation: 0, + leading: IconButton( + icon: Icon( + Icons.arrow_back_ios, + size: 25, + color: Colors.greenAccent, + ), + onPressed: (){ + _checkSub(context); + } + ), + actions: [ + Container( + alignment: Alignment.center, + margin: EdgeInsets.only(right: 10), + child: Text( + '帮助', + style: TextStyle( + color: Colors.greenAccent, + fontSize: 20 + ), + ), + ) + ], + backgroundColor: Colors.white, + ), + backgroundColor: Colors.white, + body: _mainbody(), + ) + ); + } + + _mainbody(){ + final _media = MediaQuery.of(context).size; + var underLineBorder = CustomUnderlineInputBorder( + textLength: 4, + textSize: 80, + letterSpace: 20.0, + borderSide: BorderSide(color: Colors.black87, width: 1.0) + ); + + return Container( + child: Column( + children: [ + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(left: 20,top: 30), + child: Text( + '输入验证码', + style: TextStyle( + color: Colors.black, + fontSize: 40 + ), + ), + ), + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(left: 20,top: 10), + child: Text( + '验证码已发送至' + '+86 ' + widget.phone_num, + ), + ), + Container( + padding: EdgeInsets.symmetric(vertical: 10.0,horizontal: 50.0), + child: TextField( + //限制输入字数 + inputFormatters: [LengthLimitingTextInputFormatter(4),WhitelistingTextInputFormatter.digitsOnly], + controller: _textEditingController, + keyboardType: TextInputType.number, + cursorWidth: 0.0, + autofocus: true, + style: TextStyle( + fontSize: 80.0, + color: Colors.black87, + letterSpacing: 20.0), + decoration: InputDecoration( + enabledBorder: underLineBorder, + focusedBorder: underLineBorder), + ), + ), + GestureDetector( + onTap:(){ + setState(() { + _loading = true; + }); + NetService.post(CODE_URL + widget.phone_num, (response){ + print(response.data['result']); + setState(() { + _loading = false; + }); + },errorCallBack: (errorMsg){ + print(errorMsg); + setState(() { + _loading = false; + }); + Fluttertoast.showToast( + msg: "网络请求异常,获取不到验证码", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.BOTTOM, + timeInSecForIos: 1, + backgroundColor: Colors.black54, + textColor: Colors.white70, + fontSize: 16.0 + ); + }); + }, + child: Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(left: 20,top: 50), + child: Text( + '点击重新接受验证码', + style: TextStyle( + color: Colors.greenAccent, + ), + ), + + ), + ) + ], + ) + ); + } + + void _checkSub(BuildContext context) { + Navigator.pop(context); + } +} \ No newline at end of file diff --git a/lib/ui/page/login/dash_path.dart b/lib/ui/page/login/dash_path.dart new file mode 100644 index 0000000..b0ef2a9 --- /dev/null +++ b/lib/ui/page/login/dash_path.dart @@ -0,0 +1,99 @@ +import 'dart:ui'; + +import 'package:meta/meta.dart'; + +/// Creates a new path that is drawn from the segments of `source`. +/// +/// Dash intervals are controled by the `dashArray` - see [CircularIntervalList] +/// for examples. +/// +/// `dashOffset` specifies an initial starting point for the dashing. +/// +/// Passing in a null `source` will result in a null result. Passing a `source` +/// that is an empty path will return an empty path. +Path dashPath( + Path source, { + @required CircularIntervalList dashArray, + DashOffset dashOffset, + }) { + assert(dashArray != null); + if (source == null) { + return null; + } + + dashOffset = dashOffset ?? const DashOffset.absolute(0.0); + // TODO: Is there some way to determine how much of a path would be visible today? + + final Path dest = Path(); + for (final PathMetric metric in source.computeMetrics()) { + double distance = dashOffset._calculate(metric.length); + bool draw = true; + while (distance < metric.length) { + final double len = dashArray.next; + if (draw) { + dest.addPath(metric.extractPath(distance, distance + len), Offset.zero); + } + distance += len; + draw = !draw; + } + } + + return dest; +} + +enum _DashOffsetType { Absolute, Percentage } + +/// Specifies the starting position of a dash array on a path, either as a +/// percentage or absolute value. +/// +/// The internal value will be guaranteed to not be null. +class DashOffset { + /// Create a DashOffset that will be measured as a percentage of the length + /// of the segment being dashed. + /// + /// `percentage` will be clamped between 0.0 and 1.0; null will be converted + /// to 0.0. + DashOffset.percentage(double percentage) + : _rawVal = percentage.clamp(0.0, 1.0) ?? 0.0, + _dashOffsetType = _DashOffsetType.Percentage; + + /// Create a DashOffset that will be measured in terms of absolute pixels + /// along the length of a [Path] segment. + /// + /// `start` will be coerced to 0.0 if null. + const DashOffset.absolute(double start) + : _rawVal = start ?? 0.0, + _dashOffsetType = _DashOffsetType.Absolute; + + final double _rawVal; + final _DashOffsetType _dashOffsetType; + + double _calculate(double length) { + return _dashOffsetType == _DashOffsetType.Absolute + ? _rawVal + : length * _rawVal; + } +} + +/// A circular array of dash offsets and lengths. +/// +/// For example, the array `[5, 10]` would result in dashes 5 pixels long +/// followed by blank spaces 10 pixels long. The array `[5, 10, 5]` would +/// result in a 5 pixel dash, a 10 pixel gap, a 5 pixel dash, a 5 pixel gap, +/// a 10 pixel dash, etc. +/// +/// Note that this does not quite conform to an [Iterable], because it does +/// not have a moveNext. +class CircularIntervalList { + CircularIntervalList(this._vals); + + final List _vals; + int _idx = 0; + + T get next { + if (_idx >= _vals.length) { + _idx = 0; + } + return _vals[_idx++]; + } +} \ No newline at end of file diff --git a/lib/ui/page/login/loginpage.dart b/lib/ui/page/login/loginpage.dart new file mode 100644 index 0000000..322b981 --- /dev/null +++ b/lib/ui/page/login/loginpage.dart @@ -0,0 +1,262 @@ +import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:groovin_material_icons/groovin_material_icons.dart'; +import 'package:animated_text_kit/animated_text_kit.dart'; +import 'package:hotel/config/application.dart'; +import 'package:hotel/http/service/NetService.dart'; +import 'package:hotel/route/routes.dart'; +import 'package:hotel/ui/widget/MyDivider.dart'; +import 'package:hotel/common/api.dart'; +import 'package:hotel/ui/widget/progress/progressdialog.dart'; +import 'package:pin_input_text_field/pin_input_text_field.dart'; + +List _loginMethod = [ + {"title": "facebook", "icon": GroovinMaterialIcons.wechat}, + { + "title": "google", + "icon": GroovinMaterialIcons.qqchat, + }, + { + "title": "twitter", + "icon": GroovinMaterialIcons.school, + }, +]; + +class LoginPage extends StatefulWidget { + + + @override + _LoginPageState createState() => new _LoginPageState(); +} + +class _LoginPageState extends State { + + bool is_send = false; + bool _loading = false; + + TextEditingController schoolController = new TextEditingController(); + TextEditingController mobileController = new TextEditingController(); + TextEditingController passController = new TextEditingController(); + + + @override + void initState() { + // TODO: implement initState + super.initState(); + } + @override + Widget build(BuildContext context) { + + return new Scaffold( + resizeToAvoidBottomPadding: false, + appBar: AppBar( + elevation: 0, + leading: IconButton( + icon: Icon( + Icons.close, + size: 30, + color: Colors.greenAccent, + ), + onPressed: (){ + _checkSub(context); + } + ), + backgroundColor: Colors.white, + ), + body: ProgressDialog( + loading: _loading, + child: loginbody(context), + ), + backgroundColor: Colors.white, + ); + } + + /// + /// 主体 + Widget loginbody(BuildContext context) { + final _media = MediaQuery.of(context).size; + return new Container( + height: _media.height, + child: Column( + children: [ + TopLogo(context,_media), + loginUserEditInput(_media), + loginButton(context), + MyDivider(height: _media.height * 0.05, endindent: _media.width*0.1,indent: _media.width*0.1,), + //ButtonLogo(context), + buildOtherMethod(context,_media), + ], + )); + } + + /// + /// 登陆按钮 + /// + Widget loginButton(BuildContext context) { + final _media = MediaQuery.of(context).size; + return new Container( + width: _media.width * 0.6, + margin: EdgeInsets.only(top: _media.height * 0.1,bottom: _media.height * 0.1), + child: new FlatButton( + color: Colors.greenAccent, + child: new Padding( + padding: EdgeInsets.all(8.0), + child: new Text( + "获取验证码", + style: new TextStyle( + fontFamily: 'HanaleiFill', + color: Colors.white, + fontSize: 16.0, + ), + ), + ), + onPressed: () { + _request(context); + + //_checkSub(context); + }, + ), + ); + } + + + void _request(BuildContext context){ + + print(CODE_URL + mobileController.value.text); + print(_loading.toString()); + setState(() { + _loading = true; + }); + NetService.post(CODE_URL + mobileController.value.text, (response){ +// Map data = json.decode(response.data); +// print(data['code']); + print(response.data['result']); + setState(() { + _loading = false; + }); + Application.navigateTo(context:context,route: '${Routes.codepage}?phone_num=${mobileController.value.text}&verifyCode=${response.data['result']}'); + + },errorCallBack: (errorMsg){ + print(errorMsg); + setState(() { + _loading = false; + }); + Fluttertoast.showToast( + msg: "网络请求异常,获取不到验证码", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.BOTTOM, + timeInSecForIos: 1, + backgroundColor: Colors.black54, + textColor: Colors.white70, + fontSize: 16.0 + ); + }); + + } + + /// + /// 用户名输入框 + /// + Widget loginUserEditInput(Size media) { + return Container( + margin: EdgeInsets.fromLTRB(20.0,media.height * 0.1, 20.0, 10.0), + child: new Stack( + alignment: Alignment(1.0, 1.0), + children: [ + new Row( + children: [ + new Padding( + padding: EdgeInsets.all(5.0), + child: new Icon(Icons.perm_identity), + ), + new Expanded( + child: new TextField( + controller: mobileController, + decoration: new InputDecoration( + hintText: "请输入电话号码", + ), + onChanged: (value){ + }, + )), + ], + ), + new IconButton( + icon: new Icon(Icons.clear), + onPressed: () { + mobileController.clear(); + }) + ], + ), + ); + } + + + /// + /// 登陆提交校验 + /// + void _checkSub(BuildContext context) { + Navigator.pop(context); + } + +} + +//Widget ButtonLogo(BuildContext context) { +// return Container( +// margin: const EdgeInsets.fromLTRB(30, 10, 30, 10), +// child: TypewriterAnimatedTextKit( +// onTap: () { +// print("Tap Event"); +// }, +// text: [ +// "the story of your university", +// "write down your beautiful memory", +// "Don't leave any regrets" +// "face life with a smile" +// ], +// textStyle: TextStyle(fontSize: 20.0, fontFamily: "lishu",color: Color.fromRGBO(116, 116, 116, 0.9)), +// ), +// ); +//} + +Widget TopLogo(BuildContext context,Size media) { + return Container( + margin: EdgeInsets.only(top: media.height * 0.05,left: 30), + alignment: Alignment.topLeft, + child:Text( + '欢迎登陆妹团', + style: TextStyle( + color: Colors.black, + fontSize: 35.0, + ), + ), + ); +} + +/// +Widget buildOtherMethod(BuildContext context,Size media) { + return ButtonBar( + alignment: MainAxisAlignment.center, + children: _loginMethod + .map((item) => Builder( + builder: (context) { + return IconButton( + icon: Icon(item['icon'], color: Colors.black), + onPressed: () { + //TODO : 第三方登录方法 + Scaffold.of(context).showSnackBar(new SnackBar( + content: new Text("${item['title']}登录"), + action: new SnackBarAction( + label: "取消", + onPressed: () {}, + ), + )); + }); + }, + )) + .toList(), + ); +} + + + + diff --git a/lib/ui/page/login/verification_code_view.dart b/lib/ui/page/login/verification_code_view.dart new file mode 100644 index 0000000..5ca3fef --- /dev/null +++ b/lib/ui/page/login/verification_code_view.dart @@ -0,0 +1,205 @@ +import 'dart:ui' as ui; + +import 'package:flutter/material.dart'; +import 'dash_path.dart' as dashPath; + +import 'dart:math'; + +num degToRad(num deg) => deg * (pi / 180.0); + +num radToDeg(num rad) => rad * (180.0 / pi); + +abstract class InputBorder extends UnderlineInputBorder { + double textSize; + double letterSpace; + int textLength; + + double textTrueWidth; + final double startOffset; + + void calcTrueTextSize() { + // 测量单个数字实际长度 + var paragraph = ui.ParagraphBuilder(ui.ParagraphStyle(fontSize: textSize)) + ..addText("0"); + var p = paragraph.build() + ..layout(ui.ParagraphConstraints(width: double.infinity)); + textTrueWidth = p.minIntrinsicWidth; + } + + InputBorder({ + this.textSize = 0.0, + this.letterSpace = 0.0, + this.textLength, + BorderSide borderSide = const BorderSide(), + }) : startOffset = letterSpace * 0.5, + super(borderSide: borderSide) { + calcTrueTextSize(); + } +} + +class CustomRectInputBorder extends InputBorder { + CustomRectInputBorder({ + double textSize = 0.0, + double letterSpace, + int textLength, + BorderSide borderSide = const BorderSide(), + }) : super( + textSize: textSize, + letterSpace: letterSpace, + textLength: textLength, + borderSide: borderSide); + + double get offsetX => textTrueWidth * 0.3; + + double get offsetY => textTrueWidth * 0.3; + + @override + void paint( + Canvas canvas, + Rect rect, { + double gapStart, + double gapExtent = 0.0, + double gapPercentage = 0.0, + TextDirection textDirection, + }) { + double curStartX = rect.left + startOffset - offsetX; + for (int i = 0; i < textLength; i++) { + Rect r = Rect.fromLTWH(curStartX, rect.top + offsetY, + textTrueWidth + offsetX * 2, rect.height - offsetY * 2); + canvas.drawRect(r, borderSide.toPaint()); + curStartX += (textTrueWidth + letterSpace); + } + } +} + +class CustomHeartInputBorder extends InputBorder { + CustomHeartInputBorder({ + double textSize = 0.0, + double letterSpace, + int textLength, + BorderSide borderSide = const BorderSide(), + }) : super( + textSize: textSize, + letterSpace: letterSpace, + textLength: textLength, + borderSide: borderSide); + + double get offsetX => textTrueWidth * 0.3; + + // angleOffset should be range 0 to 90. + double get angleOffset => 40.0; + + @override + void paint( + Canvas canvas, + Rect rect, { + double gapStart, + double gapExtent = 0.0, + double gapPercentage = 0.0, + TextDirection textDirection, + }) { + double width = rect.height - offsetX; + double radius = width * 0.25; + // 1:editable.dart _kCaretGap + double curStartX = startOffset - radius - offsetX - 1; + if (curStartX < 0) { + throw ArgumentError( + 'No enough space to paint border! LetterSpace is too small.'); + } + double top = rect.center.dy - radius * 2; + double bottom = rect.center.dy + radius * 2; + Path path = Path(); + for (int i = 0; i < textLength; i++) { + path.moveTo(curStartX + radius * 2, top + radius); + path.arcTo( + Rect.fromCircle( + center: Offset(curStartX + radius, top + radius), radius: radius), + degToRad(180.0 - angleOffset), + degToRad(180.0 + angleOffset), + true); + double sinLength = radius * sin(degToRad(angleOffset)); + double cosLength = radius * cos(degToRad(angleOffset)); + path.moveTo(curStartX + radius - cosLength, top + radius + sinLength); + path.lineTo(curStartX + radius * 2, bottom); + path.lineTo(curStartX + radius * 3 + cosLength, top + radius + sinLength); + path.arcTo( + Rect.fromCircle( + center: Offset(curStartX + radius * 3, top + radius), + radius: radius), + degToRad(angleOffset), + degToRad(-180.0 - angleOffset), + true); + curStartX += (textTrueWidth + letterSpace); + } + canvas.drawPath(path, borderSide.toPaint()); + } +} + +class CustomUnderlineInputBorder extends InputBorder { + CustomUnderlineInputBorder({ + double textSize = 0.0, + double letterSpace, + int textLength, + BorderSide borderSide = const BorderSide(), + }) : super( + textSize: textSize, + letterSpace: letterSpace, + textLength: textLength, + borderSide: borderSide); + + @override + void paint( + Canvas canvas, + Rect rect, { + double gapStart, + double gapExtent = 0.0, + double gapPercentage = 0.0, + TextDirection textDirection, + }) { +// if (borderRadius.bottomLeft != Radius.zero || +// borderRadius.bottomRight != Radius.zero) +// canvas.clipPath(getOuterPath(rect, textDirection: textDirection)); + Path path = Path(); + path.moveTo(rect.bottomLeft.dx + startOffset, rect.bottomLeft.dy); + path.lineTo(rect.bottomLeft.dx + (textTrueWidth + letterSpace) * textLength, + rect.bottomRight.dy); + path = dashPath.dashPath(path, + dashArray: dashPath.CircularIntervalList([ + textTrueWidth, + letterSpace, + ])); + canvas.drawPath(path, borderSide.toPaint()); + } +} + +class CustomImageInputBorder extends InputBorder { + final ui.Image image; + + CustomImageInputBorder({ + @required this.image, + double textSize = 0.0, + double letterSpace, + int textLength, + BorderSide borderSide = const BorderSide(), + }) : super( + textSize: textSize, + letterSpace: letterSpace, + textLength: textLength, + borderSide: borderSide); + + @override + void paint( + Canvas canvas, + Rect rect, { + double gapStart, + double gapExtent = 0.0, + double gapPercentage = 0.0, + TextDirection textDirection, + }) { + double curStartX = rect.left; + for (int i = 0; i < textLength; i++) { + canvas.drawImage(image, Offset(curStartX, 0.0), Paint()); + curStartX += (textTrueWidth + letterSpace); + } + } +} \ No newline at end of file diff --git a/lib/ui/page/mainpage.dart b/lib/ui/page/mainpage.dart index b94916a..8ceb6a4 100644 --- a/lib/ui/page/mainpage.dart +++ b/lib/ui/page/mainpage.dart @@ -1,5 +1,10 @@ import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; +import 'package:hotel/common/constant.dart'; +import 'package:hotel/ui/page/personal/unloginpage.dart'; +import 'package:hotel/ui/widget/progress/progressdialog.dart'; +import 'package:hotel/utils/storage.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import '../../config/application.dart'; import '../../route/routes.dart'; @@ -9,40 +14,68 @@ import 'order/orderpage.dart'; import 'first/firstpage.dart'; class MainPage extends StatefulWidget { - MainPage({Key key}) : super(key: key) { - print('new $key'); - } + + MainPage({Key key}) : super(key: key); + _MainPageState createState() => _MainPageState(); } class _MainPageState extends State{ static int lastExitTime = 0; + bool _loading = false; bool isLogin = true; List bodylist = List(); //创建一个非固定长度的widget列表 int _currentindex = 0; + String token = null; + @override void initState() { print("initstate"); - super.initState(); bodylist ..add(FirstPage()) ..add(FindPage()) ..add(OrderPage()) - ..add(PersonPage()); + ..add(UnloginPage()); + getStorageString(TOKEN_KEY); + print(token); + super.initState(); + + } + + Future getStorageString(key) async { + setState(() { + _loading = true; + }); + SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); + setState(() { + print("get token"); + _loading = false; + token = sharedPreferences.get(key); + bodylist.clear(); + bodylist + ..add(FirstPage()) + ..add(FindPage()) + ..add(token == null? UnloginPage(pagetype: 'order') : OrderPage()) + ..add(token == null ? UnloginPage() : PersonPage()); +// print(token); + }); } @override Widget build(BuildContext context) { // TODO: implement build - return WillPopScope( - onWillPop: _onBackPressed, - child:Scaffold( - resizeToAvoidBottomPadding: false, - body: bodylist[_currentindex], - bottomNavigationBar: _MainBottomBar(), + return ProgressDialog( + loading: _loading, + child:WillPopScope( + onWillPop: _onBackPressed, + child:Scaffold( + resizeToAvoidBottomPadding: false, + body: bodylist[_currentindex], + bottomNavigationBar: _MainBottomBar(), + ) ) ); } @@ -56,8 +89,8 @@ class _MainPageState extends State{ toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIos: 1, - backgroundColor: Colors.grey, - textColor: Colors.white, + backgroundColor: Colors.black54, + textColor: Colors.white70, fontSize: 16.0 ); return await Future.value(false); @@ -81,7 +114,13 @@ class _MainPageState extends State{ activeIcon: Icon(Icons.home, color: Colors.redAccent,), title: Text( '首页', - style: _currentindex == 0 ? TextStyle(color: Colors.redAccent,): TextStyle(color: Colors.black54), + style: _currentindex == 0 ? TextStyle( + color: Colors.redAccent, + fontFamily: 'jindian', + ): TextStyle( + fontFamily: 'jindian', + color: Colors.black54 + ), ), ), BottomNavigationBarItem( @@ -90,7 +129,13 @@ class _MainPageState extends State{ activeIcon: Icon(Icons.camera, color: Colors.redAccent,), title: Text( '发现', - style: _currentindex == 1 ? TextStyle(color: Colors.redAccent,): TextStyle(color: Colors.black54), + style: _currentindex == 1 ? TextStyle( + fontFamily: 'jindian', + color: Colors.redAccent, + ): TextStyle( + fontFamily: 'jindian', + color: Colors.black54 + ), ), ), BottomNavigationBarItem( @@ -99,7 +144,13 @@ class _MainPageState extends State{ activeIcon: Icon(Icons.assignment, color: Colors.redAccent,), title: Text( '订单', - style: _currentindex == 2 ? TextStyle(color: Colors.redAccent,): TextStyle(color: Colors.black54), + style: _currentindex == 2 ? TextStyle( + fontFamily: 'jindian', + color: Colors.redAccent, + ): TextStyle( + fontFamily: 'jindian', + color: Colors.black54 + ), ), ), BottomNavigationBarItem( @@ -108,9 +159,13 @@ class _MainPageState extends State{ activeIcon: Icon(Icons.person, color: Colors.redAccent,), title: Text( '我的', - style: _currentindex == 3 ? TextStyle(color: Colors.redAccent, + style: _currentindex == 3 ? TextStyle( + color: Colors.redAccent, + fontFamily: 'jindian', ): TextStyle( - color: Colors.black54), + fontFamily: 'jindian', + color: Colors.black54 + ), ), ), ], diff --git a/lib/ui/page/order/order_detail_page.dart b/lib/ui/page/order/order_detail_page.dart index 24816e4..5a01355 100644 --- a/lib/ui/page/order/order_detail_page.dart +++ b/lib/ui/page/order/order_detail_page.dart @@ -1,7 +1,21 @@ import 'package:flutter/material.dart'; +import 'package:hotel/common/constant.dart'; +import 'package:hotel/entity/orderview.dart'; +import 'package:hotel/ui/page/order/paystatus.dart'; +import 'package:hotel/ui/page/room/room_order_item.dart'; +import 'package:hotel/ui/widget/bottom_pop/timebottompop.dart'; +import 'package:hotel/ui/widget/loading_more/loading_more_list.dart'; +import 'package:hotel/ui/widget/shimmer/shimmer.dart'; +import 'package:hotel/ui/widget/stack_appbar/order_appbar.dart'; import '../../widget/MyDivider.dart'; class OrderDetailPage extends StatefulWidget{ + + OrderView orderView; + OrderDetailPage({ + @required + this.orderView + }); @override State createState() { // TODO: implement createState @@ -11,12 +25,491 @@ class OrderDetailPage extends StatefulWidget{ class _OrderDetailPageState extends State{ + ScrollController _scrollcontroller = ScrollController(); + OrderBarController _orderbarcontroller = new OrderBarController(); + bool _isNeedSetAlpha = false; + GlobalKey _mTitleKey = new GlobalKey(); + @override Widget build(BuildContext context) { // TODO: implement build return Scaffold( + body: _mainpage(), + backgroundColor: Colors.white.withAlpha(230) + ); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + + print(gobalUserName); + _orderbarcontroller.value.alpha = 0; + + _scrollcontroller.addListener(() { + + if ( _scrollcontroller.offset < 80.0) { + _isNeedSetAlpha = true; + _orderbarcontroller.value.alpha = ((_scrollcontroller.offset / 80) * 255).toInt(); + _mTitleKey.currentState.setState(() {}); + } else { + if (_isNeedSetAlpha) { + _orderbarcontroller.value.alpha = 255; + _mTitleKey.currentState.setState(() {}); + _isNeedSetAlpha = false; + } + } + }); + } + + + _mainpage(){ + final _media = MediaQuery.of(context).size; + + return Stack( + children: [ + new Container( + height: _media.height, + child: LoadingMoreCustomScrollView( + showGlowLeading: false, + controller: _scrollcontroller, + slivers: [ + SliverToBoxAdapter( + child: Column( + children: [ + Stack( + children: [ + Container( + height: 250, + width: _media.width, + child: Column( + children: [ + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(top: 85,left: 10), + child: Text( + _paystatustitle(widget.orderView.pay_status), + style: TextStyle( + fontSize: 30, + fontWeight: FontWeight.w600, + color: Colors.white + ), + ), + ), + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(top: 10,left: 10), + child: Text( + _payillustrate(widget.orderView.pay_status), + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w200, + color: Colors.white + ), + ), + ), + Container( + height:80, + width: 480, + padding: EdgeInsets.only(left:10.0, right:10.0,top: 30), + child: new RaisedButton( + color: Colors.white, + child: new Padding( + padding: EdgeInsets.all(8.0), + child: new Text( + _paybutton(widget.orderView.pay_status), + style: new TextStyle( + fontFamily: fontname, + color: Colors.black, + fontSize: 16.0 + ), + ), + ), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)), //圆角大小 + onPressed: () { + widget.orderView.pay_status == 0 ? "去支付": "再次预定"; + }, + ) + ), + ], + ), + decoration: new BoxDecoration( + //渐变色 + gradient: new LinearGradient( + colors: [ + Colors.deepOrangeAccent, + Colors.redAccent, + ], + begin: const FractionalOffset(0.2, 0.0), + end: const FractionalOffset(1.0, 1.0), + stops: [0.0, 1.0], + tileMode: TileMode.clamp + ) + ), + ), + Container( + height: 65, + color: Colors.white, + margin: EdgeInsets.only(top: 250), + child: Row( + children: [ + Column( + children: [ + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(top: 10,left: 20), + child: Text( + '关注"lshaoshuai"github账号', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w600, + color: Colors.black + ), + ), + ), + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(top: 5), + child: Text( + '订单通知,活动优惠不错过', + style: TextStyle( + fontSize: 13, + color: Colors.grey + ), + ), + ), + ], + ), + Expanded( + child: Container( + alignment: Alignment.centerRight, + margin: EdgeInsets.only(top: 10,right: 20), + height: 30, + child:OutlineButton( + highlightedBorderColor: Colors.greenAccent, + highlightColor: Colors.white, + onPressed: (){ +// Application.navigateTo(context:context,route: '${Routes.loginpage}'); + }, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(6) + ) + ), + borderSide: BorderSide( + color: Colors.redAccent + ), + child: Text( + '去关注', + style: TextStyle( + color: Colors.redAccent , + fontSize: _media.width / 35, + fontWeight: FontWeight.w600 + ), + ), + ), + ) + ) + ], + ) + ), + Container( + height: 50, + color: Colors.white, + margin: EdgeInsets.only(top: 320), + padding: EdgeInsets.only(left: 10,right: 10,top: 10), + child: Column( + children: [ + Row( + children: [ + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(top: 10,left: 10,bottom: 10), + child: Text( + '在线支付', + style: TextStyle( + fontSize: 13, + color: Colors.grey + ), + ), + ), + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(top: 10,left: 10,bottom: 10), + child: Text( + widget.orderView.collection_price.toString()??"", + style: TextStyle( + fontSize: 13, + color: Colors.red + ), + ), + ), + Expanded( + child: Container( + alignment: Alignment.topRight, + margin: EdgeInsets.only(top:10, right: 20, bottom: 10), + child: Text( + '费用明细', + style: TextStyle( + fontSize: 13, + color: Colors.blueAccent + ), + ), + ), + ) + ], + ), + ], + ), + + ), + Container( + height: 280, + margin: EdgeInsets.only(top: 375), + decoration: BoxDecoration( + color: Colors.white, + ), + child: Column( + children: [ + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(top: 10,left: 10), + child: Text( + widget.orderView.hotel_name??"", + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: _media.width / 20 + ), + ), + ), + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(top: 10,left: 10,bottom: 20), + child: Text( + '秋林果戈里大街附近', + softWrap: true, + ), + ), + MyDivider(height: 0,width: 0.5, endindent: 20, indent: 20,), + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(top: 10,left: 10,bottom: 20), + child: Text( + widget.orderView.room_name??"", + softWrap: true, + ), + ), + Container( + child: Row( + children: [ + _orderkey("入住人"), + _ordervalue(widget.orderView.user_id) + ], + ) + ), + Container( + child: Row( + children: [ + _orderkey("联系手机"), + _ordervalue(widget.orderView.user_id) + ], + ) + ), + Container( + child: Row( + children: [ + _orderkey("预计到店"), + _ordervalue("姓名") + ], + ) + ), + Container( + child: Row( + children: [ + _orderkey("入住说明"), + _ordervalue("姓名") + ], + ) + ) + ], + ), + ), + Container( + margin: EdgeInsets.only(top: 660), + height: 120, + width: _media.width, + color: Colors.white, + child: Column( + children: [ + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(left: 10,top: 10), + child: Text( + "订单信息", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w500, + color: Colors.black + ), + ), + ), + Container( + child: Row( + children: [ + _orderkey("订单号"), + _ordervalue(widget.orderView.order_id.toString()??""), + ], + ), + ), + Container( + child: Row( + children: [ + _orderkey("下单时间"), + _ordervalue(widget.orderView.order_set_time), + ], + ), + ) + ], + ), + ), + _questionwidget(_media) + ], + ), + ], + ), + ), +// LoadingMoreSliverList( +// SliverListConfig( +// itemBuilder: itemBuilder, +// sourceList: listSourceRepository, +// //isLastOne: false +// ) +// ), + ], + ), + ), + OrderAppBar( + height: 80.0, + controller: _orderbarcontroller, + key: _mTitleKey, + ) + ] + ); + + } + _questionwidget(_media){ + return Container( + margin: EdgeInsets.only(top: 785), + height: 200, + width: _media.width, + color: Colors.white, + child: Column( + children: [ + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(left: 10,top: 10,bottom: 20), + child: Text( + "您可能遇到以下问题", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w500, + color: Colors.black + ), + ), + ), + Container( + child: Row( + children: [ + _questioncard("如何评价酒店",_media), + _questioncard("如何取消/退款",_media), + _questioncard("查询开票难度",_media) + ], + ), + ), + Container( + child: Row( + children: [ + _questioncard("如何申请开票",_media), + _questioncard("如何删除订单",_media), + _questioncard("要求开具专票",_media) + ], + ), + ) + ], + ), ); } + _paystatustitle(int status){ + if(status == 0){ + return "等待支付"; + }else if(status == 1){ + return "已消费"; + }else{ + return "支付超时"; + } + + } + + _payillustrate(int status){ + if(status == 0){ + return "等待订单支付支付"; + }else if(status == 1){ + return '您的订单已消费,期待您再次预订哦'; + }else{ + return '订单已超过可支付的时间,请重新下单'; + } + } + + _paybutton(int status){ + if(status == 0){ + return "去支付"; + }else{ + return "再次预定"; + } + } + + _questioncard(text,_media){ + return Container( + width: _media.width * 0.3, + margin: EdgeInsets.all(5), + padding: EdgeInsets.all(10), + color: Colors.grey.withAlpha(70), + child: Text( + text, + style: TextStyle( + color: Colors.black + ), + ), + ); + } + + _orderkey(String text){ + return Container( + padding: EdgeInsets.only(left: 10,top: 10), + child:Text( + text, + style: TextStyle( + color: Colors.grey, + fontSize: 15 + ), + ), + ); + } + + _ordervalue(String text){ + return Container( + padding: EdgeInsets.only(left: 10,top: 10), + child:Text( + text, + style: TextStyle( + color: Colors.black, + fontSize: 15 + ), + ) + ); + } + } diff --git a/lib/ui/page/order/orderitem.dart b/lib/ui/page/order/orderitem.dart index 197357e..ea4c476 100644 --- a/lib/ui/page/order/orderitem.dart +++ b/lib/ui/page/order/orderitem.dart @@ -1,22 +1,37 @@ import 'package:flutter/material.dart'; +import 'package:hotel/config/application.dart'; +import 'package:hotel/entity/orderview.dart'; +import 'package:hotel/route/routes.dart'; import '../../widget/MyDivider.dart'; +import 'order_detail_page.dart'; class Orderitem extends StatefulWidget { + OrderView orderView; + DateTime room_in_time; + DateTime room_out_time; + Orderitem({ + @required + this.orderView, + this.room_in_time, + this.room_out_time + }); + _OrderitemState createState() => _OrderitemState(); } class _OrderitemState extends State { - @override Widget build(BuildContext context) { final _media = MediaQuery.of(context).size; // TODO: implement build return InkWell( - onTap:()=>{ - + onTap:(){ + Navigator.push(context, new MaterialPageRoute(builder: (BuildContext context){ + return OrderDetailPage(orderView: widget.orderView); + })); }, child: Container( child: Column( @@ -30,16 +45,19 @@ class _OrderitemState extends State { Container( padding: EdgeInsets.only(left: _media.width / 60,top: 30,bottom: 15), width: _media.width / 1.6, - child: Text('莫泰酒店(哈尔滨店)', + child: Text( + widget.orderView.hotel_name??"", overflow: TextOverflow.ellipsis, style: TextStyle( - fontSize: 20, + fontSize: 17, ), ), ), - Padding( - padding: EdgeInsets.only(left: _media.width / 20,top: 30,bottom: 15), - child: Text('已消费', + Container( + alignment: Alignment.bottomRight, + padding: EdgeInsets.only(top: 30,bottom: 10), + child: Text( + _isPay(widget.orderView.pay_status), style: TextStyle( fontSize: 15, color: Colors.grey @@ -53,14 +71,14 @@ class _OrderitemState extends State { Row( children: [ Container( - margin: EdgeInsets.only(left: _media.width / 15,top: 10), + margin: EdgeInsets.only(left: _media.width / 15), height: 50, width: 50, decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage('assets/images/1.jpg',) - ), - borderRadius: BorderRadius.all(Radius.circular(5)) + image: DecorationImage( + image: AssetImage('assets/images/1.jpg',) + ), + borderRadius: BorderRadius.all(Radius.circular(5)) ), ), Expanded( @@ -69,7 +87,8 @@ class _OrderitemState extends State { Container( alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: _media.width / 40,top: 5), - child: Text('1 ' + '间,' + '家庭房', + child: Text( + widget.orderView.room_count.toString() + '间,' + widget.orderView.room_name??"", style: TextStyle( color: Colors.black54, fontSize: 15 @@ -79,7 +98,8 @@ class _OrderitemState extends State { Container( alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: _media.width / 40,top: 5), - child: Text('01月15日 - 01月19日', + child: Text( + _datekey(widget.room_in_time,widget.room_out_time), style: TextStyle( color: Colors.black54, fontSize: 15 @@ -91,7 +111,7 @@ class _OrderitemState extends State { alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: _media.width / 40,top: 5), child: Text( - '房价: ' + '\$138.0', + '房价: ' + '¥' + widget.orderView.collection_price.toString(), style: TextStyle( color: Colors.black54, fontSize: 15 @@ -99,17 +119,59 @@ class _OrderitemState extends State { ), ) ], - ) - , + ), ) ], + ), + Container( + alignment: Alignment.topRight, + height: widget.orderView.pay_status == -1 ? 35 : 0, + margin: EdgeInsets.only(right: _media.width / 20,top: 5 ), + child: widget.orderView.pay_status == -1 ? OutlineButton( + highlightedBorderColor: Colors.greenAccent, + highlightColor: Colors.white, + onPressed: (){ + Application.navigateTo(context:context,route: '${Routes.loginpage}'); + }, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(10) + ) + ), + borderSide: BorderSide( + color: Colors.grey + ), + child: Text( + '再次预订', + style: TextStyle( + color: Colors.grey , + fontSize: 15, + fontWeight: FontWeight.w600 + ), + ), + ): SizedBox(), ) - ], ) ), ); } + _isPay(int pay){ + + if(pay == 1){ + return '已消费'; + }else if(pay == 0){ + return '等待支付'; + }else{ + return '支付超时'; + } + + } + + _datekey(DateTime datetime,DateTime otherdatetime){ + return datetime.month.toString() + "月"+ datetime.day.toString() + "日" + "-" + otherdatetime.month.toString() + "月"+ otherdatetime.day.toString() + "日"; + } + } diff --git a/lib/ui/page/order/orderpage.dart b/lib/ui/page/order/orderpage.dart index f0b472a..041f8c5 100644 --- a/lib/ui/page/order/orderpage.dart +++ b/lib/ui/page/order/orderpage.dart @@ -1,4 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:hotel/common/api.dart'; +import 'package:hotel/common/constant.dart'; +import 'package:hotel/entity/orderview.dart'; +import 'package:hotel/http/service/NetService.dart'; +import 'package:hotel/ui/widget/progress/progressdialog.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'orderitem.dart'; @@ -9,9 +16,49 @@ class OrderPage extends StatefulWidget { class _OrderPageState extends State { + bool _loading = true; + List order_list = []; - List slist = ['1','2','3']; + @override + void initState() { + // TODO: implement initState + getStorageString(USER_NAME); + super.initState(); + + } + + Future getStorageString(key) async { + + setState(() { + _loading = true; + }); + SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); + gobalUserName = sharedPreferences.get(key); + NetService.post(ORDER_URL + gobalUserName, (response){ + print(response.data['result']); + setState(() { + for(var s in response.data['result']){ + order_list.add(new OrderView.fromJson(s)); + } + _loading = false; + }); + },errorCallBack: (errorMsg){ + print(errorMsg); + setState(() { + _loading = false; + }); + Fluttertoast.showToast( + msg: "网络请求异常,获取不到订单信息", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.BOTTOM, + timeInSecForIos: 1, + backgroundColor: Colors.black54, + textColor: Colors.white70, + fontSize: 16.0 + ); + }); + } @override Widget build(BuildContext context) { @@ -39,13 +86,25 @@ class _OrderPageState extends State { ) ], ), - body: ListView.builder( - itemCount: slist.length, - itemBuilder: (BuildContext context,int index){ - return Orderitem(); - }, + body: ProgressDialog( + loading: _loading, + child:_mainbody(), ) + ); } + + _mainbody(){ + return ListView.builder( + itemCount: order_list.length, + itemBuilder: (BuildContext context,int index){ + return Orderitem( + orderView: order_list[index], + room_in_time :DateTime.parse(order_list[index].room_in_time), + room_out_time: DateTime.parse(order_list[index].room_out_time) + ); + }, + ); + } } \ No newline at end of file diff --git a/lib/ui/page/order/paystatus.dart b/lib/ui/page/order/paystatus.dart new file mode 100644 index 0000000..a866a16 --- /dev/null +++ b/lib/ui/page/order/paystatus.dart @@ -0,0 +1,3 @@ +class PayStatus{ + +} \ No newline at end of file diff --git a/lib/ui/page/order/room_order_page.dart b/lib/ui/page/order/room_order_page.dart deleted file mode 100644 index 01a6d0d..0000000 --- a/lib/ui/page/order/room_order_page.dart +++ /dev/null @@ -1,233 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:hotel/ui/widget/loading_more/common/loading_more_sliver_list.dart'; -import 'package:hotel/ui/widget/stack_appbar/hotel_appbar.dart'; -import '../../widget/MyDivider.dart'; - -class RoomOrderPage extends StatefulWidget{ - @override - State createState() { - // TODO: implement createState - return _RoomOrderPagePageState(); - } -} - -class _RoomOrderPagePageState extends State{ - - ScrollController _scrollcontroller = ScrollController(); - HotelBarController _hotelbarcontroller = new HotelBarController(); - bool _isNeedSetAlpha = false; - GlobalKey_mTitleKey = new GlobalKey(); - List list = ['1','2','3']; - - @override - void initState() { - // TODO: implement initState - super.initState(); - - _hotelbarcontroller.value.alpha = 0; - - _scrollcontroller.addListener(() { - - if ( _scrollcontroller.offset < 80.0) { - _isNeedSetAlpha = true; - _hotelbarcontroller.value.alpha = ((_scrollcontroller.offset / 80) * 255).toInt(); - _mTitleKey.currentState.setState(() {}); - } else { - if (_isNeedSetAlpha) { - _hotelbarcontroller.value.alpha = 255; - _mTitleKey.currentState.setState(() {}); - _isNeedSetAlpha = false; - } - } - }); - } - - @override - Widget build(BuildContext context) { - // TODO: implement build - return Scaffold( - body: _mainpage(context), - ); - } - _mainpage(context){ - final _media = MediaQuery.of(context).size; - return Stack( - children: [ - Container( - height: _media.height, - child: LoadingMoreCustomScrollView( - showGlowLeading: false, - controller: _scrollcontroller, - slivers: [ - SliverToBoxAdapter( - child: Column( - children: [ - Container( - margin: EdgeInsets.only(top: 80.0), - child: Text( - '七彩假日酒店公寓', - style: TextStyle( - color: Colors.black, - fontSize: 20 - ), - ), - ), - Container( - height: 80, - width: _media.width * 0.9, - color: Colors.grey, - margin: EdgeInsets.only(top: 80.0), - child: Text( - '七彩假日酒店公寓', - style: TextStyle( - color: Colors.black, - fontSize: 20 - ), - ), - ), - Container( - height: 200, - width: _media.width, - color: Colors.grey, - margin: EdgeInsets.only(top: 10.0), - child: Column( - children: [ - Container( - height: 50, - child: Text('房间数'), - - ), - Container( - height: 50, - child: Text('房间数'), - ), - Container( - height: 50, - child: Text('房间数'), - ), - Container( - height: 50, - child: Text('房间数'), - ) - ], - ), - ), - Container( - height: 150, - width: _media.width, - color: Colors.grey, - margin: EdgeInsets.only(top: 10.0), - child: Text( - '七彩假日酒店公寓', - style: TextStyle( - color: Colors.black, - fontSize: 20 - ), - ), - ), - Container( - height: 80, - width: _media.width, - color: Colors.grey, - margin: EdgeInsets.only(top: 10.0), - child: Text( - '七彩假日酒店公寓', - style: TextStyle( - color: Colors.black, - fontSize: 20 - ), - ), - ), - Container( - height: 180, - width: _media.width, - color: Colors.grey, - margin: EdgeInsets.only(top: 10.0), - child: Text( - '七彩假日酒店公寓', - style: TextStyle( - color: Colors.black, - fontSize: 20 - ), - ), - ) - ], - ) - ) - ], - ), - ), - HotelAppBar( - height: 80.0, - controller: _hotelbarcontroller, - key: _mTitleKey, - ), - Container( - margin: EdgeInsets.only(top: _media.height - 65.0), - height: 65.0, - color: Colors.white, - child: Column( - children: [ - MyDivider(height: 0,width: 0.1), - Row( - children: [ - Container( - width: _media.width * 0.5, - child: Column( - children: [ - Container( - padding: EdgeInsets.only(left: 10), - alignment: Alignment.topLeft, - child: Text( - '¥66', - style: TextStyle( - color: Colors.red, - fontSize: 25, - fontWeight: FontWeight.w600 - ), - ), - ), - Container( - padding: EdgeInsets.only(left: 10), - alignment: Alignment.topLeft, - child: Text( - '已优惠¥14', - style: TextStyle( - color: Colors.grey, - fontSize: 13, - ), - ), - ) - ], - ), - ), - - Container( - width: _media.width * 0.5, - height: 65.0, - decoration: BoxDecoration( - gradient: const LinearGradient( - colors: [Colors.deepOrangeAccent, Colors.redAccent] - ), - ), - child: GestureDetector( - child: Center( - child: Text( - '提交订单', - style: TextStyle( - color: Colors.white, - fontSize: 20 - ), - ), - ), - ), - ) - ], - ) - ], - ), - ) - ] - ); - } -} diff --git a/lib/ui/page/pay/paypage.dart b/lib/ui/page/pay/paypage.dart new file mode 100644 index 0000000..d666b9d --- /dev/null +++ b/lib/ui/page/pay/paypage.dart @@ -0,0 +1,263 @@ +import 'dart:async'; +import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:hotel/common/api.dart'; +import 'package:hotel/common/constant.dart'; +import 'package:hotel/entity/orderview.dart'; +import 'package:hotel/entity/roomview.dart'; +import 'package:hotel/http/service/NetService.dart'; +import 'package:hotel/route/routes.dart'; +import 'package:hotel/ui/widget/MyDivider.dart'; +import 'package:hotel/ui/widget/progress/progressdialog.dart'; + +class PayPage extends StatefulWidget { + + int room_id; + RoomView roomView; + String orderid; + PayPage({ + @required + this.room_id, + this.roomView, + this.orderid + }); + _PayPageState createState() => _PayPageState(); +} + +class _PayPageState extends State { + + bool _loading = false; + bool check = false; + Timer _timer; + int _countdownTime = 0; + + List order_list = []; + + @override + void initState() { + // TODO: implement initState + _startTimer(); + _countdownTime = counttime; + super.initState(); + } + + @override + void dispose() { + + if (_timer != null) { + counttime = _countdownTime; + _timer.cancel(); + } + print("dispose"); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + + final _medal = MediaQuery.of(context).size; + // TODO: implement build + return Scaffold( + appBar: AppBar( + backgroundColor: Colors.white, + elevation: 0.5, + leading: IconButton( + icon: Icon( + Icons.arrow_back, + color: Colors.black, + ), + onPressed: (){ + Navigator.pop(context); + } + ), + actions: [ + GestureDetector( + onTap: () =>{ + }, + child: Container( + padding: EdgeInsets.only(right: _medal.width/2 - 40), + alignment: Alignment.center, + child: Text( + '支付订单', + style: TextStyle( + color: Colors.black, + fontSize: 20 + ), + ), + ), + ) + ], + ), + body: ProgressDialog( + loading: _loading, + child:_mainbody(), + ) + + ); + + } + + _mainbody(){ + + final _media = MediaQuery.of(context).size; + return Stack( + children: [ + Column( + children: [ + Container( + alignment: Alignment.center, + margin: EdgeInsets.only(top: 20), + child: Text( + '支付剩余时间: ' + _countdownTime.toString(), + style: TextStyle( + + color: Colors.grey + ), + ), + ), + Container( + margin: EdgeInsets.only(top: 10), + child: Text( + widget.roomView.room_price.toString()??"", + style: TextStyle( + color: Colors.black, + fontSize: 50, + fontWeight: FontWeight.w600 + ), + ), + ), + Container( + child: Text( + widget.roomView.room_name, + style: TextStyle( + fontFamily: 'jindian', + color: Colors.grey + ), + ), + ), + SizedBox( + height: 100, + ), + MyDivider(height: 10,width: 0.5), + Container( + child: new CheckboxListTile( + secondary: const Icon( + Icons.check_circle_outline, + color: Colors.greenAccent, + ), + title: const Text( + '微信支付', + style: TextStyle( + color: Colors.black, + fontSize: 20 + ), + ), + value: this.check, + onChanged: (bool value) { + setState(() { + this.check = !this.check; + }); + }, + ), + ), + MyDivider(height: 10,width: 0.5,), + ], + ), + _mainbutton(_media), + + ], + ); + } + + _mainbutton(_media){ + return Container( + color: Colors.white, + width: _media.width, + margin: EdgeInsets.only(top: _media.height - 160), + child: Column( + children: [ + MyDivider(height: 0,width: 0.5,), + Container( + height:50, + width: _media.width * 0.85, + margin: EdgeInsets.only(top: 15), + decoration: new BoxDecoration( + //渐变色 + borderRadius: BorderRadius.all(Radius.circular(3)), + gradient: new LinearGradient( + colors: [ + Colors.deepOrangeAccent, + Colors.redAccent.withAlpha(220), + ], + begin: const FractionalOffset(0.2, 0.0), + end: const FractionalOffset(1.0, 1.0), + stops: [0.0, 1.0], + tileMode: TileMode.clamp + ) + ), + child: new FlatButton( + child: new Padding( + padding: EdgeInsets.all(8.0), + child: new Text( + "确认支付", + style: new TextStyle( + color: Colors.white, + fontSize: 23.0 + ), + ), + ), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)), //圆角大小 + onPressed: () { + setState(() { + _loading = true; + }); + NetService.post( COMMIT_ORDER_URL + widget.orderid + "/" + widget.room_id.toString(), (response){ + print(response); + setState(() { + _loading = false; + }); +// dispose(); + + Navigator.of(context).popAndPushNamed('${Routes.successpage}'); + },errorCallBack: (errorMsg){ + print(errorMsg); + setState(() { + _loading = false; + }); + Fluttertoast.showToast( + msg: "提交订单失败", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.BOTTOM, + timeInSecForIos: 1, + backgroundColor: Colors.black54, + textColor: Colors.white70, + fontSize: 16.0 + ); + },); + }, + ) + ) + ], + ) , + ); + } + + /// 启动倒计时的计时器。 + void _startTimer() { + _countdownTime = 60; + // 计时器(`Timer`)组件的定期(`periodic`)构造函数,创建一个新的重复计时器。 + _timer = Timer.periodic( + Duration(seconds: 1), + (timer) { + setState(() { + if (_countdownTime < 1) { + _timer.cancel(); + } else { + _countdownTime = _countdownTime - 1; + print(_countdownTime); + } + }); + }); + } + +} \ No newline at end of file diff --git a/lib/ui/page/pay/successpage.dart b/lib/ui/page/pay/successpage.dart new file mode 100644 index 0000000..29f6064 --- /dev/null +++ b/lib/ui/page/pay/successpage.dart @@ -0,0 +1,102 @@ +import 'package:flutter/material.dart'; +import 'package:hotel/route/routes.dart'; + +class SuccessPage extends StatefulWidget { + + _SuccessPageState createState() => _SuccessPageState(); +} + +class _SuccessPageState extends State { + + + + @override + Widget build(BuildContext context) { + // TODO: implement build + final _media = MediaQuery.of(context).size; + return _mainpage(_media); + } + + _mainpage(_media){ + return Scaffold( + appBar: AppBar( + backgroundColor: Colors.white, + elevation: 0.5, + leading: IconButton( + icon: Icon( + Icons.arrow_back, + color: Colors.black, + ), + onPressed: (){ + dispose(); + Navigator.pop(context); + } + ), + ), + body: Column( + children: [ + Container( + alignment: Alignment.center, + margin: EdgeInsets.only(top: _media.height * 0.1), + child: Text( + "支付成功", + style: TextStyle( + color: Colors.greenAccent, + fontSize: 50 + ), + ), + ), + Container( + alignment: Alignment.center, + margin: EdgeInsets.only(top: 20), + child: Icon( + Icons.check_circle_outline, + color: Colors.greenAccent, + size: 200, + ) + ), + _finishbutton(_media) + ], + ), + ); + } + + _finishbutton(_media){ + return Container( + height:50, + width: _media.width * 0.85, + margin: EdgeInsets.only(top: 50), + decoration: new BoxDecoration( + //渐变色 + borderRadius: BorderRadius.all(Radius.circular(3)), + gradient: new LinearGradient( + colors: [ + Colors.greenAccent, + Colors.greenAccent.withAlpha(200), + ], + begin: const FractionalOffset(0.2, 0.0), + end: const FractionalOffset(1.0, 1.0), + stops: [0.0, 1.0], + tileMode: TileMode.clamp + ) + ), + child: new FlatButton( + child: new Padding( + padding: EdgeInsets.all(8.0), + child: new Text( + "完成", + style: new TextStyle( + color: Colors.white, + fontSize: 23.0 + ), + ), + ), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)), //圆角大小 + onPressed: () { + Navigator.of(context).pushNamedAndRemoveUntil('${Routes.mainpage}', (Route route) => false); + }, + ) + ); + } + +} \ No newline at end of file diff --git a/lib/ui/page/personal/ippage.dart b/lib/ui/page/personal/ippage.dart new file mode 100644 index 0000000..963ec4f --- /dev/null +++ b/lib/ui/page/personal/ippage.dart @@ -0,0 +1,118 @@ + +import 'package:flutter/material.dart'; +import 'package:hotel/common/api.dart'; +import 'package:hotel/ui/widget/progress/progressdialog.dart'; + +class IpPage extends StatefulWidget { + + _IpPageState createState() => _IpPageState(); +} + +class _IpPageState extends State{ + + TextEditingController _textEditingController = new TextEditingController(); + bool _loading = false; + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context).size; + // TODO: implement build + return new Scaffold( + resizeToAvoidBottomPadding: false, + appBar: AppBar( + elevation: 0, + leading: IconButton( + icon: Icon( + Icons.close, + size: 30, + color: Colors.greenAccent, + ), + onPressed: (){ + Navigator.pop(context); + } + ), + backgroundColor: Colors.white, + ), + body: ProgressDialog( + loading: _loading, + child: _mainbody(_media), + ), + backgroundColor: Colors.white, + ); + } + + _mainbody(_media){ + return Column( + children: [ + Container( + child: Row( + children: [ + new Padding( + padding: EdgeInsets.all(5.0), + child: new Icon(Icons.trip_origin), + ), + new Expanded( + child: new TextField( + controller: _textEditingController, + decoration: new InputDecoration( + hintText: "请输入ip地址:" + BASE_URL, + ), + onChanged: (value){ + }, + ) + ), + new IconButton( + icon: new Icon(Icons.clear), + onPressed: () { + _textEditingController.clear(); + } + ) + ], + ), + ), + _finishbutton(_media) + ], + ); + } + + _finishbutton(_media){ + return Container( + height:50, + width: _media.width * 0.85, + margin: EdgeInsets.only(top: 50), + decoration: new BoxDecoration( + //渐变色 + borderRadius: BorderRadius.all(Radius.circular(3)), + gradient: new LinearGradient( + colors: [ + Colors.greenAccent, + Colors.greenAccent.withAlpha(200), + ], + begin: const FractionalOffset(0.2, 0.0), + end: const FractionalOffset(1.0, 1.0), + stops: [0.0, 1.0], + tileMode: TileMode.clamp + ) + ), + child: new FlatButton( + child: new Padding( + padding: EdgeInsets.all(8.0), + child: new Text( + "完成", + style: new TextStyle( + color: Colors.white, + fontSize: 23.0 + ), + ), + ), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)), //圆角大小 + onPressed: () { + BASE_URL = "http://" + _textEditingController.text; + Navigator.pop(context); + }, + ) + ); + } + +} + diff --git a/lib/ui/page/personal/personalpage.dart b/lib/ui/page/personal/personalpage.dart index 14605ee..7c79bab 100644 --- a/lib/ui/page/personal/personalpage.dart +++ b/lib/ui/page/personal/personalpage.dart @@ -1,28 +1,55 @@ import 'package:flutter/material.dart'; -import 'package:flutter_custom_clippers/flutter_custom_clippers.dart'; +import 'package:hotel/common/constant.dart'; +import 'package:hotel/config/application.dart'; +import 'package:hotel/route/routes.dart'; +import 'package:hotel/ui/widget/progress/progressdialog.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class PersonPage extends StatefulWidget { + bool islogin = false; + PersonPage({@required this.islogin = false}); _PersonPageState createState() => _PersonPageState(); } class _PersonPageState extends State { + double _imageHeight = 256.0; + bool _loading = false; + String username = ""; + + @override + void initState() { + // TODO: implement initState + super.initState(); + getStorageString(USER_NAME); + } @override Widget build(BuildContext context) { + // TODO: implement build - return Scaffold( - body: new Stack( - children: [ - _mainbody() - ], - ), + return ProgressDialog( + loading: _loading, + child: Scaffold( + body: new Stack( + children: [ + _mainbody() + ], + ), + ) ); } + Future deleteStorageString(key) async { + print("delete"); + SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); + sharedPreferences.remove(key); + } + Widget _mainbody() { + final _media = MediaQuery.of(context).size; double _index = 65; return CustomScrollView( @@ -33,11 +60,10 @@ class _PersonPageState extends State { automaticallyImplyLeading: false, actions: [ IconButton( - icon: const Icon(Icons.add_circle), + icon: const Icon(Icons.settings), tooltip: 'Add new entry', onPressed: () { - print('add'); - /* ... */ + Application.navigateTo(context: context, route: '${Routes.settingpage}'); }, ), ], @@ -46,46 +72,114 @@ class _PersonPageState extends State { flexibleSpace: FlexibleSpaceBar( background: new Scaffold( body: new Stack( - children: [_bulidImage(_index), _buildProfileRow()], + children: [ + _bulidImage(_index), + _buildProfileRow() + ], ), )), // floating: floating, // snap: snap, // pinned: pinned, ), + SliverToBoxAdapter( + child: Column( + children: [ + Container( + height: 100, + width: _media.width*0.95, + child: Row( + children: [ + _showitem(Icons.color_lens,'收藏',_media), + _showitem(Icons.comment,'评价',_media), + _showitem(Icons.credit_card,'卡劵',_media), + _showitem(Icons.message,'消息',_media) + ], + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(10)), + color: Colors.white + ), + ), + Container( + height: 200, + width: _media.width*0.95, + margin: EdgeInsets.only(top: 10), + child: Row( + children: [ + _showitem(Icons.local_activity,'会员卡',_media), + ], + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(10)), + color: Colors.amberAccent.withAlpha(200) + ), + ), + Container( + height: 500, + width: _media.width*0.95, + margin: EdgeInsets.only(top: 10), + child: Row( + children: [ + + ], + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(10)), + color: Colors.white + ), + ) + ], + ), + ) - SliverFixedExtentList( - itemExtent: 200.0, - delegate: SliverChildListDelegate([ - SizedBox( - height: 50, - ), - Card( - color: Colors.amber, - ), - Card( - color: Colors.amber, - ), - Card( - color: Colors.amber, - ) - ]), - ), ], ); } + _showitem(icon,msg,_media){ + return Container( + width: _media.width*0.23, + child: Column( + children: [ + Padding( + padding: EdgeInsets.only(left: 10,top: 20), + child: Icon( + icon, + size: 30, + ) + ), + Padding( + padding: EdgeInsets.only(left: 10,top: 10), + child: Text( + msg + ), + ) + ], + ), + ); + } + + Future getStorageString(key) async { + setState(() { + _loading = true; + }); + SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); + setState(() { + username = sharedPreferences.get(key); + _loading = false; + }); + } + ///APPBAR的背景图片及其剪裁 Widget _bulidImage(double index) { return new ClipPath( //clipper: CustomRect(index), - child: Image.network( - "https://img4.duitang.com/uploads/item/201402/14/20140214120558_2f4NN.jpeg", - fit: BoxFit.fill, - height: 256.0, - colorBlendMode: BlendMode.srcOver, - color: new Color.fromARGB(120, 20, 10, 40), - )); + child: Container( + height: 250, + color: Colors.grey, + ) + ); } ///用户头像及其附属信息 @@ -105,7 +199,7 @@ class _PersonPageState extends State { mainAxisSize: MainAxisSize.min, children: [ new Text( - 'Ryan Barnes', + username??"", style: new TextStyle( fontSize: 26.0, color: Colors.white, diff --git a/lib/ui/page/personal/settingpage.dart b/lib/ui/page/personal/settingpage.dart new file mode 100644 index 0000000..490408a --- /dev/null +++ b/lib/ui/page/personal/settingpage.dart @@ -0,0 +1,173 @@ +import 'package:flutter/material.dart'; +import 'package:hotel/common/constant.dart'; +import 'package:hotel/route/routes.dart'; +import 'package:hotel/ui/widget/MyDivider.dart'; +import 'package:hotel/ui/widget/progress/progressdialog.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +class SettingPage extends StatefulWidget { + + bool islogin = false; + SettingPage({@required this.islogin = false}); + _SettingPageState createState() => _SettingPageState(); +} + +class _SettingPageState extends State { + + bool _loading = false; + + @override + Widget build(BuildContext context) { + // TODO: implement build + return ProgressDialog( + loading: _loading, + child: Scaffold( + appBar: AppBar( + backgroundColor: Colors.white, + elevation: 0, + leading: IconButton( + onPressed: (){ + Navigator.pop(context); + }, + icon:Icon( + Icons.arrow_back_ios, + color: Colors.black + ), + ), + title: Text( + '设置', + style: TextStyle( + color: Colors.black + ), + ), + ), + body: _mainpage(), + ) + ); + } + Future deleteStorageString(key) async { + print("delete"); + SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); + sharedPreferences.remove(key); + } + + _mainpage(){ + return Column( + children: [ + Container( + margin: EdgeInsets.only(top: 10), + color: Colors.white, + child: Column( + children: [ + settingWidget("个人信息",null,(){}), + MyDivider(width: 0.5,), + settingWidget("换绑手机",null,(){}), + MyDivider(width: 0.5), + settingWidget("社交账号绑定","绑定/解绑",(){}), + MyDivider(width: 0.5), + settingWidget("设置密码","修改",(){}), + MyDivider(width: 0.5), + settingWidget("支付设置",null,(){}), + ], + ), + ), + Container( + margin: EdgeInsets.only(top: 10), + color: Colors.white, + child: Column( + children: [ + settingWidget("安全中心",null,(){ + Navigator.of(context).pushNamed('${Routes.ippage}'); + }), + MyDivider(width: 0.5), + settingWidget("通用",null,(){}), + ], + ), + ), + Container( + margin: EdgeInsets.only(top: 10), + color: Colors.white, + child: settingWidget("关于Hotel",null,(){}), + ), + Container( + height:80, + width: 480, + padding: EdgeInsets.only(left:10.0, right:10.0,top: 30), + child: new RaisedButton( + color: Colors.white, + child: new Padding( + padding: EdgeInsets.all(8.0), + child: new Text( + "退出当前账号", + style: new TextStyle( + fontFamily: 'HanaleiFill', color: Colors.black, fontSize: 16.0), + ), + ), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)), //圆角大小 + onPressed: () { + setState(() { + _loading = true; + }); + print('注销'); + deleteStorageString(TOKEN_KEY); + deleteStorageString(USER_NAME); + setState(() { + _loading = !_loading; + }); + Navigator.of(context).pushNamedAndRemoveUntil('${Routes.mainpage}', (Route route) => false); + }, + ) + ) + ], + ); + } + + settingWidget(String keytitle,String extendtext,Function Action){ + final _media = MediaQuery.of(context).size; + return InkWell( + onTap: Action, + child: Row( + children: [ + Container( + width: _media.width * 0.85, + child: Row( + children: [ + Container( + alignment: Alignment.centerLeft, + child: Text( + keytitle, + style: TextStyle( + fontSize: 15, + color: Colors.black), + ), + padding: EdgeInsets.only(left: 10,top: 8,bottom: 8), + ), + Expanded( + child: Container( + child: Text( + extendtext??"", + style: TextStyle( + fontSize: 15, + color: Colors.grey), + ), + padding: EdgeInsets.only(left: 10,top: 8,bottom: 8), + alignment: Alignment.centerRight, + ) + ), + ], + ) + ), + Expanded( + child: Padding( + padding: EdgeInsets.only(left: 0), + child:Icon( + Icons.keyboard_arrow_right, + size: 20, + color: Colors.grey), + ) + ), + ], + ), + ); + } + +} diff --git a/lib/ui/page/personal/unloginpage.dart b/lib/ui/page/personal/unloginpage.dart new file mode 100644 index 0000000..8b0fdf3 --- /dev/null +++ b/lib/ui/page/personal/unloginpage.dart @@ -0,0 +1,97 @@ +import 'package:flutter/material.dart'; +import 'package:hotel/config/application.dart'; +import 'package:hotel/route/routes.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +class UnloginPage extends StatefulWidget { + + String pagetype = null; + + UnloginPage({@required this.pagetype }); + + _UnloginPageState createState() => _UnloginPageState(); +} + +class _UnloginPageState extends State { + + String token; + + + @override + Widget build(BuildContext context) { + + // TODO: implement build + return _mainpage(); + } + + String selectpagetype(){ + if(widget.pagetype == null){ + return '登陆后可查看"我的"页面'; + }else{ + return '登陆后可查看"订单"页面'; + } + } + + _mainpage(){ + + final _media = MediaQuery.of(context).size; + + return Center( + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: _media.height * 0.3), + height: _media.width * 0.4, + width: _media.width * 0.4, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/images/1.jpg') + ) + ), + ), + Container( + margin: EdgeInsets.only(top: 10), + child: Text( + selectpagetype(), + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.w600, + fontSize: 20 + ), + ), + ), + Container( + margin: EdgeInsets.only(top: 20), + height: 35, + width: _media.width * 0.2, + child: OutlineButton( + highlightedBorderColor: Colors.greenAccent, + highlightColor: Colors.white, + onPressed: (){ + Application.navigateTo(context:context,route: '${Routes.loginpage}'); + }, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(10) + ) + ), + borderSide: BorderSide( + color: Colors.greenAccent + ), + child: Text( + '登陆', + style: TextStyle( + color: Colors.greenAccent , + fontSize: 15, + fontWeight: FontWeight.w600 + ), + ), + ), + ), + ], + ) + ); + + } + +} \ No newline at end of file diff --git a/lib/ui/page/order/room_order_item.dart b/lib/ui/page/room/room_order_item.dart similarity index 68% rename from lib/ui/page/order/room_order_item.dart rename to lib/ui/page/room/room_order_item.dart index 3af957c..ae3ad6d 100644 --- a/lib/ui/page/order/room_order_item.dart +++ b/lib/ui/page/room/room_order_item.dart @@ -1,11 +1,27 @@ import 'package:flutter/material.dart'; -import 'package:hotel/config/application.dart'; -import 'package:hotel/route/routes.dart'; +import 'package:hotel/common/constant.dart'; +import 'package:hotel/entity/hotelview.dart'; +import 'package:hotel/entity/roomview.dart'; +import 'package:hotel/ui/page/room/room_order_page.dart'; class RoomItem extends StatelessWidget { + RoomView roomView; + HotelView hotelView; +// List datelist; + int room_count; + RoomItem({ + @required + this.roomView, + this.hotelView, + this.room_count + }); + @override Widget build(BuildContext context) { + + + final _media = MediaQuery.of(context).size; // TODO: implement build return GestureDetector( child: Container( @@ -28,10 +44,12 @@ class RoomItem extends StatelessWidget { Container( margin: EdgeInsets.only(left: 10,top: 10), alignment: Alignment.centerLeft, - child: Text('普通大床房', + child: Text( + roomView.room_name??"", style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w500 + fontFamily: fontname, + fontSize: _media.width / 20, + fontWeight: FontWeight.w400 ), ), ), @@ -40,7 +58,7 @@ class RoomItem extends StatelessWidget { alignment: Alignment.centerLeft, child: Text('不含早 28m 大窗 有窗', style: TextStyle( - fontSize: 15, + fontSize: _media.width / 28, color: Colors.grey ), ), @@ -50,7 +68,7 @@ class RoomItem extends StatelessWidget { alignment: Alignment.centerLeft, child: Text('预定后15分钟可免费取消', style: TextStyle( - fontSize: 15, + fontSize: _media.width / 28, color: Colors.teal ), ), @@ -58,7 +76,8 @@ class RoomItem extends StatelessWidget { Container( margin: EdgeInsets.only(left: 10), alignment: Alignment.centerLeft, - child: Text('98', + child: Text( + "¥" + roomView.room_price.toString()??"", style: TextStyle( fontSize: 25, fontWeight: FontWeight.w500, @@ -71,17 +90,28 @@ class RoomItem extends StatelessWidget { ), GestureDetector( onTap: (){ - Application.navigateTo(context:context,route: '${Routes.roomorderpage}'); + Navigator.push(context, new MaterialPageRoute(builder: (BuildContext context){ + return RoomOrderPage(roomView: roomView,hotelView: hotelView); + })); }, child: Container( - margin: EdgeInsets.only(right: 10,top: 10), + margin: EdgeInsets.only(right: 15,top: 10), child: Column( children: [ Container( height: 30, - width: 50, + width: _media.width * 0.15, decoration: BoxDecoration( - color: Colors.red, + gradient: new LinearGradient( + colors: [ + Colors.deepOrangeAccent, + Colors.redAccent, + ], + begin: const FractionalOffset(0.2, 0.0), + end: const FractionalOffset(1.0, 1.0), + stops: [0.0, 1.0], + tileMode: TileMode.clamp + ), borderRadius: BorderRadius.only(topLeft: Radius.circular(5.0),topRight: Radius.circular(5.0)) ), child: Center( @@ -89,7 +119,7 @@ class RoomItem extends StatelessWidget { '预定', style: TextStyle( color: Colors.white, - fontSize: 20, + fontSize: _media.width / 24, fontWeight: FontWeight.w500 ), ), @@ -97,11 +127,11 @@ class RoomItem extends StatelessWidget { ), Container( height: 20, - width: 50, + width: _media.width * 0.15, decoration: BoxDecoration( color: Colors.white, border: Border.all( - color: Colors.red, + color: Colors.redAccent, ), borderRadius: BorderRadius.only(bottomLeft: Radius.circular(5.0),bottomRight: Radius.circular(5.0)) ), @@ -118,7 +148,7 @@ class RoomItem extends StatelessWidget { ), Container( child: Text( - '剩8间', + roomView.room_count.toString() + "间"??"获取不到房间数", style: TextStyle( color: Colors.red ), diff --git a/lib/ui/page/room/room_order_page.dart b/lib/ui/page/room/room_order_page.dart new file mode 100644 index 0000000..5902399 --- /dev/null +++ b/lib/ui/page/room/room_order_page.dart @@ -0,0 +1,594 @@ +import 'package:common_utils/common_utils.dart'; +import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:hotel/common/api.dart'; +import 'package:hotel/common/constant.dart'; +import 'package:hotel/entity/hotelview.dart'; +import 'package:hotel/entity/roomview.dart'; +import 'package:hotel/http/service/NetService.dart'; +import 'package:hotel/ui/page/pay/paypage.dart'; +import 'package:hotel/ui/widget/loading_more/common/loading_more_sliver_list.dart'; +import 'package:hotel/ui/widget/progress/CustomProgressIndicator.dart'; +import 'package:hotel/ui/widget/progress/progressdialog.dart'; +import 'package:hotel/ui/widget/stack_appbar/order_detail_appbar.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import '../../widget/MyDivider.dart'; + +class RoomOrderPage extends StatefulWidget{ + + RoomView roomView; + HotelView hotelView; + RoomOrderPage({ + @required + this.roomView, + this.hotelView,}); + + @override + State createState() { + // TODO: implement createState + return _RoomOrderPagePageState(); + } +} + +class _RoomOrderPagePageState extends State { + + ScrollController _scrollcontroller = ScrollController(); + OrderDetailBarController _hotelbarcontroller = new OrderDetailBarController(); + bool _isNeedSetAlpha = false; + GlobalKey_mTitleKey = new GlobalKey(); + TextEditingController _textEditingController = new TextEditingController(); + TextEditingController _textUserEditingController = new TextEditingController(); + String username = ""; + bool _loading = true; + + @override + void initState() { + // TODO: implement initState + super.initState(); + + _hotelbarcontroller.value.alpha = 0; + + _scrollcontroller.addListener(() { + if (_scrollcontroller.offset < 80.0) { + _isNeedSetAlpha = true; + _hotelbarcontroller.value.alpha = + ((_scrollcontroller.offset / 80) * 255).toInt(); + _mTitleKey.currentState.setState(() {}); + } else { + if (_isNeedSetAlpha) { + _hotelbarcontroller.value.alpha = 255; + _mTitleKey.currentState.setState(() {}); + _isNeedSetAlpha = false; + } + } + }); + + getStorageString(USER_NAME); + _textEditingController.text = "1"; + + } + + Future getStorageString(key) async { + setState(() { + _loading = true; + }); + SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); + setState(() { + username = sharedPreferences.get(key); + _textUserEditingController.text = username; + _loading = false; + }); + } + + @override + Widget build(BuildContext context) { + + final _media = MediaQuery.of(context).size; + // TODO: implement build + return Scaffold( + backgroundColor: Colors.white.withAlpha(240), + body: ProgressDialog( + loading: _loading, + progress: CustomProgressIndicator.HeartBeat(_media), + child: _mainpage(context,_media), + ), + ); + } + + _mainpage(context,_media) { + + return Stack( + children: [ + Container( + height: _media.height, + child: LoadingMoreCustomScrollView( + showGlowLeading: false, + controller: _scrollcontroller, + slivers: [ + SliverToBoxAdapter( + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 90.0,left: 15), + alignment: Alignment.topLeft, + child: Text( + widget.hotelView.hotel_name ?? "", + style: TextStyle( + fontFamily: fontname, + color: Colors.black, + fontSize: 20, + fontWeight: FontWeight.w600 + ), + ), + ), + Container( + margin: EdgeInsets.only(top: 10.0,left: 15), + alignment: Alignment.topLeft, + child: Text( + _actiondate(selectDate) + "-" + _actiondate(secselectDate)+ " 共" + secselectDate.difference(selectDate).inDays.toString() + "天", + style: TextStyle( + color: Colors.black, + fontSize: 15 + ), + ), + ), + Container( + margin: EdgeInsets.only(top: 10.0,left: 15), + alignment: Alignment.topLeft, + child: Text( + widget.roomView.room_name ?? "", + style: TextStyle( + fontFamily: fontname, + color: Colors.black, + fontSize: 15 + ), + ), + ), + Container( + height: 100, + width: _media.width * 0.95, + color: Colors.white, + margin: EdgeInsets.only(top: 20.0), + child: Column( + children: [ + Container( + child: Row( + children: [ + _actionicon(Icons.sentiment_very_satisfied,Colors.redAccent), + _actiontext("赞!您已选择本店最划算的客房!",Colors.redAccent) + ], + ), + ), + Container( + child: Row( + children: [ + _actionicon(Icons.card_giftcard,Colors.redAccent), + _actiontext("Hotel酒店金卡会员尊享订房优惠。",Colors.redAccent) + ], + ), + ), + Container( + child: Row( + children: [ + _actionicon(Icons.check_circle,Colors.blueGrey), + _actiontext("放心订!预定成功后15分钟内可免费取消",Colors.blueGrey) + ], + ), + ), + ], + ) + ), + Container( + width: _media.width, + color: Colors.white, + margin: EdgeInsets.only(top: 10.0), + child: Column( + children: [ + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(left: 15,top: 20,bottom: 20), + child: Row( + children: [ + Container( + width: _media.width * 0.2, + child: Text( + '房间数', + ), + ), + Container( + width: _media.width * 0.5, + child: TextField( + cursorWidth: 0, + controller: _textEditingController, + + decoration: InputDecoration( + fillColor: Colors.white, + border: InputBorder.none, + filled: true, + contentPadding: EdgeInsets.only(top: 5.0), + ) + ) + ), + Container( + width: _media.width * 0.2, + alignment: Alignment.centerRight, + child:Icon( + Icons.arrow_forward_ios, + color: Colors.grey, + size: _media.width / 20, + ), + ) + + ], + ) + ), + MyDivider(height: 0,width: 0.5,), + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(left: 15,top: 20,bottom: 20), + child: Row( + children: [ + Container( + width: _media.width * 0.15, + child: Text('入住人'), + ), + Container( + width: _media.width * 0.1, + alignment: Alignment.centerLeft, + child:Icon( + Icons.help_outline, + color: Colors.grey, + size: _media.width / 30, + ), + ), + Container( + width: _media.width * 0.5, + child: TextField( + cursorWidth: 0, + controller: _textUserEditingController, + decoration: InputDecoration( + fillColor: Colors.white, + border: InputBorder.none, + filled: true, + contentPadding: EdgeInsets.only(top: 5.0), + ) + ) + ), + Container( + width: _media.width * 0.15, + alignment: Alignment.centerRight, + child:Icon( + Icons.perm_identity, + color: Colors.grey, + size: _media.width / 15, + ), + ) + + ], + ) + ), + MyDivider(height: 0,width: 0.5), + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(left: 15,top: 20,bottom: 20), + child: Row( + children: [ + Container( + width: _media.width * 0.2, + child: Text('联系手机'), + ), + Container( + width: _media.width * 0.5, + child: TextField( + cursorWidth: 0, + decoration: InputDecoration( + fillColor: Colors.white, + border: InputBorder.none, + filled: true, + contentPadding: EdgeInsets.only(top: 5.0), + ) + ) + ), + Container( + width: _media.width * 0.2, + alignment: Alignment.centerRight, + child:Icon( + Icons.contact_phone, + color: Colors.grey, + size: _media.width / 15, + ), + ) + ], + ) + ), + MyDivider(height: 0,width: 0.5), + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(left: 15,top: 20,bottom: 20), + child: Text('预计到店'), + ) + ], + ), + ), + Container( + width: _media.width, + color: Colors.white, + margin: EdgeInsets.only(top: 10.0), + child: Column( + children: [ + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(left: 15,top: 20,bottom: 20), + child: Row( + children: [ + Container( + child: Text( + "优惠", + ), + ), + Container( + alignment: Alignment.centerRight, + child:Icon( + Icons.card_giftcard, + color: Colors.redAccent, + size: _media.width / 25, + ), + margin: EdgeInsets.only(left: 20), + ), + Container( + child: Text( + "已为您选择最大优惠", + style: TextStyle( + color: Colors.redAccent, + fontSize: _media.width / 30 + ), + ), + decoration: BoxDecoration( + border: Border.all(color: Colors.redAccent,), + borderRadius: BorderRadius.all(Radius.circular(5)) + ), + padding: EdgeInsets.all(1), + + ) + ], + ), + ), + MyDivider(height: 0,width: 0.5), + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(left: 15,top: 20,bottom: 20), + child: Row( + children: [ + Container( + child: Text( + "优惠卷", + ), + ) + ], + ), + ), + ], + ), + ), + Container( + width: _media.width, + color: Colors.white, + margin: EdgeInsets.only(top: 10.0), + child: Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(left: 15,top: 20,bottom: 20), + child: Row( + children: [ + Container( + child: Text( + "发票", + style: TextStyle( + fontWeight: FontWeight.w500 + ), + ), + ), + Expanded( + child: Container( + child: Text( + "如需发票,请向前台索取", + ), + padding: EdgeInsets.only(left: 40), + ) + ) + ], + ), + ), + ), + Container( + height: 300, + width: _media.width, + margin: EdgeInsets.only(top: 10.0,left: 15), + child: Column( + children: [ + Container( + alignment: Alignment.topLeft, + child: Text( + '退款规则', + style: TextStyle( + color: Colors.grey, + fontSize: 15 + ), + ) , + ), + Container( + alignment: Alignment.topLeft, + margin: EdgeInsets.only(top: 10), + child: Text( + '根据酒店政策,预定成功后不可' + '取消/变更,如未入住,酒店将扣除全额房费。预定成功后15分钟内可免费取消' + '无需商家同意即可马上退款至您的原支付账户(限入住日24点前),极速退款权益' + '不受酒店取消政策限制。', + softWrap: true, + style: TextStyle( + color: Colors.grey, + fontSize: 15 + ), + ), + ), + ], + ) + ) + ], + ) + ) + ], + ), + ), + OrderDetailAppBar( + height: 80.0, + controller: _hotelbarcontroller, + key: _mTitleKey, + hotelTitle: widget.hotelView.hotel_name ?? "", + ), + Container( + margin: EdgeInsets.only(top: _media.height - 65.0), + height: 65.0, + color: Colors.white, + child: Column( + children: [ + MyDivider(height: 0, width: 0.1), + Row( + children: [ + Container( + width: _media.width * 0.5, + child: Column( + children: [ + Container( + padding: EdgeInsets.only(left: 20), + alignment: Alignment.topLeft, + child: Text( + widget.roomView.room_price.toString()??"", + style: TextStyle( + color: Colors.red, + fontSize: 25, + fontWeight: FontWeight.w600 + ), + ), + ), + Container( + padding: EdgeInsets.only(left: 20), + alignment: Alignment.topLeft, + child: Text( + '已优惠'+'\$'+'14', + style: TextStyle( + fontFamily: fontname, + color: Colors.grey, + fontSize: 13, + ), + ), + ) + ], + ), + ), + + Container( + width: _media.width * 0.5, + height: 65.0, + decoration: BoxDecoration( + gradient: const LinearGradient( + colors: [Colors.deepOrangeAccent, Colors.redAccent] + ), + ), + child: InkWell( + onTap: (){ + setState(() { + _loading = true; + }); + NetService.post(CREATE_ORDER_URL, (response){ + print(response.data['result']); + setState(() { + _loading = false; + }); + Navigator.push(context, new MaterialPageRoute(builder: (BuildContext context){ + return PayPage( + room_id: widget.roomView.id, + roomView: widget.roomView, + orderid: response.data['result'] + ); + })); + },errorCallBack: (errorMsg){ + print(errorMsg); + setState(() { + _loading = false; + }); + Fluttertoast.showToast( + msg: "网络请求异常,获取不到订单信息", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.BOTTOM, + timeInSecForIos: 1, + backgroundColor: Colors.black54, + textColor: Colors.white70, + fontSize: 16.0 + ); + + },params: { + 'room_name': widget.roomView.room_name, + 'room_id': widget.roomView.id.toString(), + 'room_count': _textEditingController.text, + 'collection_price': (widget.roomView.room_price * int.parse(_textEditingController.text)).toString(), + 'room_out_time': DateUtil.getDateStrByDateTime(secselectDate,format: DateFormat.YEAR_MONTH_DAY), + 'room_in_time': DateUtil.getDateStrByDateTime(selectDate,format: DateFormat.YEAR_MONTH_DAY), + 'user_id': username, + 'hotel_name': widget.hotelView.hotel_name, + }); + + }, + child: Center( + child: Text( + '提交订单', + style: TextStyle( + color: Colors.white, + fontSize: 20 + ), + ), + ), + ), + ) + ], + ) + ], + ), + ) + ] + ); + } + + _totalday(DateTime datetime,DateTime otherdatetime){ + return (datetime.day - otherdatetime.day).toString(); + } + + _actiondate(DateTime datetime){ + return datetime.month.toString() + "月" + datetime.day.toString() + "日"; + } + + _actionicon(IconData icon,Color iconcolor) { + return Padding( + child: Icon( + icon, + size: 20, + color: iconcolor, + ), + padding: EdgeInsets.only(left: 10, top: 10), + ); + } + + _actiontext(String text,Color textcolor) { + return + Padding( + child: Text( + text, + style: TextStyle( + fontFamily: fontname, + color: textcolor, + fontSize: 15 + ), + ), + padding: EdgeInsets.only(left: 10, top: 10), + ); + } +} diff --git a/lib/ui/widget/MyDivider.dart b/lib/ui/widget/MyDivider.dart index 8284e3b..b7bee7d 100644 --- a/lib/ui/widget/MyDivider.dart +++ b/lib/ui/widget/MyDivider.dart @@ -8,7 +8,7 @@ class MyDivider extends StatelessWidget { Key key, this.height = 16.0, this.indent = 0.0, - this.width = 1.0, + this.width = 0.5, this.endindent = 0.0, this.color }) : assert(height >= 0.0), diff --git a/lib/ui/widget/ad_swiper/swiper.dart b/lib/ui/widget/ad_swiper/swiper.dart index 74f8d98..73e925c 100644 --- a/lib/ui/widget/ad_swiper/swiper.dart +++ b/lib/ui/widget/ad_swiper/swiper.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; +import 'package:hotel/common/api.dart'; class MySwiper extends StatefulWidget { @override @@ -11,6 +12,8 @@ class MySwiper extends StatefulWidget { class _MySwiperState extends State with SingleTickerProviderStateMixin{ + List bannerlists = [BASE_URL + HOTEL_BASE_PORT + '/image/banner1.jpg',BASE_URL + HOTEL_BASE_PORT + '/image/banner2.jpg',BASE_URL + HOTEL_BASE_PORT + '/image/banner3.jpg', + BASE_URL + HOTEL_BASE_PORT + '/image/banner3.jpg']; TabController tabController; var currentPage = 0; @@ -54,15 +57,15 @@ class _MySwiperState extends State with SingleTickerProviderStateMixin Widget build(BuildContext context) { // TODO: implement build return Container( - margin: EdgeInsets.only(top: 30,bottom: 15), - height: 130, - width: 500, + margin: EdgeInsets.only(top: 30,bottom: 15), + height: 110, + width: 450, child: Column( children: [ Expanded( child: PageView.builder( controller: pageController, - itemCount: tablist.length, + itemCount: bannerlists.length, onPageChanged: (index) { if (isPageCanChanged) {//由于pageview切换是会回调这个方法,又会触发切换tabbar的操作,所以定义一个flag,控制pageview的回调 onPageChange(index); @@ -70,18 +73,21 @@ class _MySwiperState extends State with SingleTickerProviderStateMixin }, itemBuilder: (BuildContext context, int index){ return Container( - margin: EdgeInsets.symmetric(horizontal: 10), - padding: EdgeInsets.symmetric(horizontal: 10), - decoration: BoxDecoration( - image: DecorationImage( fit: BoxFit.cover,image: AssetImage('assets/images/3.jpg')), - borderRadius: BorderRadius.circular(8.0) - ), + margin: EdgeInsets.symmetric(horizontal: 10), + padding: EdgeInsets.symmetric(horizontal: 10), + decoration: BoxDecoration( + image: DecorationImage( + fit: BoxFit.cover, + image: NetworkImage(bannerlists[index]) + ), + borderRadius: BorderRadius.circular(8.0) + ) ); } ) , ), TabPageSelector( - color: Colors.redAccent, + color: Colors.redAccent.withAlpha(200), indicatorSize: 8, controller: tabController, ), diff --git a/lib/ui/widget/bottom_pop/timebottompop.dart b/lib/ui/widget/bottom_pop/timebottompop.dart index c79d41b..fc8e458 100644 --- a/lib/ui/widget/bottom_pop/timebottompop.dart +++ b/lib/ui/widget/bottom_pop/timebottompop.dart @@ -1,7 +1,13 @@ import 'package:flutter/material.dart'; +import '../MyDivider.dart'; import '../calendar/calendar.dart'; class TimeBottomPop extends StatefulWidget{ + + ValueChanged onChange; + TimeBottomPop({ + this.onChange, + }); @override State createState() { // TODO: implement createState @@ -14,12 +20,20 @@ class _TimeBottomPopState extends State{ int ontaptime = 0; bool isontap = false; + List datelist = []; + ScrollController _scrollcontroller = ScrollController(); @override void initState() { // TODO: implement initState super.initState(); - + _scrollcontroller.addListener(() { + if ( _scrollcontroller.offset % 360 < 20 ) { + setState(() { + ontaptime = (_scrollcontroller.offset / 360).floor(); + }); + } + }); } @override @@ -29,176 +43,142 @@ class _TimeBottomPopState extends State{ .size; // TODO: implement build return Scaffold( - appBar: AppBar( - elevation: 0, - centerTitle:true, - title: Container( - child: Text('选择日期', - style: TextStyle( - fontSize: 20, - color: Colors.black + appBar: AppBar( + elevation: 0, + centerTitle:true, + title: Container( + child: Text('选择日期', + style: TextStyle( + fontSize: 20, + color: Colors.black + ), ), ), - ), - backgroundColor: Colors.white70, - leading: IconButton( - icon: Icon( - Icons.clear, - color: Colors.black, + backgroundColor: Colors.white70, + leading: IconButton( + icon: Icon( + Icons.clear, + color: Colors.black, + ), + onPressed: ()=>Navigator.pop(context), ), - onPressed: ()=>Navigator.pop(context), - ), - bottom: PreferredSize( - child: Container( - margin: EdgeInsets.only(bottom: 3), - child: Row( + bottom: PreferredSize( + child:Column( children: [ Container( - alignment: Alignment.center, - width: _media.width / 7, - child: Text( - '日', - style: TextStyle( - color: Colors.red, - fontSize: 15 - ), - ), - ), - Container( - alignment: Alignment.center, - width: _media.width / 7, - child: Text( - '一', - style: TextStyle( - color: Colors.black, - fontSize: 15 - ), - ), - ), - Container( - alignment: Alignment.center, - width: _media.width / 7, - child: Text( - '二', - style: TextStyle( - color: Colors.black, - fontSize: 15 - ), - ), - ), - Container( - alignment: Alignment.center, - width: _media.width / 7, - child: Text( - '三', - style: TextStyle( - color: Colors.black, - fontSize: 15 - ), - ), - ), - Container( - alignment: Alignment.center, - width: _media.width / 7, - child: Text( - '四', - style: TextStyle( - color: Colors.black, - fontSize: 15 - ), + margin: EdgeInsets.only(bottom: 3), + child: Row( + children: [ + weekkey("日",_media,Colors.red), + weekkey("一",_media,Colors.black), + weekkey("二",_media,Colors.black), + weekkey("三",_media,Colors.black), + weekkey("四",_media,Colors.black), + weekkey("五",_media,Colors.black), + weekkey("六",_media,Colors.red), + ], ), ), + MyDivider(height: 3, width: 0.5,), Container( + width: _media.width, + color: Colors.white, alignment: Alignment.center, - width: _media.width / 7, + padding: EdgeInsets.symmetric(vertical: 5), child: Text( - '五', - style: TextStyle( - color: Colors.black, - fontSize: 15 - ), + DateTime.now().year.toString() + "年" + (DateTime.now().month + ontaptime).toString() + "月" ), - ), - Container( - alignment: Alignment.center, - width: _media.width / 7, - child: Text( - '六', - style: TextStyle( - color: Colors.red, - fontSize: 15 - ), - ), - ), + ) ], - ), - ), - preferredSize: Size.fromHeight(20)), + ) , + preferredSize: Size.fromHeight(50)), - ), - body: Container( - height: 400, - child: CustomScrollView( - slivers: [ - SliverPersistentHeader( - pinned: true, - floating: true, - delegate: _SliverAppBarDelegate( - minHeight: 30.0, - maxHeight: 30.0, - child: Container( - height: 10, - color: Colors.red, - ), + ), + body: Stack( + children: [ + _mainbody(), + Container( + color: Colors.white, + margin: EdgeInsets.only(top: _media.height * 0.40), + child: Column( + children: [ + MyDivider(height: 0,width: 0.5,), + _mainbutton(_media) + ], ), + ) + ], + ) + ); + } + + _mainbutton(_media){ + return Container( + height:50, + width: _media.width * 0.8, + margin: EdgeInsets.only(top: 10), + padding: EdgeInsets.only(left:10.0, right:10.0), + child: new RaisedButton( + color: Colors.red, + child: new Padding( + padding: EdgeInsets.all(8.0), + child: new Text( + "选择日期", + style: new TextStyle( + fontFamily: 'HanaleiFill', color: Colors.white, fontSize: 25.0), ), - SliverList( - delegate: SliverChildBuilderDelegate( - (context,int index){ - return Calendar( + ), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)), //圆角大小 + onPressed: () { + Navigator.pop(context,datelist.isEmpty? [DateTime.now(),DateTime.now().add(Duration(days: 1))]:datelist); + }, + ) + ); + } + + _mainbody(){ + return Container( + height: 400, + child: CustomScrollView( + controller: _scrollcontroller, + slivers: [ + SliverList( + delegate: SliverChildBuilderDelegate( + (context,int index){ + return Calendar( initTime: DateTime.now(), firstTime: DateTime.now(), endTime: DateTime.now(), + onChange: (m){ + //print(m); + datelist.clear(); + if(m[0].isBefore(m[1])){ + print(1); + datelist.add(m[0]); + datelist.add(m[1]); + } + } ); - }, + }, childCount: 1 - ) - ) - ], - ), + ) + ), + ], ), ); } -} - -class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { - - _SliverAppBarDelegate({ - @required this.minHeight, - @required this.maxHeight, - @required this.child, - }); - - final double minHeight; - final double maxHeight; - final Widget child; - - @override - double get minExtent => minHeight; - - @override - double get maxExtent => maxHeight; - @override - Widget build( - BuildContext context, double shrinkOffset, bool overlapsContent) { - return new SizedBox.expand(child: child); - } - - @override - bool shouldRebuild(_SliverAppBarDelegate oldDelegate) { - return maxHeight != oldDelegate.maxHeight || - minHeight != oldDelegate.minHeight || - child != oldDelegate.child; + weekkey(String week,var _media,Color color){ + return Container( + alignment: Alignment.center, + width: _media.width / 7, + child: Text( + week, + style: TextStyle( + color: color, + fontSize: 15 + ), + ), + ); } -} \ No newline at end of file +} diff --git a/lib/ui/widget/calendar/calendar.dart b/lib/ui/widget/calendar/calendar.dart index b01a7c3..15252a8 100644 --- a/lib/ui/widget/calendar/calendar.dart +++ b/lib/ui/widget/calendar/calendar.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:hotel/common/constant.dart'; +import '../MyDivider.dart'; import 'timeutil.dart'; import 'daygridview.dart'; @@ -7,6 +9,7 @@ class Calendar extends StatefulWidget { DateTime firstTime; DateTime endTime; ValueChanged onChange; + ScrollController controller; Calendar({ Key key, @@ -14,6 +17,7 @@ class Calendar extends StatefulWidget { this.firstTime, this.endTime, this.onChange, + this.controller }) : super(key: key); @override @@ -22,37 +26,55 @@ class Calendar extends StatefulWidget { class _CalendarState extends State { - DateTime selectDate; + + bool is_selectsec = true; @override void initState() { super.initState(); - print(widget.firstTime.month); - selectDate = widget.initTime; +// selectDate = widget.initTime; +// secselectDate = widget.initTime.add(Duration(days: 1)); } onChange(time) { - if (selectDate != time) { - setState(() { - selectDate = time; - widget.onChange(time); - }); + if (time.containsKey(1)) { + if (secselectDate != time[1]) { + setState(() { + if(secselectDate.isAfter(time[1])) + { + selectDate = time[1]; + } + secselectDate = time[1]; + widget.onChange([selectDate,secselectDate]); + }); + } + } else { + if (selectDate != time[0]) { + setState(() { + selectDate = time[0]; + secselectDate = selectDate; + //widget.onChange(time); + }); + } } } @override Widget build(BuildContext context) { + final _media = MediaQuery.of(context).size; return Container( - color: Colors.white, - height: 300, - child: DayGridView( - initDate: DateTime(widget.initTime.year, widget.initTime.month, widget.initTime.day), - selectDate: DateTime(selectDate.year, selectDate.month, selectDate.day), - year: widget.firstTime.year + ((widget.firstTime.month) / 12).floor(), - month: (widget.firstTime.month) % 12 == 0 ? 12 : (widget.firstTime.month) % 12, - onChange: onChange, - ) - ); + child: + DayGridView( + controller: widget.controller, + initDate: DateTime(widget.initTime.year, widget.initTime.month, widget.initTime.day), + monthtime: 3, + selectDate: DateTime(selectDate.year, selectDate.month, selectDate.day), + secselectDate: DateTime(secselectDate.year, secselectDate.month, secselectDate.day), + year: widget.firstTime.year + ((widget.firstTime.month) / 12).floor(), + month: (widget.firstTime.month) % 12 == 0 ? 12 : (widget.firstTime.month) % 12, + onChange: onChange, + ) + ); } } diff --git a/lib/ui/widget/calendar/daygridview.dart b/lib/ui/widget/calendar/daygridview.dart index 0e34763..dc33011 100644 --- a/lib/ui/widget/calendar/daygridview.dart +++ b/lib/ui/widget/calendar/daygridview.dart @@ -1,20 +1,27 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; + import 'timeutil.dart'; class DayGridView extends StatefulWidget { DateTime initDate; DateTime selectDate; + DateTime secselectDate; + int monthtime; int year; int month; ValueChanged onChange; + ScrollController controller; DayGridView({ Key key, @required this.initDate, @required this.selectDate, + @required this.secselectDate, @required this.year, @required this.month, + @required this.monthtime, + @required this.controller, this.onChange, }); @@ -23,37 +30,48 @@ class DayGridView extends StatefulWidget { } class _DayGridViewState extends State { + + Color selectcolor = Colors.redAccent.withAlpha(50); + Color selecttextcolor = Colors.black.withAlpha(200); + @override void initState() { super.initState(); } List dayItems() { - List days = TimeUtil.getDay( - widget.year, widget.month, MaterialLocalizations.of(context)); + int year = widget.year; + int month = widget.month; + List days =[]; + for(int i =0;i< widget.monthtime;i++){ + if(month + i == 11){ + year+=1; + } + days.addAll(TimeUtil.getDay(year, month + i, MaterialLocalizations.of(context))); + } List dayWidgets = days.map((value) { if (value is int) { return Container(); } - if (value == widget.selectDate) { + if (value == widget.selectDate || value == widget.secselectDate) { return GestureDetector( onTap: () { - widget.onChange(widget.selectDate); + widget.onChange({0:widget.selectDate}); }, child: Container( - color: Colors.white, alignment: Alignment.center, child: Container( - width: 20, - height: 20, alignment: Alignment.center, decoration: BoxDecoration( - color: Colors.blueAccent, - borderRadius: BorderRadius.all(Radius.circular(100)), + color: Colors.redAccent, + borderRadius: value == widget.selectDate ? BorderRadius.only(topLeft: Radius.circular(5),bottomLeft:Radius.circular(5)):BorderRadius.only(topRight: Radius.circular(5),bottomRight:Radius.circular(5)), ), child: Text( value.day.toString(), - style: TextStyle(color: Colors.white), + style: TextStyle( + color: Colors.white, + fontSize: 18 + ), ), ), ), @@ -62,44 +80,86 @@ class _DayGridViewState extends State { if (value == widget.initDate) { return GestureDetector( onTap: () { - widget.onChange(widget.initDate); + if(widget.selectDate != widget.secselectDate) + { + widget.onChange({0:value}); + }else{ + widget.onChange({1:value}); + } }, child: Container( color: Colors.white, alignment: Alignment.center, child: Text( value.day.toString(), - style: TextStyle(color: Colors.blueAccent), + style: TextStyle( + color: Colors.redAccent, + fontSize: 18 + ), + ) + ), + ); + }else if(widget.selectDate.isBefore(value) && widget.secselectDate.isAfter(value) ) { + + return GestureDetector( + onTap: () { + if(widget.selectDate != widget.secselectDate) + { + widget.onChange({0:value}); + }else{ + widget.onChange({1:value}); + } + }, + child: Container( + color: selectcolor, + alignment: Alignment.center, + child: Container( + child: Text( + value.day.toString(), + style: TextStyle( + color: selecttextcolor, + fontSize: 18 + ), + ), )), ); + + } else if(widget.initDate.isAfter(value)){ + return Container( + color: Colors.white, + alignment: Alignment.center, + child: Text( + value.day.toString(), + style: TextStyle( + color: Colors.grey, + fontSize: 18 + ), + ) + ); + } else { - if (value.isAfter(widget.initDate)) { - /// 在今天之后的时间无法点击 - return GestureDetector( - child: Container( - alignment: Alignment.center, + return GestureDetector( + onTap: () { + if(widget.selectDate != widget.secselectDate) + { + widget.onChange({0:value}); + }else{ + widget.onChange({1:value}); + } + }, + child: Container( + color: Colors.white, + alignment: Alignment.center, + child: Container( child: Text( value.day.toString(), - style: TextStyle(color: Colors.black), - )), - ); - } else { - /// 在今天之前的时间可以点击 - return GestureDetector( - onTap: () { - widget.onChange(value); - }, - child: Container( - color: Colors.white, - alignment: Alignment.center, - child: Container( - child: Text( - value.day.toString(), - style: TextStyle(color: Colors.black), + style: TextStyle( + color: Colors.black, + fontSize: 18 ), - )), - ); - } + ), + )), + ); } } }).toList(); @@ -110,11 +170,12 @@ class _DayGridViewState extends State { Widget build(BuildContext context) { List list = dayItems(); return Container( - height: 400, + height: 360.0 * widget.monthtime + 60, child: GridView.custom( + controller: widget.controller, gridDelegate: _DayPickerGridDelegate(mainAxisNumber: list.length > 35 ? 6 : 5), physics: NeverScrollableScrollPhysics(), - padding: EdgeInsets.all(0), + padding: EdgeInsets.all(5), childrenDelegate: SliverChildListDelegate(list, addRepaintBoundaries: false)), ); diff --git a/lib/ui/widget/calendar/timeutil.dart b/lib/ui/widget/calendar/timeutil.dart index 5a9716b..42cec42 100644 --- a/lib/ui/widget/calendar/timeutil.dart +++ b/lib/ui/widget/calendar/timeutil.dart @@ -65,17 +65,29 @@ class TimeUtil { return (weekdayFromMonday - firstDayOfWeekFromMonday) % 7; } + static int computeFinalDayOffset(int year, int month,MaterialLocalizations localizations) { + final int daysInMonth = getDaysInMonth(year, month); + final int firstDayOffset = computeFirstDayOffset(year, month, localizations); + return (daysInMonth % 7 + firstDayOffset) %7 ; + + } /// 获取天 static List getDay(int year, int month, MaterialLocalizations localizations) { List labels = []; final int daysInMonth = getDaysInMonth(year, month); - final int firstDayOffset = - computeFirstDayOffset(year, month, localizations); + final int firstDayOffset = computeFirstDayOffset(year, month, localizations); + final int fianlDayOffset = computeFinalDayOffset(year, month, localizations); for (int i = 0; true; i += 1) { // 1-based day of month, e.g. 1-31 for January, and 1-29 for February on // a leap year. final int day = i - firstDayOffset + 1; - if (day > daysInMonth) break; + //最后超出范围后面补齐零 + if (day > daysInMonth ){ + for(int j = 0;j < 7 - fianlDayOffset;j++) { + labels.add(0); + } + break; + } if (day < 1) { labels.add(0); } else { diff --git a/lib/ui/widget/progress/CustomProgressIndicator.dart b/lib/ui/widget/progress/CustomProgressIndicator.dart new file mode 100644 index 0000000..be50706 --- /dev/null +++ b/lib/ui/widget/progress/CustomProgressIndicator.dart @@ -0,0 +1,29 @@ +import 'package:flutter/material.dart'; +import 'package:progress_indicators/progress_indicators.dart'; + +class CustomProgressIndicator{ + + static HeartBeat(_medal){ + return Container( + alignment: Alignment.center, + margin: EdgeInsets.only(top: _medal.height * 0.4), + child: Column( + children: [ + HeartbeatProgressIndicator( + child: Icon( + Icons.favorite, + color: Colors.redAccent, + size: 30, + ), + ), + Container( + margin: EdgeInsets.only(top: 30), + child: JumpingText( + 'Loading...' + ), + ) + ] + ), + ); + } +} \ No newline at end of file diff --git a/lib/ui/widget/progress/progressdialog.dart b/lib/ui/widget/progress/progressdialog.dart new file mode 100644 index 0000000..c8e86be --- /dev/null +++ b/lib/ui/widget/progress/progressdialog.dart @@ -0,0 +1,80 @@ +import 'package:flutter/material.dart'; + +class ProgressDialog extends StatelessWidget { + //子布局 + final Widget child; + + //加载中是否显示 + final bool loading; + + //进度提醒内容 + final String msg; + + //加载中动画 + final Widget progress; + + //背景透明度 + final double alpha; + + //字体颜色 + final Color textColor; + + ProgressDialog( + {Key key, + @required this.loading, + this.msg, + this.progress = const CircularProgressIndicator(), + this.alpha = 0.6, + this.textColor = Colors.white, + @required this.child}) + : assert(child != null), + assert(loading != null), + super(key: key); + + @override + Widget build(BuildContext context) { + List widgetList = []; + widgetList.add(child); + if (loading) { + Widget layoutProgress; + if (msg == null) { + layoutProgress = Center( + child: progress, + ); + } else { + layoutProgress = Center( + child: Container( + padding: const EdgeInsets.all(20.0), + decoration: BoxDecoration( + color: Colors.black87, + borderRadius: BorderRadius.circular(4.0)), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + progress, + Container( + padding: const EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 0), + child: Text( + msg, + style: TextStyle(color: textColor, fontSize: 16.0), + ), + ) + ], + ), + ), + ); + } + widgetList.add( + Opacity( + opacity: alpha, + child: new ModalBarrier(color: Colors.white70), + )); + widgetList.add(layoutProgress); + } + return Stack( + children: widgetList, + ); + } +} \ No newline at end of file diff --git a/lib/ui/widget/shimmer/shimmer.dart b/lib/ui/widget/shimmer/shimmer.dart new file mode 100644 index 0000000..4f18767 --- /dev/null +++ b/lib/ui/widget/shimmer/shimmer.dart @@ -0,0 +1,235 @@ +/// +/// * author: hunghd +/// * email: hunghd.yb@gmail.com +/// +/// A package provides an easy way to add shimmer effect to Flutter application +/// + +library shimmer; + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; + +/// +/// An enum defines all supported directions of shimmer effect +/// +/// * [ShimmerDirection.ltr] left to right direction +/// * [ShimmerDirection.rtl] right to left direction +/// * [ShimmerDirection.ttb] top to bottom direction +/// * [ShimmerDirection.btt] bottom to top direction +/// +enum ShimmerDirection { ltr, rtl, ttb, btt } + +/// +/// A widget renders shimmer effect over [child] widget tree. +/// +/// [child] defines an area that shimmer effect blends on. You can build [child] +/// from whatever [Widget] you like but there're some notices in order to get +/// exact expected effect and get better rendering performance: +/// +/// * Use static [Widget] (which is an instance of [StatelessWidget]). +/// * [Widget] should be a solid color element. Every colors you set on these +/// [Widget]s will be overridden by colors of [gradient]. +/// * Shimmer effect only affects to opaque areas of [child], transparent areas +/// still stays transparent. +/// +/// [period] controls the speed of shimmer effect. The default value is 1500 +/// milliseconds. +/// +/// [direction] controls the direction of shimmer effect. The default value +/// is [ShimmerDirection.ltr]. +/// +/// [gradient] controls colors of shimmer effect. +/// +/// [loop] the number of animation loop, set value of `0` to make animation run +/// forever. +/// +class Shimmer extends StatefulWidget { + final Widget child; + final Duration period; + final ShimmerDirection direction; + final Gradient gradient; + final int loop; + + Shimmer({ + Key key, + @required this.child, + @required this.gradient, + this.direction = ShimmerDirection.ltr, + this.period = const Duration(milliseconds: 1500), + this.loop = 0, + }) : super(key: key); + + + /// + /// A convenient constructor provides an easy and convenient way to create a + /// [Shimmer] which [gradient] is [LinearGradient] made up of `baseColor` and + /// `highlightColor`. + /// + Shimmer.fromColors( + {Key key, + @required this.child, + @required Color baseColor, + @required Color highlightColor, + this.period = const Duration(milliseconds: 5000), + this.direction = ShimmerDirection.ltr, + this.loop = 0}) + : gradient = LinearGradient( + begin: Alignment.topLeft, + end: Alignment.centerRight, + colors: [ + baseColor, + baseColor, + highlightColor, + baseColor, + baseColor + ], + stops: [ + 0.0, + 0.35, + 0.5, + 0.65, + 1.0 + ]), + super(key: key); + + @override + _ShimmerState createState() => _ShimmerState(); + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(new DiagnosticsProperty('gradient', gradient, + defaultValue: null)); + properties.add(new EnumProperty('direction', direction)); + properties.add(new DiagnosticsProperty('period', period, + defaultValue: null)); + } +} + +class _ShimmerState extends State with SingleTickerProviderStateMixin { + AnimationController _controller; + int _count; + + @override + void initState() { + super.initState(); + _count = 0; + _controller = AnimationController(vsync: this, duration: widget.period) + ..addListener(() { + setState(() {}); + }) + ..addStatusListener((status) { + if (status == AnimationStatus.completed) { + _count++; + if (widget.loop <= 0) { + _controller.repeat(); + } else if (_count < widget.loop) { + _controller.forward(from: 0.0); + } + } + }) + ..forward(); + } + + @override + Widget build(BuildContext context) { + return _Shimmer( + child: widget.child, + direction: widget.direction, + gradient: widget.gradient, + percent: _controller.value, + ); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } +} + +class _Shimmer extends SingleChildRenderObjectWidget { + final double percent; + final ShimmerDirection direction; + final Gradient gradient; + + _Shimmer({Widget child, this.percent, this.direction, this.gradient}) + : super(child: child); + + @override + _ShimmerFilter createRenderObject(BuildContext context) { + return _ShimmerFilter(percent, direction, gradient); + } + + @override + void updateRenderObject(BuildContext context, _ShimmerFilter shimmer) { + shimmer.percent = percent; + } +} + +@visibleForTesting +class _ShimmerFilter extends RenderProxyBox { + final _clearPaint = Paint(); + final Paint _gradientPaint; + final Gradient _gradient; + final ShimmerDirection _direction; + double _percent; + Rect _rect; + + _ShimmerFilter(this._percent, this._direction, this._gradient) + : _gradientPaint = Paint()..blendMode = BlendMode.srcIn; + + @override + bool get alwaysNeedsCompositing => child != null; + + set percent(double newValue) { + if (newValue != _percent) { + _percent = newValue; + markNeedsPaint(); + } + } + + @override + void paint(PaintingContext context, Offset offset) { + if (child != null) { + assert(needsCompositing); + + final width = child.size.width; + final height = child.size.height; + Rect rect; + double dx, dy; + if (_direction == ShimmerDirection.rtl) { + dx = _offset(width, -width, _percent); + dy = 0.0; + rect = Rect.fromLTWH(offset.dx - width, offset.dy, 3 * width, height); + } else if (_direction == ShimmerDirection.ttb) { + dx = 0.0; + dy = _offset(-height, height, _percent); + rect = Rect.fromLTWH(offset.dx, offset.dy - height, width, 3 * height); + } else if (_direction == ShimmerDirection.btt) { + dx = 0.0; + dy = _offset(height, -height, _percent); + rect = Rect.fromLTWH(offset.dx, offset.dy - height, width, 3 * height); + } else { + dx = _offset(-width, width, _percent); + dy = 0.0; + rect = Rect.fromLTWH(offset.dx - width, offset.dy, 3 * width, height); + } + if (_rect != rect) { + _gradientPaint.shader = _gradient.createShader(rect); + _rect = rect; + } + + context.canvas.saveLayer(offset & child.size, _clearPaint); + context.paintChild(child, offset); + context.canvas.translate(dx, dy); + context.canvas.drawRect(rect, _gradientPaint); + context.canvas.restore(); + } + } + + double _offset(double start, double end, double percent) { + return start + (end - start) * percent; + } +} diff --git a/lib/ui/widget/stack_appbar/hotel_appbar.dart b/lib/ui/widget/stack_appbar/hotel_appbar.dart index 88f3c92..c9a3fe2 100644 --- a/lib/ui/widget/stack_appbar/hotel_appbar.dart +++ b/lib/ui/widget/stack_appbar/hotel_appbar.dart @@ -2,9 +2,10 @@ import 'package:flutter/material.dart'; import '../../widget/MyDivider.dart'; class HotelAppBar extends StatefulWidget { + final Key key; final double height; - + final String hotelTitle; final HotelBarController controller; final GestureTapCallback onMenuTap; final GestureTapCallback onMessageTap; @@ -15,7 +16,9 @@ class HotelAppBar extends StatefulWidget { this.onMessageTap, this.controller, this.height: 65.0, - this.key + this.key, + this.hotelTitle + }) :super(key: key); @override @@ -56,41 +59,37 @@ class HotelAppBarState extends State { }, child: new InkWell( child: Container( - padding: EdgeInsets.only(left: 10,top: 15), + padding: EdgeInsets.only(left: 10), child: new Icon( - Icons.arrow_back, + Icons.arrow_back_ios, + size: _media.width / 18, color: _controller.value.alpha < 255/2 ? Colors.white.withAlpha(255 - _controller.value.alpha) : Colors.black.withAlpha(_controller.value.alpha), ), ), ), ), - new GestureDetector( - onTap: widget.onMessageTap==null?(){}: widget.onMessageTap, - child: new InkWell( - child: Container( - padding: EdgeInsets.only(left: 10,top: 15), - child: new Icon( - Icons.star_border, - color: _controller.value.alpha < 255/2 ? Colors.white.withAlpha(255 - _controller.value.alpha) : Colors.black.withAlpha(_controller.value.alpha), - ), + Container( + padding: EdgeInsets.only(left: 10), + child: Text( + widget.hotelTitle, + style: TextStyle( + color: _controller.value.alpha < 255/2 ? Colors.white.withAlpha(0) : Colors.black.withAlpha(_controller.value.alpha), + fontSize: _media.width / 20 ), ), ), - new GestureDetector( - onTap: widget.onMessageTap==null?(){}: widget.onMessageTap, - child: new InkWell( - child: Container( - padding: EdgeInsets.only(top: 15,right: 15), - child: Column( - children: [ - Icon( - Icons.share, - color: _controller.value.alpha < 255/2 ? Colors.white.withAlpha(255 - _controller.value.alpha) : Colors.black.withAlpha(_controller.value.alpha), - ), - ], - ) - ) - ), + GestureDetector( + onTap: widget.onMessageTap==null?(){}: widget.onMessageTap, + child: new InkWell( + child: Container( + padding: EdgeInsets.only(right: 15), + child: Icon( + Icons.share, + size: _media.width / 18, + color: _controller.value.alpha < 255/2 ? Colors.white.withAlpha(255 - _controller.value.alpha) : Colors.black.withAlpha(_controller.value.alpha), + ), + ) + ) ), ], ), diff --git a/lib/ui/widget/stack_appbar/order_appbar.dart b/lib/ui/widget/stack_appbar/order_appbar.dart new file mode 100644 index 0000000..9ae104f --- /dev/null +++ b/lib/ui/widget/stack_appbar/order_appbar.dart @@ -0,0 +1,106 @@ +import 'package:flutter/material.dart'; +import '../../widget/MyDivider.dart'; + +class OrderAppBar extends StatefulWidget { + + final Key key; + final double height; + final OrderBarController controller; + final GestureTapCallback onMenuTap; + final GestureTapCallback onMessageTap; + + OrderAppBar({ + + this.onMenuTap, + this.onMessageTap, + this.controller, + this.height: 65.0, + this.key, + + }) :super(key: key); + + @override + OrderAppBarState createState () => new OrderAppBarState(); + +} + +class OrderAppBarState extends State { + + OrderBarController _controller; + + _buildTitle(context) { + + return Container( + height: widget.height, + decoration: BoxDecoration( + color: Colors.white.withAlpha(_controller.value.alpha), + border: Border( + bottom: BorderSide( + color: Colors.black, + width: 0.1, + style: _controller.value.alpha < 255/2 ? BorderStyle.none :BorderStyle.solid + ) + ) + ), + child: new Padding( + padding: new EdgeInsets.only(top: 25.0), + child:Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + onTap: (){ + Navigator.pop(context); + }, + child: new InkWell( + child: Container( + padding: EdgeInsets.only(left: 10), + child: new Icon( + Icons.arrow_back, + color: _controller.value.alpha < 255/2 ? Colors.white.withAlpha(255 - _controller.value.alpha) : Colors.black.withAlpha(_controller.value.alpha), + ), + ), + ), + ), + new GestureDetector( + onTap: widget.onMessageTap==null?(){}: widget.onMessageTap, + child: new InkWell( + child: Container( + padding: EdgeInsets.only(right: 10), + child: Icon( + Icons.share, + color: _controller.value.alpha < 255/2 ? Colors.white.withAlpha(255 - _controller.value.alpha) : Colors.black.withAlpha(_controller.value.alpha), + ), + ) + ), + ), + ], + ), + ), + ); + } + + + @override + Widget build(BuildContext context) { + if (widget.controller == null) { + _controller = new OrderBarController(); + _controller.value.alpha = 0; + } else { + _controller = widget.controller; + } + return _buildTitle(context); + } +} + +/// A [ChangeNotifier] that holds a single value. +/// +/// When [value] is replaced with something that is not equal to the old +/// value as evaluated by the equality operator ==, this class notifies its +/// listeners. +class OrderBarController extends ValueNotifier { + OrderBarController() :super(new AlphaValue()); +} + +class AlphaValue { + int alpha; +} diff --git a/lib/ui/widget/stack_appbar/order_detail_appbar.dart b/lib/ui/widget/stack_appbar/order_detail_appbar.dart new file mode 100644 index 0000000..fd0d7e5 --- /dev/null +++ b/lib/ui/widget/stack_appbar/order_detail_appbar.dart @@ -0,0 +1,125 @@ +import 'package:flutter/material.dart'; +import 'package:hotel/common/constant.dart'; +import '../../widget/MyDivider.dart'; + +class OrderDetailAppBar extends StatefulWidget { + + final Key key; + final double height; + final String hotelTitle; + final OrderDetailBarController controller; + final GestureTapCallback onMenuTap; + final GestureTapCallback onMessageTap; + + OrderDetailAppBar({ + + this.onMenuTap, + this.onMessageTap, + this.controller, + this.height: 65.0, + this.key, + this.hotelTitle + + }) :super(key: key); + + @override + State createState() { + // TODO: implement createState + return OrderDetailAppBarState(); + } +} + +class OrderDetailAppBarState extends State { + + OrderDetailBarController _controller; + + _buildTitle(context) { + + final _media = MediaQuery.of(context).size; + + return Container( + height: widget.height, + decoration: BoxDecoration( + color: Colors.white.withAlpha(_controller.value.alpha), + border: Border( + bottom: BorderSide( + color: Colors.black, + width: 0.1, + style: _controller.value.alpha < 255/2 ? BorderStyle.none :BorderStyle.solid + ) + ) + ), + child: new Padding( + padding: new EdgeInsets.only(top: 25.0), + child:Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + onTap: (){ + Navigator.pop(context); + }, + child: new InkWell( + child: Container( + padding: EdgeInsets.only(left: 10), + child: new Icon( + Icons.arrow_back_ios, + size: _media.width / 18, + color: Colors.black, + ), + ), + ), + ), + Container( + padding: EdgeInsets.only(left: 10), + child: Text( + widget.hotelTitle, + style: TextStyle( + fontFamily: fontname, + color: _controller.value.alpha < 255/2 ? Colors.white.withAlpha(0) : Colors.black.withAlpha(_controller.value.alpha) + ), + ), + ), + new GestureDetector( + onTap: widget.onMessageTap==null?(){}: widget.onMessageTap, + child: new InkWell( + child: Container( + padding: EdgeInsets.only(right: 20), + child:Icon( + Icons.share, + size: _media.width / 18, + color: Colors.black, + ), + ) + ), + ), + ], + ), + ), + ); + } + + + @override + Widget build(BuildContext context) { + if (widget.controller == null) { + _controller = new OrderDetailBarController(); + _controller.value.alpha = 0; + } else { + _controller = widget.controller; + } + return _buildTitle(context); + } +} + +/// A [ChangeNotifier] that holds a single value. +/// +/// When [value] is replaced with something that is not equal to the old +/// value as evaluated by the equality operator ==, this class notifies its +/// listeners. +class OrderDetailBarController extends ValueNotifier { + OrderDetailBarController() :super(new AlphaValue()); +} + +class AlphaValue { + int alpha; +} diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart new file mode 100644 index 0000000..62ee2ff --- /dev/null +++ b/lib/utils/storage.dart @@ -0,0 +1,10 @@ + +import 'package:shared_preferences/shared_preferences.dart'; + +Future saveStorageString(key,value) async { + SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); + sharedPreferences.setString( + key, value); +} + + diff --git a/pubspec.lock b/pubspec.lock index 5c42558..c7a37c3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: animated_text_kit url: "https://pub.flutter-io.cn" source: hosted - version: "1.3.0" + version: "1.3.1" async: dependency: transitive description: @@ -36,6 +36,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.9.7" + city_pickers: + dependency: "direct main" + description: + name: city_pickers + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.1.16" collection: dependency: transitive description: @@ -92,6 +99,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.17" + dropdown_menu: + dependency: "direct main" + description: + name: dropdown_menu + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.1" english_words: dependency: "direct main" description: @@ -112,14 +126,14 @@ packages: name: extended_image url: "https://pub.flutter-io.cn" source: hosted - version: "0.3.2" + version: "0.3.9" extended_image_library: dependency: transitive description: name: extended_image_library url: "https://pub.flutter-io.cn" source: hosted - version: "0.1.0" + version: "0.1.2" fluro: dependency: "direct main" description: @@ -133,7 +147,7 @@ packages: name: flustars url: "https://pub.flutter-io.cn" source: hosted - version: "0.1.9" + version: "0.2.5+1" flutter: dependency: "direct main" description: flutter @@ -228,13 +242,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "3.1.3" - image_picker: + json_annotation: dependency: "direct main" description: - name: image_picker + name: json_annotation url: "https://pub.flutter-io.cn" source: hosted - version: "0.4.12+1" + version: "2.4.0" lpinyin: dependency: "direct main" description: @@ -276,7 +290,7 @@ packages: name: path_provider url: "https://pub.flutter-io.cn" source: hosted - version: "0.5.0+1" + version: "1.1.0" pedantic: dependency: transitive description: @@ -284,13 +298,27 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.5.0" + pin_input_text_field: + dependency: "direct main" + description: + name: pin_input_text_field + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.4.0" + progress_indicators: + dependency: "direct main" + description: + name: progress_indicators + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.1.2" pull_to_refresh: dependency: "direct main" description: name: pull_to_refresh url: "https://pub.flutter-io.cn" source: hosted - version: "1.3.1" + version: "1.4.3" quiver: dependency: transitive description: @@ -320,12 +348,12 @@ packages: source: hosted version: "0.0.5" shared_preferences: - dependency: transitive + dependency: "direct main" description: name: shared_preferences url: "https://pub.flutter-io.cn" source: hosted - version: "0.4.3" + version: "0.5.3+1" shimmer: dependency: "direct main" description: @@ -372,7 +400,7 @@ packages: name: synchronized url: "https://pub.flutter-io.cn" source: hosted - version: "1.5.3+2" + version: "2.1.0" term_glyph: dependency: transitive description: @@ -393,7 +421,7 @@ packages: name: timeago url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.14" + version: "2.0.16" transformer_page_view: dependency: transitive description: @@ -421,14 +449,14 @@ packages: name: video_player url: "https://pub.flutter-io.cn" source: hosted - version: "0.10.0+8" + version: "0.10.1+3" web_socket_channel: dependency: "direct main" description: name: web_socket_channel url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.12" + version: "1.0.13" sdks: dart: ">=2.2.0 <3.0.0" - flutter: ">=0.5.0 <2.0.0" + flutter: ">=1.5.0 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index b18332b..c47f0fa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,14 +23,13 @@ dependencies: # Dart 常用工具类库 https://github.com/Sky24n/common_utils common_utils: ^1.0.9 # Flutter 常用工具类库 https://github.com/Sky24n/flustars - flustars: ^0.1.9 + flustars: ^0.2.5 # Flutter 国际化/多语言库 https://github.com/Sky24n/fluintl # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.2 # 汉字转拼音库 https://github.com/flutterchina/lpinyin # video_player: ^0.10.0+8 - image_picker: ^0.4.12+1 flutter_screenutil: ^0.5.2 web_socket_channel: ^1.0.12 fluttertoast: ^2.2.11 @@ -55,7 +54,12 @@ dependencies: chewie: ^0.9.7 http_client_helper: ^0.1.9 extended_image: ^0.3.1 - + json_annotation: ^2.4.0 + pin_input_text_field: ^0.4.0 + shared_preferences: ^0.5.2+1 + city_pickers: ^0.1.16 + progress_indicators: ^0.1.2 + dropdown_menu: ^1.1.1 dev_dependencies: flutter_test: @@ -72,7 +76,10 @@ flutter: # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true - + fonts: + - family: jindian + fonts: + - asset: assets/fonts/jindian.ttf assets: - assets/images/beijing1.png - assets/images/beijing2.jpg @@ -80,6 +87,7 @@ flutter: - assets/images/1.jpg - assets/images/2.jpg - assets/images/3.jpg + - assets/images/login_logo.png # To add assets to your application, add an assets section, like this: # assets: # - images/a_dot_burr.jpeg