Skip to content

Commit

Permalink
Show upcoming events (#72)
Browse files Browse the repository at this point in the history
* Implement- Show upcoming Events

* Implement- Show upcoming Events

* Add unit test for celebrations bloc
  • Loading branch information
cp-sneha-s authored Mar 13, 2024
1 parent 104e0da commit d95e014
Show file tree
Hide file tree
Showing 25 changed files with 990 additions and 20 deletions.
11 changes: 10 additions & 1 deletion ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
"images" : [
{
"filename" : "appstore.png",
"idiom" : "universal"
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
Expand Down
12 changes: 11 additions & 1 deletion lib/data/core/extensions/date_formatter.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:projectunity/data/core/extensions/context_extension.dart';

extension DateExtension on DateTime {
String toDate() {
String toDateWithYear() {
return DateFormat("dd MMMM, yyyy").format(this);
}

String toMonthYear() {
return DateFormat("MMMM, yyyy").format(this);
}

String toDateWithoutYear(BuildContext context) {
final today = DateUtils.dateOnly(DateTime.now());
if (isAtSameMomentAs(today)) {
return context.l10n.dateFormatter_today;
}
return DateFormat("MMMM d, EEE").format(this);
}
}
18 changes: 18 additions & 0 deletions lib/data/core/extensions/date_time.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ extension DateExtention on int {
extension TimestampExtension on DateTime {
int get futureDateSelectionYear => year + 2;

bool isDateInCurrentWeek(DateTime currentDate) =>
month == currentDate.month &&
day >= currentDate.day &&
day <=
currentDate
.add(Duration(days: DateTime.daysPerWeek - currentDate.weekday))
.day;

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

Expand All @@ -26,6 +34,16 @@ extension TimestampExtension on DateTime {

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

DateTime convertToUpcomingDay() {
DateTime now = DateUtils.dateOnly(DateTime.now());
DateTime targetDate = DateUtils.dateOnly(DateTime(now.year, month, day));
if (targetDate.areSameOrUpcoming(now)) {
return targetDate;
} else {
return DateUtils.dateOnly(DateTime(now.year + 1, month, day));
}
}

bool get isWeekend =>
weekday == DateTime.sunday || weekday == DateTime.saturday;

Expand Down
6 changes: 6 additions & 0 deletions lib/data/core/mixin/input_validation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@ mixin InputValidationMixin {
email.length >= 4 &&
email.contains('@') &&
email.contains('.');

bool validPhoneNumber(String? number) {
String pattern = r'(^(?:[+0]9)?[0-9]{10}$)';
RegExp regExp = RegExp(pattern);
return number != null && regExp.hasMatch(number);
}
}
21 changes: 21 additions & 0 deletions lib/data/core/utils/date_formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,27 @@ class DateFormatter {
}
}

String showBirthdays({required DateTime dateTime, required String name}) {
final today = DateTime.now().dateOnly;
if (dateTime.dateOnly.isAtSameMomentAs(today)) {
return _localization.present_birthday_text(name);
} else {
return "${_localization.upcoming_birthday_text(name)} ${getDateRepresentation(dateTime)}🎉";
}
}

String showAnniversaries(
{required DateTime dateTime, required String name, int? number}) {
final today = DateTime.now().dateOnly;
final difference = dateTime.difference(today);
int yearDifference = (difference.inDays / 365).floor();
if (dateTime.dateOnly.isAtSameMomentAs(today)) {
return _localization.present_anniversary_text(name, yearDifference);
} else {
return "${_localization.upcoming_anniversary_text(name, yearDifference)} ${getDateRepresentation(dateTime)}🎉";
}
}

String timeAgoPresentation(DateTime date) {
Duration difference = today.difference(date);
if (difference.inDays > 365) {
Expand Down
12 changes: 8 additions & 4 deletions lib/data/di/service_locator.config.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions lib/data/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"all_tag": "All",
"ok_tag": "OK",
"profile_tag": "Profile",
"view_all_tag":"View All",


"spaces_title": "Spaces",
Expand Down Expand Up @@ -254,6 +255,52 @@
"admin_home_add_member_blood_group_hint_text": "B+",
"admin_home_add_member_address_hint_text": "552_554, Laxmi Enclave-2, Katargam, surat-395004",

"event_card_title":"Celebrations of the Week",
"birthdays_tag":"Birthdays",
"work_anniversaries_tag":"Work Anniversary",
"no_event_text":"No festivities on the calendar this week",
"upcoming_birthday_text":"{name}'s birthday is coming up on ",
"@upcoming_birthday_text":{
"placeholders":{
"name":{
"type":"String"
}
}
},
"present_birthday_text":"Today is {name}'s birthday 🥳🥳! Let's make it sparkle with cheerful wishes! ",
"@present_birthday_text":{
"placeholders":{
"name":{
"type":"String"
}
}
},

"upcoming_anniversary_text":"{name} will have successfully completed {years} years with us on ",
"@upcoming_anniversary_text":{
"placeholders":{
"name":{
"type":"String"
},
"years":{
"type":"int"
}
}
},
"present_anniversary_text":"Congratulations on {years} with us {name} 💐💐! Keep up the good work! ",
"@present_anniversary_text":{
"placeholders":{
"name":{
"type":"String"
},
"years":{
"type":"int"
}
}
},



"search_employee_tag": "Search employee",
"empty_leaves_message": "There is no any leaves, yet",

Expand Down Expand Up @@ -373,6 +420,7 @@
"fill_require_details_error": "Please fill required details!",
"invalid_date_selection_error": "Please select valid date",
"apply_leave_minimum_one_hour_error": "Please apply leave for minimum half day",
"invalid_mobile_number_error":"Please enter valid phone number",
"add_member_employee_exists_error": "Member already exists!",
"leave_already_applied_error_message": "Leave request has been already applied!",
"provide_required_information": "Please provide the required information to continue",
Expand Down
4 changes: 4 additions & 0 deletions lib/gen/assets.gen.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions lib/ui/admin/home/home_screen/admin_home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import 'package:projectunity/data/core/extensions/context_extension.dart';
import 'package:projectunity/data/core/utils/bloc_status.dart';
import 'package:projectunity/style/app_page.dart';
import 'package:projectunity/ui/admin/home/home_screen/widget/request_list.dart';
import 'package:projectunity/ui/shared/events/bloc/celebrations_bloc.dart';
import 'package:projectunity/ui/shared/events/bloc/celebrations_event.dart';
import 'package:projectunity/ui/shared/who_is_out_card/bloc/who_is_out_card_event.dart';
import '../../../../data/di/service_locator.dart';
import '../../../../data/provider/user_state.dart';
import '../../../../style/app_text_style.dart';
import '../../../shared/appbar_drawer/appbar/space_notifier_widget.dart';
import '../../../shared/appbar_drawer/drawer/bloc/app_drawer_bloc.dart';
import '../../../shared/appbar_drawer/drawer/bloc/app_drawer_event.dart';
import '../../../shared/events/celebrations_event_card.dart';
import '../../../shared/who_is_out_card/bloc/who_is_out_card_bloc.dart';
import '../../../shared/who_is_out_card/who_is_out_card.dart';
import '../../../widget/circular_progress_indicator.dart';
Expand All @@ -35,6 +38,9 @@ class AdminHomeScreenPage extends StatelessWidget {
BlocProvider(
create: (context) =>
getIt<WhoIsOutCardBloc>()..add(FetchWhoIsOutCardLeaves())),
BlocProvider(
create: (context) =>
getIt<CelebrationsBloc>()..add(FetchCelebrations())),
],
child: const AdminHomeScreen(),
);
Expand Down Expand Up @@ -77,6 +83,7 @@ class _AdminHomeScreenState extends State<AdminHomeScreen> {
body: ListView(
children: [
const WhoIsOutCard(),
const EventCard(),
const SizedBox(
height: 20,
),
Expand Down
3 changes: 1 addition & 2 deletions lib/ui/admin/home/home_screen/widget/request_list.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localization.dart';
import 'package:go_router/go_router.dart';
import 'package:projectunity/data/core/extensions/context_extension.dart';
import 'package:sticky_headers/sticky_headers.dart';
Expand Down Expand Up @@ -39,7 +38,7 @@ class LeaveRequestList extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
DateFormatter(AppLocalizations.of(context))
DateFormatter(context.l10n)
.getDateRepresentation(mapEntry.key),
style: AppTextStyle.style20.copyWith(
color: context.colorScheme.textPrimary,
Expand Down
Loading

0 comments on commit d95e014

Please sign in to comment.