123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:get/get.dart';
- import '../models/entities/CardListModel.dart';
- import '../pages/machinery/detail/index.dart';
- import 'LinearGradientText.dart';
-
- class CarsCard extends StatefulWidget {
- final CardListModel item;
-
- const CarsCard({Key? key, required this.item}) : super(key: key);
-
- @override
- _CarsCardPage createState() => _CarsCardPage();
- }
-
- class _CarsCardPage extends State<CarsCard> {
- // final CardListModel item;
- // _CarsCardPage(this.item);
- setMorKm() {
- String n = '';
- if (widget.item.distance != null) {
- if ((widget.item.distance ?? 0) >= 1000) {
- n = ((widget.item.distance ?? 0) / 1000).toStringAsFixed(2).toString() +
- '公里';
- } else {
- n = widget.item.distance.toString() + '米';
- }
- } else {
- n = '0m';
- }
- return n;
- }
-
- @override
- Widget build(BuildContext context) {
- print(widget.item);
-
- return Container(
- margin: EdgeInsets.fromLTRB(0, 20, 0, 20),
- decoration: BoxDecoration(
- color: Color(0xfff2f2f2),
- ),
- width: 345.w,
- // height: 389.h,
- child: Column(
- children: [
- GestureDetector(
- onTap: () {
- Get.to(MachineryDetailPage(), arguments: {
- 'id': widget.item.machineryId,
- 'km': setMorKm().toString()
- });
- },
- child: Image.network(
- widget.item.thumb.toString(),
- width: 345.w,
- height: 230.h,
- fit: BoxFit.cover,
- ),
- ),
-
- Container(
- padding: EdgeInsets.fromLTRB(15, 20, 0, 0),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- verticalDirection: VerticalDirection.up,
- children: <Widget>[
- Container(
- width: 210.w,
- child: Text(
- widget.item.name.toString(),
- softWrap: true,
- textAlign: TextAlign.left,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
- ),
- ),
- ],
- ),
- ),
- Container(
- padding: const EdgeInsets.fromLTRB(19, 0, 0, 0),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- verticalDirection: VerticalDirection.up,
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Container(
- child: LinearGradientText(
- colors: const <Color>[
- Color(0xFFFA7878),
- Color(0xFFB61515),
- ],
- child: RichText(
- text: TextSpan(children: <InlineSpan>[
- TextSpan(
- text: (widget.item.price! / 100).toString(),
- style: TextStyle(
- fontSize: 22,
- fontWeight: FontWeight.bold,
- )),
- TextSpan(
- text: "元/",
- style: TextStyle(
- fontSize: 22,
- fontWeight: FontWeight.bold,
- )),
- TextSpan(
- text: "亩",
- style: TextStyle(
- fontSize: 12,
- fontWeight: FontWeight.bold,
- )),
- ]),
- ),
- ),
- ),
- Align(
- widthFactor: 1.2,
- heightFactor: 1.2,
- alignment: Alignment(1.2, -5),
- child: Container(
- margin: EdgeInsets.only(right: 13),
- width: 86.w, //+6
- height: 44.h, //+10
- child: ElevatedButton(
- onPressed: () {
- Get.toNamed('/orderConfirmation',
- arguments: {'id': widget.item.machineryId});
- },
- child: const Text(
- "预约",
- style: TextStyle(
- fontSize: 19,
- color: Colors.white,
- fontWeight: FontWeight.bold),
- ),
- style: ButtonStyle(
- backgroundColor:
- MaterialStateProperty.all(const Color(0xFFFF703B)),
- shape: MaterialStateProperty.all(
- const RoundedRectangleBorder(
- //这个0像素圆角style如果删掉的话,按钮会变成默认样式,自带圆角
- borderRadius:
- BorderRadius.all(Radius.circular(0)))),
- ),
- ),
- ),
- ),
- ],
- ),
- ),
- // 地址信息 进入地图
- Container(
- padding: EdgeInsets.fromLTRB(19, 20, 0, 10),
- child: Row(
- children: [
- Image.asset(
- "images/gpsImgae.png",
- width: 11.w,
- height: 13.h,
- fit: BoxFit.cover,
- ),
- Container(
- padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
- width: 300.w,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Container(
- child: Row(
- children: [
- Text(
- '距离当前位置',
- style: TextStyle(
- fontSize: 15,
- fontWeight: FontWeight.bold),
- ),
- Text(
- setMorKm().toString(),
- style: TextStyle(
- fontSize: 15,
- fontWeight: FontWeight.bold),
- ),
- ],
- ),
- ),
- GestureDetector(
- child: Text(
- '进入地图 >>',
- style: TextStyle(
- fontSize: 15, fontWeight: FontWeight.bold),
- ),
- onTap: () {
- print('进入地图');
- Get.toNamed('/machineryMap', arguments: {
- 'id': widget.item.machineryId,
- 'km': setMorKm().toString()
- });
- },
- )
- ],
- )),
- ],
- )),
- ],
- ),
- );
- }
- }
|