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 'package:loader_overlay/loader_overlay.dart';

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

class ProfilePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GetBuilder<ProfileController>(
      init: ProfileController(),
      builder: (pc) => pc.isLoggedIn.value
          ? ProfileLoggedInPage()
          : pc.isLoginPage.value
              ? LoginPage()
              : RegisterPage(),
    );
  }
}

class ProfileLoggedInPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    debugPrint('SettingsPage: build');
    return LoaderOverlay(
      child: GetBuilder<ProfileController>(
        init: ProfileController(),
        builder: (pc) => 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_PROFILE}/user.svg',
                      text: 'personal_detail'.tr,
                      topLeftBorder: 8.0,
                      topRightBorder: 8.0,
                      path: AppRoutes.PERSONAL_INFO,
                      callback: (route) => routeToSubPage(route, {}),
                    ),
                  ),
                  ListTileDivider(),
                  FadeInDown(
                    duration: const Duration(milliseconds: 850),
                    child: ListTileItem(
                      leading: '${Constants.ASSET_PATH_PROFILE}/heart.svg',
                      text: 'wishlist'.tr,
                      path: AppRoutes.WISHLIST,
                      callback: (route) => routeToSubPage(route, {}),
                    ),
                  ),
                  ListTileDivider(),
                  FadeInDown(
                    child: ListTileItem(
                      leading: '${Constants.ASSET_PATH_PROFILE}/archive.svg',
                      text: 'order_history'.tr,
                      path: AppRoutes.ORDERS,
                      callback: (route) => routeToSubPage(route, {}),
                      bottomLeftBorder: 8.0,
                      bottomRightBorder: 8.0,
                    ),
                  ),
                  // ListTileDivider(),
                  // FadeInDown(
                  //   child: ListTileItem(
                  //     leading: '${Constants.ASSET_PATH_PROFILE}/coin.svg',
                  //     text: 'История пополнений',
                  //     bottomLeftBorder: 8.0,
                  //     bottomRightBorder: 8.0,
                  //   ),
                  // ),
                  SizedBox(height: 20.h),
                  FadeInUp(
                    child: ListTileItem(
                      leading: '${Constants.ASSET_PATH_PROFILE}/log-out.svg',
                      text: 'logout'.tr,
                      topLeftBorder: 8.0,
                      topRightBorder: 8.0,
                      bottomLeftBorder: 8.0,
                      bottomRightBorder: 8.0,
                      path: AppRoutes.LOGIN,
                      callback: (value) => pc.onLogoutTapped(),
                    ),
                  ),
                  SizedBox(height: 20.h),
                  FadeInUp(
                    child: ListTileItem(
                      leading: '${Constants.ASSET_PATH_PROFILE}/remove-user.svg',
                      text: 'delete_account'.tr,
                      topLeftBorder: 8.0,
                      topRightBorder: 8.0,
                      bottomLeftBorder: 8.0,
                      bottomRightBorder: 8.0,
                      path: AppRoutes.LOGIN,
                      callback: (value) => pc.onDeleteAccountTapped(context),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}
