process_card.dart 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import 'package:trackoffical_app/model/m_control_point.dart';
  4. import '../../service/game/game.dart';
  5. class ProcessCard extends GetView<GameService> {
  6. const ProcessCard({super.key});
  7. final cardHeight = 50.0;
  8. final cardWidth = 62.0;
  9. Widget _divider({required Color color}){
  10. return Image.asset('assets/images/ic_arrow2_up.png',
  11. height: 16,
  12. width: 16,
  13. color: color);
  14. }
  15. @override
  16. Widget build(BuildContext context) {
  17. return Column(
  18. children: [
  19. Obx((){
  20. final out = <Widget>[];
  21. final p = controller.getNextWantPoint(1);
  22. if(p != null){
  23. out.add(_ProcessCardOne(
  24. color: const Color(0xffd8d8d8),
  25. sn: p.sn,
  26. id: p.areaId,
  27. height: cardHeight,
  28. width: cardWidth,
  29. ));
  30. out.add(_divider(color: const Color(0xff333333)));
  31. }
  32. return Column(children: out);
  33. }),
  34. Obx((){
  35. final p = controller.getNextWantPoint(0);
  36. var sn = '--';
  37. var id = '--';
  38. if (p != null){
  39. sn = p.sn;
  40. id = p.areaId;
  41. }
  42. return _ProcessCardOne(
  43. color: const Color(0xffff870d),
  44. title: '请前往',
  45. sn: sn,
  46. id: id,
  47. height: cardHeight,
  48. width: cardWidth,
  49. );
  50. }),
  51. // Obx((){
  52. //
  53. // final out = <Widget>[];
  54. // final p = controller.getLastCheckedPoint();
  55. // if(p != null){
  56. // out.add(_divider(color: const Color(0xff333333)));
  57. // out.add(_ProcessCardOne(
  58. // title: '当前点',
  59. // color: p.success?const Color(0xff00ca93):const Color(0xffff4848),
  60. // sn: p.sn,
  61. // id: p.id,
  62. // height: cardHeight,
  63. // width: cardWidth,
  64. // ));
  65. //
  66. // }
  67. // return Column(children: out);
  68. // })
  69. ],
  70. );
  71. }
  72. }
  73. class _ProcessCardOne extends StatelessWidget {
  74. final Color color;
  75. final String? title;
  76. final String sn;
  77. final String id;
  78. final double height;
  79. final double width;
  80. const _ProcessCardOne(
  81. {super.key,
  82. required this.color,
  83. required this.height,
  84. required this.width,
  85. this.title, required this.sn, required this.id});
  86. Widget _snWidget(String sn){
  87. if(sn == MControlPoint.snStart){
  88. return Image.asset('assets/images/ic_point_start.png');
  89. }else if(sn ==MControlPoint.snFinish){
  90. return Image.asset('assets/images/ic_point_finish.png');
  91. }else{
  92. return Text(sn,
  93. textAlign: TextAlign.center,
  94. style: const TextStyle(fontSize: 14, color: Colors.white,
  95. fontWeight: FontWeight.w900));
  96. }
  97. }
  98. @override
  99. Widget build(BuildContext context) {
  100. final children = <Widget>[];
  101. if (title != null) {
  102. children.add(Text(title!,
  103. style: const TextStyle(fontSize: 10, color: Colors.white)));
  104. }
  105. children.add(
  106. Row(
  107. textBaseline: TextBaseline.alphabetic,
  108. mainAxisSize: MainAxisSize.min,
  109. crossAxisAlignment: CrossAxisAlignment.baseline,
  110. children: [
  111. SizedBox(width: 18, height: 16, child:
  112. _snWidget(sn)
  113. ),
  114. const Text('/',
  115. style: TextStyle(fontSize: 14, color: Colors.white,
  116. fontWeight: FontWeight.w900)),
  117. SizedBox(width: 21, height: 12,child: Text(id,
  118. style: const TextStyle(fontSize: 10, color: Colors.white,
  119. fontWeight: FontWeight.w900, overflow: TextOverflow.clip)))
  120. ,
  121. ],
  122. )
  123. );
  124. return SizedBox(
  125. height: height,
  126. width: width,
  127. child: Card(
  128. color: color,
  129. surfaceTintColor: Colors.white,
  130. shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)),
  131. child: Column(
  132. mainAxisAlignment: MainAxisAlignment.center,
  133. children: children,
  134. ),
  135. ),
  136. );
  137. }
  138. }