character_details_dialog.dart 9.8 KB

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