Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Landscape version? #2

Closed
codegrue opened this issue Aug 20, 2018 · 9 comments
Closed

Landscape version? #2

codegrue opened this issue Aug 20, 2018 · 9 comments

Comments

@codegrue
Copy link

Would love an alternate layout that works in landscape format. Perhaps with the color square in the left and the sliders on the right. For reference see the date_picker.dart showDatePicker() dialog that displays differently depending on orientation.

@mchome
Copy link
Owner

mchome commented Aug 20, 2018

flutter_01
Like this?

@codegrue
Copy link
Author

Perfect. Thanks!

Only other enhancement I would love is to be able to inject style into the title for both orientations. Trying to make it consistent with the built in material pickers and they have a background on the title.

@mchome
Copy link
Owner

mchome commented Aug 20, 2018

image
Something like this?

showDialog(
  context: context,
  builder: (BuildContext context) {
    return AlertDialog(
      titlePadding: EdgeInsets.all(0.0),
      contentPadding: EdgeInsets.all(0.0),
      title: Container(
        color: Theme.of(context).primaryColor,
        child: Center(
          child: const Text(
            'Pick a color!',
            style: TextStyle(
              fontSize: 20.0,
              color: const Color(0xffffffff),
            ),
          ),
        ),
        padding: EdgeInsets.all(20.0),
      ),
      content: SingleChildScrollView(
        child: ColorPicker(
          pickerColor: pickerColor,
          onColorChanged: changeColor,
          colorPickerWidth: 1000.0,
          pickerAreaHeightPercent: 0.7,
        ),
      ),
      actions: <Widget>[
        FlatButton(
          child: Text('Got it'),
          onPressed: () {
            setState(() => currentColor = pickerColor);
            Navigator.of(context).pop();
          },
        ),
      ],
    );
  },
)

mchome pushed a commit that referenced this issue Aug 20, 2018
@codegrue
Copy link
Author

That is very nice! Only additional tweak for consistency with stock pickers would be the buttons should be "CANCEL" and "OK".

@mchome
Copy link
Owner

mchome commented Aug 20, 2018

You can do this by editing the AlertDialog's actions look like this.

actions: <Widget>[
  FlatButton(
    child: Text('OK'),
    onPressed: () {
      setState(() => currentColor = pickerColor);
      Navigator.of(context).pop();
    },
  ),
  FlatButton(
    child: Text('CANCEL'),
    onPressed: () => Navigator.of(context).pop(),
  ),
],

@codegrue
Copy link
Author

Suggestion to update your project example to show usage of landscape orientation (and switching).

@codegrue
Copy link
Author

codegrue commented Aug 20, 2018

This is what I get trying to package it into landscape:

image

Actual usage code for reference is here:

https://github.com/codegrue/card_settings/blob/master/lib/widgets/picker_fields/card_settings_color_picker.dart

* Note: portrait works as expected.

@mchome
Copy link
Owner

mchome commented Aug 21, 2018

What's your example result? Looks like you need to fill the colorPickerWidth and disable enableLabel.

@codegrue
Copy link
Author

colorPickerWidth: 1000.0 fixed it. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants