Skip to content

Commit

Permalink
Merge pull request mchome#82 from garv-shah/master
Browse files Browse the repository at this point in the history
Fixes Material Picker: Box shadow doesn't respect theme
  • Loading branch information
mchome authored Jul 25, 2022
2 parents 41b912f + 0ebd247 commit 9b4942b
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 89 deletions.
20 changes: 10 additions & 10 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -41,6 +41,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
meta:
dependency: transitive
description:
Expand All @@ -53,20 +60,13 @@ packages:
description: flutter
source: sdk
version: "0.0.99"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
sdks:
dart: ">=2.14.0 <3.0.0"
flutter: ">=1.17.0"
flutter: ">=2.0.0"
Binary file modified example/web/icons/Icon-maskable-192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/web/icons/Icon-maskable-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
128 changes: 64 additions & 64 deletions lib/src/material_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ class _MaterialPickerState extends State<MaterialPicker> {
height: _isPortrait ? null : 60,
decoration: BoxDecoration(
color: Theme.of(context).cardColor,
boxShadow: [BoxShadow(color: Colors.grey[300]!, blurRadius: 10)],
boxShadow: [BoxShadow(color: (Theme.of(context).brightness == Brightness.light) ? (Theme.of(context).brightness == Brightness.light) ? Colors.grey[300]! : Colors.black38 : Colors.black38, blurRadius: 10)],
border: _isPortrait
? Border(right: BorderSide(color: Colors.grey[300]!, width: 1))
: Border(top: BorderSide(color: Colors.grey[300]!, width: 1)),
? Border(right: BorderSide(color: (Theme.of(context).brightness == Brightness.light) ? Colors.grey[300]! : Colors.black38, width: 1))
: Border(top: BorderSide(color: (Theme.of(context).brightness == Brightness.light) ? Colors.grey[300]! : Colors.black38, width: 1)),
),
child: ScrollConfiguration(
behavior: ScrollConfiguration.of(context).copyWith(dragDevices: PointerDeviceKind.values.toSet()),
Expand All @@ -133,7 +133,7 @@ class _MaterialPickerState extends State<MaterialPicker> {
child: Container(
color: const Color(0x00000000),
padding:
_isPortrait ? const EdgeInsets.fromLTRB(0, 7, 0, 7) : const EdgeInsets.fromLTRB(7, 0, 7, 0),
_isPortrait ? const EdgeInsets.fromLTRB(0, 7, 0, 7) : const EdgeInsets.fromLTRB(7, 0, 7, 0),
child: Align(
child: AnimatedContainer(
duration: const Duration(milliseconds: 300),
Expand All @@ -144,19 +144,19 @@ class _MaterialPickerState extends State<MaterialPicker> {
shape: BoxShape.circle,
boxShadow: _currentColorType == _colors
? [
_colorType == Theme.of(context).cardColor
? BoxShadow(
color: Colors.grey[300]!,
blurRadius: 10,
)
: BoxShadow(
color: _colorType,
blurRadius: 10,
),
]
_colorType == Theme.of(context).cardColor
? BoxShadow(
color: (Theme.of(context).brightness == Brightness.light) ? Colors.grey[300]! : Colors.black38,
blurRadius: 10,
)
: BoxShadow(
color: _colorType,
blurRadius: 10,
),
]
: null,
border: _colorType == Theme.of(context).cardColor
? Border.all(color: Colors.grey[300]!, width: 1)
? Border.all(color: (Theme.of(context).brightness == Brightness.light) ? Colors.grey[300]! : Colors.black38, width: 1)
: null,
),
),
Expand Down Expand Up @@ -199,66 +199,66 @@ class _MaterialPickerState extends State<MaterialPicker> {
curve: Curves.fastOutSlowIn,
duration: const Duration(milliseconds: 500),
width:
_isPortrait ? (_currentShading == _color ? 250 : 230) : (_currentShading == _color ? 50 : 30),
_isPortrait ? (_currentShading == _color ? 250 : 230) : (_currentShading == _color ? 50 : 30),
height: _isPortrait ? 50 : 220,
decoration: BoxDecoration(
color: _color,
boxShadow: _currentShading == _color
? [
(_color == Colors.white) || (_color == Colors.black)
? BoxShadow(
color: Colors.grey[300]!,
blurRadius: 10,
)
: BoxShadow(
color: _color,
blurRadius: 10,
),
]
(_color == Colors.white) || (_color == Colors.black)
? BoxShadow(
color: (Theme.of(context).brightness == Brightness.light) ? Colors.grey[300]! : Colors.black38,
blurRadius: 10,
)
: BoxShadow(
color: _color,
blurRadius: 10,
),
]
: null,
border: (_color == Colors.white) || (_color == Colors.black)
? Border.all(color: Colors.grey[300]!, width: 1)
? Border.all(color: (Theme.of(context).brightness == Brightness.light) ? Colors.grey[300]! : Colors.black38, width: 1)
: null,
),
child: widget.enableLabel
? _isPortrait
? Row(
children: [
Text(
' ${color.values.first}',
style: TextStyle(color: useWhiteForeground(_color) ? Colors.white : Colors.black),
),
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: Text(
'#${(_color.toString().replaceFirst('Color(0xff', '').replaceFirst(')', '')).toUpperCase()} ',
style: TextStyle(
color: useWhiteForeground(_color) ? Colors.white : Colors.black,
fontWeight: FontWeight.bold,
),
),
),
),
],
)
: AnimatedOpacity(
duration: const Duration(milliseconds: 300),
opacity: _currentShading == _color ? 1 : 0,
child: Container(
padding: const EdgeInsets.only(top: 16),
alignment: Alignment.topCenter,
child: Text(
color.values.first,
style: TextStyle(
color: useWhiteForeground(_color) ? Colors.white : Colors.black,
fontWeight: FontWeight.bold,
fontSize: 14,
),
softWrap: false,
),
),
)
? Row(
children: [
Text(
' ${color.values.first}',
style: TextStyle(color: useWhiteForeground(_color) ? Colors.white : Colors.black),
),
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: Text(
'#${(_color.toString().replaceFirst('Color(0xff', '').replaceFirst(')', '')).toUpperCase()} ',
style: TextStyle(
color: useWhiteForeground(_color) ? Colors.white : Colors.black,
fontWeight: FontWeight.bold,
),
),
),
),
],
)
: AnimatedOpacity(
duration: const Duration(milliseconds: 300),
opacity: _currentShading == _color ? 1 : 0,
child: Container(
padding: const EdgeInsets.only(top: 16),
alignment: Alignment.topCenter,
child: Text(
color.values.first,
style: TextStyle(
color: useWhiteForeground(_color) ? Colors.white : Colors.black,
fontWeight: FontWeight.bold,
fontSize: 14,
),
softWrap: false,
),
),
)
: const SizedBox(),
),
),
Expand Down
30 changes: 15 additions & 15 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -81,6 +81,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
meta:
dependency: transitive
description:
Expand All @@ -94,7 +101,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -106,7 +113,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -141,21 +148,14 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.3"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "0.4.9"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
sdks:
dart: ">=2.14.0 <3.0.0"
flutter: ">=1.17.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.0.0"

0 comments on commit 9b4942b

Please sign in to comment.