Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: contributors dialog #641

Merged
merged 2 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ContributorsModel {
ContributorsModel({required this.avatarUrl, required this.profilePath});

ContributorsModel.fromJson(Map<String, String?> json)
ContributorsModel.fromJson(Map<String, dynamic> json)
: profilePath = json['html_url'].toString(),
avatarUrl = json['avatar_url'].toString();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:convert' as convert;
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:http/http.dart' as http;
Expand Down Expand Up @@ -239,27 +240,31 @@ class UserContributionView extends StatelessWidget {
);
}

Future<void> _contributors(BuildContext context) async {
Future<void> _contributors(BuildContext context) {
return showDialog<void>(
context: context,
builder: (BuildContext context) {
return SmoothAlertDialog(
title: AppLocalizations.of(context)!.contributors,
body: FutureBuilder<http.Response>(
future: http.get(Uri.https('api.github.com',
'/repos/openfoodfacts/smooth-app/contributors')),
future: http.get(
Uri.https(
'api.github.com',
'/repos/openfoodfacts/smooth-app/contributors',
),
),
builder: (BuildContext context, AsyncSnapshot<http.Response> snap) {
if (snap.hasData) {
final List<dynamic> contributors =
convert.jsonDecode(snap.data!.body) as List<dynamic>;
jsonDecode(snap.data!.body) as List<dynamic>;

return SingleChildScrollView(
child: Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: contributors.map((dynamic contributorsData) {
final ContributorsModel _contributor =
ContributorsModel.fromJson(
contributorsData as Map<String, String>);
contributorsData as Map<String, dynamic>);

return Padding(
padding: const EdgeInsets.all(5.0),
Expand All @@ -271,7 +276,8 @@ class UserContributionView extends StatelessWidget {
child: CircleAvatar(
foregroundImage:
NetworkImage(_contributor.avatarUrl),
backgroundColor: Colors.brown.shade800,
backgroundColor:
Theme.of(context).colorScheme.primary,
),
),
);
Expand Down