import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../../../../app/app.dart';
import 'controller.dart';

final BoxDecoration decoration = BoxDecoration(
  border: Border.all(
    color: ThemeColor.mainColor,
  ),
  borderRadius: BorderRadius.circular(8),
);

class ContactsScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Material(
      color: ThemeColor.white,
      child: GetX<ContactsController>(
        init: ContactsController(),
        builder: (cc) => SafeArea(
          child: Scaffold(
            appBar: CustomAppbarWidget(
              leading: AppBarBackBtn(),
              elevation: 2,
            ),
            body: Container(
              padding: EdgeInsets.only(left: 30.w, right: 30.w, top: 20.h),
              child: SingleChildScrollView(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    AppTheme.appSizeDivider20H,
                    Text('contacts'.tr, style: AppTheme.headerStyle),
                    AppTheme.appSizeDivider20H,
                    AppTheme.appColorDivider,
                    AppTheme.appSizeDivider20H,
                    cc.isLoading.value
                        ? CustomLoader()
                        : cc.hasError.value
                            ? Center(child: retryBuilder(() => cc.getContacts()))
                            : Column(
                                children: [
                                  Container(
                                    decoration: decoration,
                                    child: ListTile(
                                      leading: Icon(Icons.phone),
                                      iconColor: ThemeColor.mainColor,
                                      title: Text(
                                        cc.contacts!.phone,
                                        style: TextStyle(fontSize: 16.sp),
                                      ),
                                    ),
                                  ),
                                  AppTheme.appSizeDivider30H,
                                  Container(
                                    decoration: decoration,
                                    child: ListTile(
                                      leading: Icon(Icons.email),
                                      iconColor: ThemeColor.mainColor,
                                      title: Text(
                                        cc.contacts!.mail,
                                        style: TextStyle(fontSize: 16.sp),
                                      ),
                                    ),
                                  ),
                                  AppTheme.appSizeDivider30H,
                                  Container(
                                    padding: const EdgeInsets.all(5.0),
                                    decoration: decoration,
                                    child: ListTile(
                                      leading: Icon(Icons.location_city_rounded),
                                      iconColor: ThemeColor.mainColor,
                                      title: Text(
                                        cc.contacts!.address,
                                        style: TextStyle(fontSize: 16.sp),
                                      ),
                                    ),
                                  ),
                                  AppTheme.appSizeDivider30H,
                                  Container(
                                    padding: const EdgeInsets.all(5.0),
                                    decoration: decoration,
                                    child: ListTile(
                                      leading: Icon(Icons.punch_clock),
                                      iconColor: ThemeColor.mainColor,
                                      title: Text(
                                        cc.contacts!.workHours,
                                        style: TextStyle(fontSize: 16.sp),
                                      ),
                                    ),
                                  ),
                                  AppTheme.appSizeDivider30H,
                                  ColoredButton(
                                    title: 'call'.tr,
                                    btnColor: ThemeColor.mainColor,
                                    callback: cc.makePhoneCall,
                                  ),
                                ],
                              ),
                  ],
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
