import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:location/resource/assets.gen.dart'; import 'package:location/resource/colors.gen.dart'; import 'package:location/resource/string.gen.dart'; import 'package:location/utils/common_expand.dart'; import 'package:location/utils/common_style.dart'; import 'package:location/utils/toast_util.dart'; typedef FriendUpdateRemarkCallback = void Function(String remark); class FriendUpdateRemarkDialog { static const String _tag = "FriendUpdateRemarkDialog"; static void show( {String? remark, required FriendUpdateRemarkCallback callback}) { SmartDialog.show( builder: (_) { return FriendUpdateRemarkView( remark: remark, callback: callback, ); }, tag: _tag); } static void dismiss() { SmartDialog.dismiss(tag: _tag); } } class FriendUpdateRemarkView extends Dialog { final FriendUpdateRemarkCallback callback; final String? remark; final Rx _remark = Rx(''); final TextEditingController editingController = TextEditingController(); FriendUpdateRemarkView({super.key, required this.callback, this.remark}) { editingController.addListener(() { _remark.value = editingController.text; }); editingController.text = remark ?? ''; } @override Widget build(BuildContext context) { return IntrinsicHeight( child: Container( width: 307.w, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(20.w), ), child: Stack( children: [ Positioned( top: 12.w, right: 12.w, child: GestureDetector( onTap: () { FriendUpdateRemarkDialog.dismiss(); }, child: Assets.images.iconDialogClose .image(width: 24.w, height: 24.w))), Column( children: [ SizedBox(height: 27.w), Text(StringName.friendUpdateRemarkTitle, style: TextStyle( fontSize: 18.sp, color: ColorName.black90, fontWeight: FontWeight.bold)), SizedBox(height: 20.w), Container( padding: EdgeInsets.symmetric(horizontal: 12.w), decoration: BoxDecoration( color: '#F9F9F9'.color, borderRadius: BorderRadius.circular(10.w)), margin: EdgeInsets.symmetric(horizontal: 22.w), child: Row( children: [ Expanded( child: TextField( controller: editingController, style: TextStyle( fontSize: 14.sp, color: ColorName.primaryTextColor), maxLines: 1, maxLength: 11, keyboardType: TextInputType.text, textAlignVertical: TextAlignVertical.center, textInputAction: TextInputAction.next, decoration: InputDecoration( hintText: StringName.friendUpdateRemarkHint, counterText: '', hintStyle: TextStyle( fontSize: 14, color: "#AAAAAA".toColor()), labelStyle: const TextStyle( fontSize: 14, color: ColorName.primaryTextColor, ), contentPadding: const EdgeInsets.all(0), border: const OutlineInputBorder( borderSide: BorderSide.none)))), Obx(() { return Text( _remark.value.isEmpty ? '0' : _remark.value.length.toString(), style: TextStyle( fontSize: 14.sp, color: _remark.value.isNotEmpty ? ColorName.black90 : '#AAAAAA'.color)); }), Text('/', style: TextStyle( fontSize: 14.sp, color: '#AAAAAA'.color)), Text('11', style: TextStyle( fontSize: 14.sp, color: '#AAAAAA'.color)) ], ), ), SizedBox(height: 20.w), GestureDetector( onTap: () { callback(_remark.value); }, child: Container( width: 229.w, height: 43.w, decoration: getPrimaryBtnDecoration(46.w), child: Center( child: Text(StringName.dialogSure, style: TextStyle( fontSize: 14.sp, color: Colors.white, fontWeight: FontWeight.bold)), ), ), ), SizedBox(height: 20.w) ], ) ], ), ), ); } }