import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:dreampad/app/shared/constants/styles.dart'; class QuestionDialog extends StatefulWidget { const QuestionDialog({ required this.question, required this.controller, super.key, }); final String question; final TextEditingController controller; @override State createState() => _QuestionDialogState(); } class _QuestionDialogState extends State { final _focusNode = FocusNode(); @override void initState() { WidgetsBinding.instance.addPostFrameCallback((timeStamp) { _focusNode.requestFocus(); }); super.initState(); } @override Widget build(BuildContext context) { return AnimatedPadding( padding: MediaQuery.of(context).viewInsets, duration: const Duration(milliseconds: 100), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ const RSizedBox( height: 80.0, ), Container( margin: REdgeInsets.only(left: 40.0, right: 30.0), padding: REdgeInsets.only(left: 16.0, right: 16.0), decoration: const BoxDecoration( color: Colors.transparent, ), child: Row( children: [ Text( '问:', style: TextStyles.mediumWhite24, ), Text( widget.question, style: TextStyles.mediumWhite24, ), ], ), ), const RSizedBox( height: 24.0, ), Container( margin: REdgeInsets.only(left: 40.0, right: 30.0), padding: REdgeInsets.only(left: 16.0, right: 16.0), decoration: const BoxDecoration( color: Colors.transparent, ), child: Row( children: [ Text( '答:', style: TextStyles.mediumWhite24, ), Expanded( child: TextField( controller: widget.controller, focusNode: _focusNode, cursorColor: Colors.white, style: TextStyles.mediumWhite24, autofocus: true, maxLines: null, minLines: 1, textInputAction: TextInputAction.done, onEditingComplete: () { _focusNode.unfocus(); SmartDialog.dismiss(); }, decoration: InputDecoration( hintText: '请回答', hintStyle: TextStyles.mediumWhite24, counterText: '', border: InputBorder.none, ), ), ), ], ), ), ], ), ); } }