Skip to content

Commit

Permalink
Clean up (#40)
Browse files Browse the repository at this point in the history
* Clean up

* Add crashlytics as app module dependacies
  • Loading branch information
cp-pratik-k authored Jul 25, 2023
1 parent de6e69f commit c7714a9
Show file tree
Hide file tree
Showing 79 changed files with 720 additions and 4,144 deletions.
Binary file removed assets/images/loginPage_background.jpg
Binary file not shown.
Binary file removed assets/images/loginPage_vector.jpg
Binary file not shown.
Binary file removed assets/images/onboard_screen1.jpg
Binary file not shown.
Binary file removed assets/images/onboard_screen2.jpg
Binary file not shown.
Binary file removed assets/images/onboard_screen3.jpg
Binary file not shown.
19 changes: 11 additions & 8 deletions lib/data/Repo/employee_repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ import '../services/employee_service.dart';
class EmployeeRepo {
final EmployeeService _employeeService;
final UserStateNotifier _userStateNotifier;
final FirebaseCrashlytics _crashlytics;
late BehaviorSubject<List<Employee>> _employeeController;
StreamSubscription<List<Employee>>? _employeeStreamSubscription;

EmployeeRepo(this._employeeService, this._userStateNotifier) {
EmployeeRepo(this._employeeService, this._userStateNotifier, this._crashlytics) {
_employeeController = BehaviorSubject<List<Employee>>();
_employeeStreamSubscription = _employeeService
.employees(_userStateNotifier.currentSpaceId!)
.listen((value) {
_employeeController.add(value);
}, onError: (e, s) async {
_employeeController.addError(e);
await FirebaseCrashlytics.instance.recordError(e, s);
await _crashlytics.recordError(e, s);
});
}

Expand All @@ -40,12 +41,14 @@ class EmployeeRepo {
Future<void> reset() async {
_employeeController = BehaviorSubject<List<Employee>>();
await _employeeStreamSubscription?.cancel();
_employeeStreamSubscription =
_employeeService.employees(_userStateNotifier.currentSpaceId!).listen(
(value) {
_employeeController.add(value);
},
);
_employeeStreamSubscription = _employeeService
.employees(_userStateNotifier.currentSpaceId!)
.listen((value) {
_employeeController.add(value);
}, onError: (e, s) async {
_employeeController.addError(e);
await _crashlytics.recordError(e, s);
});
}

@disposeMethod
Expand Down
16 changes: 9 additions & 7 deletions lib/data/Repo/leave_repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ import 'package:rxdart/rxdart.dart';
@LazySingleton()
class LeaveRepo {
final LeaveService _leaveService;
final FirebaseCrashlytics _crashlytics;
late BehaviorSubject<List<Leave>> _leavesController;
StreamSubscription<List<Leave>>? _leavesStreamSubscription;

LeaveRepo(this._leaveService) {
LeaveRepo(this._leaveService, this._crashlytics) {
_leavesController = BehaviorSubject<List<Leave>>();
_leavesStreamSubscription = _leaveService.leaves.listen((value) {
_leavesController.add(value);
}, onError: (e, s) async {
_leavesController.addError(e);
await FirebaseCrashlytics.instance.recordError(e, s);
await _crashlytics.recordError(e, s);
});
}

Expand All @@ -40,11 +41,12 @@ class LeaveRepo {
Future<void> reset() async {
_leavesController = BehaviorSubject<List<Leave>>();
await _leavesStreamSubscription?.cancel();
_leavesStreamSubscription = _leaveService.leaves.listen(
(value) {
_leavesController.add(value);
},
);
_leavesStreamSubscription = _leaveService.leaves.listen((value) {
_leavesController.add(value);
}, onError: (e, s) async {
_leavesController.addError(e);
await _crashlytics.recordError(e, s);
});
}

Stream<List<Leave>> userLeaveRequest(String uid) =>
Expand Down
6 changes: 0 additions & 6 deletions lib/data/configs/colors.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import 'package:flutter/material.dart';

class AppColors {
static const peachColor = Color(0xfff2a699);
static const creamColor = Color(0xfffef9f5);

//Color used for rejected status container
static const redColor = Colors.red;

Expand All @@ -13,10 +10,7 @@ class AppColors {

static const Color primaryGray = Color(0xFFd7dee9);
static const Color primaryDarkYellow = Color(0xFFf2d97c);
static const Color primaryPink = Color(0xFFda9090);
static const Color primaryGreen = Color(0xFF74d8c1);
static const Color primaryBlue = Color(0xFF75a2ed);
static const Color darkBlue = Color(0xff0072bb);
static const Color blackColor = Colors.black;
static const Color whiteColor = Colors.white;
static const Color darkGrey = Color(0xff7d7d7d);
Expand Down
1 change: 0 additions & 1 deletion lib/data/configs/font_size.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class AppFontSize {
static const double appTitleTextSize = 50;
static const double header = 22;
static const double title = 20;
static const double bodyLarge = 18;
Expand Down
10 changes: 5 additions & 5 deletions lib/data/configs/scroll_behavior.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:flutter/material.dart';
class AppScrollBehaviour extends MaterialScrollBehavior {
@override
Set<PointerDeviceKind> get dragDevices => {
PointerDeviceKind.touch,
PointerDeviceKind.trackpad,
PointerDeviceKind.mouse,
};
}
PointerDeviceKind.touch,
PointerDeviceKind.trackpad,
PointerDeviceKind.mouse,
};
}
10 changes: 2 additions & 8 deletions lib/data/configs/text_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ class AppFontStyle {
static const buttonTextStyle =
TextStyle(color: AppColors.primaryBlue, fontSize: AppFontSize.label);

static TextStyle appTitleText = const TextStyle(
fontSize: AppFontSize.appTitleTextSize,
color: AppColors.blackColor,
);

static const appbarHeaderDark = TextStyle(
color: AppColors.blackColor,
fontSize: AppFontSize.header,
Expand All @@ -20,9 +15,8 @@ class AppFontStyle {
fontSize: AppFontSize.header,
fontWeight: FontWeight.w500);

static const headerDark = TextStyle(
color: AppColors.darkText,
fontSize: AppFontSize.header);
static const headerDark =
TextStyle(color: AppColors.darkText, fontSize: AppFontSize.header);

static const titleDark = TextStyle(
color: AppColors.darkText,
Expand Down
9 changes: 4 additions & 5 deletions lib/data/configs/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,14 @@ class AppTheme {
static CalendarStyle calendarStyle = const CalendarStyle(
outsideDaysVisible: false,
weekendTextStyle: AppFontStyle.bodySmallHeavy,
selectedDecoration: BoxDecoration(
color: AppColors.primaryBlue, shape: BoxShape.circle),
selectedDecoration:
BoxDecoration(color: AppColors.primaryBlue, shape: BoxShape.circle),
markerDecoration: BoxDecoration(
color: AppColors.orangeColor,
shape: BoxShape.circle,
),
todayDecoration: BoxDecoration(
color: AppColors.textFieldBg,
shape: BoxShape.circle),
todayDecoration:
BoxDecoration(color: AppColors.textFieldBg, shape: BoxShape.circle),
todayTextStyle: AppFontStyle.bodySmallRegular,
);

Expand Down
2 changes: 1 addition & 1 deletion lib/data/core/converters /date_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ class DateTimeConverter implements JsonConverter<DateTime, int> {

@override
int toJson(DateTime dateTime) => dateTime.millisecondsSinceEpoch;
}
}
1 change: 0 additions & 1 deletion lib/data/core/exception/custom_exception.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

class CustomException implements Exception {
String errorMessage;

Expand Down
22 changes: 0 additions & 22 deletions lib/data/core/extensions/calendar_format_extension.dart

This file was deleted.

9 changes: 7 additions & 2 deletions lib/data/core/extensions/date_time.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import 'package:flutter/material.dart';

import '../../model/leave/leave.dart';

extension DateExtention on int {
DateTime get toDate => DateTime.fromMillisecondsSinceEpoch(this);

TimeOfDay get toTime =>
TimeOfDay.fromDateTime(DateTime.fromMillisecondsSinceEpoch(this));

DateTime get dateOnly => DateUtils.dateOnly(toDate);

bool get isFirstHalf => toTime.hour >= 8 && toTime.hour < 13;

bool get isSecondHalf => toTime.hour >= 13 && toTime.hour <= 18;
}

extension TimestampExtension on DateTime {
int get futureDateSelectionYear => year + 2;

bool isBeforeOrSame(DateTime date) => isBefore(date) || isAtSameMomentAs(date);
bool isBeforeOrSame(DateTime date) =>
isBefore(date) || isAtSameMomentAs(date);

bool isAfterOrSame(DateTime date) => isBefore(date) || isAtSameMomentAs(date);

int get timeStampToInt => millisecondsSinceEpoch;
Expand Down
7 changes: 4 additions & 3 deletions lib/data/core/extensions/double_extension.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
extension DoubleExtension on double{
dynamic fixedAt(int l) => (toInt() == this)?toInt():double.parse(toStringAsFixed(l));
}
extension DoubleExtension on double {
dynamic fixedAt(int l) =>
(toInt() == this) ? toInt() : double.parse(toStringAsFixed(l));
}
1 change: 0 additions & 1 deletion lib/data/core/extensions/leave_extension.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'date_time.dart';
import '../../model/leave/leave.dart';


extension LeaveExtension on Leave {
Map<DateTime, LeaveDayDuration> getDateAndDuration() {
List<DateTime> dates = List.generate(
Expand Down
3 changes: 2 additions & 1 deletion lib/data/core/extensions/map_extension.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:projectunity/data/model/leave/leave.dart';

import '../../model/leave/leave.dart';
import 'date_time.dart';

extension MapExtensions on Map<DateTime, LeaveDayDuration> {
Expand Down
2 changes: 1 addition & 1 deletion lib/data/core/extensions/string_extension.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
extension NullCheckString on String? {
bool get isNotNullOrEmpty => !(this == null || this!.trim().isEmpty);
}
}
File renamed without changes.
4 changes: 0 additions & 4 deletions lib/data/core/utils/const/image_constant.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
class ImageConst{
static const String loginPageBackgroundImage =
'assets/images/loginPage_background.jpg';
static const String loginPageVectorImage = 'assets/images/office_growth.png';
static const String loginCreateSpaceButtonVector = 'assets/images/onboard_screen3.jpg';
static const String googleLogoImage = 'assets/images/google_logo.png';
static const String emptyLeaveStateImage = 'assets/images/empty_state.png';
static const String companyLogo = 'https://media.glassdoor.com/sqll/3194462/canopas-squarelogo-1607599457197.png';
}


Expand Down
16 changes: 12 additions & 4 deletions lib/data/di/app_module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,31 @@ import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:image_picker/image_picker.dart';
import 'package:injectable/injectable.dart';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';


@module
abstract class AppModule {
@preResolve
Future<SharedPreferences> get preferences => SharedPreferences.getInstance();

Connectivity get connectivity => Connectivity();
ImagePicker get imagePicker =>ImagePicker();

ImagePicker get imagePicker => ImagePicker();

FirebaseCrashlytics get firebaseCrashlytics => FirebaseCrashlytics.instance;

FirebaseStorage get firebaseStorage => FirebaseStorage.instance;

FirebaseFirestore get firebaseFireStore => FirebaseFirestore.instance;

FirebaseAuth get firebaseAuth => FirebaseAuth.instance;

DeviceInfoPlugin get deviceInfoPlugin => DeviceInfoPlugin();
http.Client get httpClient => http.Client();

}
http.Client get httpClient => http.Client();
}
Loading

0 comments on commit c7714a9

Please sign in to comment.