import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:novyronst/common/help/help_image.dart'; import 'package:novyronst/tools/widgets/novy_com_widget.dart'; class RecentHistoryView extends StatelessWidget { const RecentHistoryView({super.key, required this.searchHistory, this.onTapHistory, this.onTapClear, }); final List searchHistory; final ValueChanged? onTapHistory; final Function()? onTapClear; @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.symmetric(horizontal: 15.w), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Expanded(child: NovyText('Recent Searches', fontSize: 14, color: Colors.white, fontWeight: FontWeight.bold, lineHeight: 1, )), InkWell(onTap: () { onTapClear?.call(); }, child: HelpImage.asset(ConstImage.remove, width: 36, height: 36)), ], ), const SizedBox(height: 8), Wrap( spacing: 16.w, runSpacing: 14.h, children: searchHistory .map( (item) => _HistoryChip( text: item, onTap: () => onTapHistory?.call(item), ), ) .toList(), ), ], ), ); } } class _HistoryChip extends StatelessWidget { const _HistoryChip({ required this.text, this.onTap, }); final String text; final VoidCallback? onTap; @override Widget build(BuildContext context) { return InkWell( onTap: onTap, child: Container( padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 5.h), decoration: BoxDecoration( color: Colors.white.withAlpha(39), borderRadius: BorderRadius.circular(6), ), child: Text( text, style: TextStyle( color: Colors.white, fontSize: 12.sp, fontWeight: FontWeight.w500, height: 1, ), ), ), ); } }