Skip to content

Commit

Permalink
docs: update documentation for the updated widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
mkobuolys committed Aug 14, 2023
1 parent 052641b commit ea64db1
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 112 deletions.
9 changes: 5 additions & 4 deletions lib/src/flutter_deck_configuration.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_deck/src/flutter_deck_slide.dart';
import 'package:flutter_deck/src/templates/templates.dart';
import 'package:flutter_deck/src/transitions/transitions.dart';
import 'package:flutter_deck/src/widgets/widgets.dart';
Expand All @@ -22,11 +23,11 @@ class FlutterDeckConfiguration {
/// The background configuration for the slide deck. By default, the
/// background is transparent and the [Scaffold.backgroundColor] is used.
///
/// This configuration is used by all the templates that extend the
/// [FlutterDeckSlideBase] class and do not override the background method
/// This configuration is used by all the templates that use the
/// [FlutterDeckSlideBase] class and do not pass the background builder
/// explicitly. This also means that the configuration cannot be overridden
/// via the slide configuration, but rather by overriding the
/// [FlutterDeckSlideBase.background] method.
/// via the slide configuration, but rather by passing a background builder
/// for the [FlutterDeckSlide].
final FlutterDeckBackgroundConfiguration background;

/// Configures the controls for the slide deck. By default, controls are
Expand Down
114 changes: 93 additions & 21 deletions lib/src/flutter_deck_slide.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,53 @@
import 'package:flutter/material.dart';
import 'package:flutter_deck/src/flutter_deck.dart';
import 'package:flutter_deck/src/flutter_deck_configuration.dart';
import 'package:flutter_deck/src/flutter_deck_speaker_info.dart';
import 'package:flutter_deck/src/templates/templates.dart';
import 'package:flutter_deck/src/widgets/internal/internal.dart';

/// An abstract class that must be extended when creating a new slide for the
/// slide deck.
///
/// This class is used to create a new slide for the slide deck. It ensures that
/// each slide has a defined [FlutterDeckSlideConfiguration] and a [build]
/// method to create the slide. Diffently from the [StatelessWidget] class, the
/// [build] method returns a [FlutterDeckSlide] instead of a [Widget].
///
/// See also:
///
/// * [FlutterDeckSlide], which represents a slide in a slide deck.
/// * [FlutterDeckSlide.blank], which creates a blank slide.
/// * [FlutterDeckSlide.custom], which creates a custom slide.
/// * [FlutterDeckSlide.image], which creates a slide with an image.
/// * [FlutterDeckSlide.split], which creates a slide with two columns.
/// * [FlutterDeckSlide.template], which creates a slide with a standard layout.
/// * [FlutterDeckSlide.title], which creates a title slide.
///
/// Example:
///
/// ```dart
/// import 'package:flutter/widgets.dart';
/// import 'package:flutter_deck/flutter_deck.dart';
///
/// class ExampleSlide extends FlutterDeckSlideWidget {
/// const ExampleSlide()
/// : super(
/// configuration: const FlutterDeckSlideConfiguration(
/// route: '/example',
/// header: FlutterDeckHeaderConfiguration(title: 'Example'),
/// ),
/// );
///
/// @override
/// FlutterDeckSlide build(BuildContext context) {
/// return FlutterDeckSlide.blank(
/// builder: (context) => const Center(
/// child: Text('This is an example slide'),
/// ),
/// );
/// }
/// }
/// ```
abstract class FlutterDeckSlideWidget {
///
const FlutterDeckSlideWidget({
Expand All @@ -18,35 +61,29 @@ abstract class FlutterDeckSlideWidget {
FlutterDeckSlide build(BuildContext context);
}

/// The base class for a slide in a slide deck.
/// The main widget for a slide in a slide deck.
///
/// This class is used to create a slide in a slide deck. It is responsible for
/// wrapping the slide in a [Scaffold] and displaying the navigation drawer.
///
/// It is recommended to extend this class directly only if you want to create
/// a custom slide with its own layout. If the slide has a standard layout, a
/// better option is to extend the [FlutterDeckSlideBase] class.
///
/// See also:
///
/// * [FlutterDeckSlideBase], which represents a slide with a standard layout.
/// * [FlutterDeckBlankSlide], which represents a blank slide.
/// * [FlutterDeckImageSlide], which represents a slide with an image.
/// * [FlutterDeckSplitSlide], which represents a slide with two columns.
/// * [FlutterDeckTitleSlide], which represents a title slide.
/// * [FlutterDeckSlideConfiguration], which represents a configuration for a
/// single slide.
/// To create a new slide, use one of the named constructors.
class FlutterDeckSlide extends StatelessWidget {
/// Creates a new slide.
///
/// The [configuration] argument must not be null. This configuration
/// overrides the global configuration of the slide deck.
/// This constructor is private and should not be used directly. Instead, use
/// one of the named constructors to create a new slide.
const FlutterDeckSlide._({
required WidgetBuilder builder,
super.key,
}) : _builder = builder;

/// Creates a new blank slide.
///
/// This constructor creates a blank slide in a slide deck with the default
/// header and footer, and the content in-between.
///
/// The [builder] argument must not be null. The [backgroundBuilder] argument
/// is optional.
FlutterDeckSlide.blank({
required WidgetBuilder builder,
WidgetBuilder? backgroundBuilder,
Expand All @@ -59,7 +96,13 @@ class FlutterDeckSlide extends StatelessWidget {
key: key,
);

/// Creates a new custom slide.
///
/// This constructor creates a custom slide in a slide deck. This constructor
/// does not provide any default layout for the slide. It is up to the user to
/// define it.
///
/// The [builder] argument must not be null.
const FlutterDeckSlide.custom({
required WidgetBuilder builder,
Key? key,
Expand All @@ -68,7 +111,14 @@ class FlutterDeckSlide extends StatelessWidget {
key: key,
);

/// Creates a new image slide.
///
/// This constructor creates a slide in a slide deck with the default header
/// and footer, and the image in-between.The image can be a local asset or a
/// network image.
///
/// The [imageBuilder] argument must not be null. The [label] and
/// [backgroundBuilder] arguments are optional.
FlutterDeckSlide.image({
required ImageBuilder imageBuilder,
String? label,
Expand All @@ -83,10 +133,23 @@ class FlutterDeckSlide extends StatelessWidget {
key: key,
);

/// Creates a new slide with two columns.
///
/// This constructor creates a slide with two columns in a slide deck. It is
/// responsible for rendering the default header and footer of the slide deck,
/// and use the [leftBuilder] and [rightBuilder] to create the content of the
/// left and right columns.
///
/// The [leftBuilder] and [rightBuilder] arguments must not be null. The
/// [backgroundBuilder], [leftBackgroundColor], [rightBackgroundColor], and
/// [splitRatio] arguments are optional.
///
/// If [splitRatio] is not specified, the left and right columns will have the
/// same width.
FlutterDeckSlide.split({
required WidgetBuilder leftBuilder,
required WidgetBuilder rightBuilder,
WidgetBuilder? backgroundBuilder,
Color? leftBackgroundColor,
Color? rightBackgroundColor,
SplitSlideRatio? splitRatio,
Expand All @@ -95,14 +158,20 @@ class FlutterDeckSlide extends StatelessWidget {
builder: (context) => FlutterDeckSplitSlide(
leftBuilder: leftBuilder,
rightBuilder: rightBuilder,
backgroundBuilder: backgroundBuilder,
leftBackgroundColor: leftBackgroundColor,
rightBackgroundColor: rightBackgroundColor,
splitRatio: splitRatio,
),
key: key,
);

/// Creates a new slide with a standard layout.
///
/// This constructor creates a slide with a standard layout in a slide deck.
///
/// The [backgroundBuilder], [contentBuilder], [footerBuilder], and
/// [headerBuilder] arguments are optional.
FlutterDeckSlide.template({
WidgetBuilder? backgroundBuilder,
WidgetBuilder? contentBuilder,
Expand All @@ -119,7 +188,15 @@ class FlutterDeckSlide extends StatelessWidget {
key: key,
);

/// Creates a new title slide.
///
/// This constructor creates a title slide in a slide deck with the default
/// header and footer, and the content in-between. The content is composed of
/// the [title] and [subtitle]. Also, if the [FlutterDeckSpeakerInfo] is set,
/// it will render the speaker info below the title and subtitle.
///
/// The [title] argument must not be null. The [subtitle] and
/// [backgroundBuilder] arguments are optional.
FlutterDeckSlide.title({
required String title,
String? subtitle,
Expand All @@ -136,11 +213,6 @@ class FlutterDeckSlide extends StatelessWidget {

final WidgetBuilder _builder;

/// An abstract method that must be implemented by subclasses.
///
/// Usually, this method is implemented in the template.
// Widget slide(BuildContext context) => const SizedBox();

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down
20 changes: 7 additions & 13 deletions lib/src/templates/blank_slide.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,30 @@ import 'package:flutter_deck/src/flutter_deck_layout.dart';
import 'package:flutter_deck/src/templates/slide_base.dart';
import 'package:flutter_deck/src/widgets/widgets.dart';

/// The base class for a blank slide in a slide deck.
/// A slide widget that represents a blank slide.
///
/// This class is used to create a blank slide in a slide deck. It is
/// responsible for rendering the default header and footer of the slide deck,
/// and placing the content of the [body] of the slide in the correct place.
/// and rendering the content of the slide using the provided [builder].
///
/// To use a custom background, you can override the [background] method.
/// To use a custom background, you can pass the [backgroundBuilder].
class FlutterDeckBlankSlide extends StatelessWidget {
/// Creates a new blank slide.
///
/// The [configuration] argument must not be null. This configuration
/// overrides the global configuration of the slide deck.
/// The [builder] argument must not be null. The [backgroundBuilder] argument
/// is optional.
const FlutterDeckBlankSlide({
required this.builder,
this.backgroundBuilder,
super.key,
});

///
/// Creates the content of the slide.
final WidgetBuilder builder;

///
/// A builder for the background of the slide.
final WidgetBuilder? backgroundBuilder;

/// Creates the body of the slide.
///
/// This method is called by the [slide] method. It is responsible for
/// rendering the body of the slide between the header and footer.
// Widget body(BuildContext context);

@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
Expand Down
14 changes: 7 additions & 7 deletions lib/src/templates/image_slide.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,34 @@ import 'package:flutter_deck/src/widgets/widgets.dart';
///
typedef ImageBuilder = Image Function(BuildContext context);

/// The base class for a slide that only contains an image.
/// A slide widget that represents a slide with an image.
///
/// This class is used to create a slide that only contains an image. It is
/// responsible for rendering the default header and footer of the slide deck,
/// and placing the [image] in the correct place.
/// and rendering the image using the provided [imageBuilder].
///
/// To use a custom background, you can override the [background] method.
/// To use a custom background, you can pass the [backgroundBuilder].
class FlutterDeckImageSlide extends StatelessWidget {
/// Creates a new image slide.
///
/// The [configuration] argument must not be null. This configuration
/// overrides the global configuration of the slide deck.
/// The [imageBuilder] argument must not be null. The [label] and
/// [backgroundBuilder] arguments are optional.
const FlutterDeckImageSlide({
required this.imageBuilder,
this.label,
this.backgroundBuilder,
super.key,
});

/// The image to display in the slide.
/// Creates the image of the slide.
final ImageBuilder imageBuilder;

/// The label to display below the image.
///
/// If this is null, no label will be displayed.
final String? label;

///
/// A builder for the background of the slide.
final WidgetBuilder? backgroundBuilder;

@override
Expand Down
57 changes: 16 additions & 41 deletions lib/src/templates/slide_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ import 'package:flutter/material.dart';
import 'package:flutter_deck/src/flutter_deck.dart';
import 'package:flutter_deck/src/widgets/widgets.dart';

/// The base class for a slide with a standard layout.
/// A base widget for a slide with a standard layout.
///
/// This class is used to create a slide with a standard layout. It is
/// responsible for placing the header, footer, and content of the slide in the
/// correct places. Also, it is responsible for displaying the background of the
/// slide.
///
/// If you want to create your own reusable layout, you can extend this class
/// and override the [header], [footer], [content], and [background] methods.
/// If you want to create your own reusable layout, use this class and pass in
/// the appropriate builders: [backgroundBuilder], [contentBuilder],
/// [headerBuilder], and [footerBuilder].
class FlutterDeckSlideBase extends StatelessWidget {
/// Creates a new slide with a standard layout.
///
/// The [configuration] argument must not be null. This configuration
/// overrides the global configuration of the slide deck.
/// [backgroundBuilder], [contentBuilder], [headerBuilder], and
/// [footerBuilder] are optional.
const FlutterDeckSlideBase({
this.backgroundBuilder,
this.contentBuilder,
Expand All @@ -24,50 +25,24 @@ class FlutterDeckSlideBase extends StatelessWidget {
super.key,
});

///
/// A builder for the background of the slide. It is responsible for placing
/// the background of the slide. If not provided, an appropriate
/// [FlutterDeckBackground] from the global configuration of the slide deck is
/// used based on the current theme.
final WidgetBuilder? backgroundBuilder;

///
/// A builder for the content of the slide. It is responsible for placing the
/// content between the header and footer of the slide.
final WidgetBuilder? contentBuilder;

///
/// A builder for the footer of the slide. It is responsible for placing the
/// footer at the bottom of the slide.
final WidgetBuilder? footerBuilder;

///
/// A builder for the header of the slide. It is responsible for placing the
/// header at the top of the slide.
final WidgetBuilder? headerBuilder;

/// Creates the content of the slide.
///
/// This method is called by the [slide] method. It is responsible for
/// placing the content between the header and footer of the slide.
// Widget? content(BuildContext context);

/// Creates the header of the slide.
///
/// This method is called by the [slide] method. It is responsible for
/// placing the header at the top of the slide.
// Widget? header(BuildContext context);

/// Creates the footer of the slide.
///
/// This method is called by the [slide] method. It is responsible for
/// placing the footer at the bottom of the slide.
// Widget? footer(BuildContext context);

/// Creates the background of the slide.
///
/// This method is called by the [slide] method. It is responsible for
/// placing the background of the slide. By default, it uses the appropriate
/// [FlutterDeckBackground] from the global configuration of the slide deck
/// based on the current theme.
// FlutterDeckBackground background(BuildContext context) {
// final background = context.flutterDeck.globalConfiguration.background;

// return Theme.of(context).brightness == Brightness.dark
// ? background.dark
// : background.light;
// }

@override
Widget build(BuildContext context) {
final globalConfiguration = context.flutterDeck.globalConfiguration;
Expand Down
Loading

0 comments on commit ea64db1

Please sign in to comment.