import 'package:flutter/material.dart';

import '../../presentation/components/assets/fonts.gen.dart';

part 'app_color.dart';
part 'app_style.dart';
part 'app_value.dart';

UnderlineInputBorder _inputBorder = UnderlineInputBorder(
  borderSide: BorderSide(color: AppColor.borderDark, width: 1),
);

class ThemeApp {
  static ThemeData get theme => ThemeData(
    useMaterial3: true,
    fontFamily: FontFamily.quicksand,
    primaryColor: AppColor.primary,
    scaffoldBackgroundColor: AppColor.white,
    datePickerTheme: DatePickerThemeData(
      backgroundColor: AppColor.white,
      todayBackgroundColor: MaterialStateProperty.resolveWith<Color?>((states) {
        if (states.contains(MaterialState.selected)) {
          return AppColor.primary; // warna background tanggal terpilih
        }
        return null; // default
      }),
      todayBorder: BorderSide(color: AppColor.primary, width: 1),
      dayBackgroundColor: MaterialStateProperty.resolveWith<Color?>((states) {
        if (states.contains(MaterialState.selected)) {
          return AppColor.primary; // warna background tanggal terpilih
        }
        return null; // default
      }),
      dayForegroundColor: MaterialStateProperty.resolveWith<Color?>((states) {
        if (states.contains(MaterialState.selected)) {
          return AppColor.white; // warna text tanggal terpilih
        }
        return null; // default
      }),
    ),
    appBarTheme: AppBarTheme(
      backgroundColor: AppColor.white,
      foregroundColor: AppColor.textPrimary,
      elevation: 0,
      titleTextStyle: AppStyle.xl.copyWith(
        color: AppColor.primary,
        fontWeight: FontWeight.w600,
      ),
      centerTitle: true,
      iconTheme: IconThemeData(color: AppColor.primary),
      scrolledUnderElevation: 0.0,
    ),
    elevatedButtonTheme: ElevatedButtonThemeData(
      style: ElevatedButton.styleFrom(
        backgroundColor: AppColor.primary,
        foregroundColor: Colors.white,
        elevation: 0,
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
      ),
    ),
    inputDecorationTheme: InputDecorationTheme(
      border: _inputBorder,
      focusedBorder: _inputBorder.copyWith(
        borderSide: BorderSide(color: AppColor.primary, width: 2),
      ),
      enabledBorder: _inputBorder,
      disabledBorder: _inputBorder.copyWith(
        borderSide: BorderSide(color: AppColor.border),
      ),
      errorBorder: _inputBorder.copyWith(
        borderSide: BorderSide(color: AppColor.error),
      ),
      hintStyle: AppStyle.md.copyWith(
        color: AppColor.textLight,
        fontWeight: FontWeight.w500,
      ),
      contentPadding: const EdgeInsets.symmetric(vertical: 12),
    ),
    bottomNavigationBarTheme: BottomNavigationBarThemeData(
      type: BottomNavigationBarType.fixed,
      selectedItemColor: AppColor.primary,
      unselectedItemColor: AppColor.textSecondary,
      backgroundColor: AppColor.white,
      elevation: 4,
    ),
    tabBarTheme: TabBarThemeData(
      indicatorColor: AppColor.primary,
      labelColor: AppColor.primary,
      unselectedLabelColor: AppColor.textSecondary,
    ),
  );
}
