import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shadcn_ui/shadcn_ui.dart';

import '../common/router/app_router.dart';
import '../common/theme/jinzhi_theme.dart';
import '../common/theme/spacing.dart';
import '../common/theme/theme_controller.dart';
import '../common/widgets/smart_refresh.dart';

class JinzhiApp extends ConsumerWidget {
  const JinzhiApp({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final router = ref.watch(routerProvider);
    final mode = ref.watch(themeModeControllerProvider);
    final textTheme = ShadTextTheme();
    return RefreshConfiguration(
      springDescription: const SpringDescription(
        mass: 1,
        stiffness: 364.718677686,
        damping: 35.2,
      ),
      headerBuilder: () => const MaterialClassicHeader(),
      footerBuilder: () => jinzhiClassicFooter,
      hideFooterWhenNotFull: true,
      headerTriggerDistance: 60,
      maxOverScrollExtent: 100,
      child: ShadApp.router(
        title: '金值',
        themeMode: mode,
        theme: ShadThemeData(
          brightness: Brightness.light,
          colorScheme: jinzhiLightScheme,
          textTheme: textTheme,
          radius: BorderRadius.circular(Spacing.radiusBase),
        ),
        darkTheme: ShadThemeData(
          brightness: Brightness.dark,
          colorScheme: jinzhiDarkScheme,
          textTheme: textTheme,
          radius: BorderRadius.circular(Spacing.radiusBase),
        ),
        routerConfig: router,
      ),
    );
  }
}
