// harness.dart — 测试公共脚手架
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:pangolin_vpn/pangolin_theme.dart';

/// 测试环境禁用 google_fonts 运行时网络拉取(离线确定化)。
void disableGoogleFontsFetching() {
  GoogleFonts.config.allowRuntimeFetching = false;
}

/// 用穿山甲明/暗主题包裹被测组件,并固定宽度便于 golden 对照。
Widget wrapThemed(
  Widget child, {
  bool dark = false,
  double width = 360,
  List<Override> overrides = const [],
}) {
  return ProviderScope(
    overrides: overrides,
    child: MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: PangolinTheme.light,
      darkTheme: PangolinTheme.dark,
      themeMode: dark ? ThemeMode.dark : ThemeMode.light,
      home: Scaffold(
        body: Center(
          child: SizedBox(width: width, child: child),
        ),
      ),
    ),
  );
}
