import 'package:hmg_patient_app/pages/feedback/feedback_home_page.dart';
import 'package:hmg_patient_app/uitl/location_util.dart';
import 'package:hmg_patient_app/widgets/data_display/medical/medical_profile_item.dart';
import 'package:hmg_patient_app/widgets/others/app_scaffold_widget.dart';
import 'package:hmg_patient_app/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';

import '../../uitl/translations_delegate_base.dart';
import 'LiveChat/livechat_page.dart';
import 'findus/findus_page.dart';

class ContactUsPage extends StatefulWidget {
  @override
  _ContactUsPageState createState() => _ContactUsPageState();
}

class _ContactUsPageState extends State<ContactUsPage> {
  late LocationUtils locationUtils;

  @override
  void initState() {
    locationUtils = new LocationUtils(isShowConfirmDialog: true, context: context);
    WidgetsBinding.instance.addPostFrameCallback((_) => locationUtils.getCurrentLocation());

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    List<Widget> myMedicalList = myOptionsList(context);

    return AppScaffold(
      isShowAppBar: true,
      appBarTitle: TranslationBase.of(context).contactUs,
      isShowDecPage: false,
      showNewAppBar: true,
      showNewAppBarTitle: true,
      backgroundColor: Color(0xffF8F8F8),
      body: Column(
        children: [
          Container(
            width: double.infinity,
            height: 30,
          ),
          Padding(
            padding: EdgeInsets.only(left: 12, right: 12),
            child: GridView.builder(
              shrinkWrap: true,
              primary: false,
              physics: NeverScrollableScrollPhysics(),
              gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 2 / 2, crossAxisSpacing: 12, mainAxisSpacing: 12),
              padding: EdgeInsets.zero,
              itemCount: myMedicalList.length,
              itemBuilder: (BuildContext context, int index) {
                return myMedicalList[index];
              },
            ),
          ),
        ],
      ),
    );
  }

  List<Widget> myOptionsList(BuildContext context) {
    List<Widget> medical =[];

    medical.add(InkWell(
      onTap: () => Navigator.push(
        context,
        FadePage(page: FindUsPage()),
      ),
      child: MedicalProfileItem(
        title: TranslationBase.of(context).findUs,
        imagePath: 'assets/images/new-design/find_us_icon.png',
        subTitle: "",
        isPngImage: true,
      ),
    ));

    medical.add(InkWell(
      onTap: () => Navigator.push(
        context,
        FadePage(page: FeedbackHomePage()),
      ),
      child: MedicalProfileItem(
        title: TranslationBase.of(context).feedback,
        imagePath: 'assets/images/new-design/feedback_icon.png',
        subTitle: "",
        isPngImage: true,
      ),
    ));

    medical.add(InkWell(
      onTap: () => Navigator.push(
        context,
        FadePage(page: LiveChatPage()),
      ),
      child: MedicalProfileItem(
        title: TranslationBase.of(context).liveChat,
        imagePath: 'assets/images/new-design/live_chat_icon.png',
        subTitle: "",
        isPngImage: true,
      ),
    ));

    return medical;
  }
}
