Hibok
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

239 rindas
7.5 KiB

  1. import 'package:chat/chat/ChatPage.dart';
  2. import 'package:chat/chat/coin_bag_info.dart';
  3. import 'package:chat/chat/coin_bag_view.dart';
  4. import 'package:chat/chat/company_server_view.dart';
  5. import 'package:chat/chat/group_chat_view.dart';
  6. import 'package:chat/data/constants.dart';
  7. import 'package:chat/generated/i18n.dart';
  8. import 'package:chat/home/InformUser.dart';
  9. import 'package:chat/home/ProfilePage.dart';
  10. import 'package:chat/home/SearchPage.dart';
  11. import 'package:chat/home/audio_chat_view.dart';
  12. import 'package:chat/home/create_group_view.dart';
  13. import 'package:chat/home/forward_view.dart';
  14. import 'package:chat/home/group_all_member.dart';
  15. import 'package:chat/home/group_qr_view.dart';
  16. import 'package:chat/home/homeMain.dart';
  17. import 'package:chat/home/qr_scanner_view.dart';
  18. import 'package:chat/home/qr_view.dart';
  19. import 'package:chat/home/service_view.dart';
  20. import 'package:chat/home/translate_robot.dart';
  21. import 'package:chat/home/webview_page.dart';
  22. import 'package:chat/map/location_result.dart';
  23. import 'package:chat/map/map_view.dart';
  24. import 'package:chat/models/ChatMsg.dart';
  25. import 'package:chat/models/UserInfo.dart';
  26. import 'package:chat/models/group_info_model.dart';
  27. import 'package:chat/utils/NetUtil.dart';
  28. import 'package:chat/utils/conversation_table.dart';
  29. import 'package:flutter/material.dart';
  30. import 'package:oktoast/oktoast.dart';
  31. class AppNavigator {
  32. static SlideTransition createTransition(
  33. Animation<double> animation, Widget child) {
  34. return new SlideTransition(
  35. position: new Tween<Offset>(
  36. begin: const Offset(1.0, 0.0),
  37. end: const Offset(0.0, 0.0),
  38. ).animate(animation),
  39. child: child,
  40. );
  41. }
  42. static FadeTransition createFadeTransition(
  43. Animation<double> animation, Widget child) {
  44. return FadeTransition(
  45. opacity: Tween(begin: 1.0, end: 0.0).animate(
  46. CurvedAnimation(parent: animation, curve: Curves.fastOutSlowIn)),
  47. child: child,
  48. );
  49. }
  50. static SlideTransition createUpTransition(
  51. Animation<double> animation, Widget child) {
  52. return SlideTransition(
  53. position: new Tween<Offset>(
  54. begin: const Offset(0.0, 1.0),
  55. end: const Offset(0.0, 0.0),
  56. ).animate(animation),
  57. child: child,
  58. );
  59. }
  60. static defaultPush(BuildContext context, Widget scene) {
  61. Navigator.of(context).push(
  62. new MaterialPageRoute(
  63. builder: (context) {
  64. return scene;
  65. },
  66. ),
  67. );
  68. }
  69. static push(BuildContext context, Widget scene) {
  70. Navigator.push(context, PageRouteBuilder(pageBuilder: (BuildContext context,
  71. Animation<double> animation, Animation<double> secondaryAnimation) {
  72. // 跳转的路由对象
  73. return createTransition(animation, scene);
  74. }));
  75. }
  76. //主页
  77. static pushHomePage(BuildContext context) {
  78. Navigator.pushAndRemoveUntil(context, PageRouteBuilder(pageBuilder:
  79. (BuildContext context, Animation<double> animation,
  80. Animation<double> secondaryAnimation) {
  81. // 跳转的路由对象
  82. return createTransition(animation, HomeMain());
  83. }), (route) => route == null);
  84. }
  85. //search
  86. static pushSearchPage(BuildContext context) {
  87. AppNavigator.push(context, SearchPage());
  88. }
  89. //扫描
  90. static pushScannerPage(BuildContext context) {
  91. AppNavigator.defaultPush(context, QrScannerPage());
  92. }
  93. //聊天
  94. static pushChatPage(BuildContext context, int friendId,
  95. {enterType = 0, enterContent}) async {
  96. if (enterType == 1 ||enterType == 2) {
  97. Navigator.of(context).pop(context);
  98. }
  99. AppNavigator.defaultPush(
  100. context,
  101. ChatPage(
  102. key: Key('Chat'),
  103. friendId: friendId,
  104. enterType: enterType,
  105. enterContent: enterContent,
  106. ));
  107. }
  108. //群聊
  109. static pushGroupChatPage(BuildContext context, GroupInfoModel groupInfoModel,
  110. {enterType = 0, enterContent}) async {
  111. if (enterType == 1 ||enterType == 2) {
  112. Navigator.of(context).pop(context);
  113. }
  114. AppNavigator.defaultPush(
  115. context,
  116. GroupChatPage(
  117. key: Key('GroupChat'),
  118. groupInfoModel: groupInfoModel,
  119. enterType: enterType,
  120. enterContent: enterContent,
  121. ));
  122. }
  123. //客服
  124. static pushServicePage(BuildContext context, {questionIndex = -1}) async {
  125. AppNavigator.push(context, ServiceCenterPage(questionIndex : questionIndex));
  126. }
  127. //群成员列表
  128. static pushGroupAllMember(BuildContext context, GroupInfoModel model) async {
  129. AppNavigator.push(context, GroupAllMember(groupInfoModel: model));
  130. }
  131. //群聊二维码
  132. static pushGroupQrPage(BuildContext context, GroupInfoModel model) {
  133. AppNavigator.push(context, GroupQrPage(model));
  134. }
  135. //内部webview
  136. static pushWebview(BuildContext context, String url) async {
  137. AppNavigator.push(context, WebviewPage(url));
  138. }
  139. //连麦
  140. static pushAudioChatPage(BuildContext context, UserInfo userInfo,
  141. [bool isReply = false]) {
  142. //if (SocketUtil().isConnect && SocketUtil().isLogin) {
  143. if (NetWork().isConnect && NetWork().isLogin) {
  144. AppNavigator.push(
  145. context, AudioChatPage(userInfo: userInfo, isReplay: isReply));
  146. } else {
  147. showToast(I18n.of(context).net_error);
  148. }
  149. }
  150. //红包发送界面
  151. static pushCoinBagPage(context) {
  152. Navigator.push(context, PageRouteBuilder(pageBuilder: (BuildContext context,
  153. Animation<double> animation, Animation<double> secondaryAnimation) {
  154. // 跳转的路由对象
  155. return createUpTransition(animation, CoinBagPage());
  156. }));
  157. }
  158. //红包打开界面
  159. static pushCoinBagInfoPage(context, MsgModel msgModel, titleStr) {
  160. AppNavigator.push(context, CoinBagInfoPage(msgModel, titleStr: titleStr));
  161. }
  162. //打开个人信息页面 fromWhere- 0私聊 1首页 2 群聊 addMode : 0不添加,1添加朋友,2新朋友
  163. static pushProfileInfoPage(BuildContext context, int userId,
  164. {int fromWhere = 0, int addMode = 0}) {
  165. AppNavigator.push(
  166. context,
  167. ProfilePage(
  168. userId: userId,
  169. fromWhere: fromWhere,
  170. addMode: addMode,
  171. ));
  172. }
  173. //打开地图界面
  174. static pushMapPage(BuildContext context, LocationResult result) {
  175. AppNavigator.push(context, MapView(locationResult: result));
  176. }
  177. //打开举报界面
  178. static pushInformUserPage(BuildContext context, bool isMale, int userId) {
  179. Navigator.of(context).push(
  180. new MaterialPageRoute(
  181. builder: (context) {
  182. return InformUserPage(
  183. isMan: isMale,
  184. userId: userId,
  185. );
  186. },
  187. ),
  188. );
  189. }
  190. //我的二维码
  191. static pushQrPage(BuildContext context) {
  192. AppNavigator.push(context, QrPage());
  193. }
  194. //进入翻译机器人页面
  195. static pushTranslateRobotPage(BuildContext context) {
  196. AppNavigator.push(context, TranslateRobotPage());
  197. }
  198. //进入反馈小助手页面
  199. static pushCompanyServerPage(BuildContext context) {
  200. AppNavigator.push(context, CompanyServerPage());
  201. }
  202. //发起群聊界面
  203. static pushGroupCreatePage(
  204. BuildContext context, List<FriendModel> friendList) {
  205. AppNavigator.push(
  206. context, CreateGroupPage(GroupOperatingPageType.CreateGroup, [], null));
  207. }
  208. //发起群聊界面
  209. static pushForwardPage(BuildContext context, MsgModel msg) {
  210. AppNavigator.push(context, ForwardPage(msg));
  211. }
  212. }