Blame view

lib/pages/user/setting/reback_page.dart 6.53 KB
a423aad7   xiaoyu   用户反馈添加字符输入数量显示,添加...
1
2
3
4
5
  import 'dart:async';
  import 'dart:io';
  import 'dart:math';
  
  import 'package:device_info_plus/device_info_plus.dart';
3840b7fe   liangchengyou   feat:更新设置页面
6
  import 'package:flutter/material.dart';
a423aad7   xiaoyu   用户反馈添加字符输入数量显示,添加...
7
8
  import 'package:flutter/services.dart';
  import 'package:flutter_easyloading/flutter_easyloading.dart';
3840b7fe   liangchengyou   feat:更新设置页面
9
  import 'package:flutter_screenutil/flutter_screenutil.dart';
a423aad7   xiaoyu   用户反馈添加字符输入数量显示,添加...
10
  import 'package:wow_english/common/core/app_config_helper.dart';
3840b7fe   liangchengyou   feat:更新设置页面
11
  import 'package:wow_english/common/extension/string_extension.dart';
a423aad7   xiaoyu   用户反馈添加字符输入数量显示,添加...
12
  import 'package:wow_english/route/route.dart';
3840b7fe   liangchengyou   feat:更新设置页面
13
14
  import 'package:wow_english/utils/color_util.dart';
  
a423aad7   xiaoyu   用户反馈添加字符输入数量显示,添加...
15
16
17
  import 'package:wow_english/common/request/dao/user_dao.dart';
  import 'package:wow_english/common/widgets/we_app_bar.dart';
  import 'package:wow_english/utils/toast_util.dart';
3840b7fe   liangchengyou   feat:更新设置页面
18
19
20
21
22
23
24
25
26
27
28
29
  
  class ReBackPage extends StatefulWidget {
    const ReBackPage({super.key});
  
    @override
    State<StatefulWidget> createState() {
      return ReBackPageState();
    }
  }
  
  class ReBackPageState extends State<ReBackPage> {
    late bool _canEnsure;
a423aad7   xiaoyu   用户反馈添加字符输入数量显示,添加...
30
31
    int _textCount = 0;
    String _textInputStr = "";
3840b7fe   liangchengyou   feat:更新设置页面
32
33
34
35
36
  
    @override
    void initState() {
      super.initState();
      _canEnsure = false;
a423aad7   xiaoyu   用户反馈添加字符输入数量显示,添加...
37
38
      _textCount = 0;
      _textInputStr = "";
3840b7fe   liangchengyou   feat:更新设置页面
39
40
41
42
43
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
2d1ead53   吴启风   feat:背景音播放优化
44
45
          appBar: const WEAppBar(
            titleText: '我要反馈',
3840b7fe   liangchengyou   feat:更新设置页面
46
          ),
2d1ead53   吴启风   feat:背景音播放优化
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
          body: Container(
            color: Colors.white,
            padding: EdgeInsets.symmetric(horizontal: 10.w),
            child: SafeArea(
              child: LayoutBuilder(builder: (context, constraints) {
                return SingleChildScrollView(
                  child: ConstrainedBox(
                    constraints: BoxConstraints(
                      minHeight: constraints.maxHeight,
                    ),
                    child: IntrinsicHeight(
                      child: Column(
                        children: [
                          20.verticalSpace,
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Text(
                                '请输入您要反馈的问题和意见,10-500个字',
                                textAlign: TextAlign.left,
                                style: TextStyle(
                                    fontSize: 19.sp, color: HexColor('#333333')),
                              ),
                              Text(
a423aad7   xiaoyu   用户反馈添加字符输入数量显示,添加...
71
                                '$_textCount/500',
2d1ead53   吴启风   feat:背景音播放优化
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
                                textAlign: TextAlign.right,
                                style: TextStyle(
                                    fontSize: 19.sp, color: HexColor('#333333')),
                              )
                            ],
                          ),
                          9.5.verticalSpace,
                          Expanded(
                            child: Container(
                              decoration: BoxDecoration(
                                  image: DecorationImage(
                                      image: AssetImage('bg_reback'.assetPng),
                                      fit: BoxFit.fill)),
                              child: Padding(
                                padding: const EdgeInsets.symmetric(
                                    vertical: 10, horizontal: 16),
                                // 设置对称内边距
                                child: TextField(
a423aad7   xiaoyu   用户反馈添加字符输入数量显示,添加...
90
91
92
93
94
95
96
97
98
99
100
                                  inputFormatters: [
                                    LengthLimitingTextInputFormatter(500, maxLengthEnforcement: MaxLengthEnforcement.truncateAfterCompositionEnds),
                                  ],
                                  onChanged: (String value) {
                                    setState(() {
                                      _textInputStr = value;
                                      _textCount = min(value.length, 500);
                                      _canEnsure = value.length >= 10;
                                    });
                                  },
                                  maxLines: null,
2d1ead53   吴启风   feat:背景音播放优化
101
102
103
104
105
106
107
108
109
110
111
                                  textInputAction: TextInputAction.done,
                                  decoration: InputDecoration(
                                      border: InputBorder.none,
                                      hintStyle: TextStyle(
                                          fontSize: 16.sp,
                                          color: const Color(0xFF999999))),
                                ),
                              ),
                            ),
                          ),
                          4.5.verticalSpace,
a423aad7   xiaoyu   用户反馈添加字符输入数量显示,添加...
112
113
                          GestureDetector(
                            onTap: () {
398c987d   xiaoyu   反馈内容小于10个时点击按钮不提交
114
115
116
117
                              if (_textInputStr.length < 10) {
                                // 输入范围为10-450以内
                                return;
                              }
a423aad7   xiaoyu   用户反馈添加字符输入数量显示,添加...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
                              userFeedBack(_textInputStr);
                            },
                            child: Container(
                              decoration: BoxDecoration(
                                  image: DecorationImage(
                                      fit: BoxFit.fill,
                                      image: AssetImage(_canEnsure
                                          ? 're_button'.assetPng
                                          : 're_button_dis'.assetPng))),
                              alignment: Alignment.center,
                              width: 91.w,
                              height: 45.h,
                              child: Text(
                                '提交',
                                textAlign: TextAlign.center,
                                style:
                                    TextStyle(color: Colors.white, fontSize: 17.sp),
                              ),
2d1ead53   吴启风   feat:背景音播放优化
136
                            ),
3840b7fe   liangchengyou   feat:更新设置页面
137
                          )
2d1ead53   吴启风   feat:背景音播放优化
138
                        ],
3840b7fe   liangchengyou   feat:更新设置页面
139
140
141
                      ),
                    ),
                  ),
2d1ead53   吴启风   feat:背景音播放优化
142
143
                );
              }),
3840b7fe   liangchengyou   feat:更新设置页面
144
            ),
2d1ead53   吴启风   feat:背景音播放优化
145
          ));
3840b7fe   liangchengyou   feat:更新设置页面
146
    }
a423aad7   xiaoyu   用户反馈添加字符输入数量显示,添加...
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
  
     Future<void> userFeedBack(content) async {
      String deviceModel = "";
      String osType = AppConfigHelper.isIosPlatform() ? "ios" : "android";
      String osVersion = "";
      if (AppConfigHelper.isIosPlatform()) {
        final iosDeviceInfo = await DeviceInfoPlugin().iosInfo;
        osVersion = iosDeviceInfo.systemVersion;
        deviceModel = iosDeviceInfo.model;
      } else {
        final androidInfo = await DeviceInfoPlugin().androidInfo;
        osVersion = androidInfo.version.release.toString();
        deviceModel = androidInfo.manufacturer;
      }
      EasyLoading.show();
      await UserDao.feedBack(content, deviceModel, osType, osVersion);
      EasyLoading.dismiss();
      showToast('提交成功');
      popPage();
    }
2d1ead53   吴启风   feat:背景音播放优化
167
  }