import 'package:flutter/widgets.dart'; import '../domain/diff_search.dart'; /// The active diff search, handed down to the rendered patch lines: the query /// they highlight, the current match drawn stronger and the key that match's /// line carries so the page can scroll it into view. class DiffHighlight extends InheritedWidget { const DiffHighlight({ super.key, required this.query, required this.current, required this.currentKey, required super.child, }); final String query; final DiffMatch? current; final GlobalKey currentKey; bool get active => query.trim().isNotEmpty; static DiffHighlight? maybeOf(BuildContext context) => context.dependOnInheritedWidgetOfExactType(); @override bool updateShouldNotify(DiffHighlight oldWidget) => query != oldWidget.query || current != oldWidget.current; } /// The index of the file a rendered patch belongs to in the viewed list, so a /// line can tell whether the current match is on it. class DiffFileIndex extends InheritedWidget { const DiffFileIndex({super.key, required this.index, required super.child}); final int index; static int? maybeOf(BuildContext context) => context.dependOnInheritedWidgetOfExactType()?.index; @override bool updateShouldNotify(DiffFileIndex oldWidget) => index != oldWidget.index; }