view.dart 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import 'package:electronic_assistant/base/base_page.dart';
  2. import 'package:electronic_assistant/resource/assets.gen.dart';
  3. import 'package:electronic_assistant/resource/colors.gen.dart';
  4. import 'package:electronic_assistant/resource/string.gen.dart';
  5. import 'package:electronic_assistant/utils/expand.dart';
  6. import 'package:flutter/material.dart';
  7. import 'package:flutter_screenutil/flutter_screenutil.dart';
  8. import 'package:get/get.dart';
  9. import 'controller.dart';
  10. class HomePage extends BasePage<HomePageController> {
  11. const HomePage({super.key});
  12. @override
  13. Widget? buildBody(BuildContext context) {
  14. return Stack(
  15. children: [
  16. buildBgBox(),
  17. buildTopGradient(),
  18. SafeArea(
  19. child: Column(
  20. children: [
  21. Container(
  22. width: 1.sw,
  23. padding: const EdgeInsets.all(12).w,
  24. child: buildOperationBar(),
  25. ),
  26. Expanded(
  27. child: CustomScrollView(
  28. slivers: [
  29. SliverToBoxAdapter(
  30. child: Column(
  31. children: [
  32. SizedBox(height: 7.h),
  33. Padding(
  34. padding: const EdgeInsets.symmetric(horizontal: 12).w,
  35. child: Row(
  36. crossAxisAlignment: CrossAxisAlignment.center,
  37. children: [
  38. Text(StringName.homeTalkRecord.tr,
  39. style: TextStyle(
  40. fontWeight: FontWeight.bold,
  41. fontSize: 17.sp,
  42. color: ColorName.primaryTextColor)),
  43. const Spacer(),
  44. GestureDetector(
  45. onTap: () {},
  46. child: Row(
  47. crossAxisAlignment: CrossAxisAlignment.center,
  48. children: [
  49. Text(
  50. StringName.homeTalkSeeAll.tr,
  51. style: TextStyle(
  52. fontSize: 13.sp,
  53. color: ColorName.secondaryTextColor),
  54. ),
  55. SizedBox(
  56. width: 16.w,
  57. height: 16.w,
  58. child: Assets.images.iconHomeTalkArrow
  59. .image()),
  60. ],
  61. ),
  62. )
  63. ],
  64. ),
  65. ),
  66. SizedBox(height: 12.h),
  67. ],
  68. ),
  69. ),
  70. SliverList(
  71. delegate: SliverChildBuilderDelegate(
  72. (context, index) {
  73. return ListTile(
  74. title: Text('Item $index'),
  75. );
  76. },
  77. childCount: 20, // 列表项的数量
  78. ),
  79. ),
  80. SliverToBoxAdapter(
  81. child: Container(
  82. padding: EdgeInsets.all(16),
  83. color: Colors.green,
  84. child: Text('尾部', style: TextStyle(color: Colors.white)),
  85. ),
  86. ),
  87. ],
  88. ))
  89. ],
  90. ),
  91. )
  92. ],
  93. );
  94. }
  95. Row buildOperationBar() {
  96. return Row(children: [
  97. GestureDetector(
  98. onTap: () {},
  99. child: Row(
  100. children: [
  101. SizedBox(
  102. width: 0.1.sw,
  103. height: 0.1.sw,
  104. child: Assets.images.iconHomeLogged.image()),
  105. SizedBox(width: 8.w),
  106. Text(StringName.homeGoLogin.tr,
  107. style: TextStyle(
  108. fontWeight: FontWeight.bold,
  109. fontSize: 15.sp,
  110. color: ColorName.primaryTextColor))
  111. ],
  112. ),
  113. ),
  114. const Spacer(),
  115. GestureDetector(
  116. child: DecoratedBox(
  117. decoration: BoxDecoration(
  118. color: Colors.white,
  119. borderRadius: BorderRadius.circular(16),
  120. ),
  121. child: Padding(
  122. padding:
  123. const EdgeInsets.symmetric(horizontal: 8, vertical: 2).w,
  124. child: Row(
  125. crossAxisAlignment: CrossAxisAlignment.center,
  126. children: [
  127. SizedBox(
  128. width: 28.w,
  129. height: 28.w,
  130. child: Assets.images.iconCharge.image()),
  131. SizedBox(width: 4.w),
  132. SizedBox(
  133. width: 28.w,
  134. child: Assets.images.iconChargeTxt.image()),
  135. SizedBox(
  136. width: 12.w,
  137. height: 12.w,
  138. child: Assets.images.iconChargeArrow.image()),
  139. ],
  140. ),
  141. )),
  142. onTap: () {})
  143. ]);
  144. }
  145. Container buildTopGradient() {
  146. return Container(
  147. width: 1.sw,
  148. height: 0.4444444444444444.sw,
  149. decoration: BoxDecoration(
  150. gradient: LinearGradient(
  151. colors: ['#E8EBFF'.toColor(), '#00E8EBFF'.toColor()],
  152. begin: Alignment.topCenter,
  153. end: Alignment.bottomCenter,
  154. stops: const [0.3, 1.0],
  155. ),
  156. ) // 其他子小部件
  157. );
  158. }
  159. DecoratedBox buildBgBox() {
  160. return DecoratedBox(
  161. decoration: BoxDecoration(color: '#F6F6F6'.toColor()),
  162. child: Container(
  163. height: double.infinity,
  164. ));
  165. }
  166. }