Skip to content

Commit 11a0286

Browse files
committed
feat: little something
1 parent 18632b5 commit 11a0286

File tree

3 files changed

+176
-159
lines changed

3 files changed

+176
-159
lines changed

lib/Screens/Search/SearchScreen.dart

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ class SearchScreenState extends State<SearchScreen> {
6666
}
6767

6868
Widget _buildContent() {
69-
var key = "${service.getName}${widget.title.name.toUpperCase()}_searchHistory";
69+
var key =
70+
"${service.getName}${widget.title.name.toUpperCase()}_searchHistory";
7071
var theme = context.theme.colorScheme;
7172
List<String> searchHistory = loadCustomData(key) ?? [];
7273

@@ -81,60 +82,67 @@ class SearchScreenState extends State<SearchScreen> {
8182
padding: const EdgeInsets.symmetric(vertical: 8),
8283
child: Obx(() {
8384
if (screen.showHistory.value) {
84-
return ListView.builder(
85-
shrinkWrap: true,
86-
physics: const NeverScrollableScrollPhysics(),
87-
itemCount: searchHistory.length,
88-
itemBuilder: (context, index) {
89-
return Padding(
90-
padding: const EdgeInsets.symmetric(
91-
vertical: 4.0,
92-
horizontal: 24.0,
93-
),
94-
child: Card(
95-
elevation: 3,
96-
shape: RoundedRectangleBorder(
97-
borderRadius: BorderRadius.circular(10),
98-
),
99-
child: ListTile(
100-
title: Text(
101-
searchHistory[index],
102-
style: TextStyle(
103-
color: theme.onSurface,
104-
fontWeight: FontWeight.bold,
105-
),
106-
),
107-
contentPadding: const EdgeInsets.only(
108-
right: 8,
109-
bottom: 4,
110-
top: 4,
111-
left: 16,
85+
return Column(
86+
children: [
87+
...screen.topWidget(context),
88+
ListView.builder(
89+
shrinkWrap: true,
90+
physics: const NeverScrollableScrollPhysics(),
91+
itemCount: searchHistory.length,
92+
itemBuilder: (context, index) {
93+
return Padding(
94+
padding: const EdgeInsets.symmetric(
95+
vertical: 4.0,
96+
horizontal: 24.0,
11297
),
113-
trailing: IconButton(
114-
icon: Icon(
115-
FontAwesome.trash_solid,
116-
size: 18,
98+
child: Card(
99+
elevation: 3,
100+
shape: RoundedRectangleBorder(
101+
borderRadius: BorderRadius.circular(10),
102+
),
103+
child: ListTile(
104+
title: Text(
105+
searchHistory[index],
106+
style: TextStyle(
107+
color: theme.onSurface,
108+
fontWeight: FontWeight.bold,
109+
),
110+
),
111+
contentPadding: const EdgeInsets.only(
112+
right: 8,
113+
bottom: 4,
114+
top: 4,
115+
left: 16,
116+
),
117+
trailing: IconButton(
118+
icon: Icon(
119+
FontAwesome.trash_solid,
120+
size: 18,
121+
),
122+
onPressed: () {
123+
setState(() {
124+
var list =
125+
List<String>.from(searchHistory);
126+
list.removeAt(index);
127+
saveCustomData(key, list);
128+
});
129+
},
130+
),
131+
onTap: () {
132+
_searchController.text = searchHistory[index];
133+
_onSearchChanged(searchHistory[index]);
134+
},
117135
),
118-
onPressed: () {
119-
setState(() {
120-
var list = List<String>.from(searchHistory);
121-
list.removeAt(index);
122-
saveCustomData(key, list);
123-
});
124-
},
125136
),
126-
onTap: () {
127-
_searchController.text = searchHistory[index];
128-
_onSearchChanged(searchHistory[index]);
129-
},
130-
),
131-
),
132-
);
133-
},
137+
);
138+
},
139+
)
140+
],
134141
);
135142
} else {
136143
return Column(
137144
children: [
145+
...screen.topWidget(context),
138146
...screen.searchWidget(context),
139147
SizedBox(
140148
height: 64,
@@ -244,7 +252,8 @@ class SearchScreenState extends State<SearchScreen> {
244252
void _onSearchChanged(String value) {
245253
if (_debounce?.isActive ?? false) _debounce!.cancel();
246254
_debounce = Timer(const Duration(milliseconds: 500), () {
247-
var key = "${service.getName}${widget.title.name.toUpperCase()}_searchHistory";
255+
var key =
256+
"${service.getName}${widget.title.name.toUpperCase()}_searchHistory";
248257
List<String> searchHistory = loadCustomData(key) ?? [];
249258
if (!searchHistory.contains(value.trim().toLowerCase()) &&
250259
value.isNotEmpty) {

lib/Services/Screens/BaseSearchScreen.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ abstract class BaseSearchScreen extends GetxController {
2525

2626
List<Widget> searchWidget(BuildContext context);
2727

28+
List<Widget> topWidget(BuildContext context) => [];
29+
2830
Future<void>? loadNextPage() => null;
2931

3032
void init({SearchResults? s}) {

0 commit comments

Comments
 (0)