feedback.dart 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import 'dart:async';
  2. import 'package:fast/constants.dart';
  3. import 'package:fast/utils/api.dart';
  4. import 'package:fast/utils/http_utils.dart';
  5. import 'package:fast/utils/size_fit.dart';
  6. import 'package:fast/view/component/fast_btn.dart';
  7. import 'package:fast/view/component/navi_bar.dart';
  8. import 'package:flutter/material.dart';
  9. import 'package:get/get.dart';
  10. import 'component/toast.dart';
  11. class FeedbackPage extends StatefulWidget {
  12. const FeedbackPage({Key? key}) : super(key: key);
  13. @override
  14. State<FeedbackPage> createState() => _FeedbackPageState();
  15. }
  16. class _FeedbackPageState extends State<FeedbackPage> {
  17. String content = '';
  18. Future commit() async {
  19. if (content.trim().isEmpty) {
  20. return;
  21. }
  22. var data = await HttpUtils.post(Api.feedback, data: {'content': content});
  23. if (data != null) {
  24. showDialog(
  25. context: context,
  26. barrierDismissible: false,
  27. barrierColor: Colors.transparent,
  28. builder: (BuildContext context) {
  29. return Toast(
  30. title: '反馈成功',
  31. content: const SizedBox(
  32. width: 0,
  33. ),
  34. );
  35. });
  36. Timer(const Duration(seconds: 3), () {
  37. Get.back();
  38. });
  39. }
  40. }
  41. @override
  42. Widget build(BuildContext context) {
  43. SizeFit.initialize(context);
  44. EdgeInsets safePadding = MediaQuery.of(context).padding;
  45. return Material(
  46. child: Container(
  47. padding: EdgeInsets.only(top: 0, bottom: safePadding.bottom),
  48. color: kBgColor,
  49. alignment: Alignment.centerLeft,
  50. child:
  51. Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
  52. NaviBar(
  53. title: '意见反馈',
  54. closeCallback: () {
  55. Get.back();
  56. }),
  57. Container(
  58. margin: EdgeInsets.fromLTRB(14.px, 30.px, 14.px, 20.px),
  59. padding: EdgeInsets.only(
  60. left: 18.px, right: 18.px, top: 15.px, bottom: 15.px),
  61. height: 102.px,
  62. decoration: BoxDecoration(
  63. color: const Color(0x26C4CCDA),
  64. borderRadius: BorderRadius.all(Radius.circular(16.px))),
  65. child: TextField(
  66. onChanged: (value) => {
  67. setState(() {
  68. content = value;
  69. })
  70. },
  71. style: TextStyle(color: Colors.white, fontSize: 16.px),
  72. cursorColor: Colors.white,
  73. maxLines: 10,
  74. maxLength: 100,
  75. autofocus: true,
  76. decoration: const InputDecoration(
  77. counterText: "",
  78. hintText: '请填写您的意见反馈,100个汉字以内。',
  79. border: InputBorder.none,
  80. contentPadding: EdgeInsets.zero,
  81. hintStyle: TextStyle(color: Color(0x66FFFFFF))),
  82. ),
  83. ),
  84. Container(
  85. margin: EdgeInsets.only(left: 14.px),
  86. child: FastBtn(
  87. title: "确定",
  88. disable: content.isEmpty,
  89. width: 347.px,
  90. height: 50.px,
  91. callback: () {
  92. commit();
  93. }),
  94. )
  95. ])));
  96. }
  97. }