import 'dart:async'; import 'package:fast/constants.dart'; import 'package:fast/utils/api.dart'; import 'package:fast/utils/http_utils.dart'; import 'package:fast/utils/size_fit.dart'; import 'package:fast/view/component/fast_btn.dart'; import 'package:fast/view/component/navi_bar.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'component/toast.dart'; class FeedbackPage extends StatefulWidget { const FeedbackPage({Key? key}) : super(key: key); @override State createState() => _FeedbackPageState(); } class _FeedbackPageState extends State { String content = ''; Future commit() async { if (content.trim().isEmpty) { return; } var data = await HttpUtils.post(Api.feedback, data: {'content': content}); if (data != null) { showDialog( context: context, barrierDismissible: false, barrierColor: Colors.transparent, builder: (BuildContext context) { return Toast( title: '反馈成功', content: const SizedBox( width: 0, ), ); }); Timer(const Duration(seconds: 3), () { Get.back(); }); } } @override Widget build(BuildContext context) { SizeFit.initialize(context); EdgeInsets safePadding = MediaQuery.of(context).padding; return Material( child: Container( padding: EdgeInsets.only(top: 0, bottom: safePadding.bottom), color: kBgColor, alignment: Alignment.centerLeft, child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ NaviBar( title: '意见反馈', closeCallback: () { Get.back(); }), Container( margin: EdgeInsets.fromLTRB(14.px, 30.px, 14.px, 20.px), padding: EdgeInsets.only( left: 18.px, right: 18.px, top: 15.px, bottom: 15.px), height: 102.px, decoration: BoxDecoration( color: const Color(0x26C4CCDA), borderRadius: BorderRadius.all(Radius.circular(16.px))), child: TextField( onChanged: (value) => { setState(() { content = value; }) }, style: TextStyle(color: Colors.white, fontSize: 16.px), cursorColor: Colors.white, maxLines: 10, maxLength: 100, autofocus: true, decoration: const InputDecoration( counterText: "", hintText: '请填写您的意见反馈,100个汉字以内。', border: InputBorder.none, contentPadding: EdgeInsets.zero, hintStyle: TextStyle(color: Color(0x66FFFFFF))), ), ), Container( margin: EdgeInsets.only(left: 14.px), child: FastBtn( title: "确定", disable: content.isEmpty, width: 347.px, height: 50.px, callback: () { commit(); }), ) ]))); } }