Skip to content
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

[Refactor] Improved Code Quality #132

Merged
merged 2 commits into from
Oct 8, 2024
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
11 changes: 6 additions & 5 deletions lib/constants/routes.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'package:flutter/material.dart';
import 'package:page_transition/page_transition.dart';
import 'package:mynotes/views/chat/chat_room.dart';
import 'package:mynotes/views/home/search_view.dart';
import 'package:mynotes/views/notes/create_update_note_view.dart';
import 'package:mynotes/views/profile/user_details.dart';
import 'package:mynotes/views/profile/user_profile.dart';

import '/views/chat/chat_room.dart';
import '/views/home/search_view.dart';
import '/views/notes/create_update_note_view.dart';
import '/views/profile/user_details.dart';
import '/views/profile/user_profile.dart';

const createOrUpdateNoteRoute = '/notes/new-note';
const searchRoute = '/constants/search-view';
Expand Down
4 changes: 3 additions & 1 deletion lib/helper/loading/loading_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:mynotes/helper/loading/loading_screen_controller.dart';

import '/helper/loading/loading_screen_controller.dart';

class LoadingScreen {
factory LoadingScreen() => _shared;
Expand Down
5 changes: 3 additions & 2 deletions lib/helper/loading/shimmer_loading.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'package:flutter/material.dart';
import 'package:mynotes/config/size_config.dart';
import 'package:mynotes/constants/colors.dart';
import 'package:shimmer/shimmer.dart';
import 'package:velocity_x/velocity_x.dart';

import '/config/size_config.dart';
import '/constants/colors.dart';

class SkeletonNotes extends StatelessWidget {
const SkeletonNotes({
Key? key,
Expand Down
27 changes: 14 additions & 13 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:mynotes/constants/routes.dart';
import 'package:mynotes/helper/loading/loading_screen.dart';
import 'package:mynotes/services/auth/bloc/auth_bloc.dart';
import 'package:mynotes/services/auth/bloc/auth_event.dart';
import 'package:mynotes/services/auth/bloc/auth_state.dart';
import 'package:mynotes/services/auth/firebase_auth_provider.dart';
import 'package:mynotes/views/login_view.dart';
import 'package:mynotes/views/forgot_password_view.dart';
import 'package:mynotes/views/home/home.dart';
import 'package:mynotes/views/register_view.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:mynotes/views/verify_email_view.dart';
import 'package:mynotes/extentions/buildcontext/loc.dart';
import 'package:overlay_support/overlay_support.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

import '/constants/routes.dart';
import '/helper/loading/loading_screen.dart';
import '/services/auth/bloc/auth_bloc.dart';
import '/services/auth/bloc/auth_event.dart';
import '/services/auth/bloc/auth_state.dart';
import '/services/auth/firebase_auth_provider.dart';
import '/views/login_view.dart';
import '/views/forgot_password_view.dart';
import '/views/home/home.dart';
import '/views/register_view.dart';
import '/views/verify_email_view.dart';
import '/extentions/buildcontext/loc.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
Expand Down
2 changes: 1 addition & 1 deletion lib/services/auth/auth_provider.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:mynotes/services/auth/auth_user.dart';
import '/services/auth/auth_user.dart';

abstract class AuthProvider {
Future<void> initialize();
Expand Down
6 changes: 3 additions & 3 deletions lib/services/auth/auth_serivce.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:mynotes/services/auth/auth_provider.dart';
import 'package:mynotes/services/auth/auth_user.dart';
import 'package:mynotes/services/auth/firebase_auth_provider.dart';
import '/services/auth/auth_provider.dart';
import '/services/auth/auth_user.dart';
import '/services/auth/firebase_auth_provider.dart';

class AuthService implements AuthProvider {
final AuthProvider provider;
Expand Down
9 changes: 5 additions & 4 deletions lib/services/auth/bloc/auth_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'package:bloc/bloc.dart';
import 'package:mynotes/services/auth/auth_provider.dart';
import 'package:mynotes/services/auth/bloc/auth_event.dart';
import 'package:mynotes/services/auth/bloc/auth_state.dart';
import 'package:mynotes/services/auth/google_auth.dart';

import '/services/auth/auth_provider.dart';
import '/services/auth/bloc/auth_event.dart';
import '/services/auth/bloc/auth_state.dart';
import '/services/auth/google_auth.dart';

class AuthBloc extends Bloc<AuthEvent, AuthState> {
AuthBloc(AuthProvider provider)
Expand Down
9 changes: 2 additions & 7 deletions lib/services/auth/bloc/auth_state.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:flutter/foundation.dart' show immutable;
import 'package:mynotes/services/auth/auth_user.dart';
import 'package:equatable/equatable.dart';

import '/services/auth/auth_user.dart';

@immutable
abstract class AuthState {
final bool isLoading;
Expand Down Expand Up @@ -44,23 +45,17 @@ class AuthStateLoggedIn extends AuthState {
}

class AuthStateLoggedInWithGmail extends AuthState {

const AuthStateLoggedInWithGmail({

required bool isLoading,
}) : super(isLoading: isLoading);
}



class AuthStateNeedsVerification extends AuthState {
const AuthStateNeedsVerification({
required bool isLoading,
}) : super(isLoading: isLoading);
}



class AuthStateLoggedOut extends AuthState with EquatableMixin {
final Exception? exception;
const AuthStateLoggedOut({
Expand Down
7 changes: 4 additions & 3 deletions lib/services/auth/firebase_auth_provider.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import 'package:firebase_core/firebase_core.dart';
import 'package:mynotes/firebase_options.dart';
import 'package:mynotes/services/auth/auth_user.dart';
import 'package:mynotes/services/auth/auth_provider.dart';
import 'package:mynotes/services/auth/auth_exception.dart';
import 'package:firebase_auth/firebase_auth.dart'
show FirebaseAuth, FirebaseAuthException;

import '/services/auth/auth_user.dart';
import '/services/auth/auth_provider.dart';
import '/services/auth/auth_exception.dart';

class FirebaseAuthProvider implements AuthProvider {
@override
Future<void> initialize() async {
Expand Down
3 changes: 2 additions & 1 deletion lib/services/cloud/cloud_note.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:mynotes/services/cloud/cloud_storage_constants.dart';
import 'package:flutter/cupertino.dart';

import '/services/cloud/cloud_storage_constants.dart';

@immutable
class CloudNote {
final String documentId;
Expand Down
7 changes: 4 additions & 3 deletions lib/services/cloud/firebase_cloud_storgae.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:intl/intl.dart';
import 'package:mynotes/services/cloud/cloud_note.dart';
import 'package:mynotes/services/cloud/cloud_storage_constants.dart';
import 'package:mynotes/services/cloud/cloud_storage_exception.dart';

import '/services/cloud/cloud_note.dart';
import '/services/cloud/cloud_storage_constants.dart';
import '/services/cloud/cloud_storage_exception.dart';

class FirebaseCloudStorage {
final notes = FirebaseFirestore.instance.collection('notes');
Expand Down
5 changes: 3 additions & 2 deletions lib/utilities/dialogs/cannot_share_empty_not_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:mynotes/extentions/buildcontext/loc.dart';
import 'package:mynotes/utilities/dialogs/generic_dialog.dart';

import '/extentions/buildcontext/loc.dart';
import '/utilities/dialogs/generic_dialog.dart';

Future<void> showCannotShareEmptyNoteDialog(BuildContext context) {
return showGenericDialog<void>(
Expand Down
8 changes: 5 additions & 3 deletions lib/utilities/dialogs/comming_soon.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'package:flutter/material.dart';

import 'package:google_fonts/google_fonts.dart';
import 'package:mynotes/config/size_config.dart';
import 'package:mynotes/constants/colors.dart';
import 'package:mynotes/widget/popup.dart';

import '/config/size_config.dart';
import '/constants/colors.dart';
import '/widget/popup.dart';

commingSoon(BuildContext context) {
showDialog(
Expand Down
5 changes: 3 additions & 2 deletions lib/utilities/dialogs/delete_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:mynotes/extentions/buildcontext/loc.dart';
import 'package:mynotes/utilities/dialogs/generic_dialog.dart';

import '/extentions/buildcontext/loc.dart';
import '/utilities/dialogs/generic_dialog.dart';

Future<bool> showDeleteDialog(BuildContext context) {
return showGenericDialog<bool>(
Expand Down
5 changes: 3 additions & 2 deletions lib/utilities/dialogs/error_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:mynotes/extentions/buildcontext/loc.dart';
import 'package:mynotes/utilities/dialogs/generic_dialog.dart';

import '/extentions/buildcontext/loc.dart';
import '/utilities/dialogs/generic_dialog.dart';

Future<void> showErrorDialog(
BuildContext context,
Expand Down
5 changes: 3 additions & 2 deletions lib/utilities/dialogs/logout_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:mynotes/extentions/buildcontext/loc.dart';
import 'package:mynotes/utilities/dialogs/generic_dialog.dart';

import '/extentions/buildcontext/loc.dart';
import '/utilities/dialogs/generic_dialog.dart';

Future<bool> showLogOutDialog(BuildContext context) {
return showGenericDialog<bool>(
Expand Down
5 changes: 3 additions & 2 deletions lib/utilities/dialogs/password_reset.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:mynotes/extentions/buildcontext/loc.dart';
import 'package:mynotes/utilities/dialogs/generic_dialog.dart';

import '/extentions/buildcontext/loc.dart';
import '/utilities/dialogs/generic_dialog.dart';

Future<void> showPasswordResetSentDialog(BuildContext context) {
return showGenericDialog(
Expand Down
5 changes: 3 additions & 2 deletions lib/utilities/internet_snak_bar.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:lottie/lottie.dart';
import 'package:mynotes/config/size_config.dart';
import 'package:mynotes/constants/colors.dart';
import 'package:overlay_support/overlay_support.dart';

import '/config/size_config.dart';
import '/constants/colors.dart';

class InternetSnackBar {
static void showTopSnackBar(BuildContext context) {
// cusotom bottom snackbar
Expand Down
7 changes: 4 additions & 3 deletions lib/views/chat/chat_home_page.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:mynotes/config/size_config.dart';
import 'package:mynotes/constants/colors.dart';
import 'package:mynotes/constants/routes.dart';

import '/config/size_config.dart';
import '/constants/colors.dart';
import '/constants/routes.dart';

class ChatView extends StatelessWidget {
const ChatView({
Expand Down
5 changes: 3 additions & 2 deletions lib/views/chat/chat_room.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_iconly/flutter_iconly.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:mynotes/config/size_config.dart';
import 'package:mynotes/constants/colors.dart';

import '/config/size_config.dart';
import '/constants/colors.dart';

class ChatRoom extends StatelessWidget {
const ChatRoom({super.key});
Expand Down
17 changes: 9 additions & 8 deletions lib/views/forgot_password_view.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:mynotes/config/size_config.dart';
import 'package:mynotes/constants/colors.dart';
import 'package:mynotes/extentions/buildcontext/loc.dart';
import 'package:mynotes/services/auth/bloc/auth_bloc.dart';
import 'package:mynotes/services/auth/bloc/auth_event.dart';
import 'package:mynotes/services/auth/bloc/auth_state.dart';
import 'package:mynotes/utilities/dialogs/error_dialog.dart';
import 'package:mynotes/utilities/dialogs/password_reset.dart';

import '/config/size_config.dart';
import '/constants/colors.dart';
import '/extentions/buildcontext/loc.dart';
import '/services/auth/bloc/auth_bloc.dart';
import '/services/auth/bloc/auth_event.dart';
import '/services/auth/bloc/auth_state.dart';
import '/utilities/dialogs/error_dialog.dart';
import '/utilities/dialogs/password_reset.dart';

class ForgotPasswordView extends StatefulWidget {
const ForgotPasswordView({Key? key}) : super(key: key);
Expand Down
17 changes: 9 additions & 8 deletions lib/views/home/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:mynotes/config/size_config.dart';
import 'package:mynotes/constants/colors.dart';
import 'package:mynotes/constants/routes.dart';
import 'package:mynotes/services/auth/bloc/auth_event.dart';
import 'package:mynotes/utilities/internet_snak_bar.dart';
import 'package:mynotes/views/login_view.dart';
import 'package:mynotes/widget/slider.dart';
import '../../services/auth/bloc/auth_bloc.dart';

import '/config/size_config.dart';
import '/constants/colors.dart';
import '/constants/routes.dart';
import '/services/auth/bloc/auth_event.dart';
import '/utilities/internet_snak_bar.dart';
import '/views/login_view.dart';
import '/widget/slider.dart';
import '/services/auth/bloc/auth_bloc.dart';

class NewNotesView extends StatefulWidget {
const NewNotesView({super.key});
Expand Down
7 changes: 4 additions & 3 deletions lib/views/home/search_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:iconsax/iconsax.dart';
import 'package:mynotes/config/size_config.dart';
import 'package:mynotes/constants/colors.dart';
import 'package:mynotes/widget/download.dart';
import 'package:velocity_x/velocity_x.dart';

import '/config/size_config.dart';
import '/constants/colors.dart';
import '/widget/download.dart';

class SearchView extends StatefulWidget {
const SearchView({super.key});

Expand Down
19 changes: 10 additions & 9 deletions lib/views/login_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:iconsax/iconsax.dart';
import 'package:mynotes/config/size_config.dart';
import 'package:mynotes/constants/colors.dart';
import 'package:mynotes/extentions/buildcontext/loc.dart';
import 'package:mynotes/services/auth/auth_exception.dart';
import 'package:mynotes/services/auth/bloc/auth_bloc.dart';
import 'package:mynotes/services/auth/bloc/auth_event.dart';
import 'package:mynotes/services/auth/bloc/auth_state.dart';
import 'package:mynotes/utilities/dialogs/error_dialog.dart';
import 'package:mynotes/utilities/internet_snak_bar.dart';

import '/config/size_config.dart';
import '/constants/colors.dart';
import '/extentions/buildcontext/loc.dart';
import '/services/auth/auth_exception.dart';
import '/services/auth/bloc/auth_bloc.dart';
import '/services/auth/bloc/auth_event.dart';
import '/services/auth/bloc/auth_state.dart';
import '/utilities/dialogs/error_dialog.dart';
import '/utilities/internet_snak_bar.dart';

class LoginView extends StatefulWidget {
const LoginView({Key? key}) : super(key: key);
Expand Down
17 changes: 9 additions & 8 deletions lib/views/notes/create_update_note_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ import 'package:flutter_svg/svg.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:iconsax/iconsax.dart';
import 'package:image_picker/image_picker.dart';
import 'package:mynotes/config/size_config.dart';
import 'package:mynotes/constants/colors.dart';
import 'package:mynotes/extentions/buildcontext/loc.dart';
import 'package:mynotes/services/auth/auth_serivce.dart';
import 'package:mynotes/utilities/dialogs/cannot_share_empty_not_dialog.dart';
import 'package:mynotes/utilities/generic/get_argumnets.dart';
import 'package:mynotes/services/cloud/cloud_note.dart';
import 'package:mynotes/services/cloud/firebase_cloud_storgae.dart';
import 'package:share_plus/share_plus.dart';

import '/config/size_config.dart';
import '/constants/colors.dart';
import '/extentions/buildcontext/loc.dart';
import '/services/auth/auth_serivce.dart';
import '/utilities/dialogs/cannot_share_empty_not_dialog.dart';
import '/utilities/generic/get_argumnets.dart';
import '/services/cloud/cloud_note.dart';
import '/services/cloud/firebase_cloud_storgae.dart';

class CreateUpdateNoteView extends StatefulWidget {
const CreateUpdateNoteView({Key? key}) : super(key: key);

Expand Down
Loading
Loading