Skip to content

Commit

Permalink
Merge pull request #15 from ChammounC/fix-folder-typo
Browse files Browse the repository at this point in the history
Fix folder & file name typo, and Update imports from 'modal' to 'model'
  • Loading branch information
tanishq5414 authored Jul 9, 2023
2 parents b48cd24 + 06591ce commit b211ac3
Show file tree
Hide file tree
Showing 33 changed files with 148 additions and 148 deletions.
10 changes: 5 additions & 5 deletions lib/apis/advertisment_api.dart
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import 'package:companion/config/config.dart';
import 'package:companion/core/core.dart';
import 'package:companion/modal/advertisment.modal.dart';
import 'package:companion/model/advertisment.model.dart';
import 'package:dio/dio.dart';
import 'package:fpdart/fpdart.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

final advertisementAPIProvider = Provider((ref) => AdvertisementAPI());

abstract class IAdvertisementAPI {
FutureEither<List<AdvertismentModal>> getAdvertisements();
FutureEither<List<AdvertismentModel>> getAdvertisements();
}

class AdvertisementAPI implements IAdvertisementAPI {
final Dio dio = Dio();

@override
FutureEither<List<AdvertismentModal>> getAdvertisements() async {
FutureEither<List<AdvertismentModel>> getAdvertisements() async {
try {
final advertisementData = await dio.get(advertismentURL);
List<AdvertismentModal> advertisementsList = [];
List<AdvertismentModel> advertisementsList = [];
advertisementData.data.forEach((element) {
advertisementsList.add(AdvertismentModal.fromJson(element));
advertisementsList.add(AdvertismentModel.fromJson(element));
});
return right(advertisementsList);
} catch (e, st) {
Expand Down
10 changes: 5 additions & 5 deletions lib/apis/courses.api.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:companion/config/config.dart';
import 'package:companion/core/core.dart';
import 'package:companion/modal/courses.modal.dart';
import 'package:companion/model/courses.model.dart';
import 'package:dio/dio.dart';
import 'package:fpdart/fpdart.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand All @@ -9,18 +9,18 @@ final coursesAPIProvider = Provider((ref) => CoursesAPI());
final dio = Dio();

abstract class ICoursesAPI {
FutureEither<List<CoursesModal>> getCourses(String token);
FutureEither<List<CoursesModel>> getCourses(String token);
}

class CoursesAPI implements ICoursesAPI {
@override
FutureEither<List<CoursesModal>> getCourses(String token) async {
FutureEither<List<CoursesModel>> getCourses(String token) async {
try {
dio.options.headers['authorization'] = token;
final coursesData = await dio.get(coursesUrl);
List<CoursesModal> coursesList = [];
List<CoursesModel> coursesList = [];
coursesData.data['data']['files'].forEach((element) {
coursesList.add(CoursesModal.fromJson(element));
coursesList.add(CoursesModel.fromJson(element));
});
return right(coursesList);
} catch (e, st) {
Expand Down
32 changes: 16 additions & 16 deletions lib/apis/notes.api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'dart:io';

import 'package:companion/config/config.dart';
import 'package:companion/core/core.dart';
import 'package:companion/modal/notes.modal.dart';
import 'package:companion/modal/trending.modal.dart';
import 'package:companion/model/notes.model.dart';
import 'package:companion/model/trending.model.dart';
import 'package:dio/dio.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:fpdart/fpdart.dart';
Expand All @@ -13,10 +13,10 @@ final notesAPIProvider = Provider((ref) => NotesAPI());
final dio = Dio();

abstract class INotesAPI {
FutureEither<List<NotesModal>> getNotes(String token);
FutureEither<List<NotesModal>> getTrendingNotesDay(String token);
FutureEither<List<NotesModal>> getTreandingNotesWeek(String token);
FutureVoid addTrendingData({required List<TrendingModal> trendingData});
FutureEither<List<NotesModel>> getNotes(String token);
FutureEither<List<NotesModel>> getTrendingNotesDay(String token);
FutureEither<List<NotesModel>> getTreandingNotesWeek(String token);
FutureVoid addTrendingData({required List<TrendingModel> trendingData});
FutureEither<void> uploadNotes({
required String name,
required String year,
Expand All @@ -33,15 +33,15 @@ abstract class INotesAPI {

class NotesAPI implements INotesAPI {
@override
FutureEither<List<NotesModal>> getNotes(String token) async {
FutureEither<List<NotesModel>> getNotes(String token) async {
try {
dio.options.headers['authorization'] = token;
final notesData = await dio.get(
notesUrl,
);
List<NotesModal> notesList = [];
List<NotesModel> notesList = [];
notesData.data['data']['files'].forEach((element) {
notesList.add(NotesModal.fromJson(element));
notesList.add(NotesModel.fromJson(element));
});
return right(notesList);
} catch (e, st) {
Expand Down Expand Up @@ -84,13 +84,13 @@ class NotesAPI implements INotesAPI {
}

@override
FutureEither<List<NotesModal>> getTreandingNotesWeek(String token) async {
FutureEither<List<NotesModel>> getTreandingNotesWeek(String token) async {
try {
dio.options.headers['authorization'] = token;
final notesData = await dio.get(trendingNotesByWeekURL);
List<NotesModal> notesList = [];
List<NotesModel> notesList = [];
notesData.data['data']['trending'].forEach((element) {
notesList.add(NotesModal.fromJson(element));
notesList.add(NotesModel.fromJson(element));
});
return right(notesList);
} catch (e, st) {
Expand All @@ -99,14 +99,14 @@ class NotesAPI implements INotesAPI {
}

@override
FutureEither<List<NotesModal>> getTrendingNotesDay(String token) async {
FutureEither<List<NotesModel>> getTrendingNotesDay(String token) async {
try {
dio.options.headers['authorization'] = token;
final notesData = await dio.get(trendingNotesByDayURL);
print(notesData.data);
List<NotesModal> notesList = [];
List<NotesModel> notesList = [];
notesData.data['data']['trending'].forEach((element) {
notesList.add(NotesModal.fromJson(element));
notesList.add(NotesModel.fromJson(element));
});
return right(notesList);
} catch (e, st) {
Expand All @@ -116,7 +116,7 @@ class NotesAPI implements INotesAPI {

@override
FutureVoid addTrendingData(
{required List<TrendingModal> trendingData}) async {
{required List<TrendingModel> trendingData}) async {
try {

var options = Options(
Expand Down
10 changes: 5 additions & 5 deletions lib/apis/user_api.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:companion/core/core.dart';
import 'package:companion/modal/user.modal.dart';
import 'package:companion/model/user.model.dart';
import 'package:dio/dio.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:fpdart/fpdart.dart';
Expand All @@ -16,7 +16,7 @@ final dio = Dio();
abstract class IUserAPI {
FutureVoid saveUserData(
{required uid, required email, required name, required photoUrl});
Stream<UserModal> getUserData(String uid);
Stream<UserModel> getUserData(String uid);
FutureVoid deleteUser(String uid);
FutureVoid updateName(String uid, String name);
FutureVoid updateBookmarks(String uid, List<String> bookmarks);
Expand All @@ -35,14 +35,14 @@ class UserAPI implements IUserAPI {
: _supabaseClient = supabaseClient;

@override
Stream<UserModal> getUserData(String uid) {
Stream<UserModal> user;
Stream<UserModel> getUserData(String uid) {
Stream<UserModel> user;
user = _supabaseClient
.from('userscollection')
.stream(primaryKey: ['uid'])
.eq('uid', uid)
.map((event) {
return UserModal.fromJson(event.first);
return UserModel.fromJson(event.first);
});
return user;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/core/providers/dummy_user_provider.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:companion/modal/user.modal.dart';
import 'package:companion/model/user.model.dart';

UserModal nullUser = UserModal(
UserModel nullUser = UserModel(
uid: '',
email: '',
name: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import 'dart:convert';
import 'package:companion/apis/advertisment_api.dart';
import 'package:companion/core/core.dart';
import 'package:companion/features/hive/boxes.dart';
import 'package:companion/modal/advertisment.modal.dart';
import 'package:companion/model/advertisment.model.dart';

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

final advertisementsDataProvider =
StateProvider<List<AdvertismentModal>?>((ref) => null);
StateProvider<List<AdvertismentModel>?>((ref) => null);

final advertisementControllerProvider =
StateNotifierProvider<AdvertisementController, bool>((ref) {
Expand Down Expand Up @@ -52,10 +52,10 @@ class AdvertisementController extends StateNotifier<bool> {
final notes = networkCache.get('getAdvertisements');
if (notes != null) {
final List<String> getAdvertisments = notes.cast<String>();
List<AdvertismentModal> notesList = [];
List<AdvertismentModel> notesList = [];
getAdvertisments.forEach((noteString) {
final Map<String, dynamic> noteMap = jsonDecode(noteString);
notesList.add(AdvertismentModal.fromJson(noteMap));
notesList.add(AdvertismentModel.fromJson(noteMap));
});
_ref.read(advertisementsDataProvider.notifier).update((state) => notesList);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/features/courses/controller/courses_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import 'dart:convert';
import 'package:companion/apis/courses.api.dart';
import 'package:companion/core/core.dart';
import 'package:companion/features/hive/boxes.dart';
import 'package:companion/modal/courses.modal.dart';
import 'package:companion/model/courses.model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:companion/features/hive/boxes.dart';

final coursesDataProvider = StateProvider<List<CoursesModal>?>((ref) => null);
final coursesDataProvider = StateProvider<List<CoursesModel>?>((ref) => null);

final coursesControllerProvider =
StateNotifierProvider<CoursesController, bool>((ref) {
Expand Down Expand Up @@ -45,10 +45,10 @@ class CoursesController extends StateNotifier<bool> {
final courses = networkCache.get('getCourses');
if (courses != null) {
final List<String> courseListString = courses.cast<String>();
List<CoursesModal> courseList = [];
List<CoursesModel> courseList = [];
courseListString.forEach((noteString) {
final Map<String, dynamic> noteMap = jsonDecode(noteString);
courseList.add(CoursesModal.fromJson(noteMap));
courseList.add(CoursesModel.fromJson(noteMap));
});
_ref.read(coursesDataProvider.notifier).update((state) => courseList);
}
Expand Down
10 changes: 5 additions & 5 deletions lib/features/courses/views/course_filter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:companion/core/core.dart';
import 'package:companion/core/providers/dummy_user_provider.dart';
import 'package:companion/features/courses/controller/courses_controller.dart';
import 'package:companion/features/user/controller/user_controller.dart';
import 'package:companion/modal/courses.modal.dart';
import 'package:companion/model/courses.model.dart';
import 'package:companion/theme/pallete.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand All @@ -26,15 +26,15 @@ class _CourseListFilterPageState extends ConsumerState<CourseFilterView> {
TextEditingController editingController = TextEditingController();

late List<String> usercourseslist;
late List<CoursesModal> courseListFinal;
late List<CoursesModal> courseList;
late List<CoursesModel> courseListFinal;
late List<CoursesModel> courseList;
@override
void initState() {
super.initState();
var user = ref.read(userDataProvider)??nullUser;
usercourseslist = List.from(user.cid!);
List<CoursesModal> selectedCourses = [];
List<CoursesModal> unselectedCourses = [];
List<CoursesModel> selectedCourses = [];
List<CoursesModel> unselectedCourses = [];
var courses = ref.read(coursesDataProvider);
courseList = courses!;
courseList.sort((a, b) => a.cname!.compareTo(b.cname!));
Expand Down
40 changes: 20 additions & 20 deletions lib/features/courses/views/course_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import 'package:companion/features/notes/controller/notes_controller.dart';
import 'package:companion/features/notes/views/notes_menu.dart';
import 'package:companion/features/notes/views/notes_pdf_view.dart';
import 'package:companion/features/user/controller/user_controller.dart';
import 'package:companion/modal/courses.modal.dart';
import 'package:companion/modal/notes.modal.dart';
import 'package:companion/modal/user.modal.dart';
import 'package:companion/model/courses.model.dart';
import 'package:companion/model/notes.model.dart';
import 'package:companion/model/user.model.dart';
import 'package:companion/theme/pallete.dart';
import 'package:flutter/material.dart';
import 'package:flutter_octicons/flutter_octicons.dart';import 'package:timeago/timeago.dart' as timeago;
Expand All @@ -18,11 +18,11 @@ typedef BoolCallback = void Function(bool val);
final sortNoteProvider = StateProvider<bool?>((ref) => null);

class BasicSliverAppBar extends ConsumerStatefulWidget {
final CoursesModal course;
final CoursesModel course;
const BasicSliverAppBar({super.key, required this.course});

static Route route({
required CoursesModal course,
required CoursesModel course,
}) {
return MaterialPageRoute<void>(
builder: (_) => BasicSliverAppBar(
Expand All @@ -46,14 +46,14 @@ class _BasicSliverAppBarState extends ConsumerState<BasicSliverAppBar> {
});
}

getnotes(List<String> fileIds, List<NotesModal> notes) {
Map<String, NotesModal> notesMap = {};
getnotes(List<String> fileIds, List<NotesModel> notes) {
Map<String, NotesModel> notesMap = {};

for (var note in notes) {
notesMap[note.fileId!] = note;
}

List<NotesModal> notesList = [];
List<NotesModel> notesList = [];

for (var fileId in fileIds) {
var note = notesMap[fileId];
Expand All @@ -65,14 +65,14 @@ class _BasicSliverAppBarState extends ConsumerState<BasicSliverAppBar> {
return notesList;
}

getNotesByUnit(List<String> fileIds, List<NotesModal> notes, int unit) {
Map<String, NotesModal> notesMap = {};
getNotesByUnit(List<String> fileIds, List<NotesModel> notes, int unit) {
Map<String, NotesModel> notesMap = {};

for (var note in notes) {
notesMap[note.fileId!] = note;
}

List<NotesModal> notesList = [];
List<NotesModel> notesList = [];

for (var fileId in fileIds) {
var note = notesMap[fileId];
Expand All @@ -96,18 +96,18 @@ class _BasicSliverAppBarState extends ConsumerState<BasicSliverAppBar> {
final user = ref.watch(userDataProvider) ?? nullUser;
var sortedAlphabetical = ref.watch(sortNoteProvider) ?? false;

List<NotesModal> notesList = getnotes(widget.course.fileId!, notes);
List<NotesModal> unit0notesList =
List<NotesModel> notesList = getnotes(widget.course.fileId!, notes);
List<NotesModel> unit0notesList =
getNotesByUnit(widget.course.fileId!, notes, 0);
List<NotesModal> unit1notesList =
List<NotesModel> unit1notesList =
getNotesByUnit(widget.course.fileId!, notes, 1);
List<NotesModal> unit2notesList =
List<NotesModel> unit2notesList =
getNotesByUnit(widget.course.fileId!, notes, 2);
List<NotesModal> unit3notesList =
List<NotesModel> unit3notesList =
getNotesByUnit(widget.course.fileId!, notes, 3);
List<NotesModal> unit4notesList =
List<NotesModel> unit4notesList =
getNotesByUnit(widget.course.fileId!, notes, 4);
List<NotesModal> unit5notesList =
List<NotesModel> unit5notesList =
getNotesByUnit(widget.course.fileId!, notes, 5);
var index = widget.course.cid! % 10;
return Container(
Expand Down Expand Up @@ -225,7 +225,7 @@ class _BasicSliverAppBarState extends ConsumerState<BasicSliverAppBar> {
}

ExpansionTile UnitExpansionTile(
List<NotesModal> unitnotesList, UserModal user, Size size, String title) {
List<NotesModel> unitnotesList, UserModel user, Size size, String title) {
return ExpansionTile(
iconColor: Pallete.whiteColor,
collapsedIconColor: Pallete.whiteColor,
Expand Down Expand Up @@ -269,7 +269,7 @@ class _BasicSliverAppBarState extends ConsumerState<BasicSliverAppBar> {
}

ListTile NotesView(
List<NotesModal> notesList, int index, UserModal user, Size size) {
List<NotesModel> notesList, int index, UserModel user, Size size) {
return ListTile(
onTap: () {
Navigator.push(context, NotesPdfView.route(notes: notesList[index]));
Expand Down
Loading

0 comments on commit b211ac3

Please sign in to comment.