Skip to content

Commit

Permalink
Merge pull request #367 from rishabh7923/main
Browse files Browse the repository at this point in the history
Fixed Redox Search Bug
  • Loading branch information
andoriyaprashant authored Oct 17, 2024
2 parents 49da3a4 + 1abdecb commit a743e04
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions lib/programs screen/redox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ class RsocPage extends StatefulWidget {
}

class _RsocPageState extends State<RsocPage> {
List<RsocProjectModal> projectList = [];
List<RsocProjectModal> projects = [];
List<RsocProjectModal> allProjects =[];

String currectPage = "/rsoc";
String currentProject = "RSoC";
bool isBookmarked = true;
Expand All @@ -26,9 +28,10 @@ class _RsocPageState extends State<RsocPage> {
await rootBundle.loadString('assets/projects/redox/redox.json');
var jsonList = await json.decode(response);
for (var data in jsonList) {
projectList.add(RsocProjectModal.fromJson(data));
allProjects.add(RsocProjectModal.fromJson(data));
}
print(projectList);

projects = allProjects;
}

@override
Expand All @@ -45,20 +48,15 @@ class _RsocPageState extends State<RsocPage> {
});
}

void searchTag(String searchTag) {
projectList = projectList
.where((element) => element.name.toLowerCase().contains(searchTag))
.toList();
setState(() {});
}

void search(String searchText) {
if (searchText.isEmpty) {
projects = allProjects;
setState(() {});
return;
}

searchText = searchText.toLowerCase();
projectList = projectList
projects = allProjects
.where((element) =>
element.name.toLowerCase().contains(searchText) ||
element.contributor.toLowerCase().contains(searchText))
Expand All @@ -67,7 +65,7 @@ class _RsocPageState extends State<RsocPage> {
}

Future<void> _refresh() async {
projectList.clear();
projects.clear();
await initializeProjectLists();
setState(() {});
}
Expand Down Expand Up @@ -159,25 +157,20 @@ class _RsocPageState extends State<RsocPage> {
horizontal: ScreenUtil().setWidth(20),
),
),
onFieldSubmitted: (value) {
search(value.trim());
},
onChanged: (value) {
if (value.isEmpty) {
search(value);
}
search(value.trim());
},
),
SizedBox(height: ScreenUtil().setHeight(20)),
SizedBox(
height: MediaQuery.of(context).size.height * 0.8,
height: MediaQuery.of(context).size.height * 0.9,
child: ListView.builder(
itemCount: projectList.length,
itemCount: projects.length,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: RsocProjectWidget(
modal: projectList[index],
modal: projects[index],
height: ScreenUtil().screenHeight * 0.10,
width: ScreenUtil().screenWidth,
index: index+1,
Expand Down

0 comments on commit a743e04

Please sign in to comment.