import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hooks_riverpod/hooks_riverpod.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';

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);
    // DM Sans 作主字体（拉丁/数字），中文走系统级联（iOS 苹方 / Android 厂商
    // 中文字体）——主流做法，不显式点名、不内置字体。
    final dmSansFamily = GoogleFonts.dmSans().fontFamily;
    final textTheme = ShadTextTheme(family: dmSansFamily);
    return 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,
    );
  }
}
