Commit graph

58 commits

Author SHA1 Message Date
Dragoș Tiselice eafe1c7a4e Renamed Positioned constructor. (#5927)
Renames stretch constructor to fill for better consistency with
the rest of the framework.
2016-09-19 10:46:06 -07:00
Dragoș Tiselice 51cd8b6799 Added a stretch Positioned constructor. (#5894)
Fixes #5835.
2016-09-16 15:59:01 -07:00
Hans Muller 4fe80830ca Use updated appbar background assets (#5248) 2016-08-05 09:02:34 -07:00
Hans Muller 3a7508d702 New gallery identity (#5210) 2016-08-04 11:07:59 -07:00
Ian Hickson 1aeea6263a Fix some misuse of types (#5197)
Thanks to @leafpetersen for catching these.
2016-08-03 13:18:41 -07:00
Ian Hickson 51f8fb9979 Add a scrollbar to the license screen. (#5114)
And make Scrollbar work with LazyBlock.

And an about box to the Stocks sample app.
2016-07-29 15:44:12 -07:00
Adam Barth c674b4a803 Rename Image.fromNetwork and Image.fromAssetBundle (#5149)
These now have sorter names to make the callers less verbose.
2016-07-29 13:28:08 -07:00
Adam Barth 79364f0a06 Add Container.align and Container.position (#5128)
These let you add Align widget to the inside or outside of a container.
Several customers have asked for these properties.

Fixes #4950
2016-07-29 10:27:11 -07:00
Adam Barth 534097ffb6 Use named Image constructors (#5129)
Some folks didn't realize these existed and asked us to add them. By
using them in examples, hopefully folks will discover them more easily.
2016-07-29 08:27:28 -07:00
Dragos Tiselice 65e77142e9 Updated DrawerHeader and added UserAccountDrawer.
Removed old Stack layout and added a simple-to-extend interface for the
new drawer header. Also added a specialized UserAccountsDrawerHeader
consistent with Material Design guidelines.
2016-07-20 16:16:08 -07:00
Ian Hickson e502e9c8f8 ImageIcon (#4649)
Anywhere that accepted IconData now accepts either an Icon or an
ImageIcon.

Places that used to take an IconData in an `icon` argument, notably
IconButton and DrawerItem, now take a Widget in that slot. You can wrap
the value that used to be passed in in an Icon constructor to get the
same result.

Icon itself now takes the icon as a positional argument, for brevity.

ThemeData now has an iconTheme as well as a primaryIconTheme, the same
way it has had a textTheme and primaryTextTheme for a while.

IconTheme.of() always returns a value now (though that value itself may
have nulls in it). It defaults to the ThemeData.iconTheme.

IconThemeData.fallback() is a new method that returns an icon theme data
structure with all fields filled in.

IconTheme.merge() is a new constructor that takes a context and creates
a widget that mixes in the new values with the inherited values.

Most places that introduced an IconTheme widget now use IconTheme.merge.

IconThemeData.merge and IconThemeData.copyWith act in a way analogous to
the similarly-named members of TextStyle.

ImageIcon is introduced. It acts like Icon but takes an ImageProvider
instead of an IconData.

Also: Fix the analyzer to actually check the stocks app.
2016-06-20 21:04:45 -07:00
Ian Hickson 2dfdc840b1 Refactor everything to do with images (#4583)
Overview
========

This patch refactors images to achieve the following goals:

* it allows references to unresolved assets to be passed
  around (previously, almost every layer of the system had to know about
  whether an image came from an asset bundle or the network or
  elsewhere, and had to manually interact with the image cache).

* it allows decorations to use the same API for declaring images as the
  widget tree.

It requires some minor changes to call sites that use images, as
discussed below.

Widgets
-------

Change this:

```dart
      child: new AssetImage(
        name: 'my_asset.png',
        ...
      )
```

...to this:

```dart
      child: new Image(
        image: new AssetImage('my_asset.png'),
        ...
      )
```

Decorations
-----------

Change this:

```dart
      child: new DecoratedBox(
        decoration: new BoxDecoration(
          backgroundImage: new BackgroundImage(
            image: DefaultAssetBundle.of(context).loadImage('my_asset.png'),
            ...
          ),
          ...
        ),
        child: ...
      )
```

...to this:

```dart
      child: new DecoratedBox(
        decoration: new BoxDecoration(
          backgroundImage: new BackgroundImage(
            image: new AssetImage('my_asset.png'),
            ...
          ),
          ...
        ),
        child: ...
      )
```

DETAILED CHANGE LOG
===================

The following APIs have been replaced in this patch:

* The `AssetImage` and `NetworkImage` widgets have been split in two,
  with identically-named `ImageProvider` subclasses providing the
  image-loading logic, and a single `Image` widget providing all the
  widget tree logic.

* `ImageResource` is now `ImageStream`. Rather than configuring it with
  a `Future<ImageInfo>`, you complete it with an `ImageStreamCompleter`.

* `ImageCache.load` and `ImageCache.loadProvider` are replaced by
  `ImageCache.putIfAbsent`.

The following APIs have changed in this patch:

* `ImageCache` works in terms of arbitrary keys and caches
  `ImageStreamCompleter` objects using those keys. With the new model,
  you should never need to interact with the cache directly.

* `Decoration` can now be `const`. The state has moved to the
  `BoxPainter` class. Instead of a list of listeners, there's now just a
  single callback and a `dispose()` method on the painter. The callback
  is passed in to the `createBoxPainter()` method. When invoked, you
  should repaint the painter.

The following new APIs are introduced:

* `AssetBundle.loadStructuredData`.

* `SynchronousFuture`, a variant of `Future` that calls the `then`
  callback synchronously. This enables the asynchronous and
  synchronous (in-the-cache) code paths to look identical yet for the
  latter to avoid returning to the event loop mid-paint.

* `ExactAssetImage`, a variant of `AssetImage` that doesn't do anything clever.

* `ImageConfiguration`, a class that describes parameters that configure
  the `AssetImage` resolver.

The following APIs are entirely removed by this patch:

* `AssetBundle.loadImage` is gone. Use an `AssetImage` instead.

* `AssetVendor` is gone. `AssetImage` handles everything `AssetVendor`
  used to handle.

* `RawImageResource` and `AsyncImage` are gone.

The following code-level changes are performed:

* `Image`, which replaces `AsyncImage`, `NetworkImage`, `AssetImage`,
  and `RawResourceImage`, lives in `image.dart`.

* `DecoratedBox` and `Container` live in their own file now,
  `container.dart` (they reference `image.dart`).

DIRECTIONS FOR FUTURE RESEARCH
==============================

* The `ImageConfiguration` fields are mostly aspirational. Right now
  only `devicePixelRatio` and `bundle` are implemented. `locale` isn't
  even plumbed through, it will require work on the localisation logic.

* We should go through and make `BoxDecoration`, `AssetImage`, and
  `NetworkImage` objects `const` where possible.

* This patch makes supporting animated GIFs much easier.

* This patch makes it possible to create an abstract concept of an
  "Icon" that could be either an image or a font-based glyph (using
  `IconData` or similar). (see
  https://github.com/flutter/flutter/issues/4494)

RELATED ISSUES
==============

Fixes https://github.com/flutter/flutter/issues/4500
Fixes https://github.com/flutter/flutter/issues/4495
Obsoletes https://github.com/flutter/flutter/issues/4496
2016-06-16 09:49:48 -07:00
Hans Muller ebaf9e29a0 Gallery shrine demo uses image assets (#4544) 2016-06-13 14:48:24 -07:00
Hans Muller 187ff00294 New gallery app bar background (#4539) 2016-06-13 12:41:29 -07:00
Adam Barth 1a3adae101 Use @required for onPressed and onChanged (#4534)
We now use the `@required` annotation to encourage developers to
explicitly set onPressed and onChanged callbacks to null when that would
disable the widget.

Fixes #287
2016-06-12 13:25:06 -07:00
Matt Perry ffde6777fc Pull Flutter gallery assets from Google's git repo. (#4493)
This repo contains the final licensed images.
2016-06-09 16:03:10 -04:00
Matt Perry 3e0e6b9997 Smoothly scale the Pesto logo as the app bar resizes. (#4465)
Also update the assets version to pull in better quality logo images.

BUG=https://github.com/flutter/flutter/issues/4407
2016-06-08 15:49:21 -04:00
Adam Barth 7d9f8d903d Introduce TapDownDetails and TapUpDetails (#4431)
We have these details objects for the same reason we now have drag details
objects: future extensibility.
2016-06-07 16:16:53 -07:00
Todd Volkert 7ac0ce7938 Add API for specifying the system overlay style. (#4422)
Fixes 3544
2016-06-07 14:39:15 -07:00
Hans Muller 0b7e975e2c Updated fitness and weather manual tests, new asset locations (#4351) 2016-06-03 10:38:03 -07:00
Adam Barth 2d4acb8041 Convert drag gestures to use details objects (#4343)
Previously we supplied individual parameters to the various drag and pan
callbacks. However, that approach isn't extensible because each new
parameter is a breaking change to the API.

This patch makes a one-time breaking change to the API to provide a
"details" object that we can extend over time as we need to expose more
information. The first planned extension is adding enough information to
accurately produce an overscroll glow on Android.
2016-06-02 23:45:49 -07:00
Hans Muller dd27a489fa Update gallery demo list (#4335) 2016-06-02 16:12:54 -07:00
Hans Muller bacd3d2cb0 Revised Drawer Header (#4160) 2016-05-24 12:31:42 -07:00
Ian Hickson 3252701753 Make it possible to run tests live on a device (#3936)
This makes it possible to substitute 'flutter run' for 'flutter test'
and actually watch a test run on a device.

For any test that depends on flutter_test:

1. Remove any import of 'package:test/test.dart'.

2. Replace `testWidgets('...', (WidgetTester tester) {`
      with `testWidgets('...', (WidgetTester tester) async {`

3. Add an "await" in front of calls to any of the following:
    * tap()
    * tapAt()
    * fling()
    * flingFrom()
    * scroll()
    * scrollAt()
    * pump()
    * pumpWidget()

4. Replace any calls to `tester.flushMicrotasks()` with calls to
   `await tester.idle()`.

There's a guarding API that you can use, if you have particularly
complicated tests, to get better error messages. Search for
TestAsyncUtils.
2016-05-16 12:53:13 -07:00
Ian Hickson c5ff156f24 Revert "Rename DefaultTextStyle constructor to explicit (#3920)" (#3930)
This reverts commit 55f9145ef4.

Turns out that this commit breaks apps that use the material library,
because of the _errorTextStyle DefaultTextStyle which has inherit:true.
Just setting it to false doesn't work, unfortunately, because then you
hit some sort of issue with merging that text style with others that
have inherit:true.
2016-05-16 11:08:07 -07:00
Adam Barth 55f9145ef4 Rename DefaultTextStyle constructor to explicit (#3920)
To make it clear that this constructor requires an explicit style. Also
throw a descriptive error recommending the inherit constructor for
styles with the inherit bit set.

Fixes #3842
2016-05-16 10:35:35 -07:00
Jason Simmons 09dde8718b Change the Android activity launch mode to singleTop (#3792) 2016-05-09 09:31:34 -07:00
Adam Barth ee903af03f Move TextAlign out of TextStyle (#3789)
TextAlign applies to a whole paragraph instead of applying to an individual
text span. This patch moves the property out of TextStyle and into a separate
property on Text and RichText.
2016-05-06 17:33:27 -07:00
Devon Carew e464a81998 remove the packages/flutter_tools/.analysis_options file (#3733) 2016-05-04 11:43:01 -07:00
Adam Barth b2fa6c250a Fix the padding and space for FlatButton and RaisedButton (#3650)
Instead of incorporating the margin into the button, introduce a ButtonBar
widget that supplies the proper spacing between the buttons. Also, make these
buttons more configurable via ButtonTheme so that dialogs can change the
minWidth and padding of the buttons as required by the spec.

Fixes #1843
Fixes #3184
2016-04-29 16:13:25 -07:00
Ian Hickson 91dd969966 Refactor the test framework (#3622)
* Refactor widget test framework

Instead of:

```dart
  test("Card Collection smoke test", () {
    testWidgets((WidgetTester tester) {
```

...you now say:

```dart
  testWidgets("Card Collection smoke test", (WidgetTester tester) {
```

Instead of:

```dart
  expect(tester, hasWidget(find.text('hello')));
```

...you now say:

```dart
  expect(find.text('hello'), findsOneWidget);
```

Instead of the previous API (exists, widgets, widget, stateOf,
elementOf, etc), you now have the following comprehensive API. All these
are functions that take a Finder, except the all* properties.

* `any()` - true if anything matches, c.f. `Iterable.any`
* `allWidgets` - all the widgets in the tree
* `widget()` - the one and only widget that matches the finder
* `firstWidget()` - the first widget that matches the finder
* `allElements` - all the elements in the tree
* `element()` - the one and only element that matches the finder
* `firstElement()` - the first element that matches the finder
* `allStates` - all the `State`s in the tree
* `state()` - the one and only state that matches the finder
* `firstState()` - the first state that matches the finder
* `allRenderObjects` - all the render objects in the tree
* `renderObject()` - the one and only render object that matches the finder
* `firstRenderObject()` - the first render object that matches the finder

There's also `layers' which returns the list of current layers.

`tap`, `fling`, getCenter, getSize, etc, take Finders, like the APIs
above, and expect there to only be one matching widget.

The finders are:

 * `find.text(String text)`
 * `find.widgetWithText(Type widgetType, String text)`
 * `find.byKey(Key key)`
 * `find.byType(Type type)`
 * `find.byElementType(Type type)`
 * `find.byConfig(Widget config)`
 * `find.byWidgetPredicate(WidgetPredicate predicate)`
 * `find.byElementPredicate(ElementPredicate predicate)`

The matchers (for `expect`) are:

 * `findsNothing`
 * `findsWidgets`
 * `findsOneWidget`
 * `findsNWidgets(n)`
 * `isOnStage`
 * `isOffStage`
 * `isInCard`
 * `isNotInCard`

Benchmarks now use benchmarkWidgets instead of testWidgets.

Also, for those of you using mockers, `serviceMocker` now automatically
handles the binding initialization.

This patch also:

* changes how tests are run so that we can more easily swap the logic
  out for a "real" mode instead of FakeAsync.

* introduces CachingIterable.

* changes how flutter_driver interacts with the widget tree to use the
  aforementioned new API rather than ElementTreeTester, which is gone.

* removes ElementTreeTester.

* changes the semantics of a test for scrollables because we couldn't
  convince ourselves that the old semantics made sense; it only worked
  before because flushing the microtasks after every event was broken.

* fixes the flushing of microtasks after every event.

* Reindent the tests

* Fix review comments
2016-04-29 13:23:27 -07:00
Ian Hickson c167efca17 Minor widget_tester refactoring and docs (#3472)
This reorders some classes so that this file makes more sense, and adds
a bunch of docs. It also makes the following changes:

* Move allElements from Instrumentation to TestWidgets. (Instrumentation
  is going away.)

* Remove findElements.

* Rename byElement to byElementPredicate

* Rename byPredicate to byWidgetPredicate

* Implement _WidgetPredicateFinder so that byWidgetPredicate has good
  messages

* Fix one use of byElementPredicate to use byWidgetPredicate.
2016-04-21 16:35:46 -07:00
Ian Hickson 1b9476c4d9 Hide routes from the API when they're not needed. (#3431)
The 'routes' table is a point of confusion with new developers. By
providing a 'home' argument that sets the '/' route, we can delay the
point at which we teach developers about 'routes' until the point where
they want to have a second route.
2016-04-20 09:33:28 -07:00
Yegor f3a4f722c4 [flutter_test] new WidgetTester API based on finder objects (#3288) 2016-04-13 23:40:15 -07:00
Ian Hickson 7861d02943 Fix dependency skew. (#3306)
...by adding tests to our examples that don't import flutter_test, which
pins the relevant dependencies.

Also, provide more information when complaining about leaked transient
callbacks in tests.

Also, make tests display full information when they have an exception,
by bypassing the throttling we have for Android logging in tests.

Also, make the word wrapping not wrap stack traces if they happen to
be included in exception output.

Also, fix a leaked transient callback in the checkbox code.
2016-04-13 13:53:39 -07:00
Adam Barth 907215df27 Add more dartdoc to material.dart (#3167)
Also, clean up a few interfaces that looked awkward when writing docs.
2016-04-07 10:03:59 -07:00
Adam Barth f71d470154 Add Stocks to the Mozart manual test 2016-04-06 17:16:11 -07:00
Adam Barth 6fd6859793 LazyBlock docs and physics
This patch adds dartdoc to LazyBlock. Also, this patch fixes the scrolling
physics of LazyBlock. Previously, we updated a running simulation only when the
change in scroll behavior changed the current scroll offset. Now we update
running simulations every time the behavior changes because the simulation
might depend on quantities other than the current scroll offset.
2016-04-06 12:36:54 -07:00
Adam Barth 40899eb274 Port clients of ScrollableMixedWidgetList to LazyBlock
LazyBlock is going to replace ScrollableMixedWidgetList at some point.
2016-04-05 20:18:35 -07:00
Ian Hickson 6d58770499 Fix the fixed height card demo
Turns out card_collection had all kinds of bugs.
2016-04-01 16:10:22 -07:00
Ian Hickson b4e4c70375 Bring the hamburger menu back to card_collection 2016-04-01 14:55:20 -07:00
Adam Barth 1ba539a661 Add constants for FractionalOffsets
Adds some names for common FractionalOffset values.
2016-03-28 22:51:06 -07:00
Hixie 9fc29dbbb8 Support hairline borders
Previously, border with '0' was ambiguous. Sometimes we treated it as
hairline borders, sometimes as "don't show the border", though even in
the latter case we did some graphics work sometimes. Now we have an
explicit BorderStyle.none flag to not draw the border efficiently.
2016-03-24 14:05:38 -07:00
Adam Barth 502a4ae078 Use FractionalOffset for gradients
These were using Offsets, but they're really FractionalOffsets.

Fixes #2318
2016-03-15 19:30:41 -07:00
Hixie 797e27edd3 Add @override annotations to flutter framework 2016-03-14 14:02:26 -07:00
Adam Barth e2744e9a30 Stop using a prebuilt APK
Instead, require an AndroidManifest.xml and always build an APK.

Fixes #2517
2016-03-14 13:32:00 -07:00
Adam Barth d5b2e2a01c [rename fixit] Flex alignments
* justifyContent -> mainAxisAlignment
* alignItems -> crossAxisAlignment
* FlexJustifyContent -> MainAxisAlignment
* FlexAlignItems -> CrossAxisAlignment

Fixes #231
2016-03-12 18:33:47 -08:00
Adam Barth 5e1af2f37e [rename fixit] DismissDirection left -> endToStart, right -> startToEnd
Removes an LTR bias in DismissDirection.

Fixes #2562
2016-03-12 18:33:47 -08:00
Adam Barth ede5dfce30 [rename fixit] ToolBar -> AppBar
* left -> leading (Removes an LTR bias)
* center -> title (Widget was actually centered)
* right -> actions (Removes an LTR bias, asymmetric with leading)

Fixes #2348
2016-03-12 18:33:47 -08:00
Adam Barth 9b9ad3db17 [rename fixit] RouteBuilder -> BuildContext
Fixes #2353
2016-03-12 17:18:31 -08:00