forked from firka/flutter
Let Flutter SDK use cupertino_icons 1.0.0 (#65087)
This commit is contained in:
@@ -32,18 +32,19 @@ const List<String> coolColorNames = <String>[
|
||||
const int _kChildCount = 50;
|
||||
|
||||
class CupertinoNavigationDemo extends StatelessWidget {
|
||||
CupertinoNavigationDemo()
|
||||
CupertinoNavigationDemo({ this.randomSeed })
|
||||
: colorItems = List<Color>.generate(_kChildCount, (int index) {
|
||||
return coolColors[math.Random().nextInt(coolColors.length)];
|
||||
return coolColors[math.Random(randomSeed).nextInt(coolColors.length)];
|
||||
}) ,
|
||||
colorNameItems = List<String>.generate(_kChildCount, (int index) {
|
||||
return coolColorNames[math.Random().nextInt(coolColorNames.length)];
|
||||
return coolColorNames[math.Random(randomSeed).nextInt(coolColorNames.length)];
|
||||
});
|
||||
|
||||
static const String routeName = '/cupertino/navigation';
|
||||
|
||||
final List<Color> colorItems;
|
||||
final List<String> colorNameItems;
|
||||
final int randomSeed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -56,15 +57,15 @@ class CupertinoNavigationDemo extends StatelessWidget {
|
||||
tabBar: CupertinoTabBar(
|
||||
items: const <BottomNavigationBarItem>[
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.home),
|
||||
icon: Icon(CupertinoIcons.house, size: 27),
|
||||
label: 'Home',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.conversation_bubble),
|
||||
icon: Icon(CupertinoIcons.chat_bubble, size: 27),
|
||||
label: 'Support',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.profile_circled),
|
||||
icon: Icon(CupertinoIcons.person_circle, size: 27),
|
||||
label: 'Profile',
|
||||
),
|
||||
],
|
||||
@@ -78,6 +79,7 @@ class CupertinoNavigationDemo extends StatelessWidget {
|
||||
return CupertinoDemoTab1(
|
||||
colorItems: colorItems,
|
||||
colorNameItems: colorNameItems,
|
||||
randomSeed: randomSeed,
|
||||
);
|
||||
},
|
||||
defaultTitle: 'Colors',
|
||||
@@ -134,10 +136,15 @@ final Widget trailingButtons = Row(
|
||||
);
|
||||
|
||||
class CupertinoDemoTab1 extends StatelessWidget {
|
||||
const CupertinoDemoTab1({this.colorItems, this.colorNameItems});
|
||||
const CupertinoDemoTab1({
|
||||
this.colorItems,
|
||||
this.colorNameItems,
|
||||
this.randomSeed,
|
||||
});
|
||||
|
||||
final List<Color> colorItems;
|
||||
final List<String> colorNameItems;
|
||||
final int randomSeed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -165,6 +172,7 @@ class CupertinoDemoTab1 extends StatelessWidget {
|
||||
lastItem: index == _kChildCount - 1,
|
||||
color: colorItems[index],
|
||||
colorName: colorNameItems[index],
|
||||
randomSeed: randomSeed,
|
||||
);
|
||||
},
|
||||
childCount: _kChildCount,
|
||||
@@ -178,12 +186,19 @@ class CupertinoDemoTab1 extends StatelessWidget {
|
||||
}
|
||||
|
||||
class Tab1RowItem extends StatelessWidget {
|
||||
const Tab1RowItem({this.index, this.lastItem, this.color, this.colorName});
|
||||
const Tab1RowItem({
|
||||
this.index,
|
||||
this.lastItem,
|
||||
this.color,
|
||||
this.colorName,
|
||||
this.randomSeed,
|
||||
});
|
||||
|
||||
final int index;
|
||||
final bool lastItem;
|
||||
final Color color;
|
||||
final String colorName;
|
||||
final int randomSeed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -196,6 +211,7 @@ class Tab1RowItem extends StatelessWidget {
|
||||
color: color,
|
||||
colorName: colorName,
|
||||
index: index,
|
||||
randomSeed: randomSeed,
|
||||
),
|
||||
));
|
||||
},
|
||||
@@ -274,11 +290,12 @@ class Tab1RowItem extends StatelessWidget {
|
||||
}
|
||||
|
||||
class Tab1ItemPage extends StatefulWidget {
|
||||
const Tab1ItemPage({this.color, this.colorName, this.index});
|
||||
const Tab1ItemPage({this.color, this.colorName, this.index, this.randomSeed});
|
||||
|
||||
final Color color;
|
||||
final String colorName;
|
||||
final int index;
|
||||
final int randomSeed;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => Tab1ItemPageState();
|
||||
@@ -289,7 +306,7 @@ class Tab1ItemPageState extends State<Tab1ItemPage> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
relatedColors = List<Color>.generate(10, (int index) {
|
||||
final math.Random random = math.Random();
|
||||
final math.Random random = math.Random(widget.randomSeed);
|
||||
return Color.fromARGB(
|
||||
255,
|
||||
(widget.color.red + random.nextInt(100) - 50).clamp(0, 255) as int,
|
||||
|
||||
@@ -40,17 +40,15 @@ class _CupertinoTextFieldDemoState extends State<CupertinoTextFieldDemo> {
|
||||
keyboardType: TextInputType.multiline,
|
||||
prefix: const Padding(padding: EdgeInsets.symmetric(horizontal: 4.0)),
|
||||
suffix: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 2.0),
|
||||
child: CupertinoButton(
|
||||
color: CupertinoColors.activeGreen,
|
||||
minSize: 0.0,
|
||||
child: const Icon(
|
||||
CupertinoIcons.up_arrow,
|
||||
size: 21.0,
|
||||
color: CupertinoColors.white,
|
||||
CupertinoIcons.arrow_up_circle_fill,
|
||||
size: 28.0,
|
||||
color: CupertinoColors.activeGreen,
|
||||
),
|
||||
padding: const EdgeInsets.all(2.0),
|
||||
borderRadius: BorderRadius.circular(15.0),
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
onPressed: ()=> setState(()=> _chatTextController.clear()),
|
||||
),
|
||||
),
|
||||
@@ -63,7 +61,7 @@ class _CupertinoTextFieldDemoState extends State<CupertinoTextFieldDemo> {
|
||||
Widget _buildNameField() {
|
||||
return const CupertinoTextField(
|
||||
prefix: Icon(
|
||||
CupertinoIcons.person_solid,
|
||||
CupertinoIcons.person_fill,
|
||||
color: CupertinoColors.lightBackgroundGray,
|
||||
size: 28.0,
|
||||
),
|
||||
@@ -81,9 +79,9 @@ class _CupertinoTextFieldDemoState extends State<CupertinoTextFieldDemo> {
|
||||
Widget _buildEmailField() {
|
||||
return const CupertinoTextField(
|
||||
prefix: Icon(
|
||||
CupertinoIcons.mail_solid,
|
||||
CupertinoIcons.envelope_fill,
|
||||
color: CupertinoColors.lightBackgroundGray,
|
||||
size: 28.0,
|
||||
size: 26,
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 6.0, vertical: 12.0),
|
||||
clearButtonMode: OverlayVisibilityMode.editing,
|
||||
@@ -100,9 +98,9 @@ class _CupertinoTextFieldDemoState extends State<CupertinoTextFieldDemo> {
|
||||
return CupertinoTextField(
|
||||
controller: _locationTextController,
|
||||
prefix: const Icon(
|
||||
CupertinoIcons.location_solid,
|
||||
CupertinoIcons.location_fill,
|
||||
color: CupertinoColors.lightBackgroundGray,
|
||||
size: 28.0,
|
||||
size: 26,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6.0, vertical: 12.0),
|
||||
clearButtonMode: OverlayVisibilityMode.editing,
|
||||
@@ -117,9 +115,9 @@ class _CupertinoTextFieldDemoState extends State<CupertinoTextFieldDemo> {
|
||||
Widget _buildPinField() {
|
||||
return const CupertinoTextField(
|
||||
prefix: Icon(
|
||||
CupertinoIcons.padlock_solid,
|
||||
CupertinoIcons.lock_open_fill,
|
||||
color: CupertinoColors.lightBackgroundGray,
|
||||
size: 28.0,
|
||||
size: 26,
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 6.0, vertical: 12.0),
|
||||
clearButtonMode: OverlayVisibilityMode.editing,
|
||||
@@ -137,9 +135,9 @@ class _CupertinoTextFieldDemoState extends State<CupertinoTextFieldDemo> {
|
||||
return CupertinoTextField(
|
||||
controller: TextEditingController(text: 'colleague, reading club'),
|
||||
prefix: const Icon(
|
||||
CupertinoIcons.tags_solid,
|
||||
CupertinoIcons.tag_fill,
|
||||
color: CupertinoColors.lightBackgroundGray,
|
||||
size: 28.0,
|
||||
size: 26,
|
||||
),
|
||||
enabled: false,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6.0, vertical: 12.0),
|
||||
|
||||
@@ -8,12 +8,12 @@ dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
collection: 1.15.0-nullsafety.3
|
||||
device_info: 0.4.2+8
|
||||
device_info: 0.4.2+9
|
||||
intl: 0.16.1
|
||||
connectivity: 0.4.9+3
|
||||
connectivity: 0.4.9+5
|
||||
string_scanner: 1.1.0-nullsafety.1
|
||||
url_launcher: 5.7.2
|
||||
cupertino_icons: 0.1.3
|
||||
url_launcher: 5.7.5
|
||||
cupertino_icons: 1.0.0
|
||||
video_player: 0.10.6
|
||||
scoped_model: 1.0.1
|
||||
shrine_images: 1.1.2
|
||||
@@ -277,4 +277,4 @@ flutter:
|
||||
- asset: packages/flutter_gallery_assets/fonts/merriweather/Merriweather-Regular.ttf
|
||||
- asset: packages/flutter_gallery_assets/fonts/merriweather/Merriweather-Light.ttf
|
||||
|
||||
# PUBSPEC CHECKSUM: 023a
|
||||
# PUBSPEC CHECKSUM: 1f3d
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright 2014 The Flutter 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/cupertino.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_gallery/demo/cupertino/cupertino_navigation_demo.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Navigation demo golden', (WidgetTester tester) async {
|
||||
// The point is to mainly test the cupertino icons that we don't have a
|
||||
// dependency against in the flutter/cupertino package directly.
|
||||
|
||||
final Future<ByteData> font = rootBundle.load(
|
||||
'packages/cupertino_icons/assets/CupertinoIcons.ttf'
|
||||
);
|
||||
|
||||
await (FontLoader('packages/cupertino_icons/CupertinoIcons')..addFont(font))
|
||||
.load();
|
||||
|
||||
await tester.pumpWidget(CupertinoApp(
|
||||
home: CupertinoNavigationDemo(randomSeed: 123456),
|
||||
));
|
||||
|
||||
await expectLater(
|
||||
find.byType(CupertinoNavigationDemo),
|
||||
matchesGoldenFile('cupertino_navigation_demo.screen.1.png'),
|
||||
);
|
||||
|
||||
// Tap some row to go to the next page.
|
||||
await tester.tap(find.text('Buy this cool color').first);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
await expectLater(
|
||||
find.byType(CupertinoNavigationDemo),
|
||||
matchesGoldenFile('cupertino_navigation_demo.screen.2.png'),
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user