project.dart 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import 'package:fixnum/fixnum.dart';
  2. import 'package:get/get.dart';
  3. import 'm_net_image.dart';
  4. import 'm_position.dart';
  5. import 'package:trackoffical_app/pb.dart' as pb;
  6. class ProjectInfo {
  7. Int64 id = Int64(0);
  8. // 方案图片
  9. MNetImage pic = MNetImage();
  10. String name = "";
  11. String address = "";
  12. MPosition position = MPosition();
  13. // 项目介绍
  14. String introduction = "";
  15. // 及格线,关门时间
  16. Duration passLine = 0.seconds;
  17. // 结束时限
  18. Duration deadLine = 0.seconds;
  19. int totalControlNum = 0;
  20. // 直线距离:米
  21. int straightLineDistance = 0;
  22. bool isInGame = false;
  23. // 地图图片
  24. MNetImage image = MNetImage();
  25. // 比例尺
  26. int mapScale = 0;
  27. // 等高距(米)
  28. int contourIntervalM = 0;
  29. List<MapRoute> routes = [];
  30. }
  31. class MapRoute {
  32. Int64 id = Int64(0);
  33. String name = "";
  34. MNetImage image = MNetImage();
  35. }
  36. extension PbProjectInfoExtension on pb.ProjectInfoSimple {
  37. ProjectInfo toModel() {
  38. return ProjectInfo()
  39. ..id = rsId
  40. ..name = rsName
  41. ..address = addr
  42. ..pic = projectImage.toModel()
  43. ..position = position.toModel()
  44. ..isInGame = isInGame;
  45. }
  46. }
  47. extension PbProjectDetailExtension on pb.ProjectDetailReply {
  48. ProjectInfo toModel() {
  49. final out = baseInfo.toModel();
  50. out.introduction = content;
  51. out.passLine = lockup.seconds;
  52. out.deadLine = forcedEntTime.seconds;
  53. out.totalControlNum = totalControlNum;
  54. out.straightLineDistance = maxRange;
  55. out.image = image.toModel();
  56. out.mapScale = mapScaleNumber;
  57. out.contourIntervalM = contourInterval;
  58. out.routes = routes
  59. .map((m) => MapRoute()
  60. ..id = m.id
  61. ..name = m.name
  62. ..image = m.image.toModel())
  63. .toList();
  64. return out;
  65. }
  66. }