Commit 4dd4bae7012d99cc94fdec78f8a367cbd862dcb4

Authored by gaiyaguang
1 parent 0df94843

日历日期显示调整

1 -c7478470bf91c541bd7a94c1a6b7fe20  
  1 +081ce440b595dea4e6dbd6e5e186ed70
  1 +import 'dart:io';
  2 +
1 import 'package:dio/dio.dart'; 3 import 'package:dio/dio.dart';
2 import 'package:fluro/fluro.dart'; 4 import 'package:fluro/fluro.dart';
3 import 'package:flutter/material.dart'; 5 import 'package:flutter/material.dart';
@@ -10,6 +12,7 @@ import 'package:one_key/pages/detail/handle_online_page.dart'; @@ -10,6 +12,7 @@ import 'package:one_key/pages/detail/handle_online_page.dart';
10 import 'package:one_key/provider/message_dialog_model.dart'; 12 import 'package:one_key/provider/message_dialog_model.dart';
11 import 'package:intl/date_symbol_data_local.dart'; 13 import 'package:intl/date_symbol_data_local.dart';
12 import 'package:one_key/provider/tools.dart'; 14 import 'package:one_key/provider/tools.dart';
  15 +import 'package:one_key/utils/navigator_util.dart';
13 import 'package:one_key/utils/utils.dart'; 16 import 'package:one_key/utils/utils.dart';
14 import 'package:provider/provider.dart'; 17 import 'package:provider/provider.dart';
15 import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart'; 18 import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart';
@@ -64,6 +67,8 @@ class MyApp extends StatefulWidget { @@ -64,6 +67,8 @@ class MyApp extends StatefulWidget {
64 67
65 class MyAppState extends State<MyApp> { 68 class MyAppState extends State<MyApp> {
66 69
  70 + int xgCount=1;//注册信鸽次数,最多5次
  71 +
67 @override 72 @override
68 void initState() { 73 void initState() {
69 // TODO: implement initState 74 // TODO: implement initState
@@ -177,6 +177,13 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { @@ -177,6 +177,13 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
177 MyAppBar( 177 MyAppBar(
178 "在线预订详情", 178 "在线预订详情",
179 showBack: true, 179 showBack: true,
  180 + callback: (){
  181 + if(widget.fromNotify){
  182 + NavigatorUtil.goHomePage(context,initialIndex: 0);
  183 + }else{
  184 + Navigator.of(context).pop();
  185 + }
  186 + },
180 ), 187 ),
181 Expanded( 188 Expanded(
182 child: DefaultTextStyle( 189 child: DefaultTextStyle(
@@ -391,6 +391,13 @@ class NotebookDetailPageState extends State<NotebookDetailPage> { @@ -391,6 +391,13 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
391 MyAppBar( 391 MyAppBar(
392 "订座详情", 392 "订座详情",
393 showBack: true, 393 showBack: true,
  394 + callback: (){
  395 + if(widget.fromNotify){
  396 + NavigatorUtil.goHomePage(context,initialIndex: 0);
  397 + }else{
  398 + Navigator.of(context).pop();
  399 + }
  400 + },
394 ), 401 ),
395 Expanded( 402 Expanded(
396 child: DefaultTextStyle( 403 child: DefaultTextStyle(
1 import 'dart:async'; 1 import 'dart:async';
  2 +import 'dart:convert';
2 import 'dart:io'; 3 import 'dart:io';
3 import 'package:flutter/cupertino.dart'; 4 import 'package:flutter/cupertino.dart';
4 import 'package:flutter/material.dart'; 5 import 'package:flutter/material.dart';
@@ -70,7 +71,9 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver{ @@ -70,7 +71,9 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver{
70 )); 71 ));
71 WidgetsBinding.instance.addPostFrameCallback((_){ 72 WidgetsBinding.instance.addPostFrameCallback((_){
72 if(widget.initialIndex==0)return; 73 if(widget.initialIndex==0)return;
73 - _getIntent(); 74 + if(Platform.isAndroid){
  75 + _getIntent();
  76 + }
74 Future.delayed(Duration(milliseconds: 300),(){ 77 Future.delayed(Duration(milliseconds: 300),(){
75 initPlatformState(); 78 initPlatformState();
76 }); 79 });
@@ -160,7 +163,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver{ @@ -160,7 +163,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver{
160 xgPushClickAction: (Map<String, dynamic> msg) async { 163 xgPushClickAction: (Map<String, dynamic> msg) async {
161 print("flutter xgPushClickAction ${msg['custom']}"); 164 print("flutter xgPushClickAction ${msg['custom']}");
162 if(Platform.isIOS&&msg!=null&&msg['custom']!=null){ 165 if(Platform.isIOS&&msg!=null&&msg['custom']!=null){
163 - Map<String,dynamic> custom=msg['custom']; 166 + Map<String,dynamic> custom=jsonDecode(msg['custom'].toString());
164 switch(custom["messageType"].toString()){ 167 switch(custom["messageType"].toString()){
165 case "10": 168 case "10":
166 NavigatorUtil.goNotebookDetailPage(context, custom['rid'].toString(),fromNotify: true); 169 NavigatorUtil.goNotebookDetailPage(context, custom['rid'].toString(),fromNotify: true);
@@ -249,14 +249,20 @@ class NoteBookPageState extends State<NoteBookPage> { @@ -249,14 +249,20 @@ class NoteBookPageState extends State<NoteBookPage> {
249 if (Utils.isOneDay(day, dateTime)) return; //日期没变 249 if (Utils.isOneDay(day, dateTime)) return; //日期没变
250 setState(() { 250 setState(() {
251 DateTime dateNow = DateTime.now(); 251 DateTime dateNow = DateTime.now();
  252 + dateText =
  253 + Utils.addZeroNumber(day.month) + "-" +Utils.addZeroNumber(day.day);
252 if (Utils.isOneDay(day, dateNow)) { 254 if (Utils.isOneDay(day, dateNow)) {
253 - dateText = Utils.addZeroNumber(dateNow.month) +  
254 - "-" +  
255 - Utils.addZeroNumber(dateNow.day) + 255 + dateText +=
256 " 今天"; 256 " 今天";
257 - } else {  
258 - dateText =  
259 - Utils.addZeroNumber(day.month) + "-" + Utils.addZeroNumber(day.day); 257 + } else if(Utils.isOneDay(day,dateNow.add(Duration(days: 1)))){
  258 + dateText +=
  259 + " 明天";
  260 + }else if(Utils.isOneDay(day,dateNow.add(Duration(days: 2)))){
  261 + dateText +=
  262 + " 后天";
  263 + }else{
  264 + dateText +=
  265 + " 周${Utils.formatWeekDayNum(day.weekday)}";
260 } 266 }
261 dateTime = day; 267 dateTime = day;
262 }); 268 });
@@ -142,6 +142,20 @@ class DialogUtil { @@ -142,6 +142,20 @@ class DialogUtil {
142 messageModel.showMessageDialog=false; 142 messageModel.showMessageDialog=false;
143 } 143 }
144 144
  145 + //解析返回显示的日期
  146 + static String _parseDateDay(DateTime dateTime){
  147 + DateTime now=DateTime.now();
  148 + if(Utils.isOneDay(dateTime,now)){
  149 + return "今";
  150 + }else if(Utils.isOneDay(dateTime,now.add(Duration(days: 1)))){
  151 + return "明";
  152 + }else if(Utils.isOneDay(dateTime,now.add(Duration(days: 2)))){
  153 + return "后";
  154 + }else{
  155 + return dateTime.day.toString();
  156 + }
  157 + }
  158 +
145 //显示日历弹框 159 //显示日历弹框
146 static Future<DateTime> showCalendarDialog(BuildContext context,DateTime selectDateTime) { 160 static Future<DateTime> showCalendarDialog(BuildContext context,DateTime selectDateTime) {
147 CalendarController _calendarController = CalendarController(); 161 CalendarController _calendarController = CalendarController();
@@ -214,6 +228,23 @@ class DialogUtil { @@ -214,6 +228,23 @@ class DialogUtil {
214 ), 228 ),
215 ); 229 );
216 }, 230 },
  231 + dayBuilder: (context,date,_){
  232 + return Container(
  233 + decoration: BoxDecoration(
  234 + shape: BoxShape.circle,
  235 + ),
  236 + alignment: Alignment.center,
  237 + margin: const EdgeInsets.all(6.0),
  238 + padding: const EdgeInsets.only(
  239 + bottom: 4.0, left: 8.0, right: 8.0, top: 4.0),
  240 + child: Text(
  241 + "${_parseDateDay(date)}",
  242 + style: TextStyle().copyWith(
  243 + fontSize: ScreenUtil().setSp(32),
  244 + color: MyColours.color_353535),
  245 + ),
  246 + );
  247 + },
217 selectedDayBuilder: (context, date, _) { 248 selectedDayBuilder: (context, date, _) {
218 return Container( 249 return Container(
219 decoration: BoxDecoration( 250 decoration: BoxDecoration(
@@ -225,9 +256,7 @@ class DialogUtil { @@ -225,9 +256,7 @@ class DialogUtil {
225 padding: const EdgeInsets.only( 256 padding: const EdgeInsets.only(
226 bottom: 4.0, left: 8.0, right: 8.0, top: 4.0), 257 bottom: 4.0, left: 8.0, right: 8.0, top: 4.0),
227 child: Text( 258 child: Text(
228 - date.day == DateTime  
229 - .now()  
230 - .day ? '今' : date.day.toString(), 259 + "${_parseDateDay(date)}",
231 style: TextStyle().copyWith( 260 style: TextStyle().copyWith(
232 fontSize: ScreenUtil().setSp(32), 261 fontSize: ScreenUtil().setSp(32),
233 color: MyColours.color_ffffff), 262 color: MyColours.color_ffffff),
  1 +
1 import 'package:flutter/material.dart'; 2 import 'package:flutter/material.dart';
2 import 'package:flutter_screenutil/flutter_screenutil.dart'; 3 import 'package:flutter_screenutil/flutter_screenutil.dart';
3 import 'package:one_key/res/colors.dart'; 4 import 'package:one_key/res/colors.dart';
4 5
5 class MyAppBar extends StatelessWidget { 6 class MyAppBar extends StatelessWidget {
6 - MyAppBar(this.title, {this.showBack = true,this.backgroundColor=MyColours.color_ffffff,this.fontColor=MyColours.color_131313});  
7 7
  8 + MyAppBar(this.title, {this.showBack = true,this.backgroundColor=MyColours.color_ffffff,this.fontColor=MyColours.color_131313, this.callback});
  9 + final VoidCallback callback;//返回回调
8 final String title;//标题文字 10 final String title;//标题文字
9 final bool showBack;//是否显示返回按钮 11 final bool showBack;//是否显示返回按钮
10 final Color backgroundColor;//背景色 12 final Color backgroundColor;//背景色
@@ -24,7 +26,11 @@ class MyAppBar extends StatelessWidget { @@ -24,7 +26,11 @@ class MyAppBar extends StatelessWidget {
24 left: 0, 26 left: 0,
25 child: showBack?GestureDetector( 27 child: showBack?GestureDetector(
26 onTap: () { 28 onTap: () {
27 - Navigator.of(context).pop(); 29 + if(this.callback!=null){
  30 + this.callback();
  31 + }else{
  32 + Navigator.of(context).pop();
  33 + }
28 }, 34 },
29 behavior: HitTestBehavior.opaque, 35 behavior: HitTestBehavior.opaque,
30 child: Padding( 36 child: Padding(