Hibok
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

200 rader
5.8 KiB

  1. import 'package:cached_network_image/cached_network_image.dart';
  2. import 'package:chat/data/UserData.dart';
  3. import 'package:chat/data/chat_data_mgr.dart';
  4. import 'package:chat/data/group_data_mgr.dart';
  5. import 'package:chat/home/add_friend.dart';
  6. import 'package:chat/home/group_announcement.dart';
  7. import 'package:chat/home/group_manage_page.dart';
  8. import 'package:chat/models/group_info_model.dart';
  9. import 'package:chat/models/ref_name_provider.dart';
  10. import 'package:chat/utils/MessageMgr.dart';
  11. import 'package:chat/utils/group_member_model.dart';
  12. import 'package:chat/utils/msgHandler.dart';
  13. import 'package:chat/utils/screen.dart';
  14. import 'package:flutter/cupertino.dart';
  15. import 'package:flutter/material.dart';
  16. import 'package:oktoast/oktoast.dart';
  17. import 'package:provider/provider.dart';
  18. import '../../data/constants.dart';
  19. import '../../generated/i18n.dart';
  20. import '../../utils/CustomUI.dart';
  21. import '../../utils/FullWithButton.dart';
  22. import '../../utils/app_navigator.dart';
  23. import '../create_group_view.dart';
  24. import 'package:chat/utils/PopUpMenu.dart' as myPop;
  25. class TranslationButlerPage extends StatefulWidget {
  26. final GroupInfoModel groupInfoModel;
  27. TranslationButlerPage({Key key, this.groupInfoModel}) : super(key: key);
  28. @override
  29. State<StatefulWidget> createState() {
  30. return TranslationButlerPageState();
  31. }
  32. }
  33. class TranslationButlerPageState extends State<TranslationButlerPage> {
  34. int curToLang = 1;
  35. int curSourceLang = UserData().language;
  36. List langList;
  37. @override
  38. void initState() {
  39. super.initState();
  40. }
  41. @override
  42. void didChangeDependencies() {
  43. super.didChangeDependencies();
  44. langList = [
  45. I18n.of(context).english,
  46. I18n.of(context).Vietnamese,
  47. I18n.of(context).traditional_Chinese,
  48. I18n.of(context).Simplified_Chinese,
  49. I18n.of(context).Korean,
  50. I18n.of(context).Japanese,
  51. ];
  52. }
  53. @override
  54. void dispose() {
  55. // MessageMgr().off('Update Group Info', updateGroupInfo);
  56. super.dispose();
  57. }
  58. _langPopMenu(bool isSource) {
  59. var curIndex = isSource ? curSourceLang : curToLang;
  60. return myPop.PopupMenuButton(
  61. child: Container(
  62. child: Row(
  63. children: <Widget>[
  64. fixedText(langList[curIndex], color: Colors.black, fontSize: 16),
  65. Icon(IconData(0xe63b, fontFamily: Constants.IconFontFamily),
  66. color: Colors.grey)
  67. ],
  68. ),
  69. ),
  70. offset: Offset(0, 100),
  71. onSelected: (int index) {
  72. if (curIndex != index) {
  73. if (isSource) {
  74. curSourceLang = index;
  75. } else {
  76. curToLang = index;
  77. }
  78. print('更换翻译语言');
  79. setState(() {});
  80. }
  81. },
  82. itemBuilder: (BuildContext context) {
  83. return List<myPop.PopupMenuItem<int>>.generate(langList.length,
  84. (int i) {
  85. return myPop.PopupMenuItem(
  86. child: Container(
  87. alignment: Alignment.center,
  88. color: Colors.white,
  89. padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
  90. child: Text(langList[i],
  91. textScaleFactor: 1.0,
  92. maxLines: 1,
  93. style: TextStyle(
  94. color: i == curIndex
  95. ? Colors.blueAccent
  96. : Color(AppColors.AppBarColor),
  97. fontSize: 14)),
  98. ),
  99. value: i,
  100. );
  101. });
  102. });
  103. }
  104. @override
  105. Widget build(BuildContext context) {
  106. Widget appBar = AppBar(
  107. backgroundColor: AppColors.NewAppbarBgColor,
  108. title: Text(
  109. I18n.of(context).translation_butler,
  110. textScaleFactor: 1.0,
  111. style: TextStyle(color: AppColors.NewAppbarTextColor),
  112. ),
  113. // leading: CustomUI.buildCustomLeading(context),
  114. centerTitle: true,
  115. );
  116. return Scaffold(
  117. appBar: appBar,
  118. body: SafeArea(
  119. child: ListView(
  120. children: <Widget>[
  121. Text(
  122. I18n.of(context).translation_butler_tips,
  123. textScaleFactor: 1.0,
  124. style: TextStyle(color: AppColors.NewAppbarTextColor),
  125. ),
  126. Text(
  127. I18n.of(context).choose_language,
  128. textScaleFactor: 1.0,
  129. style: TextStyle(color: AppColors.NewAppbarTextColor),
  130. ),
  131. SizedBox(
  132. height: 12,
  133. ),
  134. Text(
  135. I18n.of(context).travel_butler,
  136. textScaleFactor: 1.0,
  137. style: TextStyle(color: AppColors.NewAppbarTextColor),
  138. ),
  139. Column(
  140. mainAxisSize: MainAxisSize.min,
  141. children: <Widget>[
  142. _langPopMenu(true),
  143. SizedBox(width: 10),
  144. InkWell(
  145. onTap: () {
  146. var temp = curSourceLang;
  147. curSourceLang = curToLang;
  148. curToLang = temp;
  149. setState(() {});
  150. },
  151. child: Container(
  152. child: Icon(
  153. IconData(0xe669, fontFamily: Constants.IconFontFamily),
  154. size: 12,
  155. ),
  156. padding: EdgeInsets.symmetric(vertical: 5, horizontal: 5),
  157. ),
  158. ),
  159. SizedBox(width: 20),
  160. _langPopMenu(false),
  161. ],
  162. ),
  163. RaisedButton(color: Colors.blue,child: Text(I18n.of(context).translation_butler_call),onPressed: (){
  164. showToast('呼叫管家${I18n.of(context).translation_butler_call}');
  165. })
  166. ],
  167. ),
  168. ),
  169. );
  170. }
  171. }