CarsCard.dart 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. import 'package:flutter/foundation.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:get/get.dart';
  5. import 'package:get/get_core/src/get_main.dart';
  6. import '../models/entities/CardInfo.dart';
  7. import '../models/entities/CardListModel.dart';
  8. import '../pages/OrderConfirmation/index.dart';
  9. import '../pages/machinery/detail/index.dart';
  10. import '../pages/machinery/map/index.dart';
  11. import 'LinearGradientText.dart';
  12. class CarsCard extends StatefulWidget {
  13. final CardListModel item;
  14. const CarsCard({Key? key, required this.item}) : super(key: key);
  15. @override
  16. _CarsCardPage createState() => _CarsCardPage(item);
  17. }
  18. class _CarsCardPage extends State<CarsCard> {
  19. final CardListModel item;
  20. _CarsCardPage(this.item);
  21. @override
  22. Widget build(BuildContext context) {
  23. return Container(
  24. margin: EdgeInsets.fromLTRB(0, 20, 0, 20),
  25. decoration: BoxDecoration(
  26. color: Color(0xfff2f2f2),
  27. ),
  28. width: 345.w,
  29. // height: 389.h,
  30. child: Column(
  31. children: [
  32. GestureDetector(
  33. onTap: () {
  34. Get.to(MachineryDetailPage(),arguments: {'id':item.machineryId});
  35. },
  36. child: Image.network(
  37. item.thumb.toString(),
  38. width: 345.w,
  39. height: 230.h,
  40. fit: BoxFit.cover,
  41. ),
  42. ),
  43. Container(
  44. padding: EdgeInsets.fromLTRB(15, 20, 0, 0),
  45. child: Row(
  46. crossAxisAlignment: CrossAxisAlignment.start,
  47. verticalDirection: VerticalDirection.up,
  48. children: <Widget>[
  49. Container(
  50. width: 210.w,
  51. child: Text(
  52. item.name.toString(),
  53. softWrap: true,
  54. textAlign: TextAlign.left,
  55. overflow: TextOverflow.ellipsis,
  56. style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
  57. ),
  58. ),
  59. ],
  60. ),
  61. ),
  62. Container(
  63. padding: const EdgeInsets.fromLTRB(19, 0, 0, 0),
  64. child: Row(
  65. crossAxisAlignment: CrossAxisAlignment.start,
  66. verticalDirection: VerticalDirection.up,
  67. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  68. children: <Widget>[
  69. Container(
  70. child: LinearGradientText(
  71. colors: const <Color>[
  72. Color(0xFFFA7878),
  73. Color(0xFFB61515),
  74. ],
  75. child: RichText(
  76. text: TextSpan(children: <InlineSpan>[
  77. TextSpan(
  78. text: (item.price! / 100).toString(),
  79. style: TextStyle(
  80. fontSize: 22,
  81. fontWeight: FontWeight.bold,
  82. )),
  83. TextSpan(
  84. text: "元/",
  85. style: TextStyle(
  86. fontSize: 22,
  87. fontWeight: FontWeight.bold,
  88. )),
  89. TextSpan(
  90. text: "公顷",
  91. style: TextStyle(
  92. fontSize: 12,
  93. fontWeight: FontWeight.bold,
  94. )),
  95. ]),
  96. ),
  97. ),
  98. ),
  99. Align(
  100. widthFactor: 1.2,
  101. heightFactor: 1.2,
  102. alignment: Alignment(1.2, -5),
  103. child: Container(
  104. margin: EdgeInsets.only(right: 13),
  105. width: 86.w, //+6
  106. height: 44.h, //+10
  107. child: ElevatedButton(
  108. onPressed: () {
  109. Get.toNamed('/orderConfirmation',
  110. arguments: {'machineryId': item.machineryId});
  111. },
  112. child: const Text(
  113. "预约",
  114. style: TextStyle(
  115. fontSize: 19,
  116. color: Colors.white,
  117. fontWeight: FontWeight.bold),
  118. ),
  119. style: ButtonStyle(
  120. backgroundColor:
  121. MaterialStateProperty.all(const Color(0xFFFF703B)),
  122. shape: MaterialStateProperty.all(
  123. const RoundedRectangleBorder(
  124. //这个0像素圆角style如果删掉的话,按钮会变成默认样式,自带圆角
  125. borderRadius:
  126. BorderRadius.all(Radius.circular(0)))),
  127. ),
  128. ),
  129. ),
  130. ),
  131. ],
  132. ),
  133. ),
  134. // 地址信息 进入地图
  135. Container(
  136. padding: EdgeInsets.fromLTRB(19, 20, 0, 10),
  137. child: Row(
  138. children: [
  139. Image.asset(
  140. "images/gpsImgae.png",
  141. width: 11.w,
  142. height: 13.h,
  143. fit: BoxFit.cover,
  144. ),
  145. Container(
  146. padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
  147. width: 300.w,
  148. child: Row(
  149. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  150. children: [
  151. Text(
  152. '距离当前位置2.6公里',
  153. style: TextStyle(
  154. fontSize: 15, fontWeight: FontWeight.bold),
  155. ),
  156. GestureDetector(
  157. child: Text(
  158. '进入地图 >>',
  159. style: TextStyle(
  160. fontSize: 15, fontWeight: FontWeight.bold),
  161. ),
  162. onTap: () {
  163. print('进入地图');
  164. Get.toNamed('/machineryMap',
  165. arguments: {'machineryId': item.machineryId});
  166. },
  167. )
  168. ],
  169. )),
  170. ],
  171. )),
  172. ],
  173. ),
  174. );
  175. }
  176. }