You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.9 KiB
Dart
82 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
|
import 'package:mc_common_app/widgets/common_widgets/custom_rectangle_chip.dart';
|
|
import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart';
|
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
|
|
class SearchEntityWidget extends StatelessWidget {
|
|
final String title;
|
|
final Widget actionWidget;
|
|
final List<DropValue> historyContent;
|
|
final List<String>? historyContentString;
|
|
final Function(int) onHistoryItemDeleted;
|
|
final Function(DropValue) onHistoryItemTapped;
|
|
final bool isForString;
|
|
|
|
const SearchEntityWidget({
|
|
super.key,
|
|
required this.title,
|
|
required this.actionWidget,
|
|
required this.historyContent,
|
|
this.historyContentString,
|
|
required this.onHistoryItemDeleted,
|
|
required this.onHistoryItemTapped,
|
|
this.isForString = false,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
if (title.isNotEmpty) ...[
|
|
title.toText(fontSize: 16, isBold: true),
|
|
8.height,
|
|
],
|
|
actionWidget,
|
|
10.height,
|
|
if (isForString && historyContentString != null && historyContentString!.isNotEmpty) ...[
|
|
SizedBox(
|
|
height: 33,
|
|
child: ListView.builder(
|
|
shrinkWrap: true,
|
|
scrollDirection: Axis.horizontal,
|
|
itemCount: historyContentString!.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return CustomRectangleChip(
|
|
text: historyContentString![index],
|
|
onHistoryItemDeleted: () {
|
|
onHistoryItemDeleted(index);
|
|
},
|
|
onHistoryItemTapped: () {},
|
|
).paddingOnly(right: 10);
|
|
}),
|
|
)
|
|
] else ...[
|
|
historyContent.isNotEmpty
|
|
? SizedBox(
|
|
height: 33,
|
|
child: ListView.builder(
|
|
shrinkWrap: true,
|
|
scrollDirection: Axis.horizontal,
|
|
itemCount: historyContent.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return CustomRectangleChip(
|
|
text: historyContent[index].value,
|
|
onHistoryItemDeleted: () {
|
|
onHistoryItemDeleted(index);
|
|
},
|
|
onHistoryItemTapped: () {
|
|
onHistoryItemTapped(historyContent[index]);
|
|
},
|
|
).paddingOnly(right: 10);
|
|
}),
|
|
)
|
|
: const SizedBox.shrink(),
|
|
]
|
|
],
|
|
);
|
|
}
|
|
}
|