Skip to content

Commit

Permalink
creating production release
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishq5414 committed Apr 7, 2023
1 parent 276841c commit 0fff835
Show file tree
Hide file tree
Showing 23 changed files with 609 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies

Large diffs are not rendered by default.

Binary file added assets/logo/githublogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/logo/lightheads.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/logo/linkedinlogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/logo/mediumlogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion lib/core/provider/user_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class UserProvider with ChangeNotifier{
email: '',
cid: [],
bid: [],
notificationsEnabled: '',
notificationsEnabled: true,
photoUrl: '',
isAdmin: false,
isPremiumUser: false,
Expand Down
29 changes: 27 additions & 2 deletions lib/features/auth/controller/auth_controller.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ignore_for_file: unused_import, unused_local_variable

import 'package:companion_rebuild/features/auth/repository/firebase_auth_methods.dart';
import 'package:companion_rebuild/modal/trendingnotes_modal.dart';
import 'package:companion_rebuild/modal/user_modal.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';
Expand All @@ -12,7 +13,8 @@ import 'package:shared_preferences/shared_preferences.dart';
import '../../components/snack_bar.dart';

final userProvider = StateProvider<UserCollection?>((ref) => null);

final trendingDataProvider = StateProvider<List<TrendingNotesModal>?>((ref) => null);
final trendingTodayDataProvider = StateProvider<List<TrendingNotesModal>?>((ref) => null);
final authControllerProvider = StateNotifierProvider<AuthController, bool>(
(ref) => AuthController(
authRepository: ref.watch(authRepositoryProvider),
Expand Down Expand Up @@ -110,8 +112,31 @@ class AuthController extends StateNotifier<bool> {
state = false;
}

void updateName(BuildContext context, fullName, uid) async {
void getTrendingNotes(BuildContext context) async {
state = true;
final a = await _authRepository.getTrendingNotes();
a.fold((l) => Utils.showSnackBar(l.message), (r) {
_ref.read(trendingDataProvider.notifier).update((state) => r);
});
state = false;
}

void getTrendingTodayNotes(BuildContext context) async {
state = true;
final a = await _authRepository.getTrendingNotesDaily();
a.fold((l) => Utils.showSnackBar(l.message), (r) {
_ref.read(trendingTodayDataProvider.notifier).update((state) => r);
});
state = false;
}

void updateName(BuildContext context, fullName, uid) {
state = true;
final user = _authRepository.updateName(context, fullName, uid);
var a = _ref.read(userProvider.notifier).state;
a!.name = fullName;
_ref.read(userProvider.notifier).update((state) => a);
state = false;
}

void deleteAccount(BuildContext context) async {
Expand Down
135 changes: 103 additions & 32 deletions lib/features/auth/repository/firebase_auth_methods.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:companion_rebuild/core/provider/firebase_providers.dart';
import 'package:companion_rebuild/core/type_defs.dart';
import 'package:companion_rebuild/features/auth/controller/auth_controller.dart';
import 'package:companion_rebuild/features/components/snack_bar.dart';
import 'package:companion_rebuild/modal/trendingnotes_modal.dart';
import 'package:companion_rebuild/modal/user_modal.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';
Expand Down Expand Up @@ -69,17 +70,11 @@ class AuthRepository {
);
await sendEmailVerification(context);
Routemaster.of(context).push('/sendverification');
await _supabaseClient.from('userscollection').insert({
'uid': result.user!.uid,
'cid': cid,
'bid': [],
await _supabaseClient.rpc('insertuserdata', params: {
'uid': user.uid,
'email': user.email,
'name': fullName,
'photoUrl': user.photoURL ?? "",
'notificationsEnabled': "true",
'isAdmin': false,
'isPremiumUser': true,
'recentlyAccessed': [],
'name': user.displayName,
'photourl': user.photoURL ?? "",
});
} on FirebaseAuthException catch (e) {
if (e.code == 'weak-password') {
Expand Down Expand Up @@ -167,13 +162,61 @@ class AuthRepository {
}
}

// TRENDING NOTES
FutureEither<List<TrendingNotesModal>> getTrendingNotes() async {
List<TrendingNotesModal> trendingNotes = [];
var a = await _supabaseClient
.from('notesdata')
.select()
.order('times_opened', ascending: false)
.limit(10)
.execute();
for (int i = 0; i < a.data.length; i++) {
trendingNotes.add(
TrendingNotesModal(
timesopened: a.data[i]['times_opened'],
course: a.data[i]['course'],
unit: a.data[i]['unit'],
notesname: a.data[i]['notesname'],
trendingnotesmonthly: a.data[i]['trendingnotesmonthly'],
trendingnotestoday: a.data[i]['trendingnotestoday'],
trendingnotesweekly: a.data[i]['trendingnotesweekly'],
id: a.data[i]['id']));
}
return right(trendingNotes);
}

FutureEither<List<TrendingNotesModal>> getTrendingNotesDaily() async {
List<TrendingNotesModal> trendingNotes = [];
var a = await _supabaseClient
.from('notesdata')
.select()
.order('trendingnotestoday', ascending: false)
.limit(10)
.execute();
for (int i = 0; i < a.data.length; i++) {
trendingNotes.add(
TrendingNotesModal(
timesopened: a.data[i]['times_opened'],
course: a.data[i]['course'],
unit: a.data[i]['unit'],
notesname: a.data[i]['notesname'],
trendingnotesmonthly: a.data[i]['trendingnotesmonthly'],
trendingnotestoday: a.data[i]['trendingnotestoday'],
trendingnotesweekly: a.data[i]['trendingnotesweekly'],
id: a.data[i]['id']));
}
return right(trendingNotes);
}


incrementnotesopened(String uid, String notesid, String notesname,
String course, String unit) async {
List data1 = await _supabaseClient
.from('userscollection')
.select('recentlyAccessed')
.eq('uid', uid);
List data2 = data1[0]['recentlyAccessed'];
List data2 = data1[0]['recentlyAccessed'] ?? [];
data2.add(notesid);
if (data2.length > 30) {
data2 = data2.sublist(data2.length - 30, data2.length);
Expand All @@ -184,7 +227,19 @@ class AuthRepository {

var data = await _supabaseClient
.from('notesdata')
.select('times_opened')
.select('times_opened', )
.eq('id', notesid);
var data3 = await _supabaseClient
.from('notesdata')
.select('trendingnotestoday')
.eq('id', notesid);
var data4 = await _supabaseClient
.from('notesdata')
.select('trendingnotesweekly')
.eq('id', notesid);
var data5 = await _supabaseClient
.from('notesdata')
.select('trendingnotesmonthly')
.eq('id', notesid);
if (data.length == '0' || data.length == 0) {
await _supabaseClient.from('notesdata').insert({
Expand All @@ -193,12 +248,21 @@ class AuthRepository {
'notesname': notesname,
'course': course,
'unit': unit,
'trendingnotestoday': 1,
'trendingnotesweekly': 1,
'trendingnotesmonthly': 1,
});
return;
} else {
var timesopened = data[0]['times_opened'];
num timesopened = data[0]['times_opened'];
num trendingnotestoday = data3[0]['trendingnotestoday'];
num trendingnotesweekly = data4[0]['trendingnotesweekly'];
num trendingnotesmonthly = data5[0]['trendingnotesmonthly'];
await _supabaseClient.from('notesdata').update({
'times_opened': timesopened + 1,
'trendingnotestoday': trendingnotestoday + 1,
'trendingnotesweekly': trendingnotesweekly + 1,
'trendingnotesmonthly': trendingnotesmonthly + 1,
}).eq('id', notesid);
}
}
Expand Down Expand Up @@ -258,22 +322,28 @@ class AuthRepository {
email: user.email!,
name: user.displayName!,
photoUrl: user.photoURL ?? "",
notificationsEnabled: "true",
notificationsEnabled: true,
isAdmin: false,
isPremiumUser: true,
recentlyAccessed: [],
);
await _supabaseClient.from('userscollection').insert({
// await _supabaseClient.from('userscollection').insert({
// 'uid': user.uid,
// 'cid': cid,
// 'bid': [],
// 'email': user.email,
// 'name': user.displayName,
// 'photoUrl': user.photoURL ?? "",
// 'notificationsEnabled': "true",
// 'isAdmin': false,
// 'isPremiumUser': true,
// 'recentlyAccessed': [],
// });
await _supabaseClient.rpc('insertuserdata', params: {
'uid': user.uid,
'cid': cid,
'bid': [],
'email': user.email,
'name': user.displayName,
'photoUrl': user.photoURL ?? "",
'notificationsEnabled': "true",
'isAdmin': false,
'isPremiumUser': true,
'recentlyAccessed': [],
'photourl': user.photoURL ?? "",
});
userModel = await getUserData(user.uid).first;
} else {
Expand Down Expand Up @@ -355,16 +425,17 @@ class AuthRepository {
.eq('uid', uid)
.map((event) {
return UserCollection(
id: event.elementAt(0)['uid'],
bid: event.elementAt(0)['bid'],
cid: event.elementAt(0)['cid'],
notificationsEnabled: event.elementAt(0)['notificationsEnabled'],
email: event.elementAt(0)['email'],
name: event.elementAt(0)['name'],
photoUrl: event.elementAt(0)['photoUrl'],
isAdmin: event.elementAt(0)['isAdmin'],
isPremiumUser: event.elementAt(0)['isPremiumUser'],
recentlyAccessed: event.elementAt(0)['recentlyAccessed']);
id: event.elementAt(0)['uid'] ?? '',
bid: event.elementAt(0)['bid'] ?? [],
cid: event.elementAt(0)['cid'] ?? [],
notificationsEnabled:
event.elementAt(0)['notificationsEnabled'] ?? true,
email: event.elementAt(0)['email'] ?? '',
name: event.elementAt(0)['name'] ?? '',
photoUrl: event.elementAt(0)['photoUrl'] ?? '',
isAdmin: event.elementAt(0)['isAdmin'] ?? false,
isPremiumUser: event.elementAt(0)['isPremiumUser'] ?? false,
recentlyAccessed: event.elementAt(0)['recentlyAccessed'] ?? []);
});
return user;
}
Expand Down
3 changes: 3 additions & 0 deletions lib/features/bookmarks/bookmarks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ class _BookmarksPageState extends ConsumerState<BookmarksPage> {
wdlink: bookmarks[index].wdlink,
pressable: true,)),
),
SizedBox(
height: size.height * 0.15,
)
],
),
),
Expand Down
28 changes: 28 additions & 0 deletions lib/features/home/components/trending_notes_builder.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// ignore_for_file: unnecessary_new

import 'package:companion_rebuild/features/components/notes_preview.dart';
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)),
);
}
Loading

0 comments on commit 0fff835

Please sign in to comment.