import 'package:component_library/src/theme/golek_theme_data.dart';
import 'package:flutter/material.dart';

class GolekTheme extends InheritedWidget {
  const GolekTheme({
    required Widget child,
    required this.lightTheme,
    required this.darkTheme,
    Key? key,
  }) : super(
          key: key,
          child: child,
        );

  final GolekThemeData lightTheme;
  final GolekThemeData darkTheme;

  @override
  bool updateShouldNotify(
    GolekTheme oldWidget,
  ) =>
      oldWidget.lightTheme != lightTheme || oldWidget.darkTheme != darkTheme;

  static GolekThemeData of(BuildContext context) {
    final GolekTheme? inheritedTheme =
        context.dependOnInheritedWidgetOfExactType<GolekTheme>();
    assert(inheritedTheme != null, 'No GolekTheme found in context');
    final currentBrightness = Theme.of(context).brightness;
    return currentBrightness == Brightness.dark
        ? inheritedTheme!.darkTheme
        : inheritedTheme!.lightTheme;
  }
}
