|
|
@@ -1,9 +1,6 @@
|
|
|
import 'dart:async';
|
|
|
import 'dart:convert';
|
|
|
-import 'dart:io';
|
|
|
|
|
|
-import 'package:amap_flutter_location/amap_flutter_location.dart';
|
|
|
-import 'package:amap_flutter_location/amap_location_option.dart';
|
|
|
import 'package:bbyyy/beans/coupon_bean_entity.dart';
|
|
|
import 'package:bbyyy/beans/user_bean_entity.dart';
|
|
|
import 'package:bbyyy/https/MyDio.dart';
|
|
|
@@ -12,6 +9,7 @@ import 'package:bbyyy/my_tools/dims.dart';
|
|
|
import 'package:bbyyy/my_tools/easy_loading/easy_loading.dart';
|
|
|
import 'package:bbyyy/my_tools/event_bus.dart';
|
|
|
import 'package:bbyyy/my_tools/loacion_util.dart';
|
|
|
+import 'package:bbyyy/my_tools/my_colors.dart';
|
|
|
import 'package:bbyyy/my_tools/my_cookie.dart';
|
|
|
import 'package:bbyyy/my_tools/my_datas.dart';
|
|
|
import 'package:bbyyy/my_tools/my_tools.dart';
|
|
|
@@ -24,10 +22,10 @@ import 'package:bbyyy/paegs/mine_page/order_page/order_page.dart';
|
|
|
import 'package:bbyyy/paegs/msg_page/msg_page.dart';
|
|
|
import 'package:bbyyy/paegs/root_page/root_page_view.dart';
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
+import 'package:flutter/gestures.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:flutter/services.dart';
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
-import 'package:permission_handler/permission_handler.dart';
|
|
|
|
|
|
class RootPage extends StatefulWidget {
|
|
|
@override
|
|
|
@@ -37,7 +35,7 @@ class RootPage extends StatefulWidget {
|
|
|
class _RootPageState extends State<RootPage> {
|
|
|
PageController pageController = PageController(initialPage: 0);
|
|
|
DateTime lastPopTime;
|
|
|
-
|
|
|
+ double ppx;
|
|
|
|
|
|
@override
|
|
|
void initState() {
|
|
|
@@ -71,6 +69,9 @@ class _RootPageState extends State<RootPage> {
|
|
|
EventBus().on('hasNoPay', (arg) {
|
|
|
setState(() {});
|
|
|
});
|
|
|
+ EventBus().on('showRP', (arg) {
|
|
|
+ signInRedEnvelope();
|
|
|
+ });
|
|
|
MyData().init(context);
|
|
|
queryPersonalInformation();
|
|
|
checkForUpdates(context);
|
|
|
@@ -84,12 +85,14 @@ class _RootPageState extends State<RootPage> {
|
|
|
// TODO: implement dispose
|
|
|
EventBus().off('ChangePage');
|
|
|
EventBus().off('hasNoPay');
|
|
|
+ EventBus().off('showRP');
|
|
|
LocationUtil().stopLocation();
|
|
|
super.dispose();
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
+ ppx = MediaQuery.of(context).size.width / 375;
|
|
|
return WillPopScope(
|
|
|
onWillPop: () async {
|
|
|
if (lastPopTime == null ||
|
|
|
@@ -208,7 +211,333 @@ class _RootPageState extends State<RootPage> {
|
|
|
}, (error) {});
|
|
|
}
|
|
|
|
|
|
+ int showWitch = 0;
|
|
|
|
|
|
+ //登录红包
|
|
|
+ signInRedEnvelope() {
|
|
|
+ showDialog<void>(
|
|
|
+ context: context,
|
|
|
+ barrierDismissible: false,
|
|
|
+ // false = user must tap button, true = tap outside dialog
|
|
|
+ builder: (BuildContext dialogContext) {
|
|
|
+ return StatefulBuilder(builder: (BuildContext context, void Function(void Function()) setState) {
|
|
|
+ return Container(
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ showRedEnvelope(setState),
|
|
|
+ GestureDetector(
|
|
|
+ onTap: () {
|
|
|
+ showWitch = 0;
|
|
|
+ Navigator.pop(context);
|
|
|
+ },
|
|
|
+ child: Container(
|
|
|
+ margin: EdgeInsets.only(top: 24 * ppx),
|
|
|
+ child: Icon(
|
|
|
+ Icons.clear,
|
|
|
+ color: Colors.white,
|
|
|
+ ),
|
|
|
+ height: 28 * ppx,
|
|
|
+ width: 28 * ppx,
|
|
|
+ alignment: Alignment.center,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: MyColors.c25E7E7E7,
|
|
|
+ borderRadius: BorderRadius.circular(14 * ppx)),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ ),
|
|
|
+ alignment: Alignment.center,
|
|
|
+ );
|
|
|
+ },);
|
|
|
+ },
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
+ Stack showRedEnvelope(void Function(void Function() p1) setState) {
|
|
|
+ switch (showWitch) {
|
|
|
+ case 0:
|
|
|
+ return redEnvelopeP1(setState);
|
|
|
+ case 1:
|
|
|
+ return redEnvelopeP2(setState);
|
|
|
+ case 2:
|
|
|
+ return redEnvelopeP3(setState);
|
|
|
+ default:
|
|
|
+ return redEnvelopeP1(setState);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ Stack redEnvelopeP1(void Function(void Function() p1) setState) {
|
|
|
+ return Stack(
|
|
|
+ children: [
|
|
|
+ Positioned(
|
|
|
+ child: Container(
|
|
|
+ height: 396 * ppx,
|
|
|
+ width: double.infinity,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ borderRadius: BorderRadius.circular(16),
|
|
|
+ color: MyColors.cF25D4B),
|
|
|
+ margin: EdgeInsets.symmetric(horizontal: 45 * ppx),
|
|
|
+ alignment: Alignment.bottomCenter,
|
|
|
+ child: CustomPaint(
|
|
|
+ painter: RedEnvelopePath(),
|
|
|
+ size: Size(double.infinity - (90 * ppx), 120 * ppx)),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Positioned(
|
|
|
+ bottom: 40 * ppx,
|
|
|
+ left: ((375 / 2 - 45) * ppx),
|
|
|
+ child: GestureDetector(
|
|
|
+ onTap: () {
|
|
|
+ setState((){
|
|
|
+ showWitch = 1;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ behavior: HitTestBehavior.translucent,
|
|
|
+ child: Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: MyColors.cF1D19B,
|
|
|
+ borderRadius: BorderRadius.circular(45 * ppx)),
|
|
|
+ height: 90 * ppx,
|
|
|
+ width: 90 * ppx,
|
|
|
+ child: Text(
|
|
|
+ '抢',
|
|
|
+ style: TextStyle(
|
|
|
+ color: MyColors.c333333,
|
|
|
+ fontSize: 40 * ppx,
|
|
|
+ decoration: TextDecoration.none,
|
|
|
+ fontWeight: FontWeight.normal),
|
|
|
+ ),
|
|
|
+ alignment: Alignment.center,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Positioned(
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ SvgPicture.asset('images/svg/logo.svg'),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 28 * ppx),
|
|
|
+ child: Text(
|
|
|
+ '登陆红包',
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontSize: 32 * ppx,
|
|
|
+ fontWeight: FontWeight.normal,
|
|
|
+ decoration: TextDecoration.none),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 4 * ppx),
|
|
|
+ child: Text(
|
|
|
+ '每人仅限1份',
|
|
|
+ style: TextStyle(
|
|
|
+ color: MyColors.cF1D19B,
|
|
|
+ fontSize: 14 * ppx,
|
|
|
+ fontWeight: FontWeight.normal,
|
|
|
+ decoration: TextDecoration.none),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ top: 37 * ppx,
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ alignment: Alignment.topCenter,
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ Stack redEnvelopeP2(void Function(void Function() p1) setState) {
|
|
|
+ return Stack(
|
|
|
+ children: [
|
|
|
+ Positioned(
|
|
|
+ child: Container(
|
|
|
+ height: 396 * ppx,
|
|
|
+ width: double.infinity,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ borderRadius: BorderRadius.circular(16),
|
|
|
+ color: MyColors.cF55544),
|
|
|
+ margin: EdgeInsets.symmetric(horizontal: 45 * ppx),
|
|
|
+ alignment: Alignment.bottomCenter,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Positioned(
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ SvgPicture.asset('images/svg/logo.svg'),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 48 * ppx),
|
|
|
+ child: Text(
|
|
|
+ '0.30元',
|
|
|
+ style: TextStyle(
|
|
|
+ color: MyColors.cF1D19B,
|
|
|
+ fontSize: 30 * ppx,
|
|
|
+ fontWeight: FontWeight.normal,
|
|
|
+ decoration: TextDecoration.none),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 10 * ppx),
|
|
|
+ child: RichText(
|
|
|
+ text: TextSpan(
|
|
|
+ text: '自动划入钱包,去',
|
|
|
+ style: TextStyle(
|
|
|
+ color: MyColors.c333333,
|
|
|
+ decoration: TextDecoration.none,
|
|
|
+ fontSize: 13 * ppx),
|
|
|
+ children: [
|
|
|
+ TextSpan(
|
|
|
+ text: '提现',
|
|
|
+ style: TextStyle(
|
|
|
+ color: MyColors.c44D7B6,
|
|
|
+ decoration: TextDecoration.underline,
|
|
|
+ fontSize: 13 * ppx),
|
|
|
+ recognizer: TapGestureRecognizer()
|
|
|
+ ..onTap = () {
|
|
|
+ setState((){
|
|
|
+ showWitch = 2;
|
|
|
+ });
|
|
|
+ }),
|
|
|
+ ]),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ top: 37 * ppx,
|
|
|
+ ),
|
|
|
+ Positioned(
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ Text(
|
|
|
+ '详细规则',
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontSize: 12 * ppx,
|
|
|
+ fontWeight: FontWeight.normal,
|
|
|
+ decoration: TextDecoration.none),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 4 * ppx),
|
|
|
+ child: Text(
|
|
|
+ '每人每天限领一份,每天八点官方准时派发登陆活动,',
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontSize: 9 * ppx,
|
|
|
+ fontWeight: FontWeight.normal,
|
|
|
+ decoration: TextDecoration.none),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Text(
|
|
|
+ '每天10000元,最高可直接领取100元!!!',
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontSize: 9 * ppx,
|
|
|
+ fontWeight: FontWeight.normal,
|
|
|
+ decoration: TextDecoration.none),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ bottom: 20 * ppx,
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ alignment: Alignment.topCenter,
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ Stack redEnvelopeP3(void Function(void Function() p1) setState) {
|
|
|
+ return Stack(
|
|
|
+ children: [
|
|
|
+ Positioned(
|
|
|
+ child: Container(
|
|
|
+ height: 396 * ppx,
|
|
|
+ width: double.infinity,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ borderRadius: BorderRadius.circular(16),
|
|
|
+ color: MyColors.cF55544),
|
|
|
+ margin: EdgeInsets.symmetric(horizontal: 45 * ppx),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Positioned(
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ SvgPicture.asset('images/svg/logo.svg'),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 64 * ppx),
|
|
|
+ child: Text(
|
|
|
+ '呀!来晚了,明天我一定准时!',
|
|
|
+ style: TextStyle(
|
|
|
+ color: MyColors.cF1D19B,
|
|
|
+ fontSize: 15 * ppx,
|
|
|
+ fontWeight: FontWeight.normal,
|
|
|
+ decoration: TextDecoration.none),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ top: 37 * ppx,
|
|
|
+ ),
|
|
|
+ Positioned(
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ Text(
|
|
|
+ '详细规则',
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontSize: 12 * ppx,
|
|
|
+ fontWeight: FontWeight.normal,
|
|
|
+ decoration: TextDecoration.none),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 4 * ppx),
|
|
|
+ child: Text(
|
|
|
+ '每人每天限领一份,每天八点官方准时派发登陆活动,',
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontSize: 9 * ppx,
|
|
|
+ fontWeight: FontWeight.normal,
|
|
|
+ decoration: TextDecoration.none),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Text(
|
|
|
+ '每天10000元,最高可直接领取100元!!!',
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontSize: 9 * ppx,
|
|
|
+ fontWeight: FontWeight.normal,
|
|
|
+ decoration: TextDecoration.none),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ bottom: 20 * ppx,
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ alignment: Alignment.topCenter,
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class RedEnvelopePath extends CustomPainter {
|
|
|
+ Paint _paint = Paint()
|
|
|
+ ..color = MyColors.cF55544 //画笔颜色
|
|
|
+ ..strokeCap = StrokeCap.round //画笔笔触类型
|
|
|
+ ..isAntiAlias = true //是否启动抗锯齿
|
|
|
+ ..strokeWidth = 15.0; //画笔的宽度
|
|
|
+ @override
|
|
|
+ void paint(Canvas canvas, Size size) {
|
|
|
+ print(size);
|
|
|
+ var path = Path()
|
|
|
+ ..moveTo(0, 0)
|
|
|
+ ..quadraticBezierTo(size.width / 2, 80, size.width, 0)
|
|
|
+ ..lineTo(size.width, size.height - 16)
|
|
|
+ ..quadraticBezierTo(size.width, size.height, size.width - 16, size.height)
|
|
|
+ ..lineTo(16, size.height)
|
|
|
+ ..quadraticBezierTo(0, size.height, 0, size.height - 16)
|
|
|
+ ..close();
|
|
|
+ canvas.drawPath(path, _paint);
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ bool shouldRepaint(covariant CustomPainter oldDelegate) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|