Introduce a Draggable class that wraps all the logic of dragging
something and dropping it on a DragTarget.
Update examples/widgets/drag_and_drop.dart accordingly.
Make the performance/transition part of routes optional.
Initial snap offset support for ScrollableWidgetList (and ScrollableList<T>) and ScrollableMixedWidgetList. If a ```toSnapOffset(scrollOffset)``` function is provided, fling Scrolls will coast to the returned value. If ```alignmentOffset``` is specified then fling scrolls conclude when toSnapOffset's value lines up with the Scrollable widget's origin + alignmentOffset. For example if the Scrollable widget's height was 200.0, and alignmentOffset:100.0 was specified, then fling scrolls would end with the value returned by toSnapOffset() lined up with the center of the Scrollable.
This approach to Scrollable snapping assumes that the layout of whatever the Scrollable contains is known at the outset. This is often true however a ScrollableMixedWidgetList may not know its items' sizes until they've been reached by scrolling.
This is a first cut at snapping support. Among the things that remain to be done:
- Scrolling limits trump snapping. Snapping should probably trump scrolling limits.
- Drag scrolls aren't snapped. This may be desirable so perhaps the feature should be controlled with a flag.
- Specifying alignmentOffset as a percentage would probably be more convenient.
- It would be nice if one could wrap items in a SnapOffset value like: ```new SnapOffset(0.5, child: myItem)``` to snap to the center of the item.
Updated the CardCollection example: snapping and fixed size items can be turned on/off with Drawer checkboxes.
This patch makes a number of changes:
1) buildDirtyComponents now prevents all calls to setState, not just those
higher in the tree. This change is necessary for consistency with
MixedViewport and HomogeneousViewport because those widgets already build
subwidgets with that restriction. If the "normal" build didn't enforce that
rule, then some widgets would break when put inside a mixed or homogeneous
viewport.
2) We now notify global key listeners in a microtask after beginFrame. That
means setState is legal in these callbacks and that we'll produce another
frame if someone calls setState in such a callback.
This updates to mojo 4e4d51ce28a and mojo sdk 711a0bcfb141b4 and updates the sky
package's pubspec.yaml dependency to '>=0.1.0 <0.2.0' to be compatible with
the current mojo package. This includes an update to the Mojo Dart generator to
produce real classes for enums and the corresponding updates for users of the
KeyboardType enum in Sky as well as one scoped_ptr->std::unique_ptr in shell
corresponding to a change in the Mojo EDK.
When a new version of the sky and sky_services package are pushed this will fix
domokit/mojo#440.
- Remove the unique objects used as slots since we decided 'null' was
fine after all
- Rename 'slot' to 'newSlot' when it's used as an argument to change the
_slot field, to clarify which variable has the newer value
- Remove the RenderObject registry since we'll do listeners a different
way. This also removes handleEvent for the same reason.
- Remove the TODOs for mount/unmount becoming didMount/didUnmount since
the methods do in fact do the mounting/unmounting.
In the old world, we had two ways to bind a Widget tree to a
RenderObject node, one way for RenderView and one mostly untested way
for other cases (it's only tested by the spinning_mixed.dart demo). For
fn3, I made these the same code path.
This patch also introduces GlobalKey, though the GlobalKey logic isn't
hooked in yet.
This is Hello World in the new world:
```dart
import 'package:sky/src/fn3.dart';
void main() {
runApp(new Text('Hello World!'));
}
```
- I extracted the BuildScheduler into a separate binding.dart file.
- Various changes to expose private members that are needed by
binding.dart.
- Registering the render objects for event dispatch.
- Convert the tests to use the new binding mechanism.
This doesn't yet have a RenderView or event handling.
Since our build function depends on scrollBehavior.isScrollable, any
time we update scrollBehavior we are implicitly updating our state. As
such, we must do so during a setState() call, or else we won't rebuild
and might not bother to listen to the scroll gestures.
This probably broke when we made Block not listen to gestures if it
wasn't overflowing.
- move _uniqueChild earlier since a comment now mentions it earlier.
- reorder methods in Element to more closely reflect call order.
- change mount to be the place that sets the parent pointer, for consistency.
- make the lifecycleState a purely debug-time thing for consistency.
- make BuildableElement.unmount set dirty to false so that we won't
build unmounted objects.
- rename "updated" to "newWidget" for clarity.
- change how we unmount things so that the slot is reset up to a
RenderObjectElement, but not further, and don't reset the depth.
- adds dartdocs
- replaces config setter with didUpdateConfig() so that you can't replace
the config outside of the system
- renames didUnmount() with destroy().
- rename Component to StatelessComponent, ComponentConfiguration to
StatefulComponent
- move debug dump to end of file
- renamed _holder to _element
* If no source path is provided, then run the analyzer on the Sky unit tests
* Fix the filter for errors found in pub cache packages
* Generalize the filter for the analyzer's "xx errors/warnings/hints found" status message
Also fix a test that caused a warning in the analyzer.
Previously EditableText would render a text widget with no cursor if the text
value was empty.
Also adjust the height of the cursor widget to reflect the style's line
height, and update the cursor painting to match.
This patch contains a prototype of a new widget framework. In this framework,
Components can be reused in the tree as many times as the author desires. Also,
StatefulComponent is split into two pieces, a ComponentConfiguration and a
ComponentState. The ComponentConfiguration is created by the author and can be
reused as many times as desired. When mounted into the tree, the
ComponentConfiguration creates a ComponentState to hold the state for the
component. The state remains in the tree and cannot be reused.
This will ensure that the width of an empty Input is consistent with the
width of an Input that contains text.
Also add a unit test for the Input widget and a way for tests to provide mock
implementations of Mojo services such as the keyboard.
Also, introduce Colors and Typography to hold the material colors and the
typography declarations. Previously we expected clients of these libraries to
import them into a namespace, but that doesn't play nice with re-exporting them
from material.dart.
When we sync() a Component, we need to clear the old Component's _child
pointer, otherwise if we reuse that Component we'll get confused about
what the old child is.
We were not removing children if they were more recently synced than we
were. This makes no sense. We should remove all children unless they
were synced this very generation already (in which case they'll be
somewhere else in the tree by now).
This patch is part of a sequence of patches towards fewer top-level libraries.
In this patch, the gesture libraries are combined into one gestures.dart
library.
Also:
- don't mark a node as from the new generation if it is dirty, since we
know it still has to be built.
- establish the rule that you can't call setState() during initState()
or build().
- make syncChild() return early for unchanged children.
- update the tests, including adding a new one.
If it's a StatefulComponent, then it's ok to reuse it so long as it
hasn't been initialised.
If it's a regular Component or a TagNode, then it's always ok to reuse.
If it's a RenderObjectWrapper, then it's ok to reuse so long as it
doesn't have a renderObject.
To put it another way, this changes how we prevent the following
nonsensical situations from arising:
- Sync two stateful StatefulComponents together
- Sync two RenderObjectWrappers with RenderObjects together
When either of those cases happen, we just drop the old one on the
ground and use the new one unchanged.
This patch start down the road of implementing text layout and painting without
the DOM. We can construct a basic paragraph consisting of a single run of text
and we can get through layout without crashing.
Dismissable now only depends on GestureDetector.
Added a unit test that verifies that issue #1068 has been fixed. It's commented out for now.
Cleaned up VelocityTracker.cc et al a little.
That way the fling engages in the same direction as the scroll. For example, if
you have a horizontal scroll nested inside a vertical scroll, the fling will
take place in the same direction as the scroll.
Allows a non-initialised stateful component to be used as a source of
settings more than once. Instead of asserting that it was only being
used once, we assert that once you are stateful you don't get used as a
bag of settings, which is the real thing we were trying to avoid.
A lot of code ends up using StatefulComponents as a source multiple
times in a row, and before this would fail.
Patch by Ian Hickson
Move the animation libraries into src/animation and change importers to use
package:sky/animation.dart. Also, move scheduler.dart into the animation
library so that the animation library can be self-contained.
This makes the sync code stop if it would have to rearrange the
RenderObjects. I'll make it handle the cross-RenderObject case, as well
as the insertion-sync case, in subsequent patches.
Turns out many of the functions on BoxConstraints weren't used or had callers
that could easily be updated to other functions. I've added dartdoc to all the
public functions as well as renamed some functions that had similar names but
did different things.
This patch makes Center and Align expand by default, which is usually what you
want. It also adds a ShrinkWrap option to let you shrink wrap in one or both
directions if that's really what you want to do.
Alternating scroll gestures would sometimes be ignored because _ScrollGestureRecognizer didn't always reset its _state when the pointer[s] went up.
A Dismissable dismiss triggered by a drag and then a fling could cause the next attempt to drag-dimiss to fail.
Fixed the definition of lerpColor().
This should handle a case like a stateful component inside a Container
inside another Container having one of those Containers removed while
still keeping that stateful component around with its state.
The problem of how to handle the Container then being reinserted is a
separate issue not handled by this patch.
Convert Dismissable to use gestures
Convert Dismissable to use the ScrollStart, ScrollUpdate, and ScrollEnd gestures. Support for fling gestures is TBD.
Included a basic unit test that checks that one item can be dismissed with a press-drag-release gesture.
Fixed the scroll gesture recognizer: if the last pointer goes up and candidate recognizers still exist, then reject the gesture.
Convert Dismissable to use the ScrollStart, ScrollUpdate, and ScrollEnd gestures. Support for fling gestures is TBD.
Included a basic unit test that checks that one item can be dismissed with a press-drag-release gesture.
Fixed the scroll gesture recognizer: if the last pointer goes up and candidate recognizers still exist, then reject the gesture.
This patch makes ParentDataNode less general purpose and instead teaches Flex
and Stack how to program the parent data for their children. We used to have
this general system because parent data used to carry CSS styling, but we don't
need it anymore.
Fixes#957
Adds a HomogeneousViewport class that works like MixedViewport but
handles only children that have all the same height.
Converts ScrollableWidgetList to use that, so that we don't waste a
frame looking at the size of the contents each time we change size.
This allows a number of seemingly pointless double-pumps in the tests
to be removed.
Other changes that were necessary to support the above:
- RenderBlock now supports minExtent (think 'min-height' in CSS)
- RenderBlock now supports itemExtent (forces the height of each
child to be the same, so that the itemExtent passed to the fixed-
height scrollables are all authoritative instead of a source of
bugs when they don't match)
- RenderBlockViewport now supports horizontal scrolling
- improved the style of the isInfinite assert in box.dart
- fixed the position of a comment in mixed_viewport.dart
- added a test
- made the logic for how many items to show be more precise
If there are no other gestures in the arena, we should kick off the scroll
gesture right away. This change pulled a refactoring of how we dispatch events
to Widgets. Now we dispatch events to Widgets interleaved with their associated
RenderObjects. (Previously we dispatched to all of the RenderObjects first.)
Add a way of having keys based on numeric types or DateTimes by having a ValueKey<T> class.
Remove the redundant ways of declaring things, except for leaving one shorthand -- you can say `new Key(s)` instead of `new ValueKey<String>(s)`.
Also, rename build_utils.dart to widget_tester.dart. These files are now named
for their most commonly used classes.
Finally, add a .analysis_options to silence the (intentional) analyzer warnings
in append_child_test.dart.
- add debugDescribeSettings to a few classes that were missing it
- fix some minor bugs in RenderShrinkWrapWidth and ShrinkWrapWidth
- introduce RenderShrinkWrapHeight and ShrinkWrapHeight
This lets clients listen for when a widget with a given global key goes through
a sync operation. We'll need this for mimic to track its mimicable when it
moves around the tree.
This patch adds a new test harness and a first, trivial test to run with the
harness. The new test harness is built on package:test and should run on
Travis. Over time, we'll migrate our existing tests into this harness.