Skip to content

Commit

Permalink
restore merge loss
Browse files Browse the repository at this point in the history
  • Loading branch information
avani17101 committed Jul 26, 2020
1 parent c302918 commit b18a378
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
27 changes: 26 additions & 1 deletion libmate/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:libmate/datastore/model.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:provider/provider.dart';
import 'package:flutter/material.dart';
import 'package:libmate/views/about.dart';
Expand All @@ -11,6 +12,9 @@ import 'package:libmate/views/libcard.dart';
import 'package:libmate/views/request.dart';
import 'package:libmate/views/search.dart';
import 'package:libmate/views/voiceSearch.dart';
import 'package:libmate/views/issued.dart';
import 'package:fuzzy/fuzzy.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
Expand All @@ -21,18 +25,37 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> {
bool loaded;
UserModel model;
var fuse;
List<BookModel> books;


@override
void initState() {
super.initState();
loaded = false;
loadState();
}
void loadBookData() {
Firestore.instance.collection('books').getDocuments().then((snapshot) {
final documents = snapshot.documents;
books = List<BookModel>();

for (var document in documents) {
final name = document.data["name"];
books.add(BookModel(name: name));
}
}).then((some_res) {
final wk = WeightedKey(name: "keyer", getter: (obj) => obj.name, weight: 1);
final fo = FuzzyOptions(keys: [wk]);
fuse = Fuzzy(books, options: fo);
// in fuse.search, score of 0 is fullmatch, 1 is complete mismatch
});
}

void loadState() async {
model = await UserModel.fromSharedPrefs();
print(model.uid);

loadBookData();
setState(() {
loaded = true;
});
Expand Down Expand Up @@ -68,6 +91,8 @@ class _MyAppState extends State<MyApp> {
'/home': (BuildContext context) =>
new Home(loggedIn: usermodel.isLoggedIn()),
'/search': (BuildContext context) => new SearchPage(),
'/issued': (BuildContext context) => new IssuedPage(),
'/search': (BuildContext context) => new SearchPage(fuse: fuse),
'/voicesearch': (BuildContext context) => new VoiceSearchPage(),
'/contribute': (BuildContext context) => new ContributePage(),
'/friends': (BuildContext context) => new FriendsPage(),
Expand Down
1 change: 1 addition & 0 deletions libmate/lib/views/drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class AppDrawer extends StatelessWidget {
_DrawerViewItem(Icons.home, 'Home', '/home').build(context),
_DrawerViewItem(Icons.search, 'Search', '/search').build(context),
_DrawerViewItem(Icons.keyboard_voice, 'VoiceSearch', '/voicesearch').build(context),
_DrawerViewItem(Icons.location_on, 'Guide', '/guide').build(context),
_DrawerViewItem(Icons.file_upload, 'Contribute Info', '/contribute')
.build(context),
_DrawerViewItem(Icons.library_books, 'Issued Books', '/issued')
Expand Down

0 comments on commit b18a378

Please sign in to comment.