Hibok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

135 lines
4.0 KiB

  1. import 'package:chat/data/chat_data_mgr.dart';
  2. import 'package:chat/data/constants.dart';
  3. import 'package:chat/data/group_data_mgr.dart';
  4. import 'package:chat/generated/i18n.dart';
  5. import 'package:chat/home/group_item_widget.dart';
  6. import 'package:chat/home/last_chat_record_widget.dart';
  7. import 'package:chat/models/group_info_model.dart';
  8. import 'package:chat/utils/receive_share_file.dart';
  9. import 'package:flutter/cupertino.dart';
  10. import 'package:flutter/material.dart';
  11. import 'CustomUI.dart';
  12. class FileTransferPage extends StatefulWidget {
  13. final String filePath;
  14. FileTransferPage(this.filePath);
  15. @override
  16. State<StatefulWidget> createState() {
  17. return FileTransferPageState();
  18. }
  19. }
  20. class FileTransferPageState extends State<FileTransferPage>
  21. with SingleTickerProviderStateMixin {
  22. ScrollController _scrollController = ScrollController();
  23. List<GroupInfoModel> groupList = [];
  24. var lastMsgList = ChatDataMgr().lastMsgProvider.lastMsgList;
  25. TabController tabCtrl;
  26. @override
  27. void initState() {
  28. super.initState();
  29. tabCtrl = TabController(length: 2, vsync: this);
  30. groupList = GroupInfoMgr().groupInfoList;
  31. if (groupList.length == 0) {
  32. Future.delayed(Duration(seconds: 3), () {
  33. setState(() {
  34. groupList = GroupInfoMgr().groupInfoList;
  35. });
  36. });
  37. }
  38. }
  39. @override
  40. Widget build(BuildContext context) {
  41. Widget appBar = new AppBar(
  42. backgroundColor: AppColors.NewAppbarBgColor,
  43. title: new Text(
  44. '发送给',//I18n.of(context).send_to,
  45. style: TextStyle(color: AppColors.NewAppbarTextColor),
  46. textScaleFactor: 1.0,
  47. ),
  48. leading: CustomUI.buildCustomLeading(context),
  49. centerTitle: true,
  50. bottom: PreferredSize(
  51. preferredSize: Size.fromHeight(28),
  52. child: Container(
  53. padding: EdgeInsets.only(left: 2),
  54. decoration: BoxDecoration(
  55. color: Constants.LightGreyBackgroundColor,
  56. border: Border(bottom: BorderSide(color: Color(0xffeaeaea)))),
  57. alignment: Alignment.centerLeft,
  58. child: TabBar(
  59. isScrollable: true,
  60. indicatorPadding: EdgeInsets.only(left: 9, right: 9),
  61. tabs: <Widget>[
  62. Container(
  63. margin: EdgeInsets.only(right: 4),
  64. child:
  65. Text(I18n.of(context).text_chat, textScaleFactor: 1.0),
  66. ),
  67. Container(
  68. margin: EdgeInsets.only(right: 4),
  69. child: Text(I18n.of(context).group_chat,
  70. textScaleFactor: 1.0)),
  71. ],
  72. controller: tabCtrl,
  73. ),
  74. )));
  75. return Material(
  76. child: SafeArea(
  77. child: Scaffold(
  78. appBar: appBar,
  79. body: TabBarView(
  80. children: <Widget>[
  81. LastChatPage(
  82. needRobot: false,
  83. enterType: 1,
  84. enterContent: widget.filePath,
  85. ),
  86. ///群聊
  87. groupList.length == 0
  88. ? Container()
  89. : Container(
  90. child: ListView.builder(
  91. controller: _scrollController,
  92. itemBuilder: (BuildContext context, int index) {
  93. var info = groupList[index];
  94. return GroupItem(
  95. ValueKey(info),
  96. groupInfoModel: info,
  97. enterType: 1,
  98. enterContent: widget.filePath,
  99. );
  100. },
  101. itemCount: groupList.length,
  102. ))
  103. ],
  104. controller: tabCtrl,
  105. ),
  106. ),
  107. ),
  108. );
  109. // return SafeArea(child: Scaffold(body: FileReaderView(
  110. // filePath: widget.filePath,
  111. // ),));
  112. }
  113. @override
  114. void dispose() {
  115. super.dispose();
  116. ReceiveShareFile.tempFilePath = null;
  117. tabCtrl.dispose();
  118. }
  119. }