track_daily_report_dialog.dart 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. import 'package:flutter/cupertino.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 'package:location/module/track/track_dialog/track_overlapping_avatars.dart';
  7. import 'package:location/resource/colors.gen.dart';
  8. import 'package:location/utils/common_expand.dart';
  9. import '../../../resource/assets.gen.dart';
  10. class TrackDailyReportDialog {
  11. static void show({
  12. VoidCallback? cancelOnTap,
  13. VoidCallback? confirmOnTap,}) {
  14. Get.dialog(
  15. SimpleDialog(
  16. titlePadding: EdgeInsets.zero,
  17. contentPadding: EdgeInsets.zero,
  18. insetPadding: EdgeInsets.zero,
  19. backgroundColor:Colors.transparent,
  20. children: [
  21. TrackDailyReportTipView(
  22. cancelOnTap: () {
  23. Get.back();
  24. cancelOnTap!();
  25. },
  26. confirmOnTap: confirmOnTap)
  27. ],
  28. )
  29. );
  30. }
  31. }
  32. class TrackDailyReportTipView extends StatefulWidget {
  33. final VoidCallback? cancelOnTap;
  34. final VoidCallback? confirmOnTap;
  35. const TrackDailyReportTipView({
  36. super.key,
  37. this.cancelOnTap,
  38. required this.confirmOnTap,
  39. });
  40. @override
  41. State<TrackDailyReportTipView> createState() => _TrackDailyReportTipViewState();
  42. }
  43. class _TrackDailyReportTipViewState extends State<TrackDailyReportTipView> {
  44. final List<String> avatarUrls = [
  45. 'https://picsum.photos/seed/avatar1/200/200',
  46. 'https://picsum.photos/seed/avatar2/200/200',
  47. 'https://picsum.photos/seed/avatar3/200/200',
  48. 'https://picsum.photos/seed/avatar4/200/200',
  49. 'https://picsum.photos/seed/avatar5/200/200',
  50. 'https://picsum.photos/seed/avatar5/200/200',
  51. 'https://picsum.photos/seed/avatar5/200/200',
  52. ];
  53. //计算出头像总共的宽度
  54. double _calculateTheTotalWithAvatar(List<String> avatarUrls) {
  55. var resultTotalW = 38.w;
  56. if (avatarUrls.length > 5) {
  57. resultTotalW = (avatarUrls.length - 1) * 29.w + 9.w;
  58. } else if (avatarUrls.length > 1) {
  59. resultTotalW = (avatarUrls.length - 1) * 29.w + 9.w;
  60. }
  61. return resultTotalW;
  62. }
  63. @override
  64. Widget build(BuildContext context) {
  65. // TODO: implement build
  66. return Container(
  67. width: 1.sw,
  68. margin: EdgeInsets.symmetric(horizontal: 43.w),
  69. child: IntrinsicHeight(
  70. child: Column(
  71. children: [
  72. Container(
  73. decoration: BoxDecoration(
  74. color: Colors.transparent,
  75. image: DecorationImage(
  76. image: Assets.images.iconTrackDailyReport.provider(),
  77. fit: BoxFit.fill,
  78. )
  79. ),
  80. child: Column(
  81. children: [
  82. SizedBox(
  83. height: 146.w,
  84. ),
  85. Container(
  86. height: 38.w,
  87. width: _calculateTheTotalWithAvatar(avatarUrls),
  88. child: OverlappingAvatars(
  89. avatarUrls: avatarUrls,
  90. size: 38.w,
  91. overlap: 0.763,
  92. borderColor: "#A287FF".color,
  93. maxDisplay: 5,
  94. ),
  95. ),
  96. SizedBox(
  97. height: 8.w,
  98. ),
  99. Text("昨日轨迹报告",
  100. style: TextStyle(
  101. fontSize: 13.sp,
  102. color: '#57577E'.color,
  103. fontWeight: FontWeight.w700)
  104. ),
  105. SizedBox(
  106. height: 46.w,
  107. ),
  108. GestureDetector(
  109. onTap: () {
  110. Get.back();
  111. widget.confirmOnTap!();
  112. },
  113. child: Container(
  114. decoration: BoxDecoration(
  115. gradient: LinearGradient(
  116. begin: Alignment.centerLeft, // 90度相当于从左到右
  117. end: Alignment.centerRight,
  118. colors: [
  119. Color(0xFF7B7DFF), // #7B7DFF
  120. Color(0xFF6365FF), // #6365FF
  121. ],
  122. stops: [0.0, 1.0],
  123. // 从0%到100%
  124. ),
  125. borderRadius: BorderRadius.circular(40.w / 2.0),
  126. ),
  127. margin: EdgeInsets.symmetric(horizontal: 20.w),
  128. height: 40.w,
  129. alignment: Alignment.center,
  130. child: Text("立即查看",
  131. style: TextStyle(
  132. fontSize: 14.sp,
  133. color: '#FFFFFF'.color,
  134. fontWeight: FontWeight.w500)
  135. ),
  136. ),
  137. ),
  138. SizedBox(
  139. height: 10.w,
  140. ),
  141. GestureDetector(
  142. onTap: widget.cancelOnTap,
  143. child: Container(
  144. height: 20.w,
  145. child: Text("下次再说",
  146. style: TextStyle(
  147. fontSize: 11.sp,
  148. color: '#898996'.color,
  149. fontWeight: FontWeight.w500)
  150. ),
  151. ),
  152. ),
  153. SizedBox(
  154. height: 12.w,
  155. ),
  156. ],
  157. ),
  158. )
  159. ],
  160. ),
  161. ),
  162. );
  163. }
  164. }