Skip to content

Display nearby books in Explore Nearby Screen Iplemented #140

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

Merged
merged 11 commits into from
Oct 24, 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
Binary file added .gradle/6.8/fileChanges/last-build.bin
Binary file not shown.
Binary file added .gradle/6.8/fileHashes/fileHashes.lock
Binary file not shown.
Empty file added .gradle/6.8/gc.properties
Empty file.
Binary file added .gradle/checksums/checksums.lock
Binary file not shown.
Empty file.
Empty file added .gradle/vcs-1/gc.properties
Empty file.
5 changes: 4 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ dependencies {
implementation platform('com.google.firebase:firebase-bom:26.3.0')
implementation 'com.google.firebase:firebase-analytics'
implementation "androidx.browser:browser:1.3.0"
implementation 'androidx.multidex:multidex:2.0.1'
// implementation 'androidx.multidex:multidex:2.0.1'

// if you are using AndroidX its better to use above dependence for multiDex
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
Expand Down
6 changes: 3 additions & 3 deletions lib/common/themes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ ThemeData bookTheme() {
inputDecorationTheme: const InputDecorationTheme(
focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Color.fromRGBO(24, 25, 38, 1), width: 2.0),
BorderSide(color: Color.fromRGBO(24, 25, 38, 1), width: 2.0),
borderRadius: BorderRadius.all(Radius.circular(20))),
enabledBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Color.fromRGBO(24, 25, 38, 1), width: 2.0),
BorderSide(color: Color.fromRGBO(24, 25, 38, 1), width: 2.0),
borderRadius: BorderRadius.all(Radius.circular(20)))),
);
}
}
1 change: 0 additions & 1 deletion lib/config/api.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@

/// Save any API Endpoint here
const String baseHost = 'https://www.googleapis.com/books/v1/volumes';
10 changes: 5 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MyApp extends StatelessWidget {
debugShowCheckedModeBanner: false,
title: 'Explr',
home: Wrapper(),
onGenerateRoute: RouteGenerator.generateRoute,
onGenerateRoute: RouteGenerator().generateRoute,
),
);
}
Expand All @@ -65,7 +65,7 @@ class Wrapper extends StatelessWidget {
@override
Widget build(BuildContext context) {
final FirebaseAuthService firebaseAuthService =
Provider.of<FirebaseAuthService>(context);
Provider.of<FirebaseAuthService>(context);
return StreamBuilder<User?>(
stream: firebaseAuthService.onAuthStateChanged,
builder: (_, AsyncSnapshot<User?> snapshot) {
Expand All @@ -75,9 +75,9 @@ class Wrapper extends StatelessWidget {
} else {
return const Center(
child: CircularProgressIndicator(
color: blackButton,
));
color: blackButton,
));
}
});
}
}
}
4 changes: 2 additions & 2 deletions lib/providers/book.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class Book with ChangeNotifier {
Book({
// this.id,
this.isbn,
this.title,
this.title='',
this.author,
this.imageUrl,
this.imageUrl = '',
this.userid,
this.description,
this.genre,
Expand Down
47 changes: 37 additions & 10 deletions lib/providers/books.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import 'package:http/http.dart' as http;
import 'book.dart';

class Books with ChangeNotifier {

// Explore Books
final List<Book> _within3km = <Book>[];
final List<Book> _within5km = <Book>[];
final List<Book> _within10km = <Book>[];
final List<Book> _within20km = <Book>[];
final List<Book> _morethan20km = <Book>[];

//Owned Books
final List<Book> _ownedBooks = <Book>[];

Expand Down Expand Up @@ -37,7 +45,26 @@ class Books with ChangeNotifier {
return <Book>[..._discoverNew];
}

//********EXPLORE NEARBY TO BE IMPLEMENTED*******///
//********EXPLORE NEARBY TO BE IMPLEMENTED*******///
List<Book> get within3km {
return _within3km;
}

List<Book> get within5km {
return _within5km;
}

List<Book> get within10km {
return _within10km;
}

List<Book> get within20km {
return _within20km;
}

List<Book> get morethan20km {
return _morethan20km;
}

List<Book> get lentBooks {
return _lentBooks;
Expand Down Expand Up @@ -82,7 +109,7 @@ class Books with ChangeNotifier {
};
try {
final http.Response response =
await http.get(Uri.parse(url + isbn.trim()));
await http.get(Uri.parse(url + isbn.trim()));
final dynamic result = jsonDecode(response.body);
// print("Result From get Books From ISBN:");
// print(result["items"][0]);
Expand All @@ -100,7 +127,7 @@ class Books with ChangeNotifier {
final dynamic resultJson = jsonDecode(response.body);
if (resultJson != null) {
final String isbn = resultJson['items'][0]['volumeInfo']
['industryIdentifiers'][1]['identifier']
['industryIdentifiers'][1]['identifier']
.toString();
return isbn;
}
Expand All @@ -118,7 +145,7 @@ class Books with ChangeNotifier {
final String author = result['volumeInfo']['authors'][0].toString();
final String description = result['volumeInfo']['description'].toString();
final String isbn = result['volumeInfo']['industryIdentifiers'][0]
['identifier']
['identifier']
.toString();
final String infoLink = result['volumeInfo']['infoLink'].toString();

Expand All @@ -128,7 +155,7 @@ class Books with ChangeNotifier {
imageLink = imageLink.replaceFirst('http', 'https', 0);
} catch (e) {
imageLink =
'https://upload.wikimedia.org/wikipedia/commons/thumb/6/65/No-Image-Placeholder.svg/1200px-No-Image-Placeholder.svg.png';
'https://upload.wikimedia.org/wikipedia/commons/thumb/6/65/No-Image-Placeholder.svg/1200px-No-Image-Placeholder.svg.png';
}
print(imageLink.length);
if (imageLink.isEmpty) {
Expand All @@ -152,21 +179,21 @@ class Books with ChangeNotifier {
// print(result);
Book book;
final String? description =
result['items'][0]['volumeInfo']['description'] as String?;
result['items'][0]['volumeInfo']['description'] as String?;
final String isbn = isbnCode;
final String? infoLink =
result['items'][0]['volumeInfo']['infoLink'] as String?;
result['items'][0]['volumeInfo']['infoLink'] as String?;
final int? pages = result['items'][0]['volumeInfo']['pageCount'] as int?;
String? imageLink, title, author;
try {
title = result['items'][0]['volumeInfo']['title'] as String?;
author = result['items'][0]['volumeInfo']['authors'][0] as String?;
imageLink = result['items'][0]['volumeInfo']['imageLinks']['thumbnail']
as String?;
as String?;
imageLink = imageLink!.replaceFirst('http', 'https', 0);
} catch (e) {
imageLink =
'https://upload.wikimedia.org/wikipedia/commons/thumb/6/65/No-Image-Placeholder.svg/1200px-No-Image-Placeholder.svg.png';
'https://upload.wikimedia.org/wikipedia/commons/thumb/6/65/No-Image-Placeholder.svg/1200px-No-Image-Placeholder.svg.png';
author = inputAuthor;
print('imageLink is empty');
}
Expand Down Expand Up @@ -212,4 +239,4 @@ class Books with ChangeNotifier {
print(e.toString());
}
}
}
}
4 changes: 2 additions & 2 deletions lib/screens/auth/forgot_password.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
.ResetPassword(_emailController.text);
setState(() {
_message =
'Password reset link has been sent to you on email ${_emailController.text}.You will be redirected to signIn page';
'Password reset link has been sent to you on email ${_emailController.text}.You will be redirected to signIn page';
});

print(_message);
Expand Down Expand Up @@ -99,4 +99,4 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
else
return Container();
}
}
}
50 changes: 25 additions & 25 deletions lib/screens/auth/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,30 @@ class _LoginScreenState extends State<LoginScreen> {
padding: const EdgeInsets.all(10.0),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
const AuthPageTitle(name: 'Log in'),
// AuthErrorMessage(errorMessage: error.toString()),
Form(
key: formKey,
child: Column(
children: <AuthField>[
EmailTextField(_emailController),
PasswordTextField(_passwordController)
],
),
),
Button(
name: 'Sign in',
color: blackButton,
myFunction: () {
Navigator.pushNamed(context, Routes.HOME);
},
),
buildForgotPasswordButton(),
buildRegisterButton(),
],
)),
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
const AuthPageTitle(name: 'Log in'),
// AuthErrorMessage(errorMessage: error.toString()),
Form(
key: formKey,
child: Column(
children: <AuthField>[
EmailTextField(_emailController),
PasswordTextField(_passwordController)
],
),
),
Button(
name: 'Sign in',
color: blackButton,
myFunction: () {
Navigator.pushNamed(context, Routes.HOME);
},
),
buildForgotPasswordButton(),
buildRegisterButton(),
],
)),
),
);
}
Expand Down Expand Up @@ -103,4 +103,4 @@ class _LoginScreenState extends State<LoginScreen> {
),
);
}
}
}
Loading