add_friend_dialog.dart 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import 'dart:ui';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  5. import 'package:location/resource/assets.gen.dart';
  6. import 'package:location/resource/string.gen.dart';
  7. import 'package:location/utils/common_expand.dart';
  8. import 'package:location/utils/common_style.dart';
  9. class AddFriendDialog {
  10. static final String _tag = 'AddFriendDialog';
  11. static void show(
  12. {required VoidCallback onAddClick,
  13. VoidCallback? onCloseClick,
  14. VoidCallback? onNotAddDismiss}) {
  15. bool isClickAdd = false;
  16. SmartDialog.show(
  17. tag: _tag,
  18. onDismiss: () {
  19. if (!isClickAdd) {
  20. onNotAddDismiss?.call();
  21. }
  22. },
  23. builder: (_) {
  24. return AddFriendDialogView(
  25. onAddClick: () {
  26. isClickAdd = true;
  27. onAddClick();
  28. },
  29. onCloseClick: onCloseClick);
  30. });
  31. }
  32. static void dismiss() {
  33. SmartDialog.dismiss(tag: _tag);
  34. }
  35. }
  36. class AddFriendDialogView extends Dialog {
  37. final VoidCallback onAddClick;
  38. final VoidCallback? onCloseClick;
  39. const AddFriendDialogView({
  40. super.key,
  41. required this.onAddClick,
  42. this.onCloseClick,
  43. });
  44. @override
  45. Widget build(BuildContext context) {
  46. return IntrinsicHeight(
  47. child: Stack(
  48. children: [
  49. Center(
  50. child: Container(
  51. width: 289.w,
  52. margin: EdgeInsets.only(top: 34.w),
  53. decoration: BoxDecoration(
  54. color: Colors.white,
  55. borderRadius: BorderRadius.circular(20.w),
  56. ),
  57. child: IntrinsicHeight(
  58. child: Align(
  59. alignment: Alignment.topCenter,
  60. child: Stack(
  61. children: [
  62. SizedBox(
  63. width: double.infinity,
  64. child: Column(children: [
  65. SizedBox(height: 89.w),
  66. Text(StringName.dialogAddFriendTitle,
  67. style: TextStyle(
  68. fontSize: 18.sp,
  69. color: '#333333'.color,
  70. fontWeight: FontWeight.bold)),
  71. SizedBox(height: 8.w),
  72. Text(StringName.dialogAddFriendTitle,
  73. style: TextStyle(
  74. fontSize: 15.sp, color: '#404040'.color)),
  75. SizedBox(height: 23.w),
  76. GestureDetector(
  77. onTap: () {
  78. onAddClick();
  79. AddFriendDialog.dismiss();
  80. },
  81. child: Container(
  82. width: 229.w,
  83. height: 40.w,
  84. decoration: getPrimaryBtnDecoration(32.w),
  85. child: Center(
  86. child: Text(StringName.dialogAddFriendBtn,
  87. style: TextStyle(
  88. fontSize: 14.sp, color: Colors.white)),
  89. ),
  90. ),
  91. ),
  92. SizedBox(height: 22.w),
  93. ]),
  94. ),
  95. Align(
  96. alignment: Alignment.topRight,
  97. child: Container(
  98. margin: EdgeInsets.only(top: 12.w, right: 12.w),
  99. child: GestureDetector(
  100. onTap: () {
  101. onCloseClick?.call();
  102. AddFriendDialog.dismiss();
  103. },
  104. child: Assets.images.iconDialogClose
  105. .image(width: 20.w, height: 20.w),
  106. ),
  107. ))
  108. ],
  109. ),
  110. ),
  111. ),
  112. ),
  113. ),
  114. Align(
  115. alignment: Alignment.topCenter,
  116. child: Assets.images.iconDialogAddFriend.image(width: 124.w)),
  117. ],
  118. ),
  119. );
  120. }
  121. }