Macacoazul01 / month_picker_dialog

Internationalized dialog for picking a single month from an infinite list of years.
https://pub.dev/packages/month_picker_dialog
MIT License
70 stars 97 forks source link

How can we select only year? #102

Closed MohsinIkram-Auxilium closed 2 months ago

MohsinIkram-Auxilium commented 2 months ago

Your package is great. But is there any way to select only Year from this calendar? Like there is a some requirement to choose the only year. So I'm curious if there a way to select only Year? Please guide. Thanks

Macacoazul01 commented 2 months ago

Today it isnt, but i can update the package to do so

Macacoazul01 commented 2 months ago

Technically you can select the year + month and use just the year part, but this isn't efficient when looking at the user's perspective

MohsinIkram-Auxilium commented 2 months ago

@Macacoazul01 Yes but there are some requirements in daily life to pick only month and only year. So this package is great. Because it is included showMonthPicker & showMonthRangePicker. It would be great if there is an option to select only year. So people can user your package for the both Month and Year cases. Instead of added two different packages for Month and Year. Looking for your great support.

Macacoazul01 commented 2 months ago

Avaliable in 5.0.0-dev.3 with the new showYearPicker function

MohsinIkram-Auxilium commented 2 months ago

Thanks for the quick response. I have upgraded your package and set up all the things (except localisation). Because I'm using the Getx package for all the things including the localisation. So I have not added the separate package for the localisation. But I'm facing this error. Before the new version it was working fine. Please let me know how I can solve this with Getx. Looking forward to your kind response. Thanks

On Sat, 3 Aug 2024 at 03:34, Gianluca Bettega @.***> wrote:

Avaliable in 5.0.0-dev.3 with the new showYearPicker function

— Reply to this email directly, view it on GitHub https://github.com/Macacoazul01/month_picker_dialog/issues/102#issuecomment-2266219806, or unsubscribe https://github.com/notifications/unsubscribe-auth/A67NSLRMNZT6WPKIK6RC32DZPQCQBAVCNFSM6AAAAABL4RJ4X2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRWGIYTSOBQGY . You are receiving this because you authored the thread.Message ID: @.***>

Macacoazul01 commented 2 months ago

Can you send a full sample code?

MohsinIkram-Auxilium commented 2 months ago

@Gianluca Bettega Sorry. It is our company project. Let me share the basic things

Here is the method I'm using to show the Month Picker

showMonthPickerDialog(BuildContext context, DateTime selectedDate, Function(DateTime)? onMonthSelected) { showMonthPicker( context: context, firstDate: DateTime.parse(UserPreferences.getJoiningDate()), lastDate: DateTime.now(), initialDate: selectedDate, monthPickerDialogSettings: MonthPickerDialogSettings( headerSettings: const PickerHeaderSettings( headerBackgroundColor: AppColors.themeColor, headerCurrentPageTextStyle: TextStyle(fontSize: 14, color: Colors.white), headerSelectedIntervalTextStyle: TextStyle(fontSize: 16, color: Colors.white), ), dialogSettings: PickerDialogSettings( locale: const Locale('en'), dialogRoundedCornersRadius: 14, dialogBackgroundColor: Colors.blueGrey[50], yearFirst: false, dismissible: true

    ),
    buttonsSettings: PickerButtonsSettings(
      // buttonBorder: const CircleBorder(),
      buttonBorder: const RoundedRectangleBorder(),
      selectedMonthBackgroundColor: Colors.amber[900],
      selectedMonthTextColor: Colors.white,
      unselectedMonthsTextColor: Colors.black,
      currentMonthTextColor: AppColors.themeColor,
      yearTextStyle: const TextStyle(
        fontSize: 10,
      ),
      monthTextStyle: const TextStyle(
        fontWeight: FontWeight.bold,
        fontSize: 18,
      ),

    )),
confirmWidget: const Text(
  'Ok',
  style: TextStyle(
    color: AppColors.themeColor,
    // fontFamily: 'Manrope',
    // fontWeight: FontWeight.w700,
  ),
),
cancelWidget: const Text(
  'Cancel',
  style: TextStyle(
    // color: Colors.red[900],
    // fontFamily: 'Manrope',
    // fontWeight: FontWeight.w700,
  ),
),
// headerTitle: const Text(
//   'Month Picker Dialog',
//   style: TextStyle(color: Colors.white),
// ),

) .then((DateTime? date) { if (date != null) { if (onMonthSelected != null) { onMonthSelected(date); } } }); }

Here is the Code in the Main class

class MyApp extends StatelessWidget { const MyApp({super.key});

// This widget is the root of your application. @override Widget build(BuildContext context) { return GetMaterialApp( translations: Languages(), fallbackLocale: const Locale('en', 'US'), debugShowCheckedModeBanner: false, initialRoute: "/splash", initialBinding: HomeBinding(), routes: { "/splash": (context) => const SplashScreen(), }, ); } }

On Mon, 5 Aug 2024 at 19:50, Gianluca Bettega @.***> wrote:

Can you send a full sample code?

— Reply to this email directly, view it on GitHub https://github.com/Macacoazul01/month_picker_dialog/issues/102#issuecomment-2269264124, or unsubscribe https://github.com/notifications/unsubscribe-auth/A67NSLXJGS7ANEZ7BV4SXGLZP6GKTAVCNFSM6AAAAABL4RJ4X2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRZGI3DIMJSGQ . You are receiving this because you authored the thread.Message ID: @.***>

Macacoazul01 commented 2 months ago

Can you run a flutter create and generate a project with this error?

MohsinIkram-Auxilium commented 2 months ago

Sorry @Gianluca, I'm stuck in the ongoing things and have not much time. I will make the thing and share it with you in future. But for now I have fixed the issue. I just commented the line from this function and now it's working fine. The line I commented -> "locale: const Locale('en')"

Thanks for your great support.

dialogSettings: PickerDialogSettings( // locale: const Locale('en'), dialogRoundedCornersRadius: 14, dialogBackgroundColor: Colors.blueGrey[50], yearFirst: false, dismissible: true),

On Mon, 5 Aug 2024 at 20:07, Gianluca Bettega @.***> wrote:

Can you run a flutter create and generate a project with this error?

— Reply to this email directly, view it on GitHub https://github.com/Macacoazul01/month_picker_dialog/issues/102#issuecomment-2269302516, or unsubscribe https://github.com/notifications/unsubscribe-auth/A67NSLQTJU5JFMIKNSRCKELZP6IK5AVCNFSM6AAAAABL4RJ4X2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRZGMYDENJRGY . You are receiving this because you authored the thread.Message ID: @.***>

Macacoazul01 commented 2 months ago

So there isn't an issue with the package.

You were setting the locale to english on the settings and that's why it wasn't respecting the one from the material app.

MohsinIkram-Auxilium commented 2 months ago

Yes. Thanks for the great package.

On Mon, 5 Aug 2024 at 20:47, Gianluca Bettega @.***> wrote:

So there isn't an issue with the package.

You were setting the locale to english on the settings and that's why it wasn't respecting the one from the material app.

— Reply to this email directly, view it on GitHub https://github.com/Macacoazul01/month_picker_dialog/issues/102#issuecomment-2269386696, or unsubscribe https://github.com/notifications/unsubscribe-auth/A67NSLULBZ7KW2LPSBECUDLZP6NCFAVCNFSM6AAAAABL4RJ4X2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRZGM4DMNRZGY . You are receiving this because you authored the thread.Message ID: @.***>