character_details_dialog.dart 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. Column(
  105. crossAxisAlignment: CrossAxisAlignment.start,
  106. children: [
  107. Row(
  108. children: [
  109. Text(
  110. characterInfo.name ?? "",
  111. style: TextStyle(
  112. color: Colors.black.withAlpha(204),
  113. fontSize: 14.sp,
  114. fontWeight: FontWeight.w700,
  115. ),
  116. ),
  117. SizedBox(width: 4.w),
  118. characterInfo.isVip == true
  119. ? Assets.images.iconCharacterVip
  120. .image(width: 38.w, height: 16.h)
  121. : Container(),
  122. ],
  123. ),
  124. Text(
  125. characterInfo.description ?? "",
  126. style: TextStyle(
  127. color: Colors.black.withAlpha(153),
  128. fontSize: 12.sp,
  129. fontWeight: FontWeight.w400,
  130. ),
  131. ),
  132. ],
  133. ),
  134. ],
  135. ),
  136. ],
  137. ),
  138. ),
  139. SizedBox(height: 24.h),
  140. GestureDetector(
  141. onTap: () {
  142. clickCallback.call();
  143. SmartDialog.dismiss(tag: tag);
  144. },
  145. child: Container(
  146. margin: EdgeInsets.symmetric(horizontal: 30.w),
  147. width: double.infinity,
  148. height: 48.h,
  149. decoration: BoxDecoration(
  150. borderRadius: BorderRadius.circular(50.r),
  151. gradient:
  152. characterInfo.isAdd == true
  153. ? null
  154. : const LinearGradient(
  155. colors: [
  156. Color(0xFF7D46FC),
  157. Color(0xFFBC87FF),
  158. ],
  159. begin: Alignment.topLeft,
  160. end: Alignment.bottomRight,
  161. ),
  162. color:
  163. characterInfo.isAdd == true
  164. ? const Color(0xFFEDE8FF)
  165. : null,
  166. ),
  167. child: Row(
  168. mainAxisAlignment: MainAxisAlignment.center,
  169. children: [
  170. if (characterInfo.isLock == true &&
  171. characterInfo.isVip == true)
  172. Padding(
  173. padding: EdgeInsets.only(right: 2.w),
  174. child: Assets.images.iconCharacterLock.image(
  175. width: 18.r,
  176. height: 18.r,
  177. ), // 锁定图标
  178. ),
  179. Text(
  180. characterInfo.isAdd == true
  181. ? StringName.addedToKeyboard
  182. : StringName.addToKeyboard,
  183. style: TextStyle(
  184. color:
  185. characterInfo.isAdd == true
  186. ? const Color(0xFF7D46FC)
  187. : Colors.white,
  188. fontSize: 14.sp,
  189. fontWeight: FontWeight.w500,
  190. ),
  191. ),
  192. ],
  193. ),
  194. ),
  195. ),
  196. ],
  197. ),
  198. ),
  199. Container(
  200. margin: EdgeInsets.only(top: 24.h),
  201. child: GestureDetector(
  202. onTap: () {
  203. SmartDialog.dismiss(tag: tag);
  204. },
  205. child: Assets.images.iconCharacterDialogClose.image(
  206. width: 40.r,
  207. height: 40.r,
  208. ),
  209. ),
  210. ),
  211. ],
  212. ),
  213. );
  214. },
  215. );
  216. }
  217. }