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

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

class SettingsPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    debugPrint('SettingsPage: build');
    return GetX<SettingsController>(
      init: SettingsController(),
      builder: (sc) => SafeArea(
        child: Scaffold(
          backgroundColor: ThemeColor.scaffoldBckColor,
          appBar: CustomAppbarWidget(),
          body: SingleChildScrollView(
            child: Column(
              children: [
                AppTheme.appSizeDivider30H,
                FadeInDown(
                  duration: const Duration(milliseconds: 900),
                  child: ListTileItem(
                    leading: '${Constants.ASSET_PATH_SETTINGS}/translate.svg',
                    text: 'lang'.tr,
                    topLeftBorder: 8.0,
                    topRightBorder: 8.0,
                    path: AppRoutes.CHANGE_LANG,
                    callback: (route) => routeToSubPage(route, {}),
                  ),
                ),
                ListTileDivider(),
                /*  FadeInDown(
                duration: const Duration(milliseconds: 850),
                child: ListTileItem(
                  leading: '${Constants.ASSET_PATH_SETTINGS}/writing.svg',
                  text: 'Политика конфиденциальности',
                ),
              ), */
                ListTileDivider(),
                /* FadeInDown(
                  child: ListTileItem(
                    leading: '${Constants.ASSET_PATH_SETTINGS}/mail-inbox-app.svg',
                    text: 'feedback'.tr,
                    // bottomLeftBorder: 8.0,
                    // bottomRightBorder: 8.0,
                  ),
                ),
                ListTileDivider(), */
                FadeInUp(
                  child: ListTileItem(
                    leading: '${Constants.ASSET_PATH_SETTINGS}/phone-call.svg',
                    text: 'contacts'.tr,
                    // topLeftBorder: 8.0,
                    // topRightBorder: 8.0,
                    bottomLeftBorder: 8.0,
                    bottomRightBorder: 8.0,
                    path: AppRoutes.CONTACTS,
                    callback: (route) => routeToSubPage(route, {}),
                  ),
                ),
                SizedBox(height: 20.h),
                sc.isLoading.value
                    ? CustomLoader()
                    : ListView.separated(
                        shrinkWrap: true,
                        physics: NeverScrollableScrollPhysics(),
                        itemCount: sc.cmsList.length,
                        itemBuilder: (_, index) => FadeIn(
                          child: ListTileItem(
                            leading: '${Constants.ASSET_PATH_SETTINGS}/writing.svg',
                            text: '${sc.cmsList[index].pageTitle}',
                            path: AppRoutes.CMS,
                            callback: (route) => routeToSubPage(
                              route,
                              {'html_content': sc.cmsList[index].htmlContent},
                            ),
                            topLeftBorder: index == 0 ? 8.0 : 0.0,
                            topRightBorder: index == 0 ? 8.0 : 0.0,
                            bottomLeftBorder: index == sc.cmsList.length - 1 ? 8.0 : 0.0,
                            bottomRightBorder: index == sc.cmsList.length - 1 ? 8.0 : 0.0,
                          ),
                        ),
                        separatorBuilder: (_, int index) => ListTileDivider(),
                      )
              ],
            ),
          ),
        ),
      ),
    );
  }
}
