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/home/realtimehelper/translation_butler_page.dart';
import 'package:chat/home/realtimehelper/travel_butler_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 '../../r.dart';
import '../../utils/CustomUI.dart';
import '../../utils/FullWithButton.dart';
import '../../utils/app_navigator.dart';
import '../create_group_view.dart';

class RealTimeHelperPage extends StatefulWidget {
  final GroupInfoModel groupInfoModel;

  RealTimeHelperPage({Key key, this.groupInfoModel}) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return RealTimeHelperPageState();
  }
}

class RealTimeHelperPageState extends State<RealTimeHelperPage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
//    MessageMgr().off('Update Group Info', updateGroupInfo);
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    Widget appBar = AppBar(
      backgroundColor: AppColors.NewAppbarBgColor,
      title: Text(
        I18n.of(context).real_time_helper,
        textScaleFactor: 1.0,
        style: TextStyle(color: AppColors.NewAppbarTextColor),
      ),
//      leading: CustomUI.buildCustomLeading(context),
      centerTitle: false,
    );

    return Scaffold(
      appBar: appBar,
      body: SafeArea(
        child: Container(
          color: Color(0xffE8EAF0),
          child: ListView(
            children: <Widget>[
              helperCard(I18n.of(context).translation_butler,
                  R.assetsImagesImgTranslationButler, () {
                Navigator.of(context).push(
                  MaterialPageRoute(
                    builder: (_) => TranslationButlerPage(),
                  ),
                );
              }),
              helperCard(
                  I18n.of(context).travel_butler, R.assetsImagesImgTravelButler,
                  () {
                Navigator.of(context).push(
                  MaterialPageRoute(
                    builder: (_) => TravelButlerPage(),
                  ),
                );
              }),
              SizedBox(
                height: 15,
              ),
            ],
          ),
        ),
      ),
    );
  }

  Widget helperCard(String title, String assets, Function callBack) {
    return InkWell(
      child: Container(
        margin: EdgeInsets.all(10),
        child: Card(
          elevation: 5, // 阴影
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(10),
//              side: BorderSide(color: Colors.green,width: 25),
          ),
          child: Container(padding: EdgeInsets.all(10),child: Column(
            children: <Widget>[
              Image.asset(
                assets,
              ),
              Padding(
                padding: EdgeInsets.only(top: 15, bottom: 15),
                child: Text(
                  title + ' >>',
                  textScaleFactor: 1.0,
                  style: TextStyle(color: Color(0xff2685FA), fontSize: 20),
                ),
              )
            ],
          ),),
        ),
      ),
      onTap: callBack,
    );
  }
}
