Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions demo/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ void main() async {
SuperDeckApp(
options: DeckOptions(
baseStyle: borderedStyle(),
widgets: {
...demoWidgets,
'twitter': const _TwitterWidgetDefinition(),
},
widgets: {...demoWidgets, 'twitter': const _TwitterWidgetDefinition()},
// debug: true,
styles: {
'announcement': announcementStyle(),
Expand All @@ -37,6 +34,7 @@ void main() async {
footer: FooterPart(),
background: BackgroundPart(),
),
watchForChanges: true,
),
),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/builder/lib/src/parsers/raw_slide_schema.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions packages/superdeck/lib/src/deck/deck_controller_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class _DeckControllerBuilderState extends State<DeckControllerBuilder> {
options: widget.options,
);

// Start CLI watcher in debug mode for auto-rebuild
if (kCanRunProcess) {
// Start CLI watcher in debug mode for auto-rebuild (if enabled)
if (kCanRunProcess && widget.options.watchForChanges) {
try {
_cliWatcher = CliWatcher(
projectRoot: Directory.current,
Expand All @@ -65,6 +65,8 @@ class _DeckControllerBuilderState extends State<DeckControllerBuilder> {
} catch (e) {
_logger.warning('CLI watcher failed to start: $e');
}
} else if (!widget.options.watchForChanges) {
_logger.info('CLI watcher disabled via DeckOptions.watchForChanges');
}
}

Expand Down
16 changes: 14 additions & 2 deletions packages/superdeck/lib/src/deck/deck_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ class DeckOptions {
final SlideParts parts;
final bool debug;

/// Whether to watch for file changes and auto-rebuild the deck.
///
/// When `true` (default), starts a CLI watcher process that monitors
/// the slides file and rebuilds automatically on changes.
/// Set to `false` to disable file watching.
final bool watchForChanges;

const DeckOptions({
this.baseStyle,
this.styles = const <String, SlideStyle>{},
this.widgets = const <String, WidgetDefinition>{},
this.parts = const SlideParts(),
this.debug = false,
this.watchForChanges = false,
});

DeckOptions copyWith({
Expand All @@ -23,13 +31,15 @@ class DeckOptions {
Map<String, WidgetDefinition>? widgets,
SlideParts? parts,
bool? debug,
bool? watchForChanges,
}) {
return DeckOptions(
baseStyle: baseStyle ?? this.baseStyle,
styles: styles ?? this.styles,
widgets: widgets ?? this.widgets,
parts: parts ?? this.parts,
debug: debug ?? this.debug,
watchForChanges: watchForChanges ?? this.watchForChanges,
);
}

Expand All @@ -42,8 +52,10 @@ class DeckOptions {
styles == other.styles &&
widgets == other.widgets &&
parts == other.parts &&
debug == other.debug;
debug == other.debug &&
watchForChanges == other.watchForChanges;

@override
int get hashCode => Object.hash(baseStyle, styles, widgets, parts, debug);
int get hashCode =>
Object.hash(baseStyle, styles, widgets, parts, debug, watchForChanges);
}
Original file line number Diff line number Diff line change
Expand Up @@ -1359,12 +1359,11 @@ void main() {

group('Edge Cases', () {
test('handles null values gracefully', () {
final result = StyleSchemas.styleConfigSchema.safeParse({
// Schema should handle nulls gracefully without throwing
StyleSchemas.styleConfigSchema.safeParse({
'base': null,
'styles': null,
});
// Depending on schema, this might pass or fail
// The schema should handle nulls gracefully
});

test('handles very large font sizes', () {
Expand Down Expand Up @@ -1566,7 +1565,7 @@ void main() {
final result = StyleSchemas.colorSchema.safeParse('#ABCDEF');
final color = result.getOrThrow()!;
expect(color.a, 1.0); // Full alpha
expect((color.value & 0x00FFFFFF), 0xABCDEF);
expect((color.toARGB32() & 0x00FFFFFF), 0xABCDEF);
});

test('colorSchema transforms 8-digit hex correctly', () {
Expand Down
Loading