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

Unwantedly, different text color for current month #86

Closed Mercutio1243 closed 8 months ago

Mercutio1243 commented 8 months ago

First of all: This is a great package, I like it very much!

However, I am currently encountering a layout issue that I cannot get rid of: I call the showMonthPicker as follows:

    final DateTime? picked = await showMonthPicker(
      context: context,
      initialDate: currentSelection,
      headerColor: Theme.of(context).colorScheme.primaryContainer,
      headerTextColor: Theme.of(context).colorScheme.onPrimaryContainer,
      selectedMonthBackgroundColor: Theme.of(context).colorScheme.primaryContainer,
      selectedMonthTextColor: Theme.of(context).colorScheme.onPrimaryContainer,
      unselectedMonthTextColor: Colors.black,
    );

However, the current month (here: Feb 2024) unwantedly always has a different text color as show in the screenshot. Image

Am I missing something or is there an issue here?

Many thanks in advance!

Macacoazul01 commented 8 months ago

Can you send a full working main.dart that shows this error?

Macacoazul01 commented 8 months ago

I can add an option to make the current month color equal to the other ones.

Tks for the idea.

Gonna try to land this later tonight

Mercutio1243 commented 8 months ago

Here you go. My issue is the text color of the current month (here Feb). It should either be in the same color as other selectable months, or it should be specifiable. Currently, it is simply some seemingly random (and in the used theme ugly) color that I cannot change as it seems.

import 'package:flutter/material.dart';
import 'package:month_picker_dialog/month_picker_dialog.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Month Year Picker Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.brown),
        useMaterial3: true,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Month Year Picker Demo'),
      ),
      body: Center(
        child: MonthYear(),
      ),
    );
  }
}

class MonthYear extends StatefulWidget {
  const MonthYear({
    Key? key,
  }) : super(key: key);

  @override
  _MonthYearState createState() => _MonthYearState();
}

class _MonthYearState extends State<MonthYear> {
  @override
  Widget build(BuildContext context) {
        return GestureDetector(
            onTap: () => _selectMonthYear(context),
            child: Container(
              padding: const EdgeInsets.fromLTRB(16,20,16,20),
              decoration: BoxDecoration(
                border: Border.all(color: Theme.of(context).colorScheme.outline),
                borderRadius: BorderRadius.circular(12),
              ),
              child: const Column(
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: [
                  Row(
                    children: <Widget>[
                      Text("Test", style: TextStyle(fontSize: 14.0)),
                      Expanded(child: SizedBox(width: 12)),
                      Icon(Icons.calendar_today, size: 20.0, color: Colors.grey),
                    ],
                  ),
                ],
              ),
            ));
  }

  Future<void> _selectMonthYear(BuildContext context) async {
    final DateTime? picked = await showMonthPicker(
      context: context,
      lastDate: DateTime.now(),
      headerColor: Theme.of(context).colorScheme.primaryContainer,
      headerTextColor: Theme.of(context).colorScheme.onPrimaryContainer,
      selectedMonthBackgroundColor: Theme.of(context).colorScheme.primaryContainer,
      selectedMonthTextColor: Theme.of(context).colorScheme.onPrimaryContainer,
      unselectedMonthTextColor: Colors.black,
    );
  }
}

Issue: Issue

Macacoazul01 commented 8 months ago

@Mercutio1243 fixed on 2.8.0

Mercutio1243 commented 8 months ago

Superb :) Can confirm that issue is solved! Many thanks!