Skip to content

Commit

Permalink
Changes in the Projects page (OWASP-BLT#426)
Browse files Browse the repository at this point in the history
* projects page and github apis integrated

* added the get contribtors feature

* added the contributors info card + dark mode compatibility

* github apis integrated and cacheing

* github api correction

* added title to contributors page

* cache data

* added the new project apis

* remove unused files and integrate on refresh

* Update lib/src/pages/home/home.dart

Co-authored-by: DonnieBLT <[email protected]>
Signed-off-by: Uttkarsh-raj <[email protected]>

* removed print

---------

Signed-off-by: Uttkarsh-raj <[email protected]>
Co-authored-by: DonnieBLT <[email protected]>
  • Loading branch information
Uttkarsh-raj and DonnieBLT authored Aug 2, 2024
1 parent ea20e2e commit 9d0f025
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/src/models/contributors_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Contributors {
name: json['name'],
githubId: json['github_id'],
githubUrl: json['github_url'],
image: json['avatar'],
image: json['avatar_url'],
type: json['contributor_type'],
contributions: json['contributions'],
);
Expand Down
12 changes: 5 additions & 7 deletions lib/src/models/project_model.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'package:blt/src/models/contributors_model.dart';

import '../util/util_import.dart';

class Project {
final int id;
final String name;
Expand All @@ -10,7 +8,7 @@ class Project {
final String github_url;
String? wiki_url;
String? homepage_url;
final String logo;
String? logo_url;
DateTime? created;
List<Contributors>? contributors;

Expand All @@ -22,7 +20,7 @@ class Project {
required this.github_url,
this.wiki_url,
this.homepage_url,
required this.logo,
this.logo_url,
this.created,
this.contributors,
});
Expand All @@ -35,7 +33,7 @@ class Project {
String? github_url,
String? wiki_url,
String? homepage_url,
String? logo,
String? logo_url,
DateTime? created,
List<Contributors>? contributors,
}) {
Expand All @@ -47,7 +45,7 @@ class Project {
github_url: github_url ?? this.github_url,
wiki_url: wiki_url ?? this.wiki_url,
homepage_url: homepage_url ?? this.homepage_url,
logo: logo ?? this.logo,
logo_url: logo_url ?? this.logo_url,
created: created ?? this.created,
contributors: contributors ?? this.contributors,
);
Expand All @@ -63,7 +61,7 @@ class Project {
wiki_url: json['wiki_url'] != null ? json['wiki_url'] as String : "",
homepage_url:
json['homepage_url'] != null ? json['homepage_url'] as String : "",
logo: GeneralEndPoints.baseUrl + json['logo'],
logo_url: json['logo_url'] != null ? json['logo_url'] : "",
created: json['created'] != null ? DateTime.parse(json['created']) : null,
contributors: json['contributors'] != null
? Contributors.fromSnapshot(json['contributors'])
Expand Down
22 changes: 13 additions & 9 deletions lib/src/pages/drawer/projects.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class _ContributorsPageState extends ConsumerState<ContributorsPage>
if (projectList!.isEmpty) {
return Center(
child: Text(
"${AppLocalizations.of(context)!.notManyBugs}:) \n ${AppLocalizations.of(context)!.yay}",
"Looks like there aren't many projects \n right now !",
textAlign: TextAlign.center,
),
);
Expand Down Expand Up @@ -165,7 +165,7 @@ class _ProjectSectionState extends State<ProjectSection> {
List<Contributors>? contributors = [];
@override
void initState() {
contributors = widget.project.contributors;
contributors = widget.project.contributors ?? [];
super.initState();
}

Expand All @@ -179,17 +179,21 @@ class _ProjectSectionState extends State<ProjectSection> {
children: [
Row(
children: [
SizedBox(
height: 25,
width: 25,
child: ClipRRect(
borderRadius: BorderRadius.circular(4),
child: CachedNetworkImage(imageUrl: widget.project.logo),
if (widget.project.logo_url != "")
SizedBox(
height: 25,
width: 25,
child: ClipRRect(
borderRadius: BorderRadius.circular(4),
child: CachedNetworkImage(imageUrl: widget.project.logo_url!),
),
),
),
SizedBox(width: 5),
Text(
widget.project.name,
softWrap: true,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: GoogleFonts.ubuntu(
textStyle: TextStyle(
color: Color(0xFFDC4654),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/util/api/project_apis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class ProjectAPiClient {
var uri = GeneralEndPoints.apiBaseUrl + "projects/";
var response = await http.get(Uri.parse(uri));
var json_res = json.decode(response.body);
print(json_res);
projects = Project.fromSnapshot(json_res['projects']);
} catch (e) {
print(projects);
print(e);
}
return projects;
Expand Down

0 comments on commit 9d0f025

Please sign in to comment.