mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 14:58:34 +00:00
Adds the start of a new sample showcasing Cupertino widgets. (#12)
This commit is contained in:
88
veggieseasons/lib/data/veggie.dart
Normal file
88
veggieseasons/lib/data/veggie.dart
Normal file
@@ -0,0 +1,88 @@
|
||||
// Copyright 2018 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:meta/meta.dart';
|
||||
|
||||
enum VeggieCategory {
|
||||
legume,
|
||||
tuber,
|
||||
cruciferous,
|
||||
gourd,
|
||||
leafy,
|
||||
berry,
|
||||
stealthFruit,
|
||||
tropical,
|
||||
fruit,
|
||||
melon,
|
||||
stoneFruit,
|
||||
fern,
|
||||
citrus,
|
||||
root,
|
||||
allium,
|
||||
fungus,
|
||||
vegetable,
|
||||
}
|
||||
|
||||
enum Season {
|
||||
winter,
|
||||
spring,
|
||||
summer,
|
||||
autumn,
|
||||
}
|
||||
|
||||
final Map<VeggieCategory, String> veggieCategoryNames = {
|
||||
VeggieCategory.legume: 'Legume',
|
||||
VeggieCategory.tuber: 'Tuber',
|
||||
VeggieCategory.cruciferous: 'Cruciferous',
|
||||
VeggieCategory.gourd: 'Gourd',
|
||||
VeggieCategory.leafy: 'Leafy',
|
||||
VeggieCategory.berry: 'Berry',
|
||||
VeggieCategory.stealthFruit: 'Stealth fruit',
|
||||
VeggieCategory.tropical: 'Tropical',
|
||||
VeggieCategory.fruit: 'Fruit',
|
||||
VeggieCategory.melon: 'Melon',
|
||||
VeggieCategory.stoneFruit: 'Stone fruit',
|
||||
VeggieCategory.fern: 'Technically fern',
|
||||
VeggieCategory.citrus: 'Citrus',
|
||||
VeggieCategory.root: 'Root vegetable',
|
||||
VeggieCategory.allium: 'Allium',
|
||||
VeggieCategory.fungus: 'Fungus',
|
||||
VeggieCategory.vegetable: 'Vegetable',
|
||||
};
|
||||
|
||||
class Veggie {
|
||||
Veggie({
|
||||
@required this.id,
|
||||
@required this.name,
|
||||
@required this.imageAssetPath,
|
||||
@required this.category,
|
||||
@required this.shortDescription,
|
||||
@required this.accentColor,
|
||||
@required this.seasons,
|
||||
this.isFavorite = false,
|
||||
});
|
||||
|
||||
final int id;
|
||||
|
||||
final String name;
|
||||
|
||||
/// Each veggie has an associated image asset that's used as a background
|
||||
/// image and icon.
|
||||
final String imageAssetPath;
|
||||
|
||||
final VeggieCategory category;
|
||||
|
||||
final String shortDescription;
|
||||
|
||||
/// A color value to use when constructing UI elements to match the image
|
||||
/// found at [imageAssetPath].
|
||||
final int accentColor;
|
||||
|
||||
/// Seasons during which a veggie is harvested.
|
||||
final List<Season> seasons;
|
||||
|
||||
/// Whether or not the veggie has been saved to the user's garden (i.e. marked
|
||||
/// as a favorite).
|
||||
bool isFavorite;
|
||||
}
|
||||
22
veggieseasons/lib/main.dart
Normal file
22
veggieseasons/lib/main.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2018 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/cupertino.dart';
|
||||
import 'package:flutter/services.dart' show DeviceOrientation, SystemChrome;
|
||||
import 'package:veggieseasons/screens/home.dart';
|
||||
import 'package:veggieseasons/styles.dart';
|
||||
|
||||
void main() {
|
||||
SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.portraitUp,
|
||||
DeviceOrientation.portraitDown,
|
||||
]);
|
||||
|
||||
runApp(
|
||||
CupertinoApp(
|
||||
color: Styles.appBackground,
|
||||
home: HomeScreen(),
|
||||
),
|
||||
);
|
||||
}
|
||||
22
veggieseasons/lib/screens/details.dart
Normal file
22
veggieseasons/lib/screens/details.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2018 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/cupertino.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:veggieseasons/styles.dart';
|
||||
|
||||
class DetailsScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: Text('Details'),
|
||||
),
|
||||
backgroundColor: Styles.scaffoldBackground,
|
||||
child: Center(
|
||||
child: Text('Not yet implemented.'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
22
veggieseasons/lib/screens/favorites.dart
Normal file
22
veggieseasons/lib/screens/favorites.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2018 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/cupertino.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:veggieseasons/styles.dart';
|
||||
|
||||
class FavoritesScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: Text('My Garden'),
|
||||
),
|
||||
backgroundColor: Styles.scaffoldBackground,
|
||||
child: Center(
|
||||
child: Text('Not yet implemented.'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
47
veggieseasons/lib/screens/home.dart
Normal file
47
veggieseasons/lib/screens/home.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright 2018 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/cupertino.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:veggieseasons/screens/favorites.dart';
|
||||
import 'package:veggieseasons/screens/list.dart';
|
||||
import 'package:veggieseasons/screens/search.dart';
|
||||
import 'package:veggieseasons/screens/settings.dart';
|
||||
|
||||
class HomeScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoTabScaffold(
|
||||
tabBar: CupertinoTabBar(items: [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.home),
|
||||
title: Text('Home'),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.book),
|
||||
title: Text('My Garden'),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.search),
|
||||
title: Text('Search'),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.settings),
|
||||
title: Text('Settings'),
|
||||
),
|
||||
]),
|
||||
tabBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return ListScreen();
|
||||
} else if (index == 1) {
|
||||
return FavoritesScreen();
|
||||
} else if (index == 2) {
|
||||
return SearchScreen();
|
||||
} else {
|
||||
return SettingsScreen();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
22
veggieseasons/lib/screens/list.dart
Normal file
22
veggieseasons/lib/screens/list.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2018 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/cupertino.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:veggieseasons/styles.dart';
|
||||
|
||||
class ListScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: Text('List'),
|
||||
),
|
||||
backgroundColor: Styles.scaffoldBackground,
|
||||
child: Center(
|
||||
child: Text('Not yet implemented.'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
22
veggieseasons/lib/screens/search.dart
Normal file
22
veggieseasons/lib/screens/search.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2018 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/cupertino.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:veggieseasons/styles.dart';
|
||||
|
||||
class SearchScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: Text('Search'),
|
||||
),
|
||||
backgroundColor: Styles.scaffoldBackground,
|
||||
child: Center(
|
||||
child: Text('Not yet implemented.'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
22
veggieseasons/lib/screens/settings.dart
Normal file
22
veggieseasons/lib/screens/settings.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2018 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/cupertino.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:veggieseasons/styles.dart';
|
||||
|
||||
class SettingsScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: Text('Settings'),
|
||||
),
|
||||
backgroundColor: Styles.scaffoldBackground,
|
||||
child: Center(
|
||||
child: Text('Not yet implemented.'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
119
veggieseasons/lib/styles.dart
Normal file
119
veggieseasons/lib/styles.dart
Normal file
@@ -0,0 +1,119 @@
|
||||
// Copyright 2018 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/widgets.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:veggieseasons/data/veggie.dart';
|
||||
|
||||
abstract class Styles {
|
||||
static const baseTextStyle = TextStyle(
|
||||
color: Color.fromRGBO(10, 10, 8, 1.0),
|
||||
fontFamily: 'NotoSans',
|
||||
fontSize: 16.0,
|
||||
fontStyle: FontStyle.normal,
|
||||
fontWeight: FontWeight.normal,
|
||||
);
|
||||
|
||||
static const headlineText = TextStyle(
|
||||
color: Color.fromRGBO(0, 0, 0, 0.8),
|
||||
fontFamily: 'NotoSans',
|
||||
fontSize: 32.0,
|
||||
fontStyle: FontStyle.normal,
|
||||
fontWeight: FontWeight.bold,
|
||||
);
|
||||
|
||||
static const subheadText = TextStyle(
|
||||
color: Color.fromRGBO(240, 240, 240, 1.0),
|
||||
fontFamily: 'NotoSans',
|
||||
fontSize: 30.0,
|
||||
fontStyle: FontStyle.normal,
|
||||
fontWeight: FontWeight.bold,
|
||||
);
|
||||
|
||||
static const bodyText = TextStyle(
|
||||
color: Color.fromRGBO(240, 240, 240, 1.0),
|
||||
fontFamily: 'NotoSans',
|
||||
fontSize: 14.0,
|
||||
fontStyle: FontStyle.normal,
|
||||
fontWeight: FontWeight.normal,
|
||||
);
|
||||
|
||||
static const minorText = TextStyle(
|
||||
color: Color.fromRGBO(128, 128, 128, 1.0),
|
||||
fontFamily: 'NotoSans',
|
||||
fontSize: 16.0,
|
||||
fontStyle: FontStyle.normal,
|
||||
fontWeight: FontWeight.normal,
|
||||
);
|
||||
|
||||
static const headlineName = TextStyle(
|
||||
color: Color.fromRGBO(0, 0, 0, 0.9),
|
||||
fontFamily: 'NotoSans',
|
||||
fontSize: 24.0,
|
||||
fontStyle: FontStyle.normal,
|
||||
fontWeight: FontWeight.bold,
|
||||
);
|
||||
|
||||
static const headlineDescription = TextStyle(
|
||||
color: Color.fromRGBO(0, 0, 0, 0.8),
|
||||
fontFamily: 'NotoSans',
|
||||
fontSize: 16.0,
|
||||
fontStyle: FontStyle.normal,
|
||||
fontWeight: FontWeight.normal,
|
||||
);
|
||||
|
||||
static const seasonText = TextStyle(
|
||||
color: Color.fromRGBO(255, 255, 255, 0.9),
|
||||
fontFamily: 'NotoSans',
|
||||
fontSize: 24.0,
|
||||
fontStyle: FontStyle.normal,
|
||||
fontWeight: FontWeight.normal,
|
||||
);
|
||||
|
||||
static const appBackground = Color(0xffd0d0d0);
|
||||
|
||||
static const scaffoldBackground = Color(0xfff0f0f0);
|
||||
|
||||
static const buttonColor = Color(0xff007aff);
|
||||
|
||||
static const searchBackground = Color(0xffe0e0e0);
|
||||
|
||||
static const TextStyle searchText = TextStyle(
|
||||
color: Color.fromRGBO(0, 0, 0, 1.0),
|
||||
fontFamily: 'NotoSans',
|
||||
fontSize: 14.0,
|
||||
fontStyle: FontStyle.normal,
|
||||
fontWeight: FontWeight.normal,
|
||||
);
|
||||
|
||||
static const Color searchCursorColor = Color.fromRGBO(0, 122, 255, 1.0);
|
||||
|
||||
static const Color searchIconColor = Color.fromRGBO(128, 128, 128, 1.0);
|
||||
|
||||
static const seasonColors = <Season, Color>{
|
||||
Season.winter: Color(0xff336dcc),
|
||||
Season.spring: Color(0xff2fa02b),
|
||||
Season.summer: Color(0xff287213),
|
||||
Season.autumn: Color(0xff724913),
|
||||
};
|
||||
|
||||
static const seasonBorder = const Border(
|
||||
top: BorderSide(color: Color(0xff606060)),
|
||||
left: BorderSide(color: Color(0xff606060)),
|
||||
bottom: BorderSide(color: Color(0xff606060)),
|
||||
right: BorderSide(color: Color(0xff606060)),
|
||||
);
|
||||
|
||||
static const uncheckedIcon = IconData(
|
||||
0xf372,
|
||||
fontFamily: CupertinoIcons.iconFont,
|
||||
fontPackage: CupertinoIcons.iconFontPackage,
|
||||
);
|
||||
|
||||
static const checkedIcon = IconData(
|
||||
0xf373,
|
||||
fontFamily: CupertinoIcons.iconFont,
|
||||
fontPackage: CupertinoIcons.iconFontPackage,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user