Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -482,7 +482,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -531,7 +531,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
3 changes: 3 additions & 0 deletions ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
Expand All @@ -43,11 +44,13 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand Down
700 changes: 364 additions & 336 deletions lib/app_router.dart

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions lib/data/bloc/network/network_connection_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ class NetworkConnectionBloc
final Connectivity _connectivity;

NetworkConnectionBloc(this._connectivity)
: super(NetworkConnectionInitialState()) {
: super(NetworkConnectionInitialState()) {
on<NetworkConnectionObserveEvent>(_observeConnection);
on<NetworkConnectionChangeEvent>(_changeConnection);
}

Future<void> _observeConnection(NetworkConnectionObserveEvent event,
Emitter<NetworkConnectionState> emit) async {
Future<void> _observeConnection(
NetworkConnectionObserveEvent event,
Emitter<NetworkConnectionState> emit,
) async {
_subscription = _connectivity.onConnectivityChanged.listen((result) {
_checkNetworkConnection(result);
});
Expand All @@ -33,8 +35,10 @@ class NetworkConnectionBloc
}
}

void _changeConnection(NetworkConnectionChangeEvent event,
Emitter<NetworkConnectionState> emit) {
void _changeConnection(
NetworkConnectionChangeEvent event,
Emitter<NetworkConnectionState> emit,
) {
if (event.hasConnection == true) {
emit(NetWorkConnectionSuccessState());
} else {
Expand Down
56 changes: 35 additions & 21 deletions lib/data/bloc/user_state/user_state_controller_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ class UserStateControllerBloc
final SpaceChangeNotifier _spaceChangeNotifier;
StreamSubscription? _subscription;

UserStateControllerBloc(this._employeeRepo, this._userStateNotifier,
this._spaceService, this._spaceChangeNotifier)
: super(const UserInitialStatus()) {
UserStateControllerBloc(
this._employeeRepo,
this._userStateNotifier,
this._spaceService,
this._spaceChangeNotifier,
) : super(const UserInitialStatus()) {
on<CheckUserStatus>(_updateEmployee);
on<ClearDataForDisableUser>(_clearData);
on<UpdateUserData>(_updateData);
Expand All @@ -40,34 +43,41 @@ class UserStateControllerBloc
});
if (_userStateNotifier.currentSpaceId != null) {
_spaceChangeNotifier.setSpaceId(
spaceId: _userStateNotifier.currentSpaceId!);
spaceId: _userStateNotifier.currentSpaceId!,
);
}
}

Future<void> _updateEmployee(
CheckUserStatus event, Emitter<UserControllerStatus> emit) async {
CheckUserStatus event,
Emitter<UserControllerStatus> emit,
) async {
try {
log("Function called", name: "User Status");
final Space? space =
await _spaceService.getSpace(_userStateNotifier.currentSpaceId!);
log("space fetched", name: "User Status");
_subscription =
_employeeRepo.memberDetails(_userStateNotifier.userUID!).listen(
(Employee? employee) async {
log("Employee fetched", name: "User Status");
add(UpdateUserData(employee: employee, space: space));
},
onError: (error, _) {
add(ShowUserStatusFetchError());
},
final Space? space = await _spaceService.getSpace(
_userStateNotifier.currentSpaceId!,
);
log("space fetched", name: "User Status");
_subscription = _employeeRepo
.memberDetails(_userStateNotifier.userUID!)
.listen(
(Employee? employee) async {
log("Employee fetched", name: "User Status");
add(UpdateUserData(employee: employee, space: space));
},
onError: (error, _) {
add(ShowUserStatusFetchError());
},
);
} on Exception {
add(ShowUserStatusFetchError());
}
}

Future<void> _updateData(
UpdateUserData event, Emitter<UserControllerStatus> emit) async {
UpdateUserData event,
Emitter<UserControllerStatus> emit,
) async {
if (event.employee != null &&
event.space != null &&
event.employee?.status == EmployeeStatus.active) {
Expand All @@ -86,14 +96,18 @@ class UserStateControllerBloc
}
}

Future<void> _showError(ShowUserStatusFetchError event,
Emitter<UserControllerStatus> emit) async {
Future<void> _showError(
ShowUserStatusFetchError event,
Emitter<UserControllerStatus> emit,
) async {
log("Error occurs", name: "User Status");
emit(const UserErrorStatus());
}

Future<void> _clearData(
ClearDataForDisableUser event, Emitter<UserControllerStatus> emit) async {
ClearDataForDisableUser event,
Emitter<UserControllerStatus> emit,
) async {
await _userStateNotifier.removeEmployeeWithSpace();
log("All data cleared", name: "User Status");
}
Expand Down
8 changes: 4 additions & 4 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,
};
}
65 changes: 36 additions & 29 deletions lib/data/configs/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,50 @@ import 'package:table_calendar/table_calendar.dart'

class AppTheme {
static CalendarStyle calendarStyle(BuildContext context) => CalendarStyle(
outsideDaysVisible: false,
defaultTextStyle: AppTextStyle.style16
.copyWith(color: context.colorScheme.textPrimary),
weekendTextStyle: AppTextStyle.style14
.copyWith(color: context.colorScheme.textSecondary),
selectedDecoration: BoxDecoration(
color: context.colorScheme.primary, shape: BoxShape.circle),
markerDecoration: BoxDecoration(
color: context.colorScheme.tertiary,
shape: BoxShape.circle,
),
todayDecoration: BoxDecoration(
border: Border.all(color: context.colorScheme.primary),
shape: BoxShape.circle,
),
todayTextStyle: AppTextStyle.style14
.copyWith(color: context.colorScheme.textSecondary),
);
outsideDaysVisible: false,
defaultTextStyle: AppTextStyle.style16.copyWith(
color: context.colorScheme.textPrimary,
),
weekendTextStyle: AppTextStyle.style14.copyWith(
color: context.colorScheme.textSecondary,
),
selectedDecoration: BoxDecoration(
color: context.colorScheme.primary,
shape: BoxShape.circle,
),
markerDecoration: BoxDecoration(
color: context.colorScheme.tertiary,
shape: BoxShape.circle,
),
todayDecoration: BoxDecoration(
border: Border.all(color: context.colorScheme.primary),
shape: BoxShape.circle,
),
todayTextStyle: AppTextStyle.style14.copyWith(
color: context.colorScheme.textSecondary,
),
);

static DaysOfWeekStyle daysOfWeekStyle(BuildContext context) =>
DaysOfWeekStyle(
weekdayStyle: AppTextStyle.style14.copyWith(
color: context.colorScheme.textPrimary,
fontWeight: FontWeight.w600),
color: context.colorScheme.textPrimary,
fontWeight: FontWeight.w600,
),
weekendStyle: AppTextStyle.style14.copyWith(
color: context.colorScheme.textDisable,
fontWeight: FontWeight.w600),
color: context.colorScheme.textDisable,
fontWeight: FontWeight.w600,
),
);

static List<BoxShadow> commonBoxShadow(BuildContext context) => [
BoxShadow(
color: context.colorScheme.outlineColor,
blurRadius: 3,
offset: const Offset(0, 0),
spreadRadius: 1,
)
];
BoxShadow(
color: context.colorScheme.outlineColor,
blurRadius: 3,
offset: const Offset(0, 0),
spreadRadius: 1,
),
];

static BorderRadius commonBorderRadius = BorderRadius.circular(12);
}
2 changes: 1 addition & 1 deletion lib/data/core/exception/exception_msg.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_gen/gen_l10n/app_localization.dart';
import 'package:projectunity/data/l10n/app_localization.dart';

import 'error_const.dart';

Expand Down
2 changes: 1 addition & 1 deletion lib/data/core/extensions/context_extension.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/cupertino.dart';
import '../../../style/app_theme.dart';
import '../../../style/colors.dart';
import 'package:flutter_gen/gen_l10n/app_localization.dart';
import 'package:projectunity/data/l10n/app_localization.dart';

extension BuildContextExtension on BuildContext {
AppColorScheme get colorScheme => appColorSchemeOf(this);
Expand Down
26 changes: 16 additions & 10 deletions lib/data/core/extensions/date_time.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ extension TimestampExtension on DateTime {

bool isDateInCurrentWeek(DateTime currentDate) {
DateTime now = DateTime.now().dateOnly;
DateTime startOfWeek =
now.dateOnly.subtract(Duration(days: now.weekday - 1));
DateTime endOfWeek = startOfWeek.dateOnly
.add(const Duration(days: DateTime.daysPerWeek - 1));
DateTime startOfWeek = now.dateOnly.subtract(
Duration(days: now.weekday - 1),
);
DateTime endOfWeek = startOfWeek.dateOnly.add(
const Duration(days: DateTime.daysPerWeek - 1),
);

DateTime birthdayThisYear = DateTime(currentDate.year, month, day).dateOnly;
DateTime birthdayNextYear =
DateTime(currentDate.year + 1, month, day).dateOnly;
DateTime birthdayNextYear = DateTime(
currentDate.year + 1,
month,
day,
).dateOnly;

return (birthdayThisYear.isAfterOrSame(now) &&
birthdayThisYear.isBefore(endOfWeek)) ||
Expand Down Expand Up @@ -66,15 +71,16 @@ extension TimestampExtension on DateTime {

LeaveDayDuration getLeaveDayDuration() => isWeekend
? isNotForthSaturday()
? LeaveDayDuration.noLeave
: LeaveDayDuration.firstHalfLeave
? LeaveDayDuration.noLeave
: LeaveDayDuration.firstHalfLeave
: LeaveDayDuration.fullLeave;

bool isNotForthSaturday() {
DateTime monthFirstDate = DateTime(year, month);
List<DateTime> allDatesInMonth = List.generate(
DateTime(year, month + 1).difference(monthFirstDate).inDays,
(days) => monthFirstDate.add(Duration(days: days)));
DateTime(year, month + 1).difference(monthFirstDate).inDays,
(days) => monthFirstDate.add(Duration(days: days)),
);
int saturdayCount = 0;
DateTime forthSaturdayDate = allDatesInMonth.where((date) {
if (date.weekday == DateTime.saturday) {
Expand Down
12 changes: 7 additions & 5 deletions lib/data/core/extensions/leave_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import '../../model/leave/leave.dart';
extension LeaveExtension on Leave {
Map<DateTime, LeaveDayDuration> getDateAndDuration() {
List<DateTime> dates = List.generate(
endDate.dateOnly.difference(startDate.dateOnly).inDays,
(days) => startDate.dateOnly.add(Duration(days: days)))
..add(endDate.dateOnly);
return Map<DateTime, LeaveDayDuration>.fromIterable(dates,
value: (date) => perDayDuration[dates.indexOf(date)]);
endDate.dateOnly.difference(startDate.dateOnly).inDays,
(days) => startDate.dateOnly.add(Duration(days: days)),
)..add(endDate.dateOnly);
return Map<DateTime, LeaveDayDuration>.fromIterable(
dates,
value: (date) => perDayDuration[dates.indexOf(date)],
);
}

bool findUserOnLeaveByDate({required DateTime day}) =>
Expand Down
10 changes: 6 additions & 4 deletions lib/data/core/extensions/list.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
extension Iterables<E> on Iterable<E> {
Map<K, List<E>> groupBy<K>(K Function(E) keyFunction) => fold(
<K, List<E>>{},
(Map<K, List<E>> map, E element) =>
map..putIfAbsent(keyFunction(element), () => <E>[]).add(element));
<K, List<E>>{},
(Map<K, List<E>> map, E element) =>
map..putIfAbsent(keyFunction(element), () => <E>[]).add(element),
);
}

extension IterableListMergeExtension<T> on Iterable<List<T>> {
Expand All @@ -19,7 +20,8 @@ extension ConvertListToMapExtension<T> on List<T> {
Map<DateTime, List<T>> groupByMonth(DateTime Function(T element) extractor) {
sort((a, b) => extractor(b).compareTo(extractor(a)));
return groupBy(
(item) => DateTime(extractor(item).year, extractor(item).month));
(item) => DateTime(extractor(item).year, extractor(item).month),
);
}

void removeWhereAndAdd(T? newElement, bool Function(T element) where) {
Expand Down
13 changes: 8 additions & 5 deletions lib/data/core/extensions/map_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ import '../../model/leave/leave.dart';
import 'date_time.dart';

extension MapExtensions on Map<DateTime, LeaveDayDuration> {
Map<DateTime, LeaveDayDuration> getSelectedLeaveOfTheDays(
{required DateTime startDate, required DateTime endDate}) {
Map<DateTime, LeaveDayDuration> getSelectedLeaveOfTheDays({
required DateTime startDate,
required DateTime endDate,
}) {
List<DateTime> dates = [];
if (startDate.isAtSameMomentAs(endDate)) {
dates = [startDate];
} else if (startDate.isBefore(endDate)) {
dates = List.generate(endDate.difference(startDate).inDays,
(days) => startDate.add(Duration(days: days)))
..add(endDate);
dates = List.generate(
endDate.difference(startDate).inDays,
(days) => startDate.add(Duration(days: days)),
)..add(endDate);
}
for (var date in dates) {
putIfAbsent(date.dateOnly, () => date.getLeaveDayDuration());
Expand Down
Loading
Loading