character_details_dialog.dart 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. import 'package:cached_network_image/cached_network_image.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_screenutil/flutter_screenutil.dart';
  5. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  6. import 'package:keyboard/resource/string.gen.dart';
  7. import '../data/bean/character_info.dart';
  8. import '../resource/assets.gen.dart';
  9. import '../resource/colors.gen.dart';
  10. class CharacterDetailsDialog {
  11. static const String tag = 'CharacterDetailsDialog';
  12. static void show({
  13. required CharacterInfo characterInfo,
  14. required VoidCallback clickCallback,
  15. }) {
  16. SmartDialog.show(
  17. tag: tag,
  18. backType: SmartBackType.block,
  19. clickMaskDismiss: false,
  20. maskColor: ColorName.black70,
  21. builder: (_) {
  22. return SizedBox(
  23. width: double.infinity,
  24. height: double.infinity,
  25. child: Column(
  26. mainAxisAlignment: MainAxisAlignment.center,
  27. children: [
  28. Container(
  29. margin: EdgeInsets.only(left: 30.w, right: 30.w),
  30. padding: EdgeInsets.only(bottom: 28.h),
  31. alignment: Alignment.topCenter,
  32. width: double.infinity,
  33. decoration: BoxDecoration(
  34. image: DecorationImage(
  35. image: Assets.images.bgCharacterDialog.provider(),
  36. fit: BoxFit.cover,
  37. ),
  38. borderRadius: BorderRadius.circular(20.r),
  39. ),
  40. child: Column(
  41. children: [
  42. Container(
  43. padding: EdgeInsets.only(
  44. top: 12.h,
  45. left: 12.w,
  46. right: 12.w,
  47. bottom: 12.h,
  48. ),
  49. margin: EdgeInsets.only(
  50. left: 20.w,
  51. right: 20.w,
  52. top: 20.h,
  53. ),
  54. width: double.infinity,
  55. decoration: ShapeDecoration(
  56. color: Colors.white,
  57. shape: RoundedRectangleBorder(
  58. borderRadius: BorderRadius.circular(20.r),
  59. ),
  60. shadows: [
  61. BoxShadow(
  62. color: const Color(0xFFDDE2F9),
  63. blurRadius: 10.r,
  64. offset: Offset(0, 4),
  65. spreadRadius: 0,
  66. ),
  67. ],
  68. ),
  69. child: Column(
  70. crossAxisAlignment: CrossAxisAlignment.center,
  71. mainAxisAlignment: MainAxisAlignment.start,
  72. children: [
  73. Container(
  74. padding: EdgeInsets.only(
  75. top: 20.h,
  76. left: 20.w,
  77. right: 20.w,
  78. ),
  79. height: 236.w,
  80. width: 236.w,
  81. decoration: BoxDecoration(
  82. image: DecorationImage(
  83. image:
  84. Assets.images.bgCharacterDialogImage
  85. .provider(),
  86. fit: BoxFit.fill,
  87. ),
  88. borderRadius: BorderRadius.circular(20.r),
  89. ),
  90. child: CachedNetworkImage(
  91. imageUrl: characterInfo.imageUrl ?? "",
  92. fit: BoxFit.fill,
  93. ),
  94. ),
  95. SizedBox(height: 10.h),
  96. Row(
  97. crossAxisAlignment: CrossAxisAlignment.start,
  98. children: [
  99. Assets.images.iconCharacterDialogLogo.image(
  100. width: 32.r,
  101. height: 32.r,
  102. ),
  103. SizedBox(width: 10.w),
  104. Expanded(
  105. child: Column(
  106. crossAxisAlignment: CrossAxisAlignment.start,
  107. children: [
  108. Row(
  109. children: [
  110. Text(
  111. characterInfo.name ?? "",
  112. style: TextStyle(
  113. color: Colors.black.withAlpha(204),
  114. fontSize: 14.sp,
  115. fontWeight: FontWeight.w700,
  116. ),
  117. ),
  118. SizedBox(width: 4.w),
  119. characterInfo.isVip == true
  120. ? Assets.images.iconCharacterVip
  121. .image(
  122. width: 38.w,
  123. height: 16.h,
  124. )
  125. : Container(),
  126. ],
  127. ),
  128. Text(
  129. characterInfo.description ?? "",
  130. softWrap: true,
  131. style: TextStyle(
  132. color: Colors.black.withAlpha(153),
  133. fontSize: 12.sp,
  134. fontWeight: FontWeight.w400,
  135. ),
  136. ),
  137. ],
  138. ),
  139. ),
  140. ],
  141. ),
  142. ],
  143. ),
  144. ),
  145. SizedBox(height: 24.h),
  146. GestureDetector(
  147. onTap: () {
  148. clickCallback.call();
  149. SmartDialog.dismiss(tag: tag);
  150. },
  151. child: Container(
  152. margin: EdgeInsets.symmetric(horizontal: 30.w),
  153. width: double.infinity,
  154. height: 48.h,
  155. decoration: BoxDecoration(
  156. borderRadius: BorderRadius.circular(50.r),
  157. gradient:
  158. characterInfo.isAdd == true
  159. ? null
  160. : const LinearGradient(
  161. colors: [
  162. Color(0xFF7D46FC),
  163. Color(0xFFBC87FF),
  164. ],
  165. begin: Alignment.topLeft,
  166. end: Alignment.bottomRight,
  167. ),
  168. color:
  169. characterInfo.isAdd == true
  170. ? const Color(0xFFEDE8FF)
  171. : null,
  172. ),
  173. child: Row(
  174. mainAxisAlignment: MainAxisAlignment.center,
  175. children: [
  176. if (characterInfo.isLock == true &&
  177. characterInfo.isVip == true)
  178. Padding(
  179. padding: EdgeInsets.only(right: 2.w),
  180. child: Assets.images.iconCharacterLock.image(
  181. width: 18.r,
  182. height: 18.r,
  183. ), // 锁定图标
  184. ),
  185. Text(
  186. characterInfo.isAdd == true
  187. ? StringName.addedToKeyboard
  188. : StringName.addToKeyboard,
  189. style: TextStyle(
  190. color:
  191. characterInfo.isAdd == true
  192. ? const Color(0xFF7D46FC)
  193. : Colors.white,
  194. fontSize: 14.sp,
  195. fontWeight: FontWeight.w500,
  196. ),
  197. ),
  198. ],
  199. ),
  200. ),
  201. ),
  202. ],
  203. ),
  204. ),
  205. Container(
  206. margin: EdgeInsets.only(top: 24.h),
  207. child: GestureDetector(
  208. onTap: () {
  209. SmartDialog.dismiss(tag: tag);
  210. },
  211. child: Assets.images.iconCharacterDialogClose.image(
  212. width: 40.r,
  213. height: 40.r,
  214. ),
  215. ),
  216. ),
  217. ],
  218. ),
  219. );
  220. },
  221. );
  222. }
  223. }