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

grid view option added for contributor list #96

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
112 changes: 105 additions & 7 deletions lib/contributors_screen/contributorsScreen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hacktoberfest/contributors_screen/user.dart';
import 'package:hacktoberfest/themes.dart';
import 'package:hacktoberfest/util/custom_grid_tile.dart';
import 'package:hacktoberfest/util/custom_tile.dart';

import '../contributorsList.dart';
Expand All @@ -15,6 +17,11 @@ class ContributorsScreen extends StatefulWidget {
class _ContributorsScreenState extends State<ContributorsScreen> {
List<User> users = getUsers();

bool _isLinear = true;
bool _isSearchTextOn = false;

String _searchName = "";

@override
Widget build(BuildContext context) {
return Container(
Expand Down Expand Up @@ -44,6 +51,82 @@ class _ContributorsScreenState extends State<ContributorsScreen> {
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
IconButton(
onPressed: () {
setState(() {
_isLinear = true;
});
},
icon: (_isLinear == true)
? const Icon(Icons.menu,
color: Colors.blueGrey, size: 34.0)
: const Icon(Icons.menu,
color: Colors.white, size: 24.0),
),
const SizedBox(width: 5.0),
IconButton(
onPressed: () {
setState(() {
_isLinear = false;
});
},
icon: (_isLinear == false)
? const Icon(Icons.grid_view,
color: Colors.blueGrey, size: 34.0)
: const Icon(Icons.grid_view,
color: Colors.white, size: 24.0),
),
],
),
Row(
children: [
(_isSearchTextOn)
? Container(
height: 35.0,
width: MediaQuery.of(context).size.width * 0.5,
padding: const EdgeInsets.fromLTRB(5, 5, 5, 0),
color: Colors.white,
child: TextField(
onChanged: (text) {
setState(() {
_searchName = text.trim();
});
},
maxLines: 1,
style: TextStyle(
color: Colors.black,
fontFamily:
GoogleFonts.openSans().fontFamily),
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Type a name...',
hintStyle: TextStyle(
color: Colors.grey,
fontFamily:
GoogleFonts.openSans().fontFamily)),
),
)
: Container(),
IconButton(
onPressed: () {
setState(() {
_isSearchTextOn = !_isSearchTextOn;
_searchName = "";
});
},
icon: (!_isSearchTextOn)
? const Icon(Icons.search, color: Colors.white)
: const Icon(Icons.search_off_outlined,
color: Colors.white)),
],
),
],
),
Flexible(
child: SizedBox(
// height: 400,
Expand All @@ -57,11 +140,26 @@ class _ContributorsScreenState extends State<ContributorsScreen> {
);
}

Widget buildUser(List<User> users) => ListView.builder(
itemCount: users.length,
itemBuilder: ((context, index) {
final user = users[index];
return CListTile(Name: user.name, Username: user.username);
}),
);
Widget buildUser(List<User> users) => (_isLinear)
? ListView.builder(
itemCount: users.length,
itemBuilder: ((context, index) {
final user = users[index];
return (user.name.toLowerCase().contains(_searchName.toLowerCase()))
? CListTile(Name: user.name, Username: user.username)
: Container();
}),
)
: GridView.builder(
itemCount: users.length,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
),
itemBuilder: ((context, index) {
final user = users[index];
return (user.name.toLowerCase().contains(_searchName.toLowerCase()))
? CGridTile(Name: user.name, Username: user.username)
: Container();
}),
);
}
17 changes: 17 additions & 0 deletions lib/generated_plugin_registrant.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Generated file. Do not edit.
//

// ignore_for_file: directives_ordering
// ignore_for_file: lines_longer_than_80_chars
// ignore_for_file: depend_on_referenced_packages

import 'package:url_launcher_web/url_launcher_web.dart';

import 'package:flutter_web_plugins/flutter_web_plugins.dart';

// ignore: public_member_api_docs
void registerPlugins(Registrar registrar) {
UrlLauncherPlugin.registerWith(registrar);
registrar.registerMessageHandler();
}
5 changes: 5 additions & 0 deletions lib/themes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ TextStyle kName = TextStyle(
fontWeight: FontWeight.bold,
fontFamily: GoogleFonts.openSans().fontFamily,
color: kprimevoid);
TextStyle kName1 = TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
fontFamily: GoogleFonts.openSans().fontFamily,
color: kprimevoid);
TextStyle kUsername = TextStyle(
fontSize: 22.0,
fontWeight: FontWeight.normal,
Expand Down
81 changes: 81 additions & 0 deletions lib/util/custom_grid_tile.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:hacktoberfest/themes.dart';
import 'package:url_launcher/url_launcher_string.dart';

class CGridTile extends StatelessWidget {
final Name;
final Username;
const CGridTile({super.key, required this.Name, required this.Username});

@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
launchUrlString('https://github.com/$Username');
},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0),
child: Card(
elevation: 5.0,
color: Colors.transparent,
child: Container(
height: 150,
width: MediaQuery.of(context).size.width * 0.5,
decoration: BoxDecoration(
border: Border.all(color: const Color(0xff40ddff), width: 5.0),
borderRadius: const BorderRadius.all(Radius.circular(20)),
gradient: const LinearGradient(
colors: [
Color(0xff7a82ff),
Color(0xff58b7ff),
Color(0xff43d8ff),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
child: Container(
padding: const EdgeInsets.all(14.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.5 - 90,
child: Text(
Name,
textAlign: TextAlign.left,
style: kName1,
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
),
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.5 - 90,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
FaIcon(
FontAwesomeIcons.github,
color: kprimevoid,
),
FaIcon(
FontAwesomeIcons.arrowRight,
size: 20.0,
color: kprimevoid,
)
],
),
),
],
),
),
),
),
),
);
}
}
25 changes: 16 additions & 9 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.9.0"
version: "2.8.2"
boolean_selector:
dependency: transitive
description:
Expand All @@ -21,14 +21,21 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.1"
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
version: "1.1.0"
collection:
dependency: transitive
description:
Expand Down Expand Up @@ -56,7 +63,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
version: "1.3.0"
ffi:
dependency: transitive
description:
Expand Down Expand Up @@ -148,7 +155,7 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.12"
version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
Expand All @@ -162,14 +169,14 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.7.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
version: "1.8.1"
path_provider:
dependency: transitive
description:
Expand Down Expand Up @@ -279,14 +286,14 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.1"
version: "1.2.0"
test_api:
dependency: transitive
description:
Expand Down