Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
mahmoud-eslami committed Jun 10, 2023
2 parents ce8eb1b + dc2d840 commit 5c497da
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 95 deletions.
94 changes: 60 additions & 34 deletions lib/core/shared_widgets/global_datetime_picker.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import "package:flutter/material.dart";
import "package:flutter_bloc/flutter_bloc.dart";
import "package:flutter_datetime_picker/flutter_datetime_picker.dart";
import "package:pomodore/core/constant/constant.dart";
import "package:pomodore/core/utils/responsive/size_config.dart";
import "package:pomodore/features/configuration/presentation/blocs/settings_bloc/settings_bloc.dart";

class GlobalDateTimePicker extends StatelessWidget {
const GlobalDateTimePicker({
Expand All @@ -16,41 +18,65 @@ class GlobalDateTimePicker extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Container(
height: SizeConfig.heightMultiplier * 5,
decoration: BoxDecoration(
border: Border.all(color: Theme.of(context).colorScheme.onBackground),
borderRadius: BorderRadius.circular(AppConstant.radius),
),
child: TextButton(
onPressed: () {
DatePicker.showDateTimePicker(
context,
showTitleActions: true,
theme: DatePickerTheme(
backgroundColor: Theme.of(context).colorScheme.background,
itemStyle: Theme.of(context).textTheme.titleLarge!.copyWith(
color: Theme.of(context).colorScheme.onBackground,
),
cancelStyle: Theme.of(context).textTheme.titleLarge!.copyWith(
color: Theme.of(context).colorScheme.onBackground,
),
doneStyle: Theme.of(context).textTheme.titleLarge!.copyWith(
color: Theme.of(context).colorScheme.error,
),
return BlocBuilder<SettingsBloc, SettingsState>(
builder: (context, state) {
Locale locale = const Locale("en");
LocaleType localeType = LocaleType.en;
if (state is InitDataFetchSuccess) {
locale = state.locale;
}

if (state is ChangeLanguageSuccess) {
locale = state.locale;
}

if (locale.languageCode == "fa") {
localeType = LocaleType.fa;
} else if (locale.languageCode == "de") {
localeType = LocaleType.de;
} else {
localeType = LocaleType.en;
}

return Container(
height: SizeConfig.heightMultiplier * 5,
decoration: BoxDecoration(
border:
Border.all(color: Theme.of(context).colorScheme.onBackground),
borderRadius: BorderRadius.circular(AppConstant.radius),
),
child: TextButton(
onPressed: () {
DatePicker.showDateTimePicker(
context,
showTitleActions: true,
theme: DatePickerTheme(
backgroundColor: Theme.of(context).colorScheme.background,
itemStyle: Theme.of(context).textTheme.titleLarge!.copyWith(
color: Theme.of(context).colorScheme.onBackground,
),
cancelStyle: Theme.of(context).textTheme.titleLarge!.copyWith(
color: Theme.of(context).colorScheme.onBackground,
),
doneStyle: Theme.of(context)
.textTheme
.titleLarge!
.copyWith(color: Theme.of(context).colorScheme.error),
),
minTime: DateTime.now(),
maxTime: DateTime.now().add(const Duration(days: 1)),
onChanged: onChanged,
onConfirm: onConfirm,
currentTime: DateTime.now(),
locale: localeType,
);
},
child: Text(
buttonTitle,
),
minTime: DateTime.now(),
maxTime: DateTime.now().add(const Duration(days: 1)),
onChanged: onChanged,
onConfirm: onConfirm,
currentTime: DateTime.now(),
locale: LocaleType.en,
);
},
child: Text(
buttonTitle,
),
),
),
);
},
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ChangeLanguageBottomSheet extends StatelessWidget {

final List<LanguageEntity> flags = [
LanguageEntity("English", "en"),
LanguageEntity("Persian/Farsi", "fa"),
LanguageEntity("German", "de"),
];
return Padding(
Expand Down Expand Up @@ -74,8 +75,9 @@ class ChangeLanguageBottomSheet extends StatelessWidget {
child: InkWell(
onTap: () {
context.read<SettingsBloc>().add(
LocaleChanged(
flags[index].languageCode));
LocaleChanged(
flags[index].languageCode),
);
Navigator.pop(context);
},
child: Padding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class AddTaskView extends HookWidget {
),
20.spaceH(),
GlobalDateTimePicker(
buttonTitle: "Select Deadline DateTime",
buttonTitle: localization.selectDate,
onChanged: (time) {
context.read<TasksBloc>().add(DateAdded(time));
dateTime.value = time;
Expand All @@ -117,8 +117,10 @@ class AddTaskView extends HookWidget {
onPressed: () {
if (formKey.value.currentState!.validate()) {
if (dateTime.value == null) {
showSnackBar(context,
title: "Please select a datetime");
showSnackBar(
context,
title: localization.selectDate,
);
} else {
context.read<TasksBloc>().add(TaskAdded(TaskEntity(
id: Utils.createUniqueId(),
Expand Down
3 changes: 2 additions & 1 deletion lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@
"completedHabit": "Abgeschlossen",
"noHabitMessage": "Es gibt keine Gewohnheit!",
"updateHabit": "Gewohnheit aktualisieren",
"remainTaskTitle": "Aufgaben (#) verbleiben"
"remainTaskTitle": "Aufgaben (#) verbleiben",
"selectDate":"Auswählen des Fälligkeitsdatums"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@
"completedHabit":"Completed",
"noHabitMessage":"There is no habit!",
"updateHabit":"Update Habit",
"remainTaskTitle":"Tasks ( # )"
"remainTaskTitle":"Tasks ( # )",
"selectDate":"Select Deadline Datetime"
}
109 changes: 55 additions & 54 deletions lib/l10n/app_fa.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"homeTab": "خانه",
"tasksTab": "وظایف",
"timerTab": "تایمر",
"profileTab": "نمایه",
"profileTab": "پروفایل",
"settingTab": "تنظیمات",
"timerTitle": "تایمر",
"smile": ":)",
Expand All @@ -14,14 +14,14 @@
"vibrationTitle": "لرزش",
"appUpdatesTitle": "به روز رسانی برنامه",
"newTipTitle": "نکات جدید",
"showAdsTitle": "نمایش تبلیغات برای پشتیبانی",
"showAdsTitle": "نمایش تبلیغات",
"changeThemeTitle": "تغییر پوسته",
"changeLanguageTitle": "تغییر زبان",
"tasksTitle": "وظایف",
"emptyTaskListTitle": "امروز هیچ وظیفه ای ندارید!",
"emptyTaskListHint": "برای افزودن یک کار جدید روی نماد (+) کلیک کنید!",
"homeTitle": "پومودور",
"welcomeTitle": "صبح بخیر # 👋🏻",
"welcomeTitle": "صبح بخیر #",
"dailyTasksDoneTitle": "وای! اهداف روزانه شما تقریباً انجام شده است!",
"completedTasks": "{d} از {a} کامل شده!",
"todayTasks": "امروز وظایف (#)",
Expand All @@ -33,12 +33,12 @@
"categoryTitle": "دسته",
"submitTask": "ثبت وظیفه",
"analysisPageTitle":"تحلیل",
"todayPmodoreTitle":"امروز دوره Pomodoro :",
"todayPmodoreTitle":"امروز دوره پومودور :",
"todayFocusTitle":"امروز تمرکز :",
"fromYesterdayTitle":"x از دیروز",
"taskDetailTitle":"جزئیات وظایف امروز",
"yearAnalysisTitle":"تحلیل سالانه Pomodoro",
"dailyActivityTitle":"شمارش فعالیت روزانه Pomodoro",
"yearAnalysisTitle":"تحلیل سالانه پومودور",
"dailyActivityTitle":"شمارش فعالیت روزانه پومودور",
"successTitle":"موفقیت آمیز",
"taskDescription":"شرح",
"addCategoryTitle":"افزودن دسته بندی",
Expand All @@ -51,52 +51,53 @@
"yesTitle":"بله",
"noTitle":"خیر",
"startTimerWithoutTaskWarning":"لطفا یک وظیفه انتخاب کنید!",
"todayCompletedTask":"Today's Completed Task :",
"lessTitle":"less",
"moreTitle":"more",
"selectDailyGoalTitle":"Select daily goal :",
"saveDailyGoalButton":"Save",
"dailyGoalTitle":"Daily Goal",
"dailyGoalHint":"How many task you can do in one day :)",
"submitButton":"Submit",
"minCharValidationTitle":"Minimum size 2 character",
"taskManagementTitle":"Task management",
"editTaskTitle":"Edit Task",
"deleteTaskTitle":"Delete Task",
"completeTaskTitle":"Complete Task",
"firstStageDailyGoalTitle":"Start strong",
"secondStageDailyGoalTitle":"You can. You should do more",
"thirdStageDailyGoalTitle":"Wow! Your daily goals is almost done!",
"lastStageDailyGoalTitle":"Well done, you did it",
"changeTimerDurationTitle":"Change timer duration (min)",
"yayTitle":"بسیار عالی! 😎",
"niceJobTitle":"کارت درسته! 😎",
"completedAPomodoroBody":"یک پوموردور انجام دادید!",
"hohoTitle":"درود! 😎",
"anotherPomodoroBody":"You can do another pomodoro!",
"userTitle":"User Area",
"nameHint":"Full name",
"emailHint":"Email",
"usernameHint":"Username",
"passwordHint":"Password",
"forgetPasswordHint":"Forget password",
"signUpBtn":"Sign Up",
"signInBtn":"Sign In",
"doYouHaveAcc":"Do you have an account ?",
"registerNewAccount":"Register new account!",
"logoutButton":"Logout",
"lastSync":"Last sync at #",
"profileTitle":"Profile",
"habitTrackingTitle":"Habit Traking",
"noHabitMessage":"There is no habit!\n Please define new habit",
"addHabitTitle":"Add Habit",
"habitNameHint":"Name",
"habitDescriptionHint":"Description",
"habitIcon":"Icon",
"habitColor":"Color",
"completeHabit":"Complete",
"completedHabit":"Completed",
"noHabitMessage":"There is no habit!",
"updateHabit":"Update Habit",
"remainTaskTitle":"Tasks ( # )"
"todayCompletedTask":"وظایف کامل شده امروز :",
"lessTitle":"کمتر",
"moreTitle": "بیشتر",
"selectDailyGoalTitle": "هدف روزانه را انتخاب کنید:",
"saveDailyGoalButton": "ذخیره",
"dailyGoalTitle": "هدف روزانه",
"dailyGoalHint": "تعداد وظایفی که می‌توانید در یک روز انجام دهید :)",
"submitButton": "ثبت",
"minCharValidationTitle": "حداقل تعداد کاراکترها 2 است",
"taskManagementTitle": "مدیریت وظایف",
"editTaskTitle": "ویرایش وظیفه",
"deleteTaskTitle": "حذف وظیفه",
"completeTaskTitle": "انجام دادن وظیفه",
"firstStageDailyGoalTitle": "چند وظیفه وجود دارد، شروع قوی کنید",
"secondStageDailyGoalTitle": "می‌توانید بیشتر کار کنید، باید کار بیشتری انجام دهید",
"thirdStageDailyGoalTitle": "واو! هدف روزانه شما تقریباً به پایان رسیده است!",
"lastStageDailyGoalTitle": "عالی بود، موفق شدید",
"changeTimerDurationTitle": "تغییر مدت زمان تایمر (دقیقه)",
"yayTitle": "یاااااهووو! 😇",
"niceJobTitle": "کار خوبی انجام دادید! 😎",
"completedAPomodoroBody": "شما یک پومودورو انجام دادید!",
"hohoTitle": "هووووهووو! 🥳",
"anotherPomodoroBody": "می‌توانید پومودوروی دیگری انجام دهید!",
"userTitle": "منطقه کاربری",
"nameHint": "نام کامل",
"emailHint": "ایمیل",
"usernameHint": "نام کاربری",
"passwordHint": "رمز عبور",
"forgetPasswordHint": "فراموشی رمز عبور",
"signUpBtn": "ثبت نام",
"signInBtn": "ورود",
"doYouHaveAcc": "حساب کاربری دارید؟",
"registerNewAccount": "ثبت نام حساب کاربری جدید!",
"logoutButton": "خروج",
"lastSync": "آخرین همگام سازی در #",
"profileTitle": "پروفایل",
"habitTrackingTitle": "ردیابی عادت‌ها",
"noHabitMessage": "هیچ عادتی وجود ندارد! \n لطفاً یک عادت جدید تعریف کنید",
"addHabitTitle": "افزودن عادت",
"habitNameHint": "نام",
"habitDescriptionHint": "توضیحات",
"habitIcon": "آیکون",
"habitColor": "رنگ",
"completeHabit": "انجام دادن",
"completedHabit": "انجام شده",
"noHabitMessage": "هیچ عادتی وجود ندارد!",
"updateHabit": "به‌روزرسانی عادت",
"remainTaskTitle": "وظایف (#) باقی مانده",
"selectDate":"تاریخ و زمان را انتخاب کنید"
}
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
supportedLocales: const [
Locale("en"),
Locale("de"),
Locale("fa"),
],
locale: locale,
);
Expand Down

0 comments on commit 5c497da

Please sign in to comment.