friend_update_remark_dialog.dart 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  4. import 'package:get/get.dart';
  5. import 'package:location/resource/assets.gen.dart';
  6. import 'package:location/resource/colors.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. import 'package:location/utils/toast_util.dart';
  11. typedef FriendUpdateRemarkCallback = void Function(String remark);
  12. class FriendUpdateRemarkDialog {
  13. static const String _tag = "FriendUpdateRemarkDialog";
  14. static void show(
  15. {String? remark, required FriendUpdateRemarkCallback callback}) {
  16. SmartDialog.show(
  17. builder: (_) {
  18. return FriendUpdateRemarkView(
  19. remark: remark,
  20. callback: callback,
  21. );
  22. },
  23. tag: _tag);
  24. }
  25. static void dismiss() {
  26. SmartDialog.dismiss(tag: _tag);
  27. }
  28. }
  29. class FriendUpdateRemarkView extends Dialog {
  30. final FriendUpdateRemarkCallback callback;
  31. final String? remark;
  32. final Rx<String> _remark = Rx<String>('');
  33. final TextEditingController editingController = TextEditingController();
  34. FriendUpdateRemarkView({super.key, required this.callback, this.remark}) {
  35. editingController.addListener(() {
  36. _remark.value = editingController.text;
  37. });
  38. editingController.text = remark ?? '';
  39. }
  40. @override
  41. Widget build(BuildContext context) {
  42. return IntrinsicHeight(
  43. child: Container(
  44. width: 307.w,
  45. decoration: BoxDecoration(
  46. color: Colors.white,
  47. borderRadius: BorderRadius.circular(20.w),
  48. ),
  49. child: Stack(
  50. children: [
  51. Positioned(
  52. top: 12.w,
  53. right: 12.w,
  54. child: GestureDetector(
  55. onTap: () {
  56. FriendUpdateRemarkDialog.dismiss();
  57. },
  58. child: Assets.images.iconDialogClose
  59. .image(width: 24.w, height: 24.w))),
  60. Column(
  61. children: [
  62. SizedBox(height: 27.w),
  63. Text(StringName.friendUpdateRemarkTitle,
  64. style: TextStyle(
  65. fontSize: 18.sp,
  66. color: ColorName.black90,
  67. fontWeight: FontWeight.bold)),
  68. SizedBox(height: 20.w),
  69. Container(
  70. padding: EdgeInsets.symmetric(horizontal: 12.w),
  71. decoration: BoxDecoration(
  72. color: '#F9F9F9'.color,
  73. borderRadius: BorderRadius.circular(10.w)),
  74. margin: EdgeInsets.symmetric(horizontal: 22.w),
  75. child: Row(
  76. children: [
  77. Expanded(
  78. child: TextField(
  79. controller: editingController,
  80. style: TextStyle(
  81. fontSize: 14.sp,
  82. color: ColorName.primaryTextColor),
  83. maxLines: 1,
  84. maxLength: 11,
  85. keyboardType: TextInputType.text,
  86. textAlignVertical: TextAlignVertical.center,
  87. textInputAction: TextInputAction.next,
  88. decoration: InputDecoration(
  89. hintText: StringName.friendUpdateRemarkHint,
  90. counterText: '',
  91. hintStyle: TextStyle(
  92. fontSize: 14, color: "#AAAAAA".toColor()),
  93. labelStyle: const TextStyle(
  94. fontSize: 14,
  95. color: ColorName.primaryTextColor,
  96. ),
  97. contentPadding: const EdgeInsets.all(0),
  98. border: const OutlineInputBorder(
  99. borderSide: BorderSide.none)))),
  100. Obx(() {
  101. return Text(
  102. _remark.value.isEmpty
  103. ? '0'
  104. : _remark.value.length.toString(),
  105. style: TextStyle(
  106. fontSize: 14.sp,
  107. color: _remark.value.isNotEmpty
  108. ? ColorName.black90
  109. : '#AAAAAA'.color));
  110. }),
  111. Text('/',
  112. style: TextStyle(
  113. fontSize: 14.sp, color: '#AAAAAA'.color)),
  114. Text('11',
  115. style: TextStyle(
  116. fontSize: 14.sp, color: '#AAAAAA'.color))
  117. ],
  118. ),
  119. ),
  120. SizedBox(height: 20.w),
  121. GestureDetector(
  122. onTap: () {
  123. callback(_remark.value);
  124. },
  125. child: Container(
  126. width: 229.w,
  127. height: 43.w,
  128. decoration: getPrimaryBtnDecoration(46.w),
  129. child: Center(
  130. child: Text(StringName.dialogSure,
  131. style: TextStyle(
  132. fontSize: 14.sp,
  133. color: Colors.white,
  134. fontWeight: FontWeight.bold)),
  135. ),
  136. ),
  137. ),
  138. SizedBox(height: 20.w)
  139. ],
  140. )
  141. ],
  142. ),
  143. ),
  144. );
  145. }
  146. }