detail.dart 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. import '../../widgets/summary.dart';
  7. Widget page({ required BuildContext context, required Size appbarSize, required void Function() handleClick}) {
  8. final _offset = 20.w;
  9. final width = MediaQuery.of(context).size.width;
  10. final height = MediaQuery.of(context).size.height
  11. - appbarSize.height
  12. - MediaQuery.of(context).padding.top;
  13. final mapHeight = height * 0.3;
  14. final cardHeight = (height - mapHeight) / 2 + _offset;
  15. final img = 'https://yz-websit.oss-cn-hangzhou.aliyuncs.com/xlk/index-icon19.jpg';
  16. final LatLng position = LatLng(32.690712, 112.091892);
  17. return Stack(
  18. alignment: Alignment.topCenter,
  19. children: [
  20. // 第一个组件用来撑满全屏
  21. SizedBox(
  22. width: width,
  23. height: height,
  24. ),
  25. SizedBox(
  26. width: width,
  27. height: mapHeight,
  28. child: AMap(position: position),
  29. ),
  30. Positioned(
  31. left: 0,
  32. top: mapHeight - _offset,
  33. height: cardHeight,
  34. child: _thumb(context, img),
  35. ),
  36. Positioned(
  37. left: 0,
  38. top: mapHeight + cardHeight - 2 * _offset,
  39. height: cardHeight,
  40. child: _content(context, handleClick),
  41. ),
  42. ],);
  43. }
  44. Widget _card(BuildContext context, Widget child) {
  45. final _border = 20.w;
  46. return Container(
  47. width: MediaQuery.of(context).size.width,
  48. clipBehavior: Clip.hardEdge,
  49. decoration: BoxDecoration(
  50. borderRadius: BorderRadius.vertical(top: Radius.circular(_border))
  51. ),
  52. child: child,
  53. );
  54. }
  55. Widget _thumb(BuildContext context, String imgUrl) {
  56. return _card(context, Image.network(imgUrl, fit: BoxFit.cover));
  57. }
  58. Widget _button(void Function() handleClick) {
  59. return ElevatedButton(
  60. child: const Text("预约"),
  61. style: ElevatedButton.styleFrom(
  62. primary: const Color(0xFFFF703B),
  63. textStyle: TextStyle(color: Colors.white, fontSize: 20.sp, letterSpacing: 5.sp),
  64. elevation: 0,
  65. minimumSize: Size(double.infinity, 49.w),
  66. shape: RoundedRectangleBorder(
  67. borderRadius: BorderRadius.all(Radius.circular(24.5.w)),
  68. )
  69. ),
  70. onPressed: handleClick,
  71. );
  72. }
  73. Widget _content(BuildContext context, void Function() handleClick) {
  74. return _card(context, Container(
  75. padding: EdgeInsets.only(top: 45.w, left: 15.w, right: 15.w, bottom: 20.w),
  76. decoration: const BoxDecoration(
  77. color: Colors.white,
  78. ),
  79. child: Column(
  80. children: [
  81. summary(),
  82. _button(handleClick),
  83. ],
  84. ),
  85. ));
  86. }