From b77e4e9095ca506e6e351d0def57377b9e8bd9c9 Mon Sep 17 00:00:00 2001 From: "mr.mojtaba" Date: Sun, 27 Apr 2025 09:39:58 +0330 Subject: [PATCH] feat : persian calendar and date picker --- .../presentation/location_details/view.dart | 17 +++++++++++++++-- lib/main.dart | 9 ++++++++- .../auth/auth_with_use_and_pass/view.dart | 18 ++++++++++++------ packages/core/lib/core.dart | 1 + packages/core/pubspec.lock | 13 +++++++++++++ packages/core/pubspec.yaml | 6 +++++- pubspec.lock | 9 +++++++-- copyAssets.sh => tools/copyAssets.sh | 0 runner.sh => tools/runner.sh | 0 vecGeneratoe.sh => tools/vecGeneratoe.sh | 0 10 files changed, 61 insertions(+), 12 deletions(-) rename copyAssets.sh => tools/copyAssets.sh (100%) rename runner.sh => tools/runner.sh (100%) rename vecGeneratoe.sh => tools/vecGeneratoe.sh (100%) diff --git a/features/inspection/lib/presentation/location_details/view.dart b/features/inspection/lib/presentation/location_details/view.dart index 0a6c17a..559508c 100644 --- a/features/inspection/lib/presentation/location_details/view.dart +++ b/features/inspection/lib/presentation/location_details/view.dart @@ -70,7 +70,19 @@ class LocationDetailsPage extends GetView { Expanded( child: ROutlinedElevatedIcon( icon: FaIcon(FontAwesomeIcons.calendar), - onPressed: () {}, + onPressed:() async { + + Jalali? picked = await showPersianDatePicker( + context: context, + initialDate: Jalali.now(), + firstDate: Jalali(1385, 8), + lastDate: Jalali(1450, 9), + + initialEntryMode: + PersianDatePickerEntryMode.calendarOnly, + initialDatePickerMode: PersianDatePickerMode.day, + ); + }, text: 'از تاریخ', textStyle: AppFonts.yekan16.copyWith( color: AppColor.blueNormal, @@ -81,16 +93,17 @@ class LocationDetailsPage extends GetView { child: ROutlinedElevatedIcon( icon: FaIcon(FontAwesomeIcons.calendar), onPressed: () async { + Jalali? picked = await showPersianDatePicker( context: context, initialDate: Jalali.now(), firstDate: Jalali(1385, 8), lastDate: Jalali(1450, 9), + initialEntryMode: PersianDatePickerEntryMode.calendarOnly, initialDatePickerMode: PersianDatePickerMode.day, ); - var label = picked?.formatFullDate(); }, text: 'تا تاریخ', textStyle: AppFonts.yekan16.copyWith( diff --git a/lib/main.dart b/lib/main.dart index cb30700..4eeebaa 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -42,15 +42,22 @@ class MyApp extends StatelessWidget { return GetMaterialApp( title: 'رصدیار', theme: ThemeData( + fontFamily: 'yekan', colorScheme: ColorScheme.fromSeed(seedColor: AppColor.blueNormal), ), initialRoute: AppPages.initRoutes, initialBinding: BindingsBuilder.put(() => UserService()), getPages: AppPages.pages, - locale: Locale('fa'), + locale: const Locale("fa", "IR"), + supportedLocales: const [ + Locale("fa", "IR"), + ], localizationsDelegates: [ PersianMaterialLocalizations.delegate, PersianCupertinoLocalizations.delegate, + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, ], ); } diff --git a/lib/presentation/pages/auth/auth_with_use_and_pass/view.dart b/lib/presentation/pages/auth/auth_with_use_and_pass/view.dart index dd0b469..f6cd2d7 100644 --- a/lib/presentation/pages/auth/auth_with_use_and_pass/view.dart +++ b/lib/presentation/pages/auth/auth_with_use_and_pass/view.dart @@ -1,9 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; -import 'package:inspection/inspection.dart'; import 'package:rasadyar_core/core.dart'; -import 'package:rasadyar_core/presentation/widget/captcha/captcha_widget.dart'; import 'logic.dart'; @@ -227,11 +225,19 @@ class AuthWithUseAndPassPage extends GetView { SizedBox(height: 23), RElevated( text: 'ورود', - onPressed: () { + onPressed: () async { + Jalali? picked = await showPersianDatePicker( + context: Get.context!, + + initialDate: Jalali.now(), + firstDate: Jalali(1385, 8), + lastDate: Jalali(1450, 9), + initialEntryMode: PersianDatePickerEntryMode.calendarOnly, + initialDatePickerMode: PersianDatePickerMode.year, + ); + if (data.value.currentState?.validate() == true && - controller.captchaController.validate()) { - Get.toNamed(InspectionRoutes.inspection); - } + controller.captchaController.validate()) {} }, width: Get.width, height: 48, diff --git a/packages/core/lib/core.dart b/packages/core/lib/core.dart index 67a5d70..409edfe 100644 --- a/packages/core/lib/core.dart +++ b/packages/core/lib/core.dart @@ -6,6 +6,7 @@ export 'package:rasadyar_core/presentation/utils/utils.dart'; export 'package:rasadyar_core/presentation/widget/widget.dart'; //other packages +export 'package:flutter_localizations/flutter_localizations.dart'; export 'package:flutter_slidable/flutter_slidable.dart'; export 'package:font_awesome_flutter/font_awesome_flutter.dart'; export 'package:flutter_rating_bar/flutter_rating_bar.dart'; diff --git a/packages/core/pubspec.lock b/packages/core/pubspec.lock index deedfa1..f5a3aee 100644 --- a/packages/core/pubspec.lock +++ b/packages/core/pubspec.lock @@ -230,6 +230,11 @@ packages: url: "https://pub.dev" source: hosted version: "5.0.0" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" flutter_rating_bar: dependency: "direct main" description: @@ -384,6 +389,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.2" + intl: + dependency: "direct main" + description: + name: intl + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + url: "https://pub.dev" + source: hosted + version: "0.19.0" io: dependency: transitive description: diff --git a/packages/core/pubspec.yaml b/packages/core/pubspec.yaml index 88133be..4df8b74 100644 --- a/packages/core/pubspec.yaml +++ b/packages/core/pubspec.yaml @@ -9,6 +9,9 @@ environment: dependencies: flutter: sdk: flutter + flutter_localizations: + sdk: flutter + #UI cupertino_icons: ^1.0.8 @@ -41,9 +44,10 @@ dependencies: ##Di get_it: ^8.0.3 + #other permission_handler: ^12.0.0+1 persian_datetime_picker: ^3.1.0 - + intl: ^0.19.0 diff --git a/pubspec.lock b/pubspec.lock index c5248f3..8f91457 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -118,6 +118,11 @@ packages: url: "https://pub.dev" source: hosted version: "5.0.0" + flutter_localizations: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" flutter_map: dependency: transitive description: @@ -291,10 +296,10 @@ packages: dependency: transitive description: name: intl - sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5" + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf url: "https://pub.dev" source: hosted - version: "0.20.2" + version: "0.19.0" json_annotation: dependency: transitive description: diff --git a/copyAssets.sh b/tools/copyAssets.sh similarity index 100% rename from copyAssets.sh rename to tools/copyAssets.sh diff --git a/runner.sh b/tools/runner.sh similarity index 100% rename from runner.sh rename to tools/runner.sh diff --git a/vecGeneratoe.sh b/tools/vecGeneratoe.sh similarity index 100% rename from vecGeneratoe.sh rename to tools/vecGeneratoe.sh