• Alexander Aprelev's avatar
    Roll engine to b6df7a637498ca9beda1fa9cd7210e3202ea599f. (#15444) · 2f8474f9
    Alexander Aprelev authored
    * Roll engine to b6df7a637498ca9beda1fa9cd7210e3202ea599f.
    
    Changes since last roll:
    ```
    b6df7a637 Roll dart to 290c576264faa096a0b3206c71b2435309d9f904. (#4771)
    a6764dbd5 Add sources for Fuchsia target. (#4763)
    2d5900615 [fuchsia] Remove unused header file. (#4769)
    9717063b7 Revert "Roll dart to c080951d45e79cd25df98036c4be835b284a269c. (#4767)" (#4768)
    9a9814312 Roll dart to c080951d45e79cd25df98036c4be835b284a269c. (#4767)
    e74e8b35c [async] Update includes of async headers to new path (#4760)
    e2c4b2760 Use Dart 2 camel case constants in the engine Dart libraries (#4766)
    9c1e48434 Updates for Fuchsia roll. (#4765)
    14c940e27 Switch from fxl::Mutex to std::mutex (#4764)
    debf82c0b Roll Garnet (#4759)
    5bffdefbb Use weak pointers to the accesibility bridge from objects vended to the UIKit accessibility framework. (#4761)
    ```
    2f8474f9
animated_icons.dart 2.89 KB
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';

class AnimatedIconsTestApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Animated Icons Test',
      home: const Scaffold(
        body: const IconsList(),
      ),
    );
  }
}

class IconsList extends StatelessWidget {
  const IconsList();

  @override
  Widget build(BuildContext context) {
    return new ListView(
      children: samples.map((IconSample s) => new IconSampleRow(s)).toList(),
    );
  }
}

class IconSampleRow extends StatefulWidget {
  const IconSampleRow(this.sample);

  final IconSample sample;

  @override
  State createState() => new IconSampleRowState();
}

class IconSampleRowState extends State<IconSampleRow> with SingleTickerProviderStateMixin {
  AnimationController progress;

  @override
  Widget build(BuildContext context) {
    return new ListTile(
      leading: new InkWell(
        onTap: () { progress.forward(from: 0.0); },
        child: new AnimatedIcon(
          icon: widget.sample.icon,
          progress: progress,
          color: Colors.lightBlue,
        ),
      ),
      title: new Text(widget.sample.description),
      subtitle: new Slider(
        value: progress.value,
        onChanged: (double v) { progress.animateTo(v, duration: Duration.zero); },
      ),
    );
  }

  @override
  void initState() {
    super.initState();
    progress = new AnimationController(vsync: this, duration: const Duration(milliseconds: 300));
    progress.addListener(_handleChange);
  }

  @override
  void dispose() {
    progress.removeListener(_handleChange);
    super.dispose();
  }

  void _handleChange() {
    setState(() {});
  }
}

const List<IconSample> samples = const <IconSample> [
  const IconSample(AnimatedIcons.arrow_menu, 'arrow_menu'),
  const IconSample(AnimatedIcons.menu_arrow, 'menu_arrow'),

  const IconSample(AnimatedIcons.close_menu, 'close_menu'),
  const IconSample(AnimatedIcons.menu_close, 'menu_close'),

  const IconSample(AnimatedIcons.home_menu, 'home_menu'),
  const IconSample(AnimatedIcons.menu_home, 'menu_home'),

  const IconSample(AnimatedIcons.play_pause, 'play_pause'),
  const IconSample(AnimatedIcons.pause_play, 'pause_play'),

  const IconSample(AnimatedIcons.list_view, 'list_view'),
  const IconSample(AnimatedIcons.view_list, 'view_list'),

  const IconSample(AnimatedIcons.add_event, 'add_event'),
  const IconSample(AnimatedIcons.event_add, 'event_add'),

  const IconSample(AnimatedIcons.ellipsis_search, 'ellipsis_search'),
  const IconSample(AnimatedIcons.search_ellipsis, 'search_ellipsis'),
];

class IconSample {
  const IconSample(this.icon, this.description);
  final AnimatedIconData icon;
  final String description;
}

void main() => runApp(new AnimatedIconsTestApp());