|
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:chat/data/UserData.dart';
- import 'package:chat/data/chat_data_mgr.dart';
- import 'package:chat/data/group_data_mgr.dart';
- import 'package:chat/home/add_friend.dart';
- import 'package:chat/home/group_announcement.dart';
- import 'package:chat/home/group_manage_page.dart';
- import 'package:chat/models/group_info_model.dart';
- import 'package:chat/models/ref_name_provider.dart';
- import 'package:chat/utils/MessageMgr.dart';
- import 'package:chat/utils/group_member_model.dart';
- import 'package:chat/utils/msgHandler.dart';
- import 'package:chat/utils/screen.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:oktoast/oktoast.dart';
- import 'package:provider/provider.dart';
-
- import '../../data/constants.dart';
- import '../../generated/i18n.dart';
- import '../../utils/CustomUI.dart';
- import '../../utils/FullWithButton.dart';
- import '../../utils/app_navigator.dart';
- import '../create_group_view.dart';
- import 'package:chat/utils/PopUpMenu.dart' as myPop;
- class TranslationButlerPage extends StatefulWidget {
- final GroupInfoModel groupInfoModel;
-
- TranslationButlerPage({Key key, this.groupInfoModel}) : super(key: key);
-
- @override
- State<StatefulWidget> createState() {
- return TranslationButlerPageState();
- }
- }
-
- class TranslationButlerPageState extends State<TranslationButlerPage> {
-
-
- int curToLang = 1;
- int curSourceLang = UserData().language;
- List langList;
- @override
- void initState() {
- super.initState();
-
-
- }
-
- @override
- void didChangeDependencies() {
- super.didChangeDependencies();
-
- langList = [
- I18n.of(context).english,
- I18n.of(context).Vietnamese,
- I18n.of(context).traditional_Chinese,
- I18n.of(context).Simplified_Chinese,
- I18n.of(context).Korean,
- I18n.of(context).Japanese,
- ];
- }
-
- @override
- void dispose() {
- // MessageMgr().off('Update Group Info', updateGroupInfo);
- super.dispose();
- }
-
- _langPopMenu(bool isSource) {
- var curIndex = isSource ? curSourceLang : curToLang;
-
- return myPop.PopupMenuButton(
- child: Container(
- child: Row(
- children: <Widget>[
- fixedText(langList[curIndex], color: Colors.black, fontSize: 16),
- Icon(IconData(0xe63b, fontFamily: Constants.IconFontFamily),
- color: Colors.grey)
- ],
- ),
- ),
- offset: Offset(0, 100),
- onSelected: (int index) {
- if (curIndex != index) {
- if (isSource) {
- curSourceLang = index;
- } else {
- curToLang = index;
- }
- print('更换翻译语言');
- setState(() {});
- }
- },
- itemBuilder: (BuildContext context) {
- return List<myPop.PopupMenuItem<int>>.generate(langList.length,
- (int i) {
- return myPop.PopupMenuItem(
- child: Container(
- alignment: Alignment.center,
- color: Colors.white,
- padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
- child: Text(langList[i],
- textScaleFactor: 1.0,
- maxLines: 1,
- style: TextStyle(
- color: i == curIndex
- ? Colors.blueAccent
- : Color(AppColors.AppBarColor),
- fontSize: 14)),
- ),
- value: i,
- );
- });
- });
- }
-
-
- @override
- Widget build(BuildContext context) {
-
- Widget appBar = AppBar(
- backgroundColor: AppColors.NewAppbarBgColor,
- title: Text(
- I18n.of(context).translation_butler,
- textScaleFactor: 1.0,
- style: TextStyle(color: AppColors.NewAppbarTextColor),
- ),
- // leading: CustomUI.buildCustomLeading(context),
- centerTitle: true,
- );
-
- return Scaffold(
- appBar: appBar,
- body: SafeArea(
- child: ListView(
- children: <Widget>[
-
- Text(
- I18n.of(context).translation_butler_tips,
- textScaleFactor: 1.0,
- style: TextStyle(color: AppColors.NewAppbarTextColor),
- ),
-
-
-
- Text(
- I18n.of(context).choose_language,
- textScaleFactor: 1.0,
- style: TextStyle(color: AppColors.NewAppbarTextColor),
- ),
-
- SizedBox(
- height: 12,
- ),
-
- Text(
- I18n.of(context).travel_butler,
- textScaleFactor: 1.0,
- style: TextStyle(color: AppColors.NewAppbarTextColor),
- ),
-
-
- Column(
- mainAxisSize: MainAxisSize.min,
- children: <Widget>[
- _langPopMenu(true),
- SizedBox(width: 10),
- InkWell(
- onTap: () {
- var temp = curSourceLang;
- curSourceLang = curToLang;
- curToLang = temp;
- setState(() {});
- },
- child: Container(
- child: Icon(
- IconData(0xe669, fontFamily: Constants.IconFontFamily),
- size: 12,
- ),
- padding: EdgeInsets.symmetric(vertical: 5, horizontal: 5),
- ),
- ),
- SizedBox(width: 20),
- _langPopMenu(false),
- ],
- ),
-
- RaisedButton(color: Colors.blue,child: Text(I18n.of(context).translation_butler_call),onPressed: (){
- showToast('呼叫管家${I18n.of(context).translation_butler_call}');
- })
-
- ],
- ),
- ),
- );
- }
-
- }
|