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

feat: Add a builder for speakerInfo #68

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/src/flutter_deck.dart
Expand Up @@ -63,6 +63,7 @@ class FlutterDeck extends InheritedWidget {
required FlutterDeckConfiguration configuration,
required FlutterDeckRouter router,
required FlutterDeckSpeakerInfo? speakerInfo,
required FlutterDeckSpeakerInfoBuilder? speakerInfoBuilder,
required FlutterDeckAutoplayNotifier autoplayNotifier,
required FlutterDeckControlsNotifier controlsNotifier,
required FlutterDeckDrawerNotifier drawerNotifier,
Expand All @@ -74,6 +75,7 @@ class FlutterDeck extends InheritedWidget {
}) : _configuration = configuration,
_router = router,
_speakerInfo = speakerInfo,
_speakerInfoBuilder = speakerInfoBuilder,
_autoplayNotifier = autoplayNotifier,
_controlsNotifier = controlsNotifier,
_drawerNotifier = drawerNotifier,
Expand All @@ -84,6 +86,7 @@ class FlutterDeck extends InheritedWidget {
final FlutterDeckConfiguration _configuration;
final FlutterDeckRouter _router;
final FlutterDeckSpeakerInfo? _speakerInfo;
final FlutterDeckSpeakerInfoBuilder? _speakerInfoBuilder;
final FlutterDeckAutoplayNotifier _autoplayNotifier;
final FlutterDeckControlsNotifier _controlsNotifier;
final FlutterDeckDrawerNotifier _drawerNotifier;
Expand Down Expand Up @@ -125,6 +128,9 @@ class FlutterDeck extends InheritedWidget {
/// Returns the speaker info.
FlutterDeckSpeakerInfo? get speakerInfo => _speakerInfo;

/// Returns the builder to build [FlutterDeckSpeakerInfo].
FlutterDeckSpeakerInfoBuilder? get speakerInfoBuilder => _speakerInfoBuilder;

/// Returns the configuration for the current slide.
FlutterDeckSlideConfiguration get configuration =>
_router.getCurrentSlideConfiguration();
Expand Down
5 changes: 5 additions & 0 deletions lib/src/flutter_deck_app.dart
Expand Up @@ -58,6 +58,7 @@ class FlutterDeckApp extends StatefulWidget {
required this.slides,
this.configuration = const FlutterDeckConfiguration(),
this.speakerInfo,
this.speakerInfoBuilder,
this.lightTheme,
this.darkTheme,
this.themeMode = ThemeMode.system,
Expand Down Expand Up @@ -89,6 +90,9 @@ class FlutterDeckApp extends StatefulWidget {
/// Information about the speaker.
final FlutterDeckSpeakerInfo? speakerInfo;

/// Builder function to create [FlutterDeckSpeakerInfo] using [BuildContext].
final FlutterDeckSpeakerInfoBuilder? speakerInfoBuilder;

/// The theme to use when the app is in light mode.
///
/// If not provided, the default [FlutterDeckThemeData.light] is used.
Expand Down Expand Up @@ -194,6 +198,7 @@ class _FlutterDeckAppState extends State<FlutterDeckApp> {
configuration: widget.configuration,
router: _flutterDeckRouter,
speakerInfo: widget.speakerInfo,
speakerInfoBuilder: widget.speakerInfoBuilder,
autoplayNotifier: _autoplayNotifier,
controlsNotifier: _controlsNotifier,
drawerNotifier: _drawerNotifier,
Expand Down
7 changes: 7 additions & 0 deletions lib/src/flutter_deck_speaker_info.dart
@@ -1,3 +1,5 @@
import 'package:flutter/widgets.dart';

/// Stores information about the speaker.
class FlutterDeckSpeakerInfo {
/// Creates a new [FlutterDeckSpeakerInfo] instance.
Expand All @@ -24,3 +26,8 @@ class FlutterDeckSpeakerInfo {
/// This should be a path to an image asset in the app's assets directory.
final String imagePath;
}

/// A function to build [FlutterDeckSpeakerInfo] instance using [BuildContext].
typedef FlutterDeckSpeakerInfoBuilder = FlutterDeckSpeakerInfo Function(
BuildContext context,
);
3 changes: 2 additions & 1 deletion lib/src/templates/title_slide.dart
Expand Up @@ -47,7 +47,8 @@ class FlutterDeckTitleSlide extends StatelessWidget {
final configuration = context.flutterDeck.configuration;
final footerConfiguration = configuration.footer;
final headerConfiguration = configuration.header;
final speakerInfo = context.flutterDeck.speakerInfo;
final speakerInfo = context.flutterDeck.speakerInfo ??
context.flutterDeck.speakerInfoBuilder?.call(context);

return FlutterDeckSlideBase(
backgroundBuilder: backgroundBuilder,
Expand Down
4 changes: 3 additions & 1 deletion lib/src/widgets/flutter_deck_footer.dart
Expand Up @@ -69,6 +69,8 @@ class FlutterDeckFooter extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = FlutterDeckFooterTheme.of(context);
final speakerInfo = context.flutterDeck.speakerInfo ??
context.flutterDeck.speakerInfoBuilder?.call(context);

return Padding(
padding: FlutterDeckLayout.slidePadding,
Expand All @@ -83,7 +85,7 @@ class FlutterDeckFooter extends StatelessWidget {
)
else if (showSocialHandle)
Text(
context.flutterDeck.speakerInfo?.socialHandle ?? '',
speakerInfo?.socialHandle ?? '',
style: theme.socialHandleTextStyle?.copyWith(
color: theme.socialHandleColor,
fontWeight: FontWeight.bold,
Expand Down