Skip to content

Commit

Permalink
feat: apply default configuration to widget slides
Browse files Browse the repository at this point in the history
  • Loading branch information
mkobuolys committed Oct 31, 2024
1 parent 77e8819 commit 1e9e890
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/flutter_deck/lib/src/flutter_deck_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,25 @@ class _FlutterDeckAppState extends State<FlutterDeckApp> {

FlutterDeckRouterSlide? _buildRouterSlide((int, Widget) indexedSlide) {
final (index, slide) = indexedSlide;
final slideConfiguration =
slide is FlutterDeckSlideWidget ? slide.configuration : null;

if (slideConfiguration?.hidden ?? false) return null;
var slideWidget = slide;

final configuration = slideConfiguration ??
FlutterDeckSlideConfiguration(route: '/slide-${index + 1}');
if (slideWidget is! FlutterDeckSlideWidget) {
final defaultConfiguration = FlutterDeckSlideConfiguration(
route: '/slide-${index + 1}',
);

slideWidget = slide.withSlideConfiguration(defaultConfiguration);
}

final configuration = slideWidget.configuration!;

if (configuration.hidden) return null;

return FlutterDeckRouterSlide(
configuration: configuration.mergeWithGlobal(widget.configuration),
route: configuration.route,
widget: slide,
widget: slideWidget,
);
}

Expand Down
13 changes: 13 additions & 0 deletions packages/flutter_deck/lib/src/flutter_deck_slide.dart
Original file line number Diff line number Diff line change
Expand Up @@ -391,3 +391,16 @@ class _SlideBody extends StatelessWidget {
);
}
}

///
extension FlutterDeckSlideWidgetX on Widget {
///
FlutterDeckSlideWidget withSlideConfiguration(
FlutterDeckSlideConfiguration configuration,
) {
return FlutterDeckSlide.custom(
configuration: configuration,
builder: (context) => this,
);
}
}

0 comments on commit 1e9e890

Please sign in to comment.