feat : persian calendar and date picker

This commit is contained in:
2025-04-27 09:39:58 +03:30
parent c10ddaf0d5
commit b77e4e9095
10 changed files with 61 additions and 12 deletions

View File

@@ -70,7 +70,19 @@ class LocationDetailsPage extends GetView<LocationDetailsLogic> {
Expanded( Expanded(
child: ROutlinedElevatedIcon( child: ROutlinedElevatedIcon(
icon: FaIcon(FontAwesomeIcons.calendar), 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: 'از تاریخ', text: 'از تاریخ',
textStyle: AppFonts.yekan16.copyWith( textStyle: AppFonts.yekan16.copyWith(
color: AppColor.blueNormal, color: AppColor.blueNormal,
@@ -81,16 +93,17 @@ class LocationDetailsPage extends GetView<LocationDetailsLogic> {
child: ROutlinedElevatedIcon( child: ROutlinedElevatedIcon(
icon: FaIcon(FontAwesomeIcons.calendar), icon: FaIcon(FontAwesomeIcons.calendar),
onPressed: () async { onPressed: () async {
Jalali? picked = await showPersianDatePicker( Jalali? picked = await showPersianDatePicker(
context: context, context: context,
initialDate: Jalali.now(), initialDate: Jalali.now(),
firstDate: Jalali(1385, 8), firstDate: Jalali(1385, 8),
lastDate: Jalali(1450, 9), lastDate: Jalali(1450, 9),
initialEntryMode: initialEntryMode:
PersianDatePickerEntryMode.calendarOnly, PersianDatePickerEntryMode.calendarOnly,
initialDatePickerMode: PersianDatePickerMode.day, initialDatePickerMode: PersianDatePickerMode.day,
); );
var label = picked?.formatFullDate();
}, },
text: 'تا تاریخ', text: 'تا تاریخ',
textStyle: AppFonts.yekan16.copyWith( textStyle: AppFonts.yekan16.copyWith(

View File

@@ -42,15 +42,22 @@ class MyApp extends StatelessWidget {
return GetMaterialApp( return GetMaterialApp(
title: 'رصدیار', title: 'رصدیار',
theme: ThemeData( theme: ThemeData(
fontFamily: 'yekan',
colorScheme: ColorScheme.fromSeed(seedColor: AppColor.blueNormal), colorScheme: ColorScheme.fromSeed(seedColor: AppColor.blueNormal),
), ),
initialRoute: AppPages.initRoutes, initialRoute: AppPages.initRoutes,
initialBinding: BindingsBuilder.put(() => UserService()), initialBinding: BindingsBuilder.put(() => UserService()),
getPages: AppPages.pages, getPages: AppPages.pages,
locale: Locale('fa'), locale: const Locale("fa", "IR"),
supportedLocales: const [
Locale("fa", "IR"),
],
localizationsDelegates: [ localizationsDelegates: [
PersianMaterialLocalizations.delegate, PersianMaterialLocalizations.delegate,
PersianCupertinoLocalizations.delegate, PersianCupertinoLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
], ],
); );
} }

View File

@@ -1,9 +1,7 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:inspection/inspection.dart';
import 'package:rasadyar_core/core.dart'; import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/presentation/widget/captcha/captcha_widget.dart';
import 'logic.dart'; import 'logic.dart';
@@ -227,11 +225,19 @@ class AuthWithUseAndPassPage extends GetView<AuthWithUseAndPassLogic> {
SizedBox(height: 23), SizedBox(height: 23),
RElevated( RElevated(
text: 'ورود', 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 && if (data.value.currentState?.validate() == true &&
controller.captchaController.validate()) { controller.captchaController.validate()) {}
Get.toNamed(InspectionRoutes.inspection);
}
}, },
width: Get.width, width: Get.width,
height: 48, height: 48,

View File

@@ -6,6 +6,7 @@ export 'package:rasadyar_core/presentation/utils/utils.dart';
export 'package:rasadyar_core/presentation/widget/widget.dart'; export 'package:rasadyar_core/presentation/widget/widget.dart';
//other packages //other packages
export 'package:flutter_localizations/flutter_localizations.dart';
export 'package:flutter_slidable/flutter_slidable.dart'; export 'package:flutter_slidable/flutter_slidable.dart';
export 'package:font_awesome_flutter/font_awesome_flutter.dart'; export 'package:font_awesome_flutter/font_awesome_flutter.dart';
export 'package:flutter_rating_bar/flutter_rating_bar.dart'; export 'package:flutter_rating_bar/flutter_rating_bar.dart';

View File

@@ -230,6 +230,11 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "5.0.0" version: "5.0.0"
flutter_localizations:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_rating_bar: flutter_rating_bar:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -384,6 +389,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.1.2" version: "4.1.2"
intl:
dependency: "direct main"
description:
name: intl
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
url: "https://pub.dev"
source: hosted
version: "0.19.0"
io: io:
dependency: transitive dependency: transitive
description: description:

View File

@@ -9,6 +9,9 @@ environment:
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
flutter_localizations:
sdk: flutter
#UI #UI
cupertino_icons: ^1.0.8 cupertino_icons: ^1.0.8
@@ -41,9 +44,10 @@ dependencies:
##Di ##Di
get_it: ^8.0.3 get_it: ^8.0.3
#other
permission_handler: ^12.0.0+1 permission_handler: ^12.0.0+1
persian_datetime_picker: ^3.1.0 persian_datetime_picker: ^3.1.0
intl: ^0.19.0

View File

@@ -118,6 +118,11 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "5.0.0" version: "5.0.0"
flutter_localizations:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
flutter_map: flutter_map:
dependency: transitive dependency: transitive
description: description:
@@ -291,10 +296,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: intl name: intl
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5" sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.20.2" version: "0.19.0"
json_annotation: json_annotation:
dependency: transitive dependency: transitive
description: description: