diff --git a/lib/src/wizard.dart b/lib/src/wizard.dart index d191eee..da98dd1 100644 --- a/lib/src/wizard.dart +++ b/lib/src/wizard.dart @@ -1,3 +1,41 @@ +import 'package:flutter/material.dart'; +import 'wizard_scope.dart'; + //! Instead of implementing all the Focus classes + widgets, maybe we should //! create widgets that manage their construction / lifecycle. The API is really -//! difficult to abstract. \ No newline at end of file +//! difficult to abstract. + +//? We don't actually need to add anything to the Focus classes themselves; +// objects like FocusTraversalPolicy should be working out-of-the-box, so it's +// probably a better idea to avoid this approach altogether. + +/// Represents an indiviudal node in the Feature Discovery. +/// +/// [WizardNode] manages a [FocusNode], which, when instantiated; should be a +/// descendant of a [WizardScope]. +class WizardNode extends StatelessWidget { + const WizardNode({ + required this.child, + this.focusNode, + this.background, + this.overlay, + Key? key, + }) : super(key: key); + + final Widget child; + final Widget? background; + final Widget? overlay; + + /// Parameters passed down to [Focus]. The lifecycle of a [focusNode] should + /// be managed inside the [Widget] it's instantiated in. If a [FocusNode] is + /// not provided, [Focus] will implicitly create and manage one. + final FocusNode? focusNode; + + @override + Widget build(BuildContext context) { + return Focus( + focusNode: focusNode, + child: child, + ); + } +} diff --git a/lib/src/wizard_node.dart b/lib/src/wizard_node.dart deleted file mode 100644 index dc45f4b..0000000 --- a/lib/src/wizard_node.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:flutter/material.dart'; - -class WizardNode extends FocusNode {} - -// class WizardNode implements FocusNode diff --git a/lib/src/wizard_scope.dart b/lib/src/wizard_scope.dart index b889d31..5b10c0e 100644 --- a/lib/src/wizard_scope.dart +++ b/lib/src/wizard_scope.dart @@ -1,15 +1,11 @@ import 'package:flutter/cupertino.dart'; +import 'package:wizardview/src/wizard.dart'; -import 'wizard_scope_node.dart'; - -class WizardScope extends FocusScope { +class WizardScope { const WizardScope({ required Widget child, required this.node, - }) : super( - child: child, - node: node, - ); + }); - final WizardScopeNode node; + final WizardNode node; } diff --git a/lib/src/wizard_scope_node.dart b/lib/src/wizard_scope_node.dart deleted file mode 100644 index ee437d7..0000000 --- a/lib/src/wizard_scope_node.dart +++ /dev/null @@ -1,22 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'wizard_node.dart'; - -class WizardScopeNode extends FocusScopeNode { - void start() { - for (final FocusNode child in children) { - if (child is WizardNode) { - final OverlayEntry entry = OverlayEntry( - builder: (_) => Positioned.fromRect( - rect: child.offset & child.size, - child: Material( - color: Colors.amber.withOpacity(0.3), - ), - ), - ); - - Overlay.of(child.context!)!.insert(entry); - } - } - } -}