detail.dart 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/widgets.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:amap_flutter_base/amap_flutter_base.dart';
  5. import 'package:farmer_client/widgets/amap/amap.dart';
  6. Widget page({ required BuildContext context, required Size appbarSize, required void Function() handleClick}) {
  7. final _offset = 20.h;
  8. final width = MediaQuery.of(context).size.width;
  9. final height = MediaQuery.of(context).size.height
  10. - appbarSize.height
  11. - MediaQuery.of(context).padding.top;
  12. final mapHeight = height * 0.3;
  13. final cardHeight = (height - mapHeight) / 2 + _offset;
  14. final img = 'https://yz-websit.oss-cn-hangzhou.aliyuncs.com/xlk/index-icon19.jpg';
  15. final LatLng position = LatLng(32.690712, 112.091892);
  16. return Stack(
  17. alignment: Alignment.topCenter,
  18. children: [
  19. // 第一个组件用来撑满全屏
  20. SizedBox(
  21. width: width,
  22. height: height,
  23. ),
  24. SizedBox(
  25. width: width,
  26. height: mapHeight,
  27. child: AMap(position: position),
  28. ),
  29. Positioned(
  30. left: 0,
  31. top: mapHeight - _offset,
  32. height: cardHeight,
  33. child: _thumb(context, img),
  34. ),
  35. Positioned(
  36. left: 0,
  37. top: mapHeight + cardHeight - 2 * _offset,
  38. height: cardHeight,
  39. child: _content(context, handleClick),
  40. ),
  41. ],);
  42. }
  43. Widget _card(BuildContext context, Widget child) {
  44. final _border = 20.w;
  45. return Container(
  46. width: MediaQuery.of(context).size.width,
  47. clipBehavior: Clip.hardEdge,
  48. decoration: BoxDecoration(
  49. borderRadius: BorderRadius.vertical(top: Radius.circular(_border))
  50. ),
  51. child: child,
  52. );
  53. }
  54. Widget _thumb(BuildContext context, String imgUrl) {
  55. return _card(context, Image.network(imgUrl, fit: BoxFit.cover));
  56. }
  57. Widget _title() {
  58. return Row(
  59. children: [
  60. Expanded(
  61. child: Text("收割机001--S001",
  62. style: TextStyle(
  63. color: Color(0xFF222222),
  64. fontSize: 18.sp,
  65. )),
  66. flex: 1),
  67. Container(
  68. width: 100.w,
  69. alignment: Alignment.centerRight,
  70. child: Text("450元",
  71. style: TextStyle(
  72. color: Color(0xFFB61515),
  73. fontSize: 22.sp,
  74. )),
  75. )
  76. ],
  77. );
  78. }
  79. Widget _desc() {
  80. return Row(
  81. children: [
  82. Icon(Icons.location_on_outlined, size: 16.sp,),
  83. Expanded(
  84. flex: 1,
  85. child: Text("距离当前位置2.3公里 >>", style: TextStyle(color: Color(0xFF222222), fontSize: 15.sp),),
  86. ),
  87. ],
  88. );
  89. }
  90. Widget _detail() {
  91. return Container(
  92. alignment: Alignment.centerLeft,
  93. child: Text("农机手1的收割机", style: TextStyle(color: Color(0xFF222222), fontSize: 15.sp),),
  94. );
  95. }
  96. Widget _button(void Function() handleClick) {
  97. return ElevatedButton(
  98. child: const Text("预约"),
  99. style: ElevatedButton.styleFrom(
  100. primary: const Color(0xFFFF703B),
  101. textStyle: TextStyle(color: Colors.white, fontSize: 20.sp, letterSpacing: 5.sp),
  102. elevation: 0,
  103. minimumSize: Size(double.infinity, 49.w),
  104. shape: RoundedRectangleBorder(
  105. borderRadius: BorderRadius.all(Radius.circular(24.5.w)),
  106. )
  107. ),
  108. onPressed: handleClick,
  109. );
  110. }
  111. Widget _content(BuildContext context, void Function() handleClick) {
  112. return _card(context, Container(
  113. padding: EdgeInsets.only(top: 45.w, left: 15.w, right: 15.w, bottom: 20.w),
  114. decoration: const BoxDecoration(
  115. color: Colors.white,
  116. ),
  117. child: Column(
  118. children: [
  119. _title(),
  120. SizedBox(height: 20.h,),
  121. _desc(),
  122. SizedBox(height: 20.h,),
  123. _detail(),
  124. SizedBox(height: 20.h,),
  125. _button(handleClick),
  126. ],
  127. ),
  128. ));
  129. }