Hibok
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

104 行
3.5 KiB

  1. import 'dart:io';
  2. import 'package:chat/data/UserData.dart';
  3. import 'package:chat/data/constants.dart';
  4. import 'package:chat/generated/i18n.dart';
  5. import 'package:chat/utils/CustomUI.dart';
  6. import 'package:chat/utils/HttpUtil.dart';
  7. import 'package:chat/utils/MessageMgr.dart';
  8. import 'package:chat/utils/TokenMgr.dart';
  9. import 'package:dio/dio.dart';
  10. import 'package:flutter/material.dart';
  11. import 'package:oktoast/oktoast.dart';
  12. class UploadPicture extends StatefulWidget {
  13. @required
  14. final File img;
  15. UploadPicture({Key key, this.img}) : super(key: key);
  16. _UploadPictureState createState() => _UploadPictureState();
  17. }
  18. class _UploadPictureState extends State<UploadPicture> {
  19. bool isAgree = false;
  20. @override
  21. Widget build(BuildContext context) {
  22. return Scaffold(
  23. appBar: AppBar(
  24. actions: <Widget>[
  25. Container(
  26. alignment: Alignment.center,
  27. child: new InkWell(
  28. child: new Padding(
  29. padding:
  30. EdgeInsets.only(right: 15, left: 15, top: 10, bottom: 10),
  31. child: new Text(I18n.of(context).determine,
  32. textScaleFactor: 1.0,
  33. style: Constants.AppBarActionTextStyle),
  34. ),
  35. onTap: () async {
  36. Map data = {"type": 2, "userId": UserData().basicInfo.userId};
  37. data['sign'] = TokenMgr().getSign(data);
  38. data['sex'] = UserData().basicInfo.sex;
  39. data['isBurn'] = isAgree ? 1 : 0;
  40. Response res = await HttpUtil().uploadFile(
  41. widget.img, data, 'upload/file/postflie', 'image',
  42. isShowLoading: true);
  43. var resData = res.data;
  44. if (resData['code'] == 0) {
  45. if (resData['data']['msg'] != '') {
  46. showToast(resData['data']['msg']);
  47. }
  48. resData['Type'] = isAgree ? 1 : 0;
  49. MessageMgr().emit('refresh_photo');
  50. Navigator.of(context).pop();
  51. }
  52. },
  53. ),
  54. )
  55. ],
  56. centerTitle: true,
  57. leading: CustomUI.buildCustomLeading(context),
  58. ),
  59. body: SafeArea(
  60. child: Container(
  61. height: MediaQuery.of(context).size.height,
  62. width: MediaQuery.of(context).size.width,
  63. child: Column(
  64. children: <Widget>[
  65. Expanded(
  66. child: Container(
  67. color: Constants.BlackTextColor,
  68. child: Image.file(
  69. widget.img,
  70. ),
  71. ),
  72. ),
  73. Container(
  74. height: 60,
  75. child: Row(
  76. mainAxisAlignment: MainAxisAlignment.start,
  77. children: <Widget>[
  78. Checkbox(
  79. value: isAgree,
  80. activeColor: Colors.blue,
  81. onChanged: (bool val) {
  82. this.setState(() {
  83. isAgree = !isAgree;
  84. });
  85. },
  86. ),
  87. Text(I18n.of(context).destroy_after, textScaleFactor: 1.0)
  88. ],
  89. ),
  90. )
  91. ],
  92. ),
  93. ),
  94. ));
  95. }
  96. }