animated_icons_data.dart 5.13 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6 7 8 9 10
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file serves as the interface between the public and private APIs for
// animated icons.
// The AnimatedIcons class is public and is used to specify available icons,
// while the _AnimatedIconData interface which used to deliver the icon data is
// kept private.

11
part of material_animated_icons; // ignore: use_string_in_part_of_directives
12

13
/// Identifier for the supported Material Design animated icons.
14 15
///
/// Use with [AnimatedIcon] class to show specific animated icons.
16 17 18 19 20 21 22 23 24 25 26
///
/// {@tool dartpad}
/// This example shows how to create an animated icon. The icon is animated
/// forward and reverse in a loop.
///
/// ** See code in examples/api/lib/material/animated_icon/animated_icons_data.0.dart **
/// {@end-tool}
///
/// See also:
///
///  * [Icons], for the list of available static Material Icons.
27
abstract final class AnimatedIcons {
28
  /// The Material Design add to event icon animation.
29 30
  ///
  /// {@animation 72 72 https://flutter.github.io/assets-for-api-docs/assets/widgets/add_event.mp4}
31 32
  static const AnimatedIconData add_event = _$add_event;

33
  /// The Material Design arrow to menu icon animation.
34 35
  ///
  /// {@animation 72 72 https://flutter.github.io/assets-for-api-docs/assets/widgets/arrow_menu.mp4}
36 37
  static const AnimatedIconData arrow_menu = _$arrow_menu;

38
  /// The Material Design close to menu icon animation.
39 40
  ///
  /// {@animation 72 72 https://flutter.github.io/assets-for-api-docs/assets/widgets/close_menu.mp4}
41 42
  static const AnimatedIconData close_menu = _$close_menu;

43
  /// The Material Design ellipsis to search icon animation.
44 45
  ///
  /// {@animation 72 72 https://flutter.github.io/assets-for-api-docs/assets/widgets/ellipsis_search.mp4}
46 47
  static const AnimatedIconData ellipsis_search = _$ellipsis_search;

48
  /// The Material Design event to add icon animation.
49 50
  ///
  /// {@animation 72 72 https://flutter.github.io/assets-for-api-docs/assets/widgets/event_add.mp4}
51 52
  static const AnimatedIconData event_add = _$event_add;

53
  /// The Material Design home to menu icon animation.
54 55
  ///
  /// {@animation 72 72 https://flutter.github.io/assets-for-api-docs/assets/widgets/home_menu.mp4}
56 57
  static const AnimatedIconData home_menu = _$home_menu;

58
  /// The Material Design list to view icon animation.
59 60
  ///
  /// {@animation 72 72 https://flutter.github.io/assets-for-api-docs/assets/widgets/list_view.mp4}
61 62
  static const AnimatedIconData list_view = _$list_view;

63
  /// The Material Design menu to arrow icon animation.
64 65
  ///
  /// {@animation 72 72 https://flutter.github.io/assets-for-api-docs/assets/widgets/menu_arrow.mp4}
66
  static const AnimatedIconData menu_arrow = _$menu_arrow;
67

68
  /// The Material Design menu to close icon animation.
69 70
  ///
  /// {@animation 72 72 https://flutter.github.io/assets-for-api-docs/assets/widgets/menu_close.mp4}
71 72
  static const AnimatedIconData menu_close = _$menu_close;

73
  /// The Material Design menu to home icon animation.
74 75
  ///
  /// {@animation 72 72 https://flutter.github.io/assets-for-api-docs/assets/widgets/menu_home.mp4}
76 77
  static const AnimatedIconData menu_home = _$menu_home;

78
  /// The Material Design pause to play icon animation.
79 80
  ///
  /// {@animation 72 72 https://flutter.github.io/assets-for-api-docs/assets/widgets/pause_play.mp4}
81 82
  static const AnimatedIconData pause_play = _$pause_play;

83
  /// The Material Design play to pause icon animation.
84 85
  ///
  /// {@animation 72 72 https://flutter.github.io/assets-for-api-docs/assets/widgets/play_pause.mp4}
86 87
  static const AnimatedIconData play_pause = _$play_pause;

88
  /// The Material Design search to ellipsis icon animation.
89 90
  ///
  /// {@animation 72 72 https://flutter.github.io/assets-for-api-docs/assets/widgets/search_ellipsis.mp4}
91 92
  static const AnimatedIconData search_ellipsis = _$search_ellipsis;

93
  /// The Material Design view to list icon animation.
94 95
  ///
  /// {@animation 72 72 https://flutter.github.io/assets-for-api-docs/assets/widgets/view_list.mp4}
96
  static const AnimatedIconData view_list = _$view_list;
97 98 99 100 101 102 103 104
}

/// Vector graphics data for icons used by [AnimatedIcon].
///
/// Instances of this class are currently opaque because we have not committed to a specific
/// animated vector graphics format.
///
/// See also:
105
///
106 107 108 109 110
///  * [AnimatedIcons], a class that contains constants that implement this interface.
abstract class AnimatedIconData {
  /// Abstract const constructor. This constructor enables subclasses to provide
  /// const constructors so that they can be used in const expressions.
  const AnimatedIconData();
111

112 113 114 115
  /// Whether this icon should be mirrored horizontally when text direction is
  /// right-to-left.
  ///
  /// See also:
116
  ///
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
  ///  * [TextDirection], which discusses concerns regarding reading direction
  ///    in Flutter.
  ///  * [Directionality], a widget which determines the ambient directionality.
  bool get matchTextDirection;
}

class _AnimatedIconData extends AnimatedIconData {
  const _AnimatedIconData(this.size, this.paths, {this.matchTextDirection = false});

  final Size size;
  final List<_PathFrames> paths;

  @override
  final bool matchTextDirection;
}