friend_dialog.dart 4.5 KB

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