-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from mkobuolys/feat/image-slide-theme
feat: add image slide theme
- Loading branch information
Showing
5 changed files
with
107 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
lib/src/theme/templates/flutter_deck_image_slide_theme.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_deck/src/templates/image_slide.dart'; | ||
import 'package:flutter_deck/src/theme/flutter_deck_theme.dart'; | ||
|
||
/// Defines the visual properties of [FlutterDeckImageSlide]. | ||
/// | ||
/// Used by [FlutterDeckImageSlideTheme] to control the visual properties of | ||
/// slides in a deck. | ||
/// | ||
/// To obtain the current [FlutterDeckImageSlideThemeData], use | ||
/// [FlutterDeckImageSlideTheme.of] to access the closest ancestor | ||
/// [FlutterDeckImageSlideTheme] of the current [BuildContext]. | ||
/// | ||
/// See also: | ||
/// | ||
/// * [FlutterDeckImageSlideTheme], an [InheritedWidget] that propagates the | ||
/// theme down its subtree. | ||
/// * [FlutterDeckTheme], which describes the overall theme information for the | ||
/// slide deck. | ||
class FlutterDeckImageSlideThemeData { | ||
/// Creates a theme to style [FlutterDeckImageSlide]. | ||
const FlutterDeckImageSlideThemeData({ | ||
this.labelTextStyle, | ||
}); | ||
|
||
/// Text style for the image label. | ||
final TextStyle? labelTextStyle; | ||
|
||
/// Creates a copy of this object with the given fields replaced with the new | ||
/// values. | ||
FlutterDeckImageSlideThemeData copyWith({ | ||
TextStyle? labelTextStyle, | ||
}) { | ||
return FlutterDeckImageSlideThemeData( | ||
labelTextStyle: labelTextStyle ?? this.labelTextStyle, | ||
); | ||
} | ||
|
||
/// Merge the given [FlutterDeckImageSlideThemeData] with this one. | ||
FlutterDeckImageSlideThemeData merge(FlutterDeckImageSlideThemeData? other) { | ||
if (other == null) return this; | ||
|
||
return copyWith( | ||
labelTextStyle: | ||
labelTextStyle?.merge(other.labelTextStyle) ?? other.labelTextStyle, | ||
); | ||
} | ||
} | ||
|
||
/// An inherited widget that defines the visual properties of | ||
/// [FlutterDeckImageSlide]. | ||
/// | ||
/// Used by [FlutterDeckImageSlide] to control the visual properties of slides | ||
/// in the slide deck. | ||
class FlutterDeckImageSlideTheme extends InheritedTheme { | ||
/// Creates a theme to style [FlutterDeckImageSlide]. | ||
/// | ||
/// The [data] argument must not be null. | ||
const FlutterDeckImageSlideTheme({ | ||
required this.data, | ||
required super.child, | ||
super.key, | ||
}); | ||
|
||
/// The visual properties of [FlutterDeckImageSlide]. | ||
final FlutterDeckImageSlideThemeData data; | ||
|
||
/// Returns the [data] from the closest [FlutterDeckImageSlideTheme] ancestor. | ||
/// If there is no ancestor, it returns | ||
/// [FlutterDeckThemeData.imageSlideTheme]. | ||
/// | ||
/// The returned theme data will never be null. | ||
static FlutterDeckImageSlideThemeData of(BuildContext context) { | ||
final theme = context | ||
.dependOnInheritedWidgetOfExactType<FlutterDeckImageSlideTheme>(); | ||
|
||
return theme?.data ?? FlutterDeckTheme.of(context).imageSlideTheme; | ||
} | ||
|
||
@override | ||
bool updateShouldNotify(FlutterDeckImageSlideTheme oldWidget) => | ||
data != oldWidget.data; | ||
|
||
@override | ||
Widget wrap(BuildContext context, Widget child) => | ||
FlutterDeckImageSlideTheme(data: data, child: child); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export 'flutter_deck_image_slide_theme.dart'; | ||
export 'flutter_deck_slide_theme.dart'; | ||
export 'flutter_deck_split_slide_theme.dart'; | ||
export 'flutter_deck_title_slide_theme.dart'; |