PhoneLogin.dart 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import 'package:flutter/material.dart';
  2. import '../model/PhoneInfo.dart';
  3. import 'PhotoView.dart';
  4. import '../widget/LinearButton.dart';
  5. class PhoneLogin extends Dialog {
  6. final List<PhoneInfo> phoneList;
  7. PhoneLogin({Key key, this.phoneList = const []}) : super(key: key);
  8. @override
  9. Widget build(BuildContext context) {
  10. return WillPopScope(
  11. child: Scaffold(
  12. backgroundColor: Color(0xCC000000),
  13. body: Container(
  14. child: SizedBox.expand(
  15. child: UnconstrainedBox(
  16. child: Container(
  17. width: 320,
  18. // padding: EdgeInsets.symmetric(horizontal: 20, vertical: 25),
  19. height: 380,
  20. decoration: BoxDecoration(color: Color(0xFF15151D), border: Border.all(width: 1, color: Theme.of(context).primaryColor)),
  21. child: Stack(
  22. children: <Widget>[
  23. Padding(
  24. padding: EdgeInsets.symmetric(horizontal: 20, vertical: 25),
  25. child: Column(
  26. mainAxisAlignment: MainAxisAlignment.center,
  27. children: <Widget>[
  28. Text.rich(TextSpan(style: TextStyle(color: Colors.white, fontSize: 14), children: [
  29. TextSpan(text: '欢迎来到杀戮的世界!您的手机可能设置了'),
  30. TextSpan(text: '“省电策略”', style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w600)),
  31. TextSpan(text: ',为了不影响您的游戏体验,请在游戏前,先选择您的手机品牌,跟着说明正确的配置手机')
  32. ])),
  33. // Container(
  34. // height: 30,
  35. // ),
  36. Container(
  37. width: double.infinity,
  38. height: 180,
  39. margin: EdgeInsets.fromLTRB(0, 0, 0, 20),
  40. child: GridView.builder(
  41. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  42. crossAxisCount: 2, //每行三列
  43. childAspectRatio: 3.0 //显示区域宽高相等
  44. ),
  45. itemCount: phoneList.length,
  46. itemBuilder: (context, index) {
  47. //如果显示到最后一个并且Icon总数小于200时继续获取数据
  48. return InkWell(
  49. child: Container(
  50. margin: EdgeInsets.all(5),
  51. color: Colors.white,
  52. child: Row(
  53. mainAxisAlignment: MainAxisAlignment.center,
  54. children: <Widget>[
  55. Image.network(
  56. phoneList[index].icon,
  57. width: 20,
  58. ),
  59. Container(
  60. width: 5,
  61. ),
  62. Text(phoneList[index].phone)
  63. ],
  64. ),
  65. ),
  66. onTap: () async {
  67. var list = phoneList[index].image.split(',');
  68. final bool res = await Navigator.of(context).push(
  69. PageRouteBuilder(
  70. opaque: false,
  71. transitionDuration: Duration(milliseconds: 300),
  72. transitionsBuilder:
  73. (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
  74. return FadeTransition(
  75. opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
  76. child: child,
  77. );
  78. },
  79. pageBuilder: (BuildContext context, _, __) {
  80. return PhotoView(imageList: list);
  81. },
  82. ),
  83. );
  84. if (res != null && res) {
  85. Navigator.of(context).pop(true);
  86. }
  87. },
  88. );
  89. })),
  90. Container(
  91. child: LinearButton(
  92. btntext: '关闭',
  93. btnHeight: 36.0,
  94. colorList: [Color(0xFF271A21), Color(0xFF271A21)],
  95. textColor: Color(0xFFD4504B),
  96. textWeight: FontWeight.w400,
  97. onTapHomeMenu: () {
  98. Navigator.of(context).pop(true);
  99. },
  100. ),
  101. ),
  102. // Container(
  103. // height: 5,
  104. // )
  105. ],
  106. ),
  107. ),
  108. Positioned(
  109. top: 0,
  110. left: 0,
  111. child: Image.asset(
  112. 'images/tancuang_shang.png',
  113. // width: 131,
  114. ),
  115. ),
  116. Positioned(
  117. bottom: 0,
  118. right: 4,
  119. child: Image.asset(
  120. 'images/tancuang_xia.png',
  121. // width: 148,
  122. ),
  123. ),
  124. ],
  125. ),
  126. ),
  127. ),
  128. ),
  129. ),
  130. ),
  131. onWillPop: () {
  132. return Future.value(false);
  133. },
  134. );
  135. }
  136. }