root_page.dart 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import 'package:bbyyy/https/my_request.dart';
  2. import 'package:bbyyy/my_tools/easy_loading/easy_loading.dart';
  3. import 'package:bbyyy/my_tools/event_bus.dart';
  4. import 'package:bbyyy/my_tools/global.dart';
  5. import 'package:bbyyy/my_tools/my_colors.dart';
  6. import 'package:bbyyy/my_tools/my_cookie.dart';
  7. import 'package:bbyyy/my_tools/my_datas.dart';
  8. import 'package:bbyyy/my_tools/my_views.dart';
  9. import 'package:bbyyy/paegs/home_page/home_page.dart';
  10. import 'package:flutter/material.dart';
  11. import 'package:flutter/services.dart';
  12. import 'home_page.dart';
  13. import 'root_page_view.dart';
  14. class RootPage1 extends StatefulWidget {
  15. @override
  16. _RootPage1State createState() => _RootPage1State();
  17. }
  18. class _RootPage1State extends State<RootPage1> {
  19. PageController pageController = PageController(initialPage: 0);
  20. DateTime lastPopTime;
  21. @override
  22. void initState() {
  23. super.initState();
  24. MyCookie().initP();
  25. // MyData().init(context);
  26. EventBus().on('toLogin', (arg) {
  27. showDialog(
  28. context: context,
  29. builder: (BuildContext context) {
  30. return Material(
  31. color: Colors.black12,
  32. child: Center(
  33. child: Container(
  34. decoration: BoxDecoration(
  35. borderRadius: BorderRadius.circular(16),
  36. color: Colors.white,
  37. ),
  38. height: 180,
  39. margin: EdgeInsets.symmetric(horizontal: 18),
  40. padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
  41. child: Column(
  42. children: [
  43. Expanded(
  44. child: Center(
  45. child: Container(
  46. child: MyViews().myText('完整体验请前往注册登录', MyColors.c333333, 14),
  47. margin: EdgeInsets.symmetric(horizontal: 20),
  48. ),
  49. ),
  50. ),
  51. Container(
  52. height: 0.5,
  53. color: MyColors.cE7E7E7,
  54. margin: EdgeInsets.only(bottom: 12),
  55. ),
  56. Container(
  57. margin: EdgeInsets.symmetric(horizontal: 10),
  58. child: Row(
  59. children: [
  60. Expanded(
  61. child: GestureDetector(
  62. onTap: () {
  63. Navigator.pop(context);
  64. },
  65. behavior: HitTestBehavior.translucent,
  66. child: Container(
  67. decoration: BoxDecoration(
  68. borderRadius: BorderRadius.only(
  69. topLeft: Radius.circular(20),
  70. bottomLeft: Radius.circular(20),
  71. ),
  72. border: Border.all(
  73. color: MyColors.cFF4233, width: 1.1),
  74. color: Colors.white),
  75. child: MyViews().myText('下次再说', MyColors.cFF4233, 14),
  76. height: 40,
  77. alignment: Alignment.center,
  78. ),
  79. ),
  80. ),
  81. Expanded(
  82. child: GestureDetector(
  83. behavior: HitTestBehavior.translucent,
  84. onTap: (){
  85. Navigator.pop(context);
  86. MyCookie().clean();
  87. navigatorKey.currentState.pushNamedAndRemoveUntil('/loginPage', ModalRoute.withName("/loginPage"));
  88. },
  89. child: Container(
  90. decoration: BoxDecoration(
  91. borderRadius: BorderRadius.only(
  92. topRight: Radius.circular(20),
  93. bottomRight: Radius.circular(20),
  94. ),
  95. color: MyColors.cFF4233),
  96. height: 40,
  97. child: MyViews().myText('现在就去', Colors.white, 14),
  98. alignment: Alignment.center,
  99. ),
  100. ),
  101. )
  102. ],
  103. ),
  104. )
  105. ],
  106. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  107. ),
  108. ),
  109. ),
  110. );
  111. },
  112. );
  113. });
  114. }
  115. @override
  116. Widget build(BuildContext context) {
  117. return WillPopScope(
  118. onWillPop: () async {
  119. if (lastPopTime == null ||
  120. DateTime.now().difference(lastPopTime) > Duration(seconds: 2)) {
  121. lastPopTime = DateTime.now();
  122. EasyLoading.showToast('再按一次退出');
  123. } else {
  124. lastPopTime = DateTime.now();
  125. await SystemChannels.platform.invokeMethod('SystemNavigator.pop');
  126. }
  127. return false;
  128. },
  129. child: Scaffold(
  130. backgroundColor: Colors.transparent,
  131. body: Column(
  132. children: [
  133. Expanded(
  134. child: PageView(
  135. controller: pageController,
  136. children: [HomePage1()],
  137. physics: NeverScrollableScrollPhysics(),
  138. ),
  139. ),
  140. RootPageView1().bottomNavigationBar(),
  141. ],
  142. ),
  143. ),
  144. );
  145. }
  146. }