CarsCard.dart 6.3KB

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