Skip to content

Commit 916b8a5

Browse files
committed
feat: GridStyle is now an abstract class with subclasses that provide lines, hierarchical, dots, cross and none styles!
1 parent 34867ab commit 916b8a5

File tree

14 files changed

+533
-496
lines changed

14 files changed

+533
-496
lines changed

packages/demo/lib/examples/advanced/theming.dart

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -546,17 +546,25 @@ class _ThemingExampleState extends State<ThemingExample> {
546546
Wrap(
547547
spacing: 8,
548548
runSpacing: 8,
549-
children: GridStyle.values.map((style) {
550-
return ChoiceChip(
551-
label: Text(style.name, style: const TextStyle(fontSize: 11)),
552-
selected: _theme.gridStyle == style,
553-
onSelected: (selected) {
554-
if (selected) {
555-
_updateTheme(_theme.copyWith(gridStyle: style));
556-
}
557-
},
558-
);
559-
}).toList(),
549+
children:
550+
[
551+
('lines', GridStyles.lines),
552+
('dots', GridStyles.dots),
553+
('hierarchical', GridStyles.hierarchical),
554+
('cross', GridStyles.cross),
555+
('none', GridStyles.none),
556+
].map((entry) {
557+
final (name, style) = entry;
558+
return ChoiceChip(
559+
label: Text(name, style: const TextStyle(fontSize: 11)),
560+
selected: _theme.gridStyle == style,
561+
onSelected: (selected) {
562+
if (selected) {
563+
_updateTheme(_theme.copyWith(gridStyle: style));
564+
}
565+
},
566+
);
567+
}).toList(),
560568
),
561569
],
562570
);

packages/demo/lib/examples/basics/ports.dart

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -622,24 +622,36 @@ class _PortCombinationsDemoState extends State<PortCombinationsDemo> {
622622
const SectionTitle('Grid Settings'),
623623
const SizedBox(height: 8),
624624
Observer(
625-
builder: (context) => DropdownButtonFormField<GridStyle>(
625+
builder: (context) => InputDecorator(
626626
decoration: const InputDecoration(
627627
labelText: 'Grid Style',
628628
border: OutlineInputBorder(),
629629
isDense: true,
630+
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
631+
),
632+
child: DropdownButtonHideUnderline(
633+
child: DropdownButton<GridStyle>(
634+
value: _themeControl._gridStyle.value,
635+
isDense: true,
636+
items:
637+
[
638+
('Lines', GridStyles.lines),
639+
('Dots', GridStyles.dots),
640+
('Hierarchical', GridStyles.hierarchical),
641+
('Cross', GridStyles.cross),
642+
('None', GridStyles.none),
643+
].map((entry) {
644+
final (name, style) = entry;
645+
return DropdownMenuItem(
646+
value: style,
647+
child: Text(name, style: const TextStyle(fontSize: 13)),
648+
);
649+
}).toList(),
650+
onChanged: (value) {
651+
_themeControl.gridStyle = value!;
652+
},
653+
),
630654
),
631-
initialValue: _themeControl._gridStyle.value,
632-
items: GridStyle.values.map((style) {
633-
return DropdownMenuItem(
634-
value: style,
635-
child: Text(style.name, style: const TextStyle(fontSize: 13)),
636-
);
637-
}).toList(),
638-
onChanged: (value) {
639-
if (value != null) {
640-
_themeControl.gridStyle = value;
641-
}
642-
},
643655
),
644656
),
645657

@@ -818,7 +830,7 @@ class ThemeControlStore {
818830
set rotationSpeed(double value) =>
819831
runInAction(() => _rotationSpeed.value = value);
820832

821-
final Observable<GridStyle> _gridStyle = Observable(GridStyle.dots);
833+
final Observable<GridStyle> _gridStyle = Observable(GridStyles.dots);
822834

823835
GridStyle get gridStyle => _gridStyle.value;
824836

packages/demo/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414
sdk: flutter
1515
flutter_mobx: ^2.3.0
1616
font_awesome_flutter: ^10.7.0
17-
go_router: ^16.3.0
17+
go_router: ^17.0.0
1818
http: ^1.2.0
1919
mobx: ^2.5.0
2020
url_launcher: ^6.3.1

0 commit comments

Comments
 (0)