-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
1,134 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:google_fonts/google_fonts.dart'; | ||
|
||
import '../models/issue_model.dart'; | ||
|
||
class IssueStatusChip extends StatelessWidget { | ||
final Issue issue; | ||
const IssueStatusChip({ | ||
Key? key, | ||
required this.issue, | ||
}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Chip( | ||
label: Text( | ||
(issue.isOpen) ? "Open" : "Closed", | ||
style: GoogleFonts.aBeeZee( | ||
textStyle: TextStyle( | ||
fontSize: 10, | ||
color: (issue.isOpen) ? Color(0xFFA3A3A3) : Color(0xFFDC4654), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import 'package:bugheist/components/issue_intro_card.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:google_fonts/google_fonts.dart'; | ||
|
||
import '../models/issuedata_model.dart'; | ||
import '../util/api/issues_api.dart'; | ||
|
||
class BugHeistSearchDelegate extends SearchDelegate { | ||
@override | ||
List<Widget>? buildActions(BuildContext context) { | ||
return [ | ||
IconButton( | ||
onPressed: () { | ||
query = ''; | ||
}, | ||
icon: Icon( | ||
Icons.clear, | ||
color: Color(0xFFDC4654), | ||
), | ||
), | ||
]; | ||
} | ||
|
||
@override | ||
Widget? buildLeading(BuildContext context) { | ||
return IconButton( | ||
icon: Icon( | ||
Icons.arrow_back_ios_new_rounded, | ||
color: Color(0xFFDC4654), | ||
), | ||
onPressed: () { | ||
Navigator.of(context).pop(); | ||
}, | ||
); | ||
} | ||
|
||
@override | ||
Widget buildResults(BuildContext context) { | ||
Future _getObj = IssueApiClient.searchIssueByKeyWord(query); | ||
|
||
ScrollController _scrollController = new ScrollController(); | ||
|
||
return FutureBuilder( | ||
future: _getObj, | ||
builder: (context, snapshot) { | ||
if (snapshot.connectionState == ConnectionState.done) { | ||
if (snapshot.hasError) { | ||
return Center( | ||
child: Text( | ||
'Something went wrong!', | ||
style: TextStyle(fontSize: 18), | ||
), | ||
); | ||
} else if (snapshot.hasData) { | ||
return ListView.builder( | ||
padding: EdgeInsets.symmetric(horizontal: 20), | ||
itemCount: (snapshot.data! as IssueData).issueList!.length, | ||
controller: _scrollController, | ||
itemBuilder: (context, index) { | ||
return IssueCard( | ||
issue: (snapshot.data! as IssueData).issueList![index], | ||
); | ||
}, | ||
); | ||
} | ||
} | ||
return Center( | ||
child: CircularProgressIndicator(), | ||
); | ||
}, | ||
); | ||
} | ||
|
||
@override | ||
Widget buildSuggestions(BuildContext context) { | ||
final Size size = MediaQuery.of(context).size; | ||
return Container( | ||
width: size.width, | ||
height: size.height, | ||
child: Center( | ||
child: Text( | ||
'Search an issue!', | ||
style: GoogleFonts.ubuntu( | ||
textStyle: TextStyle( | ||
color: Color(0xFF737373), | ||
fontSize: 20, | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import 'package:intl/intl.dart'; | ||
|
||
import './user_model.dart'; | ||
|
||
class Issue { | ||
final int id; | ||
final User? user; | ||
final String url; | ||
final String description; | ||
final String label; | ||
final bool isVerified; | ||
final int? score; | ||
final bool isOpen; | ||
final String userAgent; | ||
final String ocr; | ||
final String screenshotLink; | ||
final DateTime? closedDate; | ||
final String githubUrl; | ||
final DateTime created; | ||
final DateTime? lastModified; | ||
final int? hunt; | ||
final int? domain; | ||
final String? closedBy; | ||
|
||
final DateFormat dateFormatter = DateFormat('d MMMM, yyyy'); | ||
|
||
String? get closed_date { | ||
return (closedDate != null) | ||
? dateFormatter.format(closedDate!.toLocal()) | ||
: null; | ||
} | ||
|
||
String get created_date => dateFormatter.format(created.toLocal()); | ||
|
||
String? get last_modified_date { | ||
return (lastModified != null) | ||
? dateFormatter.format(lastModified!.toLocal()) | ||
: null; | ||
} | ||
|
||
Issue({ | ||
required this.id, | ||
this.user, | ||
required this.url, | ||
required this.description, | ||
required this.label, | ||
required this.isVerified, | ||
this.score, | ||
required this.isOpen, | ||
required this.userAgent, | ||
required this.ocr, | ||
required this.screenshotLink, | ||
this.closedDate, | ||
required this.githubUrl, | ||
required this.created, | ||
this.lastModified, | ||
this.hunt, | ||
this.domain, | ||
this.closedBy, | ||
}); | ||
|
||
factory Issue.fromJson(Map<String, dynamic> responseData) { | ||
return Issue( | ||
id: responseData["id"], | ||
user: (responseData["user"] != null) | ||
? User( | ||
id: responseData["user"]["id"], | ||
username: responseData["user"]["username"], | ||
) | ||
: null, | ||
url: responseData["url"], | ||
description: responseData["description"], | ||
label: responseData["label"].toString(), | ||
isVerified: responseData["verified"], | ||
score: responseData["score"], | ||
isOpen: (responseData["status"] == "open") ? true : false, | ||
userAgent: responseData["user_agent"], | ||
ocr: responseData["ocr"], | ||
screenshotLink: responseData["screenshot"], | ||
closedDate: (responseData["closed_date"].runtimeType != Null) | ||
? DateTime.parse(responseData["closed_date"]) | ||
: null, | ||
githubUrl: responseData["github_url"], | ||
created: DateTime.parse(responseData["created"]), | ||
lastModified: DateTime.parse(responseData["modified"]), | ||
hunt: responseData["hunt"], | ||
domain: responseData["domain"], | ||
closedBy: responseData["closed_by"], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:bugheist/models/issue_model.dart'; | ||
|
||
class IssueData { | ||
final int count; | ||
String? nextQuery; | ||
String? previousQuery; | ||
List<Issue>? issueList; | ||
|
||
IssueData({ | ||
required this.count, | ||
this.nextQuery, | ||
this.previousQuery, | ||
this.issueList, | ||
}); | ||
|
||
factory IssueData.fromJson(Map<String, dynamic> responseData) { | ||
print(responseData["next"]); | ||
return IssueData( | ||
count: responseData["count"], | ||
nextQuery: responseData["next"], | ||
previousQuery: responseData["previous"], | ||
issueList: responseData["results"], | ||
); | ||
} | ||
} |
Oops, something went wrong.