item.dart 7.77 KB
Newer Older
1 2 3 4
// Copyright 2016 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.

5 6
import 'dart:developer';

7 8
import 'package:flutter/material.dart';

9 10
import '../demo/all.dart';

11 12 13
typedef Widget GalleryDemoBuilder();

class GalleryItem extends StatelessWidget {
14
  GalleryItem({ this.title, this.subtitle, this.category: 'Components', this.routeName, this.buildRoute }) {
15 16 17 18 19
    assert(title != null);
    assert(category != null);
    assert(routeName != null);
    assert(buildRoute != null);
  }
20 21

  final String title;
22
  final String subtitle;
23
  final String category;
24
  final String routeName;
25
  final WidgetBuilder buildRoute;
26 27 28

  @override
  Widget build(BuildContext context) {
29
    return new ListItem(
30
      title: new Text(title),
31
      subtitle: new Text(subtitle),
32
      onTap: () {
33 34 35 36 37
        if (routeName != null) {
          Timeline.instantSync('Start Transition', arguments: <String, String>{
            'from': '/',
            'to': routeName
          });
38
          Navigator.pushNamed(context, routeName);
39
        }
40 41 42 43
      }
    );
  }
}
44 45 46 47 48

final List<GalleryItem> kAllGalleryItems = <GalleryItem>[
  // Demos
  new GalleryItem(
    title: 'Pesto',
49
    subtitle: 'Simple recipe browser',
50 51 52 53 54 55
    category: 'Demos',
    routeName: PestoDemo.routeName,
    buildRoute: (BuildContext context) => new PestoDemo()
  ),
  new GalleryItem(
    title: 'Shrine',
56
    subtitle:'Basic shopping app',
57 58 59 60 61
    category: 'Demos',
    routeName: ShrineDemo.routeName,
    buildRoute: (BuildContext context) => new ShrineDemo()
  ),
  new GalleryItem(
62
    title: 'Contact profile',
63
    category: 'Demos',
64
    subtitle: 'Address book entry with a flexible appbar',
65 66 67 68
    routeName: ContactsDemo.routeName,
    buildRoute: (BuildContext context) => new ContactsDemo()
  ),
  // Components
69 70 71 72 73 74
  new GalleryItem(
    title: 'Bottom navigation',
    subtitle: 'Bottom navigation with cross-fading views',
    routeName: BottomNavigationDemo.routeName,
    buildRoute: (BuildContext context) => new BottomNavigationDemo()
  ),
75 76
  new GalleryItem(
    title: 'Buttons',
77
    subtitle: 'All kinds: flat, raised, dropdown, icon, etc',
78 79 80 81 82
    routeName: ButtonsDemo.routeName,
    buildRoute: (BuildContext context) => new ButtonsDemo()
  ),
  new GalleryItem(
    title: 'Cards',
83
    subtitle: 'Material with rounded corners and a drop shadow',
84 85 86 87 88
    routeName: CardsDemo.routeName,
    buildRoute: (BuildContext context) => new CardsDemo()
  ),
  new GalleryItem(
    title: 'Chips',
89
    subtitle: 'Label with an optional delete button and avatar',
90 91 92 93 94
    routeName: ChipDemo.routeName,
    buildRoute: (BuildContext context) => new ChipDemo()
  ),
  new GalleryItem(
    title: 'Date picker',
95
    subtitle: 'Date selection widget',
96 97 98 99 100
    routeName: DatePickerDemo.routeName,
    buildRoute: (BuildContext context) => new DatePickerDemo()
  ),
  new GalleryItem(
    title: 'Dialog',
101
    subtitle: 'All kinds: simple, alert, fullscreen, etc',
102 103 104 105 106
    routeName: DialogDemo.routeName,
    buildRoute: (BuildContext context) => new DialogDemo()
  ),
  new GalleryItem(
    title: 'Expand/collapse list control',
107
    subtitle: 'List with one level of sublists',
108 109 110
    routeName: TwoLevelListDemo.routeName,
    buildRoute: (BuildContext context) => new TwoLevelListDemo()
  ),
111 112
  new GalleryItem(
    title: 'Expansion panels',
113
    subtitle: 'List of expanding panels',
114 115 116
    routeName: ExpasionPanelsDemo.routeName,
    buildRoute: (BuildContext context) => new ExpasionPanelsDemo()
  ),
117 118
  new GalleryItem(
    title: 'Floating action button',
119
    subtitle: 'Action buttons with transitions',
120 121 122 123 124
    routeName: TabsFabDemo.routeName,
    buildRoute: (BuildContext context) => new TabsFabDemo()
  ),
  new GalleryItem(
    title: 'Grid',
125
    subtitle: 'Row and column layout',
126 127 128 129 130
    routeName: GridListDemo.routeName,
    buildRoute: (BuildContext context) => new GridListDemo()
  ),
  new GalleryItem(
    title: 'Icons',
131
    subtitle: 'Enabled and disabled icons with varying opacity',
132 133 134 135 136
    routeName: IconsDemo.routeName,
    buildRoute: (BuildContext context) => new IconsDemo()
  ),
  new GalleryItem(
    title: 'Leave-behind list items',
137
    subtitle: 'List items with hidden actions',
138 139 140 141 142
    routeName: LeaveBehindDemo.routeName,
    buildRoute: (BuildContext context) => new LeaveBehindDemo()
  ),
  new GalleryItem(
    title: 'List',
143
    subtitle: 'Layout variations for scrollable lists',
144 145 146 147 148
    routeName: ListDemo.routeName,
    buildRoute: (BuildContext context) => new ListDemo()
  ),
  new GalleryItem(
    title: 'Menus',
149
    subtitle: 'Menu buttons and simple menus',
150 151 152 153 154
    routeName: MenuDemo.routeName,
    buildRoute: (BuildContext context) => new MenuDemo()
  ),
  new GalleryItem(
    title: 'Modal bottom sheet',
155
    subtitle: 'Modal sheet that slides up from the bottom',
156 157 158 159 160
    routeName: ModalBottomSheetDemo.routeName,
    buildRoute: (BuildContext context) => new ModalBottomSheetDemo()
  ),
  new GalleryItem(
    title: 'Over-scroll',
161
    subtitle: 'Refresh and overscroll indicators',
162 163 164 165 166
    routeName: OverscrollDemo.routeName,
    buildRoute: (BuildContext context) => new OverscrollDemo()
  ),
  new GalleryItem(
    title: 'Page selector',
167
    subtitle: 'Pageable list with indicator',
168 169 170 171 172
    routeName: PageSelectorDemo.routeName,
    buildRoute: (BuildContext context) => new PageSelectorDemo()
  ),
  new GalleryItem(
    title: 'Persistent bottom sheet',
173
    subtitle: 'Sheet that slides up from the bottom',
174 175 176 177 178
    routeName: PersistentBottomSheetDemo.routeName,
    buildRoute: (BuildContext context) => new PersistentBottomSheetDemo()
  ),
  new GalleryItem(
    title: 'Progress indicators',
179
    subtitle: 'All kinds: linear, circular, indeterminate, etc',
180 181 182 183 184
    routeName: ProgressIndicatorDemo.routeName,
    buildRoute: (BuildContext context) => new ProgressIndicatorDemo()
  ),
  new GalleryItem(
    title: 'Scrollable tabs',
185
    subtitle: 'Tab bar that scrolls',
186 187 188 189 190
    routeName: ScrollableTabsDemo.routeName,
    buildRoute: (BuildContext context) => new ScrollableTabsDemo()
  ),
  new GalleryItem(
    title: 'Selection controls',
191
    subtitle: 'Checkboxes, radio buttons, and switches',
192 193 194 195 196
    routeName: SelectionControlsDemo.routeName,
    buildRoute: (BuildContext context) => new SelectionControlsDemo()
  ),
  new GalleryItem(
    title: 'Sliders',
197
    subtitle: 'Widgets that select a value by dragging the slider thumb',
198 199 200 201 202
    routeName: SliderDemo.routeName,
    buildRoute: (BuildContext context) => new SliderDemo()
  ),
  new GalleryItem(
    title: 'Snackbar',
203
    subtitle: 'Temporary message that appears at the bottom',
204 205 206 207 208
    routeName: SnackBarDemo.routeName,
    buildRoute: (BuildContext context) => new SnackBarDemo()
  ),
  new GalleryItem(
    title: 'Tabs',
209
    subtitle: 'Tabs with independently scrollable views',
210 211 212 213 214
    routeName: TabsDemo.routeName,
    buildRoute: (BuildContext context) => new TabsDemo()
  ),
  new GalleryItem(
    title: 'Text fields',
215
    subtitle: 'Single line of editable text and numbers',
216 217 218 219 220
    routeName: TextFieldDemo.routeName,
    buildRoute: (BuildContext context) => new TextFieldDemo()
  ),
  new GalleryItem(
    title: 'Time picker',
221
    subtitle: 'Hour and minute selection widget',
222 223 224 225 226
    routeName: TimePickerDemo.routeName,
    buildRoute: (BuildContext context) => new TimePickerDemo()
  ),
  new GalleryItem(
    title: 'Tooltips',
227
    subtitle: 'Short message displayed after a long-press',
228 229 230 231 232 233
    routeName: TooltipDemo.routeName,
    buildRoute: (BuildContext context) => new TooltipDemo()
  ),
  // Styles
  new GalleryItem(
    title: 'Colors',
234
    subtitle: 'All of the predefined colors',
235 236 237 238 239 240
    category: 'Style',
    routeName: ColorsDemo.routeName,
    buildRoute: (BuildContext context) => new ColorsDemo()
  ),
  new GalleryItem(
    title: 'Typography',
241
    subtitle: 'All of the predefined text styles',
242 243 244 245 246
    category: 'Style',
    routeName: TypographyDemo.routeName,
    buildRoute: (BuildContext context) => new TypographyDemo()
  )
];