existing_member_hidden.dart 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. import 'package:flutter/material.dart';
  2. class ExistingMemberHidden extends StatefulWidget {
  3. const ExistingMemberHidden({Key? key}) : super(key: key);
  4. @override
  5. _ExistingMemberHiddenState createState() => _ExistingMemberHiddenState();
  6. }
  7. class _ExistingMemberHiddenState extends State<ExistingMemberHidden> {
  8. final List<Map<String, dynamic>> teaItems = [
  9. {
  10. 'type': '红茶',
  11. 'name': '黄山大红袍',
  12. 'price': '¥ 1999/两',
  13. 'sales': '9人购买',
  14. 'color': Colors.red,
  15. },
  16. {
  17. 'type': '绿茶',
  18. 'name': '西湖龙井',
  19. 'price': '¥ 999/两',
  20. 'sales': '0人购买',
  21. 'color': Colors.green,
  22. },
  23. {
  24. 'type': '青茶',
  25. 'name': '安溪铁观音',
  26. 'price': '¥ 666/两',
  27. 'sales': '9人购买',
  28. 'color': Colors.blue,
  29. },
  30. {
  31. 'type': '白茶',
  32. 'name': '徽州白毫',
  33. 'price': '¥ 500/斤',
  34. 'sales': '10人购买',
  35. 'color': Colors.white, // Assuming white text on a light grey background
  36. },
  37. {
  38. 'type': '黑茶',
  39. 'name': '滇池普洱茶',
  40. 'price': '¥ 1200/斤',
  41. 'sales': '99人购买',
  42. 'color': Colors.black,
  43. },
  44. {
  45. 'type': '黄茶',
  46. 'name': '平阳黄汤',
  47. 'price': '¥ 388/斤',
  48. 'sales': '110人购买',
  49. 'color': Colors.yellow[800],
  50. },
  51. ];
  52. @override
  53. Widget build(BuildContext context) {
  54. return Scaffold(
  55. appBar: AppBar(
  56. title: const Text('茶叶详情'),
  57. ),
  58. body: SingleChildScrollView(
  59. child: Column(
  60. crossAxisAlignment: CrossAxisAlignment.start,
  61. children: [
  62. // Header Section (Image Placeholder)
  63. Container(
  64. height: 200,
  65. color: Colors.grey[300],
  66. child: Center(
  67. child: Stack(
  68. alignment: Alignment.center,
  69. children: [
  70. // Placeholder mountain image (simplified)
  71. CustomPaint(
  72. painter: _MountainPainter(),
  73. size: const Size(double.infinity, 200),
  74. ),
  75. // Placeholder circle
  76. Container(
  77. width: 40,
  78. height: 40,
  79. decoration: BoxDecoration(
  80. color: Colors.grey[400],
  81. shape: BoxShape.circle,
  82. ),
  83. ),
  84. ],
  85. ),
  86. ),
  87. ),
  88. const SizedBox(height: 16.0),
  89. // Section Title
  90. const Padding(
  91. padding: EdgeInsets.symmetric(horizontal: 16.0),
  92. child: Text(
  93. '最新茶叶',
  94. style: TextStyle(
  95. fontSize: 20,
  96. fontWeight: FontWeight.bold,
  97. ),
  98. ),
  99. ),
  100. const SizedBox(height: 16.0),
  101. // Grid of Tea Items
  102. Padding(
  103. padding: const EdgeInsets.symmetric(horizontal: 16.0),
  104. child: GridView.builder(
  105. shrinkWrap: true,
  106. physics:
  107. const NeverScrollableScrollPhysics(), // Disable grid scrolling
  108. gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
  109. crossAxisCount: 2,
  110. crossAxisSpacing: 16.0,
  111. mainAxisSpacing: 16.0,
  112. childAspectRatio: 0.8, // Adjust as needed based on image
  113. ),
  114. itemCount: teaItems.length,
  115. itemBuilder: (context, index) {
  116. final item = teaItems[index];
  117. return _buildTeaItem(item);
  118. },
  119. ),
  120. ),
  121. const SizedBox(height: 16.0), // Add some space at the bottom
  122. ],
  123. ),
  124. ),
  125. );
  126. }
  127. Widget _buildTeaItem(Map<String, dynamic> item) {
  128. return Container(
  129. decoration: BoxDecoration(
  130. color: Colors.grey[200],
  131. borderRadius: BorderRadius.circular(8.0),
  132. ),
  133. child: Column(
  134. crossAxisAlignment: CrossAxisAlignment.start,
  135. children: [
  136. // Image Placeholder with tea type overlay
  137. Expanded(
  138. child: Container(
  139. decoration: BoxDecoration(
  140. color: Colors.grey[400],
  141. borderRadius:
  142. const BorderRadius.vertical(top: Radius.circular(8.0)),
  143. ),
  144. child: Center(
  145. child: Text(
  146. item['type'],
  147. style: TextStyle(
  148. fontSize: 24,
  149. fontWeight: FontWeight.bold,
  150. color: item['color'],
  151. ),
  152. ),
  153. ),
  154. ),
  155. ),
  156. Padding(
  157. padding: const EdgeInsets.all(8.0),
  158. child: Column(
  159. crossAxisAlignment: CrossAxisAlignment.start,
  160. children: [
  161. Text(
  162. item['name'],
  163. style: const TextStyle(
  164. fontSize: 16,
  165. fontWeight: FontWeight.bold,
  166. ),
  167. maxLines: 1,
  168. overflow: TextOverflow.ellipsis,
  169. ),
  170. const SizedBox(height: 4.0),
  171. Row(
  172. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  173. children: [
  174. Text(
  175. item['price'],
  176. style: TextStyle(
  177. fontSize: 14,
  178. color: Colors.red[700],
  179. fontWeight: FontWeight.bold,
  180. ),
  181. ),
  182. Text(
  183. item['sales'],
  184. style: TextStyle(
  185. fontSize: 12,
  186. color: Colors.grey[600],
  187. ),
  188. ),
  189. ],
  190. ),
  191. ],
  192. ),
  193. ),
  194. ],
  195. ),
  196. );
  197. }
  198. }
  199. // Custom painter for the simplified mountain range in the header
  200. class _MountainPainter extends CustomPainter {
  201. @override
  202. void paint(Canvas canvas, Size size) {
  203. final paint = Paint()
  204. ..color = Colors.blueGrey // Mountain color
  205. ..style = PaintingStyle.fill;
  206. final path = Path();
  207. path.moveTo(0, size.height * 0.6);
  208. path.lineTo(size.width * 0.2, size.height * 0.4);
  209. path.lineTo(size.width * 0.4, size.height * 0.7);
  210. path.lineTo(size.width * 0.6, size.height * 0.3);
  211. path.lineTo(size.width * 0.8, size.height * 0.5);
  212. path.lineTo(size.width, size.height * 0.4);
  213. path.lineTo(size.width, size.height);
  214. path.lineTo(0, size.height);
  215. path.close();
  216. canvas.drawPath(path, paint);
  217. }
  218. @override
  219. bool shouldRepaint(covariant CustomPainter oldDelegate) {
  220. return false;
  221. }
  222. }