123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- import 'dart:convert';
- import 'package:flutter/material.dart';
- import 'package:intl/intl.dart';
- import 'package:sport/application.dart';
- import 'package:sport/bean/feed_back.dart';
- import 'package:sport/provider/feed_back_model.dart';
- import 'package:sport/services/api/inject_api.dart';
- import 'package:sport/utils/toast.dart';
- import 'package:sport/widgets/appbar.dart';
- import 'package:sport/widgets/button_primary.dart';
- import 'package:sport/widgets/dialog/request_dialog.dart';
- import 'package:sport/widgets/space.dart';
- class FeedbackDetailPage extends StatefulWidget {
- final FeedTypeInfoData data;
- FeedbackDetailPage(this.data);
- @override
- State<StatefulWidget> createState() => _PageState();
- }
- class _PageState extends State<FeedbackDetailPage> with InjectApi {
- // List<String> tags;
- // List<String> tagsId;
- String? tag;
- String? tagId;
- String? _content;
- @override
- void initState() {
- super.initState();
- }
- postFeedBackpostFeedBack(String content, {String? typeId}) async {
- await api.postFeedback(typeId ?? "", content, extra: await Application.getDeviceInfo());
- }
- @override
- Widget build(BuildContext context) {
- // String tag = "数据不同步";
- return Scaffold(
- backgroundColor: Colors.white,
- body: CustomScrollView(
- slivers: <Widget>[
- buildSliverAppBar(context, "${widget.data.groupName}"),
- SliverToBoxAdapter(
- child: Padding(
- padding: const EdgeInsets.all(12.0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text("请选择问题类型", style: Theme.of(context).textTheme.headline3),
- Padding(
- padding: const EdgeInsets.symmetric(vertical: 6.0),
- child: Wrap(
- alignment: WrapAlignment.start,
- spacing: 12,
- children: (widget.data.types ?? []).map<Widget>((e) {
- return ChoiceChip(
- labelPadding: const EdgeInsets.fromLTRB(12.0, 0, 12.0, 0),
- pressElevation: 0,
- //未选定的时候背景
- selectedColor: Theme.of(context).accentColor,
- //被禁用得时候背景
- backgroundColor: Colors.white,
- disabledColor: Color(0xfff1f1f1),
- shape: StadiumBorder(
- side: BorderSide(color: Color(tag == e.typeName ? 0xffffffff : 0xffcecece), width: 0.5),
- ),
- selected: tag == e.typeName,
- label: Text("${e.typeName}"),
- onSelected: (value) {
- // if (tags.indexOf(e['typeName']) >= 0) {
- // tags.remove(e['typeName']);
- // tagsId.remove(e['typeId']);
- // setState(() {
- // tags = tags;
- // tagsId = tagsId;
- // });
- // } else {
- // tags.add(e['typeName']);
- // tagsId.add(e['typeId']);
- // setState(() {
- // tags = tags;
- // tagsId = tagsId;
- // });
- // }
- setState(() {
- tag = e.typeName;
- tagId = e.typeId!;
- });
- },
- );
- }).toList()),
- ),
- Space(
- height: 10,
- ),
- // Text("问题发生时间", style: Theme.of(context).textTheme.subtitle1!),
- // InkWell(
- // onTap: () async {
- // var result = await showDatePicker(
- // context: context,
- // initialDate: DateTime.now(),
- // firstDate: DateTime(1900),
- // lastDate: DateTime.now());
- // print('$result');
- // var time = await showTimePicker(
- // context: context, initialTime: TimeOfDay.now());
- // print('$time');
- // if (time != null) {
- // DateFormat.yM().format(result);
- // }
- // },
- // child: Container(
- // height: 30,
- // margin: const EdgeInsets.symmetric(vertical: 6.0),
- // decoration: BoxDecoration(
- // border: Border(
- // bottom: Divider.createBorderSide(context),
- // )),
- // ),
- // ),
- Space(
- height: 10,
- ),
- Text("问题详述", style: Theme.of(context).textTheme.subtitle1!),
- Space(
- height: 6,
- ),
- TextField(
- maxLines: 5,
- decoration: InputDecoration(
- enabledBorder: OutlineInputBorder(borderSide: BorderSide(width: 0.5, color: Theme.of(context).dividerTheme.color!)),
- hintText: '问题详述...',
- focusedBorder: OutlineInputBorder(borderSide: BorderSide(width: 0.5, color: Theme.of(context).accentColor)),
- ),
- onChanged: (value) {
- setState(() {
- _content = value;
- });
- },
- ),
- Space(
- height: 24,
- ),
- PrimaryButton(
- height: 40.0,
- content: "提交",
- callback: () async {
- if (tagId == null) {
- ToastUtil.show("请选择问题类型");
- return;
- }
- if ((_content?.isEmpty ?? true) == true) {
- ToastUtil.show("请详述反馈内容");
- return;
- }
- if (_content?.isNotEmpty == true) {
- await request(context, () async {
- postFeedBackpostFeedBack(_content!, typeId: tagId);
- });
- ToastUtil.show("感谢你的建议,我们会第一时间解决");
- Navigator.pop(context);
- }
- },
- )
- ],
- ),
- )),
- ],
- ));
- }
- }
|