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/map/google_map_location_picker.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:google_maps_flutter/google_maps_flutter.dart';
import 'package:oktoast/oktoast.dart';
import 'package:permission_handler/permission_handler.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';

class TravelButlerPage extends StatefulWidget {
  final GroupInfoModel groupInfoModel;

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

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

class TravelButlerPageState extends State<TravelButlerPage> {


  @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).travel_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>[

InkWell(child:
Text(
  I18n.of(context).travel_butler,
  textScaleFactor: 1.0,
  style: TextStyle(color: AppColors.NewAppbarTextColor),
),onTap: (){
  _openMap(context);
},)


          ],
        ),
      ),
    );
  }



  _openMap(BuildContext context) async {
    if (await CustomUI.showPermissionSetting(
        context, PermissionGroup.location, I18n.of(context).open_location)) {
      var result = await LocationPicker.pickLocation(
          context, 'AIzaSyAb9JNtW0BEZ_qLeDg87ZhvxSmZply-7hU',
          initialCenter: LatLng(UserData().latitude, UserData().longitude));

      if (result == null ||
          result.address == null ||
          result.address.length == 0) {
        return;
      }


      print('地图结果 ${result}');

    }
  }

}
