Skip to content

Commit

Permalink
fixed trending today section
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishq5414 committed Apr 8, 2023
1 parent 0fff835 commit 58816f5
Show file tree
Hide file tree
Showing 20 changed files with 71 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions lib/features/admin/addnotes.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore_for_file: unused_field
// ignore_for_file: unused_field, unused_import, library_private_types_in_public_api

import 'dart:convert';
import 'dart:io';
Expand Down Expand Up @@ -51,11 +51,12 @@ class _AddNotesState extends ConsumerState<AddNotes> {
withData: true,
type: FileType.custom,
allowMultiple: _multiPick,
onFileLoading: (FilePickerStatus status) => print(status),
// ignore: avoid_print
onFileLoading: (FilePickerStatus status) => (kDebugMode)?print(status):null,
allowedExtensions: ['pdf']))
?.files;
} on PlatformException catch (e) {
_logException('Unsupported operation' + e.toString());
_logException('Unsupported operation$e');
} catch (e) {
_logException(e.toString());
}
Expand Down Expand Up @@ -161,15 +162,11 @@ class _AddNotesState extends ConsumerState<AddNotes> {
http.MultipartFile.fromBytes('pdf', t,
filename: fileName),
);
print('request: $request');
http.StreamedResponse res = await request.send();
print('res: ${res.statusCode}');
print(fileName.characters.length);
var body = jsonEncode({
"filename": fileName,
"filepath": "./pdfStorage",
});
// print('map: $map');
http.Response request2 =
await http.post(Uri.parse(addFiletoGoogleDrive),
headers: <String, String>{
Expand All @@ -178,7 +175,6 @@ class _AddNotesState extends ConsumerState<AddNotes> {
},
body: body);

print('request2: ${request2.body}');
if (request2.statusCode == 200 && res.statusCode == 200) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
Expand Down
14 changes: 1 addition & 13 deletions lib/features/admin/addnotesdata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class _AddNotesDetailsState extends ConsumerState<AddNotesDetails> {
),
body: courselist.when(
data: (courselist) {
courselist.sort((a, b) => a.cname.compareTo(b.cname));
return SafeArea(
child: Padding(
padding: EdgeInsets.symmetric(
Expand Down Expand Up @@ -258,16 +259,6 @@ class _AddNotesDetailsState extends ConsumerState<AddNotesDetails> {
Center(
child: ElevatedButton(
onPressed: () async {
print('pressed');
print('branch' + branch);
print('year' + year.toString());
print('course' + course);
print('name' + name.text);
print('semester' + semester.text);
print('version' + version.text);
print('unit' + unit.text);


if (name.text.isEmpty ||
branch.isEmpty ||
course.isEmpty ||
Expand All @@ -292,9 +283,6 @@ class _AddNotesDetailsState extends ConsumerState<AddNotesDetails> {
"unit": unit.text,
"wdlink": webContentLink,
});
print(course.length);

// print('map: $map');
http.Response request2 =
await http.post(Uri.parse(addFileData),
headers: <String, String>{
Expand Down
2 changes: 1 addition & 1 deletion lib/features/auth/components/text_field.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore_for_file: must_be_immutable
// ignore_for_file: must_be_immutable, unnecessary_import

import 'package:companion_rebuild/theme/colors.dart';
import 'package:flutter/material.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/features/auth/controller/auth_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class AuthController extends StateNotifier<bool> {

void logInWithEmail(BuildContext context, String email, String password,
WidgetRef ref) async {
print(1);

state = true;
final user = await _authRepository.loginWithEmail(
email: email, password: password, context: context, ref: ref);
Expand Down
1 change: 0 additions & 1 deletion lib/features/auth/repository/firebase_auth_methods.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ class AuthRepository {
Utils.showSnackBar(
'Some error occurred try again in some time if it still persists contact us');
}
print(e.message);
throw e.message!;
}
}
Expand Down
1 change: 0 additions & 1 deletion lib/features/auth/screens/loginEmail/login_email.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ class _LoginPageState extends ConsumerState<LoginPage> {
ElevatedButton(
style: loginButtonStyle,
onPressed: () {
print(2);
loginUser(
emailController.text, passwordController.text);
},
Expand Down
1 change: 0 additions & 1 deletion lib/features/bookmarks/bookmarks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class _BookmarksPageState extends ConsumerState<BookmarksPage> {
allnotes.when(
data: (notes) {
allnoteslist = notes;
// print(allnoteslist);
for (var i = 0; i < userbookmarklist.length; i++) {
for (var j = 0; j < allnoteslist.length; j++) {
if (userbookmarklist[i].toString() ==
Expand Down
5 changes: 1 addition & 4 deletions lib/features/bookmarks/bookmarks_search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class _SearchState extends ConsumerState<BookmarksSearchPage> {
allnotes.when(
data: (notes) {
allnoteslist = notes;
// print(allnoteslist);
for (var i = 0; i < userbookmarklist.length; i++) {
for (var j = 0; j < allnoteslist.length; j++) {
if (userbookmarklist[i].toString() ==
Expand All @@ -58,7 +57,6 @@ class _SearchState extends ConsumerState<BookmarksSearchPage> {
final allnotes = ref.read(notesDataProvider);
var user = ref.watch(userProvider);
_notes = getBookmarks(allnotes, user);
print(_notes);
setState(() {
foundedNotes = _notes;
});
Expand Down Expand Up @@ -90,7 +88,6 @@ class _SearchState extends ConsumerState<BookmarksSearchPage> {
allnotes.when(
data: (notes) {
allnoteslist = notes;
// print(allnoteslist);
for (var i = 0; i < userbookmarklist.length; i++) {
for (var j = 0; j < allnoteslist.length; j++) {
if (userbookmarklist[i].toString() ==
Expand All @@ -99,7 +96,7 @@ class _SearchState extends ConsumerState<BookmarksSearchPage> {
}
}
}
bookmarks = new List.from(bookmarks.reversed);
bookmarks = List.from(bookmarks.reversed);
return bookmarks;
},
error: (error, stackTrace) => Text(error.toString()),
Expand Down
1 change: 0 additions & 1 deletion lib/features/components/advertisment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ ListView advertismentBuilder(Size size, context, WidgetRef ref) {

_launchURL(String url) async {
final uri = Uri.parse(url);
print(url);
// ignore: deprecated_member_use
await launch(url);
}
Expand Down
1 change: 0 additions & 1 deletion lib/features/components/course_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'course_preview.dart';
List<Course> usercourses = [];
GridView courseBuilder(Size size, context, WidgetRef ref) {
final user = ref.watch(userProvider)!;
print(user);
var userslist = user.cid;
var allcourses = ref.read(coursesDataProvider);
var usercourseslist = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class FirebaseDynamicLinkService {
}

_linkMessage = url.toString();
print(_linkMessage);
return Share.share(_linkMessage);
}

Expand All @@ -40,10 +39,8 @@ class FirebaseDynamicLinkService {
FirebaseDynamicLinks.instance.onLink.listen((event) {
final deeplink = event.link;
var isNote = deeplink.pathSegments.contains('notes');
print(isNote);
if (isNote) {
String id = deeplink.queryParameters['id']!;
print('this is the id $id');
final AsyncValue<List<Notes>> notesData = ref.watch(notesDataProvider);
var noteList = notesData.value!;
for (int i = 0; i < noteList.length - 1; i++) {
Expand Down
1 change: 0 additions & 1 deletion lib/features/home/bottom_nav.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class _AppBottomNavigatorState extends ConsumerState<AppBottomNavigator>
void initState() {
super.initState();
//Future Delayed
print('initState');

}

Expand Down
39 changes: 19 additions & 20 deletions lib/features/home/components/trending_notes_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@ import 'package:companion_rebuild/modal/notes_modal.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';


trendingbuilder(Size size, List<Notes> notesData) {
return SizedBox(
height: size.width * 0.43,
child: ListView.builder(
itemCount: notesData.length,
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) => NotesPreview(
id: notesData[index].id,
name: notesData[index].name,
year: notesData[index].year,
branch: notesData[index].branch,
course: notesData[index].course,
semester: notesData[index].semester,
version: notesData[index].version,
unit: notesData[index].unit,
wdlink: notesData[index].wdlink,
pressable: true)),
);
}
return SizedBox(
height: size.width * 0.43,
child: ListView.builder(
itemCount: notesData.length,
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) => NotesPreview(
id: notesData[index].id,
name: notesData[index].name,
year: notesData[index].year,
branch: notesData[index].branch,
course: notesData[index].course,
semester: notesData[index].semester,
version: notesData[index].version,
unit: notesData[index].unit,
wdlink: notesData[index].wdlink,
pressable: true)),
);
}
67 changes: 40 additions & 27 deletions lib/features/home/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,49 +46,56 @@ class _HomePageState extends ConsumerState<HomePage> {
}
return 'evening';
}

List<Notes> mostPopular(AsyncValue<List<Notes>> notesData, trendingData) {
List<Notes> mostpopular = [];
notesData.when(data: (data) {
for(int i = 0;i<data.length;i++){
trendingData.forEach((element) {
if(data[i].id == element.id){
mostpopular.add(data[i]);
List<Notes> mostpopular = [];
trendingData.forEach((element) {
notesData.when(
data: (data) {
for (int i = 0; i < data.length; i++) {
if (data[i].id == element.id) {
mostpopular.add(data[i]);
}
}
});
}
}, loading: () {}, error: (e, s) {});
return mostpopular;
}
},
loading: () {},
error: (e, s) {});
});
return mostpopular;
}

List<Notes> trendingtoday(AsyncValue<List<Notes>> notesData, trendingData) {
List<Notes> mostrecent = [];
notesData.when(data: (data) {
for (int i = 0; i < data.length; i++) {
trendingData.forEach((TrendingNotesModal element) {

if (data[i].id == element.id) {
mostrecent.add(data[i]);
}
});
}
}, loading: () {}, error: (e, s) {});
trendingData.forEach((element) {
notesData.when(
data: (data) {
for (int i = 0; i < data.length; i++) {
if (data[i].id == element.id) {
mostrecent.add(data[i]);
}
}
},
loading: () {},
error: (e, s) {});
});
return mostrecent;
}
}

@override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
final notesData = ref.watch(notesDataProvider);
final courseData = ref.watch(coursesDataProvider);
final user = ref.watch(userProvider);
final trendingData = ref.watch(trendingDataProvider)??[];
final trendingTodayData = ref.watch(trendingTodayDataProvider)??[];
final trendingData = ref.watch(trendingDataProvider) ?? [];
final trendingTodayData = ref.watch(trendingTodayDataProvider);
final ButtonStyle leadingStyle = ElevatedButton.styleFrom(
minimumSize: Size(size.height * 0.05, size.height * 0.05),
backgroundColor: appBackgroundColor,
padding: const EdgeInsets.symmetric(horizontal: 16),
shape: const CircleBorder(),
);

return Container(
margin: EdgeInsets.only(top: size.height * 0.02),
color: appBackgroundColor,
Expand Down Expand Up @@ -264,7 +271,12 @@ class _HomePageState extends ConsumerState<HomePage> {
),
Consumer(
builder: (context, ref, child) =>
trendingbuilder(size, trendingtoday(notesData, trendingTodayData))),
trendingbuilder(
size,
trendingtoday(
notesData,
trendingTodayData ??
trendingData))),
SizedBox(
width: size.width * 0.03,
),
Expand Down Expand Up @@ -332,7 +344,8 @@ class _HomePageState extends ConsumerState<HomePage> {
SizedBox(
width: size.width * 0.02,
),
trendingbuilder(size, mostPopular(notesData, trendingData)),
trendingbuilder(size,
mostPopular(notesData, trendingData)),
SizedBox(
width: size.width * 0.03,
),
Expand Down
3 changes: 3 additions & 0 deletions lib/features/infopages/contactdevs.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: prefer_const_constructors, duplicate_ignore

import 'package:companion_rebuild/theme/colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_octicons/flutter_octicons.dart';
Expand All @@ -11,6 +13,7 @@ class ContactDevs extends StatelessWidget {
@override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
// ignore: duplicate_ignore
return Scaffold(
appBar: CustomAppBar(title: 'Developers'),
// ignore: prefer_const_constructors
Expand Down
2 changes: 0 additions & 2 deletions lib/features/notes/notes_info.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/container.dart';
import 'package:flutter/src/widgets/framework.dart';

import 'package:routemaster/routemaster.dart';

Expand Down
2 changes: 0 additions & 2 deletions lib/features/notesView/notes_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class _NotesViewPageState extends ConsumerState<NotesViewPage> {
void createShareLink() async {
await FirebaseDynamicLinkService.createDynamicLink(
true, notes['id']!);
// print(deeplink);
}

return Scaffold(
Expand Down Expand Up @@ -121,7 +120,6 @@ class _NotesViewPageState extends ConsumerState<NotesViewPage> {
child: IconButton(
icon: const Icon(OctIcons.bookmark_fill_24),
onPressed: () {
// print("{$flag} ${user.bid}");
removebookmark();
},
),
Expand Down
3 changes: 0 additions & 3 deletions lib/features/recents/recentlyaccessed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@ class _RecentlyAccessedPageState extends ConsumerState<RecentlyAccessedPage> {
List<Notes> allnoteslist;
var userrecentlyaccessed = user!.recentlyAccessed;
List<Notes> recentlyaccessed = [];

// print(userbookmarklist);
List<Notes> getRecentlyAccessed() {
allnotes.when(
data: (notes) {
allnoteslist = notes;
// print(allnoteslist);
for (var i = 0; i < userrecentlyaccessed.length; i++) {
for (var j = 0; j < allnoteslist.length; j++) {
if (userrecentlyaccessed[i].toString() ==
Expand Down
Loading

0 comments on commit 58816f5

Please sign in to comment.