layer_under_guardian.dart 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import 'package:trackoffical_app/screen.dart';
  2. import 'widget_point.dart';
  3. import '../../../model/game_person_data.dart';
  4. import '../layer/layer_controller.dart';
  5. import '../layer/layer_trace.dart';
  6. import 'guardian_controller.dart';
  7. class LayerUnderGuardian extends GetView<LayerController> {
  8. LayerUnderGuardian(this.pointColorList, {super.key});
  9. final pointWidth = 43.0.wp;
  10. final pointHeight = 29.0.wp;
  11. final List<Color> pointColorList;
  12. @override
  13. Widget build(BuildContext context) {
  14. final c = controller;
  15. if(c is! GuardianControllerMock){
  16. return const SizedBox();
  17. }
  18. return Obx((){
  19. final children = <Widget>[
  20. SizedBox(width: context.width, height: context.height)
  21. ];
  22. var i = 0;
  23. for(var person in c.instance.gamePersonData){
  24. var p = person.myPositionOnMap;
  25. if(p != null){
  26. p = c.mapOffsetToScreen(p);
  27. children.add(Positioned(
  28. left: p.dx - pointWidth/2,
  29. top: p.dy - pointHeight,
  30. child: wPoint(pointColorList[i], person, (){
  31. c.setUserById(person.userId);
  32. })));
  33. }
  34. i++;
  35. if(i> pointColorList.length-1){
  36. i=pointColorList.length-1;
  37. }
  38. }
  39. return Stack(
  40. children: children,
  41. );
  42. });
  43. }
  44. Widget wPoint(Color color, GamePersonData data, VoidCallback onClick){
  45. final nextWantCP = data.nextWantPoint;
  46. var text = '';
  47. if(nextWantCP!= null){
  48. text = '正前往${nextWantCP.snString}点';
  49. }
  50. return GestureDetector(
  51. onTap: onClick,
  52. child: SizedBox(
  53. width: pointWidth,
  54. height: pointHeight,
  55. child: Column(
  56. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  57. children: [
  58. Container(
  59. height: 5.85.wp,
  60. width: pointWidth,
  61. decoration: BoxDecoration(color: color, borderRadius: BorderRadius.circular(3.0.wp)),
  62. padding: EdgeInsets.fromLTRB(2.6.wp, 0, 2.6.wp, 0),
  63. child: Row(
  64. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  65. crossAxisAlignment: CrossAxisAlignment.center,
  66. children: [
  67. SizedBox(width: 13.0.wp,
  68. child: Text(
  69. data.userName,
  70. style: TextStyle(fontSize: 3.5.wp, color: Colors.white),
  71. overflow: TextOverflow.clip,
  72. )),
  73. Text(text, style: TextStyle(fontSize: 3.5.wp, color: Colors.black)),
  74. Icon(Icons.arrow_forward_ios_rounded, size: 3.0.wp, color: Colors.white)
  75. ],
  76. ),
  77. ),
  78. WidgetPoint(width: 14.68.wp, height: 21.57.wp, color: color, imageBytes: data.userHead.value.data)
  79. ],
  80. ),
  81. ),
  82. );
  83. }
  84. }