Implement grid list demo (#215)

pull/216/head
rami-a 5 years ago committed by GitHub
parent c804cdec22
commit a599ec3910
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

File diff suppressed because it is too large Load Diff

@ -22,6 +22,7 @@ import 'package:gallery/demos/material/bottom_sheet_demo.dart';
import 'package:gallery/demos/material/button_demo.dart';
import 'package:gallery/demos/material/chip_demo.dart';
import 'package:gallery/demos/material/dialog_demo.dart';
import 'package:gallery/demos/material/grid_list_demo.dart';
import 'package:gallery/demos/material/list_demo.dart';
import 'package:gallery/demos/material/progress_indicator_demo.dart';
import 'package:gallery/demos/material/selection_controls_demo.dart';
@ -278,6 +279,41 @@ List<GalleryDemo> materialDemos(BuildContext context) {
),
],
),
GalleryDemo(
title: GalleryLocalizations.of(context).demoGridListsTitle,
icon: GalleryIcons.gridOn,
subtitle: GalleryLocalizations.of(context).demoGridListsSubtitle,
configurations: [
GalleryDemoConfiguration(
title: GalleryLocalizations.of(context).demoGridListsImageOnlyTitle,
description:
GalleryLocalizations.of(context).demoGridListsDescription,
documentationUrl:
'https://api.flutter.dev/flutter/widgets/GridView-class.html',
buildRoute: (context) =>
GridListDemo(type: GridListDemoType.imageOnly),
code: CodeSegments.gridListsDemo,
),
GalleryDemoConfiguration(
title: GalleryLocalizations.of(context).demoGridListsHeaderTitle,
description:
GalleryLocalizations.of(context).demoGridListsDescription,
documentationUrl:
'https://api.flutter.dev/flutter/widgets/GridView-class.html',
buildRoute: (context) => GridListDemo(type: GridListDemoType.header),
code: CodeSegments.gridListsDemo,
),
GalleryDemoConfiguration(
title: GalleryLocalizations.of(context).demoGridListsFooterTitle,
description:
GalleryLocalizations.of(context).demoGridListsDescription,
documentationUrl:
'https://api.flutter.dev/flutter/widgets/GridView-class.html',
buildRoute: (context) => GridListDemo(type: GridListDemoType.footer),
code: CodeSegments.gridListsDemo,
),
],
),
GalleryDemo(
title: GalleryLocalizations.of(context).demoListsTitle,
icon: GalleryIcons.listAlt,

@ -0,0 +1,199 @@
// Copyright 2019 The Flutter team. 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';
import 'package:gallery/l10n/gallery_localizations.dart';
// BEGIN gridListsDemo
enum GridListDemoType {
imageOnly,
header,
footer,
}
class GridListDemo extends StatelessWidget {
const GridListDemo({Key key, this.type}) : super(key: key);
final GridListDemoType type;
List<_Photo> _photos(BuildContext context) {
return [
_Photo(
assetName: 'places/india_chennai_flower_market.png',
title: GalleryLocalizations.of(context).placeChennai,
subtitle: GalleryLocalizations.of(context).placeFlowerMarket,
),
_Photo(
assetName: 'places/india_tanjore_bronze_works.png',
title: GalleryLocalizations.of(context).placeTanjore,
subtitle: GalleryLocalizations.of(context).placeBronzeWorks,
),
_Photo(
assetName: 'places/india_tanjore_market_merchant.png',
title: GalleryLocalizations.of(context).placeTanjore,
subtitle: GalleryLocalizations.of(context).placeMarket,
),
_Photo(
assetName: 'places/india_tanjore_thanjavur_temple.png',
title: GalleryLocalizations.of(context).placeTanjore,
subtitle: GalleryLocalizations.of(context).placeThanjavurTemple,
),
_Photo(
assetName: 'places/india_tanjore_thanjavur_temple_carvings.png',
title: GalleryLocalizations.of(context).placeTanjore,
subtitle: GalleryLocalizations.of(context).placeThanjavurTemple,
),
_Photo(
assetName: 'places/india_pondicherry_salt_farm.png',
title: GalleryLocalizations.of(context).placePondicherry,
subtitle: GalleryLocalizations.of(context).placeSaltFarm,
),
_Photo(
assetName: 'places/india_chennai_highway.png',
title: GalleryLocalizations.of(context).placeChennai,
subtitle: GalleryLocalizations.of(context).placeScooters,
),
_Photo(
assetName: 'places/india_chettinad_silk_maker.png',
title: GalleryLocalizations.of(context).placeChettinad,
subtitle: GalleryLocalizations.of(context).placeSilkMaker,
),
_Photo(
assetName: 'places/india_chettinad_produce.png',
title: GalleryLocalizations.of(context).placeChettinad,
subtitle: GalleryLocalizations.of(context).placeLunchPrep,
),
_Photo(
assetName: 'places/india_tanjore_market_technology.png',
title: GalleryLocalizations.of(context).placeTanjore,
subtitle: GalleryLocalizations.of(context).placeMarket,
),
_Photo(
assetName: 'places/india_pondicherry_beach.png',
title: GalleryLocalizations.of(context).placePondicherry,
subtitle: GalleryLocalizations.of(context).placeBeach,
),
_Photo(
assetName: 'places/india_pondicherry_fisherman.png',
title: GalleryLocalizations.of(context).placePondicherry,
subtitle: GalleryLocalizations.of(context).placeFisherman,
),
];
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
title: Text(GalleryLocalizations.of(context).demoGridListsTitle),
),
body: GridView.count(
crossAxisCount: 2,
mainAxisSpacing: 8,
crossAxisSpacing: 8,
padding: const EdgeInsets.all(8),
childAspectRatio: 1,
children: _photos(context).map<Widget>((photo) {
return _GridDemoPhotoItem(
photo: photo,
tileStyle: type,
);
}).toList(),
),
);
}
}
class _Photo {
_Photo({
this.assetName,
this.title,
this.subtitle,
});
final String assetName;
final String title;
final String subtitle;
}
/// Allow the text size to shrink to fit in the space
class _GridTitleText extends StatelessWidget {
const _GridTitleText(this.text);
final String text;
@override
Widget build(BuildContext context) {
return FittedBox(
fit: BoxFit.scaleDown,
alignment: AlignmentDirectional.centerStart,
child: Text(text),
);
}
}
class _GridDemoPhotoItem extends StatelessWidget {
_GridDemoPhotoItem({
Key key,
@required this.photo,
@required this.tileStyle,
}) : super(key: key);
final _Photo photo;
final GridListDemoType tileStyle;
@override
Widget build(BuildContext context) {
final Widget image = Material(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)),
clipBehavior: Clip.antiAlias,
child: Image.asset(
photo.assetName,
package: 'flutter_gallery_assets',
fit: BoxFit.cover,
),
);
switch (tileStyle) {
case GridListDemoType.imageOnly:
return image;
case GridListDemoType.header:
return GridTile(
header: Material(
color: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(4)),
),
clipBehavior: Clip.antiAlias,
child: GridTileBar(
title: _GridTitleText(photo.title),
backgroundColor: Colors.black45,
),
),
child: image,
);
case GridListDemoType.footer:
return GridTile(
footer: Material(
color: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(bottom: Radius.circular(4)),
),
clipBehavior: Clip.antiAlias,
child: GridTileBar(
backgroundColor: Colors.black45,
title: _GridTitleText(photo.title),
subtitle: _GridTitleText(photo.subtitle),
),
),
child: image,
);
}
return null;
}
}
// END

@ -1870,6 +1870,51 @@ class GalleryLocalizations {
desc: r'Tooltip for Full Screen button in a demo.');
}
String get demoGridListsDescription {
return Intl.message(
r'Grid Lists are best suited for presenting homogeneous data, typically images. Each item in a grid list is called a tile.',
locale: _localeName,
name: 'demoGridListsDescription',
desc: r'Description for the grid lists component demo.');
}
String get demoGridListsFooterTitle {
return Intl.message(r'With footer',
locale: _localeName,
name: 'demoGridListsFooterTitle',
desc:
r'Title for the grid lists component demo with footers on each tile.');
}
String get demoGridListsHeaderTitle {
return Intl.message(r'With header',
locale: _localeName,
name: 'demoGridListsHeaderTitle',
desc:
r'Title for the grid lists component demo with headers on each tile.');
}
String get demoGridListsImageOnlyTitle {
return Intl.message(r'Image only',
locale: _localeName,
name: 'demoGridListsImageOnlyTitle',
desc: r'Title for the grid lists image-only component demo.');
}
String get demoGridListsSubtitle {
return Intl.message(r'Row and column layout',
locale: _localeName,
name: 'demoGridListsSubtitle',
desc: r'Subtitle for the grid lists component demo.');
}
String get demoGridListsTitle {
return Intl.message(r'Grid Lists',
locale: _localeName,
name: 'demoGridListsTitle',
desc: r'Title for the grid lists component demo.');
}
String get demoInfoTooltip {
return Intl.message(r'Info',
locale: _localeName,
@ -2624,6 +2669,104 @@ class GalleryLocalizations {
desc: r'Header title on home screen for Gallery section.');
}
String get placeBeach {
return Intl.message(r'Beach',
locale: _localeName,
name: 'placeBeach',
desc: r'Title for Beach location.');
}
String get placeBronzeWorks {
return Intl.message(r'Bronze Works',
locale: _localeName,
name: 'placeBronzeWorks',
desc: r'Title for Bronze Works location.');
}
String get placeChennai {
return Intl.message(r'Chennai',
locale: _localeName,
name: 'placeChennai',
desc: r'Title for Chennai location.');
}
String get placeChettinad {
return Intl.message(r'Chettinad',
locale: _localeName,
name: 'placeChettinad',
desc: r'Title for Chettinad location.');
}
String get placeFisherman {
return Intl.message(r'Fisherman',
locale: _localeName,
name: 'placeFisherman',
desc: r'Title for an image of a fisherman.');
}
String get placeFlowerMarket {
return Intl.message(r'Flower Market',
locale: _localeName,
name: 'placeFlowerMarket',
desc: r'Title for Flower Market location.');
}
String get placeLunchPrep {
return Intl.message(r'Lunch Prep',
locale: _localeName,
name: 'placeLunchPrep',
desc: r'Title for an image of preparing lunch.');
}
String get placeMarket {
return Intl.message(r'Market',
locale: _localeName,
name: 'placeMarket',
desc: r'Title for Market location.');
}
String get placePondicherry {
return Intl.message(r'Pondicherry',
locale: _localeName,
name: 'placePondicherry',
desc: r'Title for Pondicherry location.');
}
String get placeSaltFarm {
return Intl.message(r'Salt Farm',
locale: _localeName,
name: 'placeSaltFarm',
desc: r'Title for Salt Farm location.');
}
String get placeScooters {
return Intl.message(r'Scooters',
locale: _localeName,
name: 'placeScooters',
desc: r'Title for image of people riding on scooters.');
}
String get placeSilkMaker {
return Intl.message(r'Silk Maker',
locale: _localeName,
name: 'placeSilkMaker',
desc: r'Title for an image of a silk maker.');
}
String get placeTanjore {
return Intl.message(r'Tanjore',
locale: _localeName,
name: 'placeTanjore',
desc: r'Title for Tanjore location.');
}
String get placeThanjavurTemple {
return Intl.message(r'Thanjavur Temple',
locale: _localeName,
name: 'placeThanjavurTemple',
desc: r'Title for Thanjavur Temple location.');
}
String rallyAccountAmount(
Object accountName, Object accountNumber, Object amount) {
return Intl.message(r'$accountName account $accountNumber with $amount.',

@ -613,6 +613,30 @@
"@demoSimpleDialogDescription": {
"description": "Description for the simple dialog component demo."
},
"demoGridListsTitle": "Grid Lists",
"@demoGridListsTitle": {
"description": "Title for the grid lists component demo."
},
"demoGridListsSubtitle": "Row and column layout",
"@demoGridListsSubtitle": {
"description": "Subtitle for the grid lists component demo."
},
"demoGridListsDescription": "Grid Lists are best suited for presenting homogeneous data, typically images. Each item in a grid list is called a tile.",
"@demoGridListsDescription": {
"description": "Description for the grid lists component demo."
},
"demoGridListsImageOnlyTitle": "Image only",
"@demoGridListsImageOnlyTitle": {
"description": "Title for the grid lists image-only component demo."
},
"demoGridListsHeaderTitle": "With header",
"@demoGridListsHeaderTitle": {
"description": "Title for the grid lists component demo with headers on each tile."
},
"demoGridListsFooterTitle": "With footer",
"@demoGridListsFooterTitle": {
"description": "Title for the grid lists component demo with footers on each tile."
},
"demoSlidersTitle": "Sliders",
"@demoSlidersTitle": {
"description": "Title for the sliders component demo."
@ -1402,6 +1426,62 @@
"@colorsBlueGrey": {
"description": "Tab title for the color blue grey."
},
"placeChennai": "Chennai",
"@placeChennai": {
"description": "Title for Chennai location."
},
"placeTanjore": "Tanjore",
"@placeTanjore": {
"description": "Title for Tanjore location."
},
"placeChettinad": "Chettinad",
"@placeChettinad": {
"description": "Title for Chettinad location."
},
"placePondicherry": "Pondicherry",
"@placePondicherry": {
"description": "Title for Pondicherry location."
},
"placeFlowerMarket": "Flower Market",
"@placeFlowerMarket": {
"description": "Title for Flower Market location."
},
"placeBronzeWorks": "Bronze Works",
"@placeBronzeWorks": {
"description": "Title for Bronze Works location."
},
"placeMarket": "Market",
"@placeMarket": {
"description": "Title for Market location."
},
"placeThanjavurTemple": "Thanjavur Temple",
"@placeThanjavurTemple": {
"description": "Title for Thanjavur Temple location."
},
"placeSaltFarm": "Salt Farm",
"@placeSaltFarm": {
"description": "Title for Salt Farm location."
},
"placeScooters": "Scooters",
"@placeScooters": {
"description": "Title for image of people riding on scooters."
},
"placeSilkMaker": "Silk Maker",
"@placeSilkMaker": {
"description": "Title for an image of a silk maker."
},
"placeLunchPrep": "Lunch Prep",
"@placeLunchPrep": {
"description": "Title for an image of preparing lunch."
},
"placeBeach": "Beach",
"@placeBeach": {
"description": "Title for Beach location."
},
"placeFisherman": "Fisherman",
"@placeFisherman": {
"description": "Title for an image of a fisherman."
},
"starterAppTitle": "Starter app",
"@starterAppTitle": {
"description": "The title and name for the starter app."

@ -577,6 +577,30 @@
name="demoSimpleDialogDescription"
description="Description for the simple dialog component demo."
>A simple dialog offers the user a choice between several options. A simple dialog has an optional title that is displayed above the choices.</string>
<string
name="demoGridListsTitle"
description="Title for the grid lists component demo."
>Grid Lists</string>
<string
name="demoGridListsSubtitle"
description="Subtitle for the grid lists component demo."
>Row and column layout</string>
<string
name="demoGridListsDescription"
description="Description for the grid lists component demo."
>Grid Lists are best suited for presenting homogeneous data, typically images. Each item in a grid list is called a tile.</string>
<string
name="demoGridListsImageOnlyTitle"
description="Title for the grid lists image-only component demo."
>Image only</string>
<string
name="demoGridListsHeaderTitle"
description="Title for the grid lists component demo with headers on each tile."
>With header</string>
<string
name="demoGridListsFooterTitle"
description="Title for the grid lists component demo with footers on each tile."
>With footer</string>
<string
name="demoSlidersTitle"
description="Title for the sliders component demo."
@ -1329,6 +1353,62 @@
name="colorsBlueGrey"
description="Tab title for the color blue grey."
>BLUE GREY</string>
<string
name="placeChennai"
description="Title for Chennai location."
>Chennai</string>
<string
name="placeTanjore"
description="Title for Tanjore location."
>Tanjore</string>
<string
name="placeChettinad"
description="Title for Chettinad location."
>Chettinad</string>
<string
name="placePondicherry"
description="Title for Pondicherry location."
>Pondicherry</string>
<string
name="placeFlowerMarket"
description="Title for Flower Market location."
>Flower Market</string>
<string
name="placeBronzeWorks"
description="Title for Bronze Works location."
>Bronze Works</string>
<string
name="placeMarket"
description="Title for Market location."
>Market</string>
<string
name="placeThanjavurTemple"
description="Title for Thanjavur Temple location."
>Thanjavur Temple</string>
<string
name="placeSaltFarm"
description="Title for Salt Farm location."
>Salt Farm</string>
<string
name="placeScooters"
description="Title for image of people riding on scooters."
>Scooters</string>
<string
name="placeSilkMaker"
description="Title for an image of a silk maker."
>Silk Maker</string>
<string
name="placeLunchPrep"
description="Title for an image of preparing lunch."
>Lunch Prep</string>
<string
name="placeBeach"
description="Title for Beach location."
>Beach</string>
<string
name="placeFisherman"
description="Title for an image of a fisherman."
>Fisherman</string>
<string
name="starterAppTitle"
description="The title and name for the starter app."

@ -486,6 +486,18 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Fullscreen"),
"demoFullscreenTooltip":
MessageLookupByLibrary.simpleMessage("Full Screen"),
"demoGridListsDescription": MessageLookupByLibrary.simpleMessage(
"Grid Lists are best suited for presenting homogeneous data, typically images. Each item in a grid list is called a tile."),
"demoGridListsFooterTitle":
MessageLookupByLibrary.simpleMessage("With footer"),
"demoGridListsHeaderTitle":
MessageLookupByLibrary.simpleMessage("With header"),
"demoGridListsImageOnlyTitle":
MessageLookupByLibrary.simpleMessage("Image only"),
"demoGridListsSubtitle":
MessageLookupByLibrary.simpleMessage("Row and column layout"),
"demoGridListsTitle":
MessageLookupByLibrary.simpleMessage("Grid Lists"),
"demoInfoTooltip": MessageLookupByLibrary.simpleMessage("Info"),
"demoInputChipDescription": MessageLookupByLibrary.simpleMessage(
"Input chips represent a complex piece of information, such as an entity (person, place, or thing) or conversational text, in a compact form."),
@ -675,6 +687,23 @@ class MessageLookup extends MessageLookupByLibrary {
"homeHeaderCategories":
MessageLookupByLibrary.simpleMessage("Categories"),
"homeHeaderGallery": MessageLookupByLibrary.simpleMessage("Gallery"),
"placeBeach": MessageLookupByLibrary.simpleMessage("Beach"),
"placeBronzeWorks":
MessageLookupByLibrary.simpleMessage("Bronze Works"),
"placeChennai": MessageLookupByLibrary.simpleMessage("Chennai"),
"placeChettinad": MessageLookupByLibrary.simpleMessage("Chettinad"),
"placeFisherman": MessageLookupByLibrary.simpleMessage("Fisherman"),
"placeFlowerMarket":
MessageLookupByLibrary.simpleMessage("Flower Market"),
"placeLunchPrep": MessageLookupByLibrary.simpleMessage("Lunch Prep"),
"placeMarket": MessageLookupByLibrary.simpleMessage("Market"),
"placePondicherry": MessageLookupByLibrary.simpleMessage("Pondicherry"),
"placeSaltFarm": MessageLookupByLibrary.simpleMessage("Salt Farm"),
"placeScooters": MessageLookupByLibrary.simpleMessage("Scooters"),
"placeSilkMaker": MessageLookupByLibrary.simpleMessage("Silk Maker"),
"placeTanjore": MessageLookupByLibrary.simpleMessage("Tanjore"),
"placeThanjavurTemple":
MessageLookupByLibrary.simpleMessage("Thanjavur Temple"),
"rallyAccountAmount": m11,
"rallyAccountDataCarSavings":
MessageLookupByLibrary.simpleMessage("Car Savings"),

@ -118,6 +118,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_gallery_assets:
dependency: "direct main"
description:
name: flutter_gallery_assets
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.9+2"
flutter_localizations:
dependency: "direct main"
description: flutter

@ -27,6 +27,7 @@ dependencies:
ref: 76bfbf9654c3842d735181383f7ab86c312a2483
shared_preferences: ^0.5.4+8
collection: ^1.14.0
flutter_gallery_assets: 0.1.9+2
dev_dependencies:
flutter_test:
@ -47,6 +48,19 @@ flutter:
- packages/rally_assets/thumb.png
- assets/crane/logo/
- assets/crane/destinations/
- packages/flutter_gallery_assets/places/india_chennai_flower_market.png
- packages/flutter_gallery_assets/places/india_thanjavur_market.png
- packages/flutter_gallery_assets/places/india_tanjore_bronze_works.png
- packages/flutter_gallery_assets/places/india_tanjore_market_merchant.png
- packages/flutter_gallery_assets/places/india_tanjore_thanjavur_temple.png
- packages/flutter_gallery_assets/places/india_pondicherry_salt_farm.png
- packages/flutter_gallery_assets/places/india_chennai_highway.png
- packages/flutter_gallery_assets/places/india_chettinad_silk_maker.png
- packages/flutter_gallery_assets/places/india_tanjore_thanjavur_temple_carvings.png
- packages/flutter_gallery_assets/places/india_chettinad_produce.png
- packages/flutter_gallery_assets/places/india_tanjore_market_technology.png
- packages/flutter_gallery_assets/places/india_pondicherry_beach.png
- packages/flutter_gallery_assets/places/india_pondicherry_fisherman.png
- packages/shrine_images/diamond.png
- packages/shrine_images/slanted_menu.png
- packages/shrine_images/0-0.jpg

Loading…
Cancel
Save