Skip to content

Commit f6bdb42

Browse files
update explore screen
1 parent 3e09b5f commit f6bdb42

File tree

3 files changed

+29
-72
lines changed

3 files changed

+29
-72
lines changed

lib/src/screens/explore.dart

Lines changed: 16 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -16,85 +16,29 @@ class _ExploreScreenState extends State<ExploreScreen> {
1616
@override
1717
void initState() {
1818
super.initState();
19-
fetchBooks();
2019
}
2120

22-
Future<void> fetchBooks() async {
23-
final response = await http.get(Uri.parse('https://gutendex.com/books/?languages=en&subjects=drama,fiction'));
24-
if (response.statusCode == 200) {
25-
final data = jsonDecode(response.body);
26-
setState(() {
27-
books = data['results'];
28-
});
29-
} else {
30-
throw Exception('Failed to load books');
31-
}
32-
}
21+
3322

3423
@override
3524
Widget build(BuildContext context) {
25+
// Scaffold is a layout for
26+
// the major Material Components.
3627
return Scaffold(
37-
body: _buildBookGrid(),
38-
);
39-
}
40-
41-
Widget _buildBookGrid() {
42-
if (books.isEmpty) {
43-
return const Center(child: CircularProgressIndicator());
44-
}
45-
46-
return GridView.builder(
47-
padding: const EdgeInsets.all(10),
48-
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
49-
crossAxisCount: 2,
50-
childAspectRatio: 0.6,
51-
crossAxisSpacing: 10,
52-
mainAxisSpacing: 10,
53-
),
54-
itemCount: books.length,
55-
itemBuilder: (context, index) {
56-
final book = books[index];
57-
return GestureDetector(
58-
onTap: () {
59-
Navigator.push(
60-
context,
61-
MaterialPageRoute(
62-
builder: (context) => DetailsScreen(
63-
imageUrl: book['formats']['image/jpeg'] ?? 'https://via.placeholder.com/150',
64-
title: book['title'],
65-
author: book['authors'].isNotEmpty ? book['authors'][0]['name'] : 'Unknown',
66-
description: book['subjects'].join(', '),
67-
bookUrl: book['formats']['text/html']
68-
),
69-
),
70-
);
71-
},
72-
child: Card(
73-
child: Column(
74-
crossAxisAlignment: CrossAxisAlignment.stretch,
75-
children: [
76-
Expanded(
77-
child: Image.network(
78-
book['formats']['image/jpeg'] ?? 'https://via.placeholder.com/150',
79-
fit: BoxFit.cover,
80-
),
81-
),
82-
Padding(
83-
padding: const EdgeInsets.all(8.0),
84-
child: Text(
85-
book['title'],
86-
style: const TextStyle(
87-
fontWeight: FontWeight.bold,
88-
fontSize: 16,
89-
),
90-
textAlign: TextAlign.center,
91-
),
92-
),
93-
],
94-
),
28+
appBar: AppBar(
29+
title: const Text('Example title'),
30+
actions: const [
31+
IconButton(
32+
icon: Icon(Icons.search),
33+
tooltip: 'Search',
34+
onPressed: null,
9535
),
96-
);
97-
},
36+
],
37+
),
38+
// body is the majority of the screen.
39+
body: const Center(
40+
child: Text('Hello, world!'),
41+
),
9842
);
9943
}
10044
}

lib/src/widgets/bottomnav.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:flutter_svg/svg.dart';
33
import '../colors/color.dart';
44
import '../screens/homepage.dart';
55
import '../screens/profile.dart';
6+
import '../screens/explore.dart';
67

78

89
class BottomNavBar extends StatefulWidget {
@@ -16,6 +17,7 @@ class _BottomNavBarState extends State<BottomNavBar> {
1617
int currentIndex = 0;
1718
final screens = [
1819
const HomePage(),
20+
const ExploreScreen(),
1921
const Profile(),
2022
];
2123

@@ -37,6 +39,13 @@ class _BottomNavBarState extends State<BottomNavBar> {
3739
),
3840
label: 'Home',
3941
),
42+
BottomNavigationBarItem(
43+
icon: SvgPicture.asset(
44+
'assets/icons/search.svg',
45+
color: KFourthColor,
46+
),
47+
label: 'Explore',
48+
),
4049
BottomNavigationBarItem(
4150
icon: SvgPicture.asset(
4251
'assets/icons/profile.svg',

web/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
<script src="flutter.js" defer></script>
4141
</head>
4242
<body>
43+
<script src="//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.11.338/pdf.min.js"></script>
44+
<script type="text/javascript">
45+
pdfjsLib.GlobalWorkerOptions.workerSrc = "//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.11.338/pdf.worker.min.js";
46+
</script>
4347
<script>
4448
window.addEventListener('load', function(ev) {
4549
// Download main.dart.js

0 commit comments

Comments
 (0)