From 89405002bc2b642d9a0db20b8288294a4f293257 Mon Sep 17 00:00:00 2001 From: xster Date: Fri, 3 Nov 2017 08:50:29 -0700 Subject: [PATCH] Add an iOS style demo to the gallery (#12651) * Built first tab * Small additions * started tab 3 * Need color arithmetics * tab 2 built * finalize * lint and tests * review * Reapply docs after rebase * use color.computeLuminance * linter * nit --- dev/benchmarks/complex_layout/pubspec.yaml | 2 +- .../ios/Runner.xcodeproj/project.pbxproj | 10 +- .../lib/demo/cupertino/cupertino.dart | 1 + .../cupertino/cupertino_navigation_demo.dart | 775 ++++++++++++++++++ examples/flutter_gallery/lib/gallery/app.dart | 4 +- .../flutter_gallery/lib/gallery/item.dart | 7 + examples/flutter_gallery/pubspec.yaml | 5 +- .../flutter_gallery/test/live_smoketest.dart | 1 + .../test_driver/transitions_perf_test.dart | 1 + .../lib/src/cupertino/bottom_tab_bar.dart | 8 +- packages/flutter/lib/src/cupertino/icons.dart | 17 +- .../flutter/lib/src/cupertino/nav_bar.dart | 10 +- 12 files changed, 827 insertions(+), 14 deletions(-) create mode 100644 examples/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart diff --git a/dev/benchmarks/complex_layout/pubspec.yaml b/dev/benchmarks/complex_layout/pubspec.yaml index 72ec1e06b1..12d949cbc7 100644 --- a/dev/benchmarks/complex_layout/pubspec.yaml +++ b/dev/benchmarks/complex_layout/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: flutter_gallery_assets: git: url: https://flutter.googlesource.com/gallery-assets - ref: 0b6cdb29b24ecc60781c2828086d955dacdc0152 + ref: 6427f36af1bdb2fffaeda1c46d5e52d7b636c93d dev_dependencies: flutter_test: diff --git a/examples/flutter_gallery/ios/Runner.xcodeproj/project.pbxproj b/examples/flutter_gallery/ios/Runner.xcodeproj/project.pbxproj index 14262ab7b9..e7a4716be8 100644 --- a/examples/flutter_gallery/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/flutter_gallery/ios/Runner.xcodeproj/project.pbxproj @@ -242,13 +242,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; 9740EEB61CF901F6004384FC /* Run Script */ = { @@ -271,9 +274,14 @@ files = ( ); inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", + "${PODS_ROOT}/../../../../bin/cache/artifacts/engine/ios/Flutter.framework", + "${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/examples/flutter_gallery/lib/demo/cupertino/cupertino.dart b/examples/flutter_gallery/lib/demo/cupertino/cupertino.dart index b7cbea57ca..75471187cb 100644 --- a/examples/flutter_gallery/lib/demo/cupertino/cupertino.dart +++ b/examples/flutter_gallery/lib/demo/cupertino/cupertino.dart @@ -5,5 +5,6 @@ export 'cupertino_activity_indicator_demo.dart'; export 'cupertino_buttons_demo.dart'; export 'cupertino_dialog_demo.dart'; +export 'cupertino_navigation_demo.dart'; export 'cupertino_slider_demo.dart'; export 'cupertino_switch_demo.dart'; diff --git a/examples/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart b/examples/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart new file mode 100644 index 0000000000..e057671fcd --- /dev/null +++ b/examples/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart @@ -0,0 +1,775 @@ +// Copyright 2017 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. + +import 'dart:async'; +import 'dart:math' as math; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +const String _kGalleryAssetsPackage = 'flutter_gallery_assets'; + +const List coolColors = const [ + const Color.fromARGB(255, 255, 59, 48), + const Color.fromARGB(255, 255, 149, 0), + const Color.fromARGB(255, 255, 204, 0), + const Color.fromARGB(255, 76, 217, 100), + const Color.fromARGB(255, 90, 200, 250), + const Color.fromARGB(255, 0, 122, 255), + const Color.fromARGB(255, 88, 86, 214), + const Color.fromARGB(255, 255, 45, 85), +]; + +const List coolColorNames = const [ + 'Sarcoline', 'Coquelicot', 'Smaragdine', 'Mikado', 'Glaucous', 'Wenge', + 'Fulvous', 'Xanadu', 'Falu', 'Eburnean', 'Amaranth', 'Australien', + 'Banan', 'Falu', 'Gingerline', 'Incarnadine', 'Labrabor', 'Nattier', + 'Pervenche', 'Sinoper', 'Verditer', 'Watchet', 'Zaffre', +]; + +class CupertinoNavigationDemo extends StatelessWidget { + CupertinoNavigationDemo() + : colorItems = new List.generate(50, (int index){ + return coolColors[new math.Random().nextInt(coolColors.length)]; + }) , + colorNameItems = new List.generate(50, (int index){ + return coolColorNames[new math.Random().nextInt(coolColorNames.length)]; + }); + + static const String routeName = '/cupertino/navigation'; + + final List colorItems; + final List colorNameItems; + + @override + Widget build(BuildContext context) { + return new WillPopScope( + // Prevent swipe popping of this page. Use explicit exit buttons only. + onWillPop: () => new Future.value(true), + child: new CupertinoTabScaffold( + tabBar: new CupertinoTabBar( + items: const [ + const BottomNavigationBarItem( + icon: const Icon(CupertinoIcons.home), + title: const Text('Home'), + ), + const BottomNavigationBarItem( + icon: const Icon(CupertinoIcons.conversation_bubble), + title: const Text('Support'), + ), + const BottomNavigationBarItem( + icon: const Icon(CupertinoIcons.profile_circled), + title: const Text('Profile'), + ), + ], + ), + tabBuilder: (BuildContext context, int index) { + return new DefaultTextStyle( + style: const TextStyle( + fontFamily: '.SF UI Text', + fontSize: 17.0, + color: CupertinoColors.black, + ), + child: new CupertinoTabView( + builder: (BuildContext context) { + switch (index) { + case 0: + return new CupertinoDemoTab1( + colorItems: colorItems, + colorNameItems: colorNameItems + ); + break; + case 1: + return new CupertinoDemoTab2(); + break; + case 2: + return new CupertinoDemoTab3(); + break; + default: + } + }, + ), + ); + }, + ), + ); + } +} + +class ExitButton extends StatelessWidget { + const ExitButton(); + + @override + Widget build(BuildContext context) { + return new CupertinoButton( + padding: EdgeInsets.zero, + child: const Tooltip( + message: 'Back', + child: const Text('Exit'), + ), + onPressed: () { + // The demo is on the root navigator. + Navigator.of(context, rootNavigator: true).pop(); + }, + ); + } +} + +class CupertinoDemoTab1 extends StatelessWidget { + const CupertinoDemoTab1({this.colorItems, this.colorNameItems}); + + final List colorItems; + final List colorNameItems; + + @override + Widget build(BuildContext context) { + return new CupertinoPageScaffold( + child: new CustomScrollView( + slivers: [ + const CupertinoSliverNavigationBar( + largeTitle: const Text('Colors'), + trailing: const ExitButton(), + ), + new SliverList( + delegate: new SliverChildBuilderDelegate( + (BuildContext context, int index) { + return new Tab1RowItem( + index: index, + lastItem: index == 49, + color: colorItems[index], + colorName: colorNameItems[index], + ); + }, + childCount: 50, + ), + ), + ], + ), + ); + } +} + +class Tab1RowItem extends StatelessWidget { + const Tab1RowItem({this.index, this.lastItem, this.color, this.colorName}); + + final int index; + final bool lastItem; + final Color color; + final String colorName; + + @override + Widget build(BuildContext context) { + final Widget row = new GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + Navigator.of(context).push(new CupertinoPageRoute( + builder: (BuildContext context) => new Tab1ItemPage( + color: color, + colorName: colorName, + index: index, + ), + )); + }, + child: new Padding( + padding: const EdgeInsets.only(left: 16.0, top: 8.0, bottom: 8.0, right: 8.0), + child: new Row( + children: [ + new Container( + height: 60.0, + width: 60.0, + decoration: new BoxDecoration( + color: color, + borderRadius: new BorderRadius.circular(8.0), + ), + ), + new Expanded( + child: new Padding( + padding: const EdgeInsets.symmetric(horizontal: 12.0), + child: new Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + new Text(colorName), + const Padding(padding: const EdgeInsets.only(top: 8.0)), + const Text( + 'Buy this cool color', + style: const TextStyle( + color: const Color(0xFF8E8E93), + fontSize: 13.0, + fontWeight: FontWeight.w300, + ), + ), + ], + ), + ), + ), + new CupertinoButton( + padding: EdgeInsets.zero, + child: const Icon(CupertinoIcons.plus_circled, color: CupertinoColors.activeBlue), + onPressed: () { }, + ), + new CupertinoButton( + padding: EdgeInsets.zero, + child: const Icon(CupertinoIcons.share, color: CupertinoColors.activeBlue), + onPressed: () { }, + ), + ], + ), + ), + ); + + if (lastItem) { + return row; + } + + return new Column( + children: [ + row, + new Container( + height: 1.0, + color: const Color(0xFFD9D9D9), + ), + ], + ); + } +} + +class Tab1ItemPage extends StatefulWidget { + const Tab1ItemPage({this.color, this.colorName, this.index}); + + final Color color; + final String colorName; + final int index; + + @override + State createState() => new Tab1ItemPageState(); +} + +class Tab1ItemPageState extends State { + @override + void initState() { + super.initState(); + relatedColors = new List.generate(10, (int index) { + final math.Random random = new math.Random(); + return new Color.fromARGB( + 255, + (widget.color.red + random.nextInt(100) - 50).clamp(0, 255), + (widget.color.green + random.nextInt(100) - 50).clamp(0, 255), + (widget.color.blue + random.nextInt(100) - 50).clamp(0, 255), + ); + }); + } + + List relatedColors; + + @override + Widget build(BuildContext context) { + return new CupertinoPageScaffold( + navigationBar: new CupertinoNavigationBar( + middle: new Text(widget.colorName), + trailing: const ExitButton(), + ), + child: new ListView( + children: [ + const Padding(padding: const EdgeInsets.only(top: 80.0)), + new Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: new Row( + mainAxisSize: MainAxisSize.max, + children: [ + new Container( + height: 128.0, + width: 128.0, + decoration: new BoxDecoration( + color: widget.color, + borderRadius: new BorderRadius.circular(24.0), + ), + ), + const Padding(padding: const EdgeInsets.only(left: 18.0)), + new Expanded( + child: new Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + new Text( + widget.colorName, + style: const TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold), + ), + const Padding(padding: const EdgeInsets.only(top: 6.0)), + new Text( + 'Item number ${widget.index}', + style: const TextStyle( + color: const Color(0xFF8E8E93), + fontSize: 16.0, + fontWeight: FontWeight.w100, + ), + ), + const Padding(padding: const EdgeInsets.only(top: 20.0)), + new Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + new CupertinoButton( + color: CupertinoColors.activeBlue, + minSize: 30.0, + padding: const EdgeInsets.symmetric(horizontal: 24.0), + borderRadius: new BorderRadius.circular(32.0), + child: const Text( + 'GET', + style: const TextStyle( + fontSize: 14.0, + fontWeight: FontWeight.w700, + letterSpacing: -0.28, + ), + ), + onPressed: () { }, + ), + new CupertinoButton( + color: CupertinoColors.activeBlue, + minSize: 30.0, + padding: EdgeInsets.zero, + borderRadius: new BorderRadius.circular(32.0), + child: const Icon(CupertinoIcons.ellipsis, color: CupertinoColors.white), + onPressed: () { }, + ), + ], + ), + ], + ), + ), + ], + ), + ), + const Padding( + padding: const EdgeInsets.only(left: 16.0, top: 28.0, bottom: 8.0), + child: const Text( + 'USERS ALSO LIKED', + style: const TextStyle( + color: const Color(0xFF646464), + letterSpacing: -0.60, + fontSize: 15.0, + fontWeight: FontWeight.w500, + ), + ), + ), + new SizedBox( + height: 200.0, + child: new ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: 10, + itemExtent: 160.0, + itemBuilder: (BuildContext context, int index) { + return new Padding( + padding: const EdgeInsets.only(left: 16.0), + child: new Container( + decoration: new BoxDecoration( + borderRadius: new BorderRadius.circular(8.0), + color: relatedColors[index], + ), + child: new Center( + child: new CupertinoButton( + child: const Icon( + CupertinoIcons.plus_circled, + color: CupertinoColors.white, + size: 36.0, + ), + onPressed: () { }, + ), + ), + ), + ); + }, + ), + ), + ], + ), + ); + } +} + +class CupertinoDemoTab2 extends StatelessWidget { + @override + Widget build(BuildContext context) { + return new CupertinoPageScaffold( + navigationBar: const CupertinoNavigationBar( + middle: const Text('Support Chat'), + trailing: const ExitButton(), + ), + child: new ListView( + children: [ + const Padding(padding: const EdgeInsets.only(top: 60.0)), + new Tab2Header(), + ]..addAll(buildTab2Conversation()), + ), + ); + } +} + +class Tab2Header extends StatelessWidget { + @override + Widget build(BuildContext context) { + return new Padding( + padding: const EdgeInsets.all(16.0), + child: new ClipRRect( + borderRadius: const BorderRadius.all(const Radius.circular(16.0)), + child: new Column( + mainAxisSize: MainAxisSize.min, + children: [ + new Container( + decoration: const BoxDecoration( + color: const Color(0xFFE5E5E5), + ), + child: new Padding( + padding: const EdgeInsets.symmetric(horizontal: 18.0, vertical: 12.0), + child: new Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text( + 'SUPPORT TICKET', + style: const TextStyle( + color: const Color(0xFF646464), + letterSpacing: -0.8, + fontSize: 14.0, + fontWeight: FontWeight.w500, + ), + ), + const Text( + 'Show More', + style: const TextStyle( + color: const Color(0xFF646464), + letterSpacing: -0.6, + fontSize: 12.0, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + ), + new Container( + decoration: const BoxDecoration( + color: const Color(0xFFF3F3F3), + ), + child: new Padding( + padding: const EdgeInsets.symmetric(horizontal: 18.0, vertical: 12.0), + child: new Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Product or product packaging damaged during transit', + style: const TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.w800, + letterSpacing: -0.6, + ), + ), + const Padding(padding: const EdgeInsets.only(top: 16.0)), + const Text( + 'REVIEWERS', + style: const TextStyle( + color: const Color(0xFF646464), + fontSize: 12.0, + letterSpacing: -0.6, + fontWeight: FontWeight.w500, + ), + ), + const Padding(padding: const EdgeInsets.only(top: 8.0)), + new Row( + children: [ + new Container( + width: 44.0, + height: 44.0, + decoration: const BoxDecoration( + image: const DecorationImage( + image: const AssetImage( + 'cupertino_navigation/person1.jpg', + package: _kGalleryAssetsPackage + ), + ), + shape: BoxShape.circle, + ), + ), + const Padding(padding: const EdgeInsets.only(left: 8.0)), + new Container( + width: 44.0, + height: 44.0, + decoration: const BoxDecoration( + image: const DecorationImage( + image: const AssetImage( + 'cupertino_navigation/person2.jpg', + package: _kGalleryAssetsPackage + ), + ), + shape: BoxShape.circle, + ), + ), + const Padding(padding: const EdgeInsets.only(left: 2.0)), + const Icon( + CupertinoIcons.check_mark_circled, + color: const Color(0xFF646464), + size: 20.0, + ), + ], + ), + ], + ), + ), + ), + ], + ), + ), + ); + } +} + +enum Tab2ConversationBubbleColor { + blue, + gray, +} + +class Tab2ConversationBubble extends StatelessWidget { + const Tab2ConversationBubble({this.text, this.color}); + + final String text; + final Tab2ConversationBubbleColor color; + + @override + Widget build(BuildContext context) { + return new Container( + decoration: new BoxDecoration( + borderRadius: const BorderRadius.all(const Radius.circular(18.0)), + color: color == Tab2ConversationBubbleColor.blue + ? CupertinoColors.activeBlue + : CupertinoColors.lightBackgroundGray, + ), + margin: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0), + padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 10.0), + child: new Text( + text, + style: new TextStyle( + color: color == Tab2ConversationBubbleColor.blue + ? CupertinoColors.white + : CupertinoColors.black, + letterSpacing: -0.4, + fontSize: 14.0, + fontWeight: color == Tab2ConversationBubbleColor.blue + ? FontWeight.w300 + : FontWeight.w400, + ), + ), + ); + } +} + +class Tab2ConversationAvatar extends StatelessWidget { + const Tab2ConversationAvatar({this.text, this.color}); + + final String text; + final Color color; + + @override + Widget build(BuildContext context) { + return new Container( + decoration: new BoxDecoration( + shape: BoxShape.circle, + gradient: new LinearGradient( + begin: FractionalOffset.topCenter, + end: FractionalOffset.bottomCenter, + colors: [ + color, + new Color.fromARGB( + color.alpha, + (color.red - 60).clamp(0, 255), + (color.green - 60).clamp(0, 255), + (color.blue - 60).clamp(0, 255), + ), + ], + ), + ), + margin: const EdgeInsets.only(left: 8.0, bottom: 8.0), + padding: const EdgeInsets.all(12.0), + child: new Text( + text, + style: const TextStyle( + color: CupertinoColors.white, + fontSize: 13.0, + fontWeight: FontWeight.w500, + ), + ), + ); + } +} + +List buildTab2Conversation() { + return [ + new Row( + mainAxisAlignment: MainAxisAlignment.end, + mainAxisSize: MainAxisSize.min, + children: [ + const Tab2ConversationBubble( + text: "My Xanadu doesn't look right", + color: Tab2ConversationBubbleColor.blue + ), + ], + ), + new Row( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + const Tab2ConversationAvatar( + text: 'KL', + color: const Color(0xFFFD5015), + ), + const Tab2ConversationBubble( + text: "We'll rush you a new one.\nIt's gonna be incredible", + color: Tab2ConversationBubbleColor.gray, + ), + ], + ), + new Row( + mainAxisAlignment: MainAxisAlignment.end, + mainAxisSize: MainAxisSize.min, + children: [ + const Tab2ConversationBubble( + text: 'Awesome thanks!', + color: Tab2ConversationBubbleColor.blue, + ), + ], + ), + new Row( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + const Tab2ConversationAvatar( + text: 'SJ', + color: const Color(0xFF34CAD6), + ), + const Tab2ConversationBubble( + text: "We'll send you our\nnewest Labrabor too!", + color: Tab2ConversationBubbleColor.gray, + ), + ], + ), + new Row( + mainAxisAlignment: MainAxisAlignment.end, + mainAxisSize: MainAxisSize.min, + children: [ + const Tab2ConversationBubble( + text: 'Yay', + color: Tab2ConversationBubbleColor.blue, + ), + ], + ), + new Row( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + const Tab2ConversationAvatar( + text: 'KL', + color: const Color(0xFFFD5015), + ), + const Tab2ConversationBubble( + text: "Actually there's one more thing...", + color: Tab2ConversationBubbleColor.gray, + ), + ], + ), + new Row( + mainAxisAlignment: MainAxisAlignment.end, + mainAxisSize: MainAxisSize.min, + children: [ + const Tab2ConversationBubble( + text: "What's that?", + color: Tab2ConversationBubbleColor.blue, + ), + ], + ), + const Padding(padding: const EdgeInsets.only(bottom: 80.0)), + ]; +} + +class CupertinoDemoTab3 extends StatelessWidget { + @override + Widget build(BuildContext context) { + return new CupertinoPageScaffold( + navigationBar: const CupertinoNavigationBar( + middle: const Text('Account'), + trailing: const ExitButton(), + ), + child: new DecoratedBox( + decoration: const BoxDecoration(color: const Color(0xFFEFEFF4)), + child: new ListView( + children: [ + const Padding(padding: const EdgeInsets.only(top: 100.0)), + new GestureDetector( + onTap: () { + Navigator.of(context, rootNavigator: true).push( + new CupertinoPageRoute( + fullscreenDialog: true, + builder: (BuildContext context) => new Tab3Dialog(), + ), + ); + }, + child: new Container( + decoration: const BoxDecoration( + color: CupertinoColors.white, + border: const Border( + top: const BorderSide(color: const Color(0xFFBCBBC1), width: 0.0), + bottom: const BorderSide(color: const Color(0xFFBCBBC1), width: 0.0), + ), + ), + height: 44.0, + child: new Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), + child: new Row(children: [ const Text( + 'Sign in', + style: const TextStyle(color: CupertinoColors.activeBlue), + ) ]), + ), + ), + ), + ], + ), + ), + ); + } +} + +class Tab3Dialog extends StatelessWidget { + @override + Widget build(BuildContext context) { + return new CupertinoPageScaffold( + navigationBar: new CupertinoNavigationBar( + leading: new CupertinoButton( + child: const Text('Cancel'), + padding: EdgeInsets.zero, + onPressed: () { + Navigator.of(context).pop(false); + }, + ), + ), + child: new Center( + child: new Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon( + CupertinoIcons.profile_circled, + size: 160.0, + color: const Color(0xFF646464), + ), + const Padding(padding: const EdgeInsets.only(top: 18.0)), + new CupertinoButton( + color: CupertinoColors.activeBlue, + child: const Text('Sign in'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ), + ), + ); + } +} diff --git a/examples/flutter_gallery/lib/gallery/app.dart b/examples/flutter_gallery/lib/gallery/app.dart index a07a707936..eae5734b44 100644 --- a/examples/flutter_gallery/lib/gallery/app.dart +++ b/examples/flutter_gallery/lib/gallery/app.dart @@ -138,8 +138,8 @@ class GalleryAppState extends State { ); } - final Map _kRoutes = new Map.fromIterable( + final Map _kRoutes = + new Map.fromIterable( // For a different example of how to set up an application routing table // using named routes, consider the example in the Navigator class documentation: // https://docs.flutter.io/flutter/widgets/Navigator-class.html diff --git a/examples/flutter_gallery/lib/gallery/item.dart b/examples/flutter_gallery/lib/gallery/item.dart index 8d373e8a30..71a1f35d59 100644 --- a/examples/flutter_gallery/lib/gallery/item.dart +++ b/examples/flutter_gallery/lib/gallery/item.dart @@ -285,6 +285,13 @@ List _buildGalleryItems() { routeName: CupertinoDialogDemo.routeName, buildRoute: (BuildContext context) => new CupertinoDialogDemo(), ), + new GalleryItem( + title: 'Navigation', + subtitle: 'Cupertino styled navigation patterns', + category: 'Cupertino Components', + routeName: CupertinoNavigationDemo.routeName, + buildRoute: (BuildContext context) => new CupertinoNavigationDemo(), + ), new GalleryItem( title: 'Sliders', subtitle: 'Cupertino styled sliders', diff --git a/examples/flutter_gallery/pubspec.yaml b/examples/flutter_gallery/pubspec.yaml index 9d3789454a..18d18d44f2 100644 --- a/examples/flutter_gallery/pubspec.yaml +++ b/examples/flutter_gallery/pubspec.yaml @@ -6,12 +6,13 @@ dependencies: intl: 0.15.2 string_scanner: 1.0.2 url_launcher: 0.4.2+5 + cupertino_icons: 0.1.1 # Also update dev/benchmarks/complex_layout/pubspec.yaml flutter_gallery_assets: git: url: https://flutter.googlesource.com/gallery-assets - ref: 0b6cdb29b24ecc60781c2828086d955dacdc0152 + ref: 6427f36af1bdb2fffaeda1c46d5e52d7b636c93d dev_dependencies: flutter_test: @@ -137,6 +138,8 @@ flutter: - packages/flutter_gallery_assets/shrine/vendors/peter-carlsson.png - packages/flutter_gallery_assets/shrine/vendors/sandra-adams.jpg - packages/flutter_gallery_assets/shrine/vendors/zach.jpg + - packages/flutter_gallery_assets/cupertino_navigation/person1.jpg + - packages/flutter_gallery_assets/cupertino_navigation/person2.jpg fonts: - family: Raleway fonts: diff --git a/examples/flutter_gallery/test/live_smoketest.dart b/examples/flutter_gallery/test/live_smoketest.dart index 0bb1e346b7..901183b147 100644 --- a/examples/flutter_gallery/test/live_smoketest.dart +++ b/examples/flutter_gallery/test/live_smoketest.dart @@ -96,6 +96,7 @@ const List demos = const [ const Demo('Activity Indicator', synchronized: false), const Demo('Buttons'), const Demo('Dialogs'), + const Demo('Navigation'), const Demo('Sliders'), const Demo('Switches'), diff --git a/examples/flutter_gallery/test_driver/transitions_perf_test.dart b/examples/flutter_gallery/test_driver/transitions_perf_test.dart index d1dd562d6a..3d52e94aaa 100644 --- a/examples/flutter_gallery/test_driver/transitions_perf_test.dart +++ b/examples/flutter_gallery/test_driver/transitions_perf_test.dart @@ -70,6 +70,7 @@ const List demos = const [ const Demo('Activity Indicator', synchronized: false), const Demo('Buttons'), const Demo('Dialogs'), + const Demo('Navigation'), const Demo('Sliders'), const Demo('Switches'), diff --git a/packages/flutter/lib/src/cupertino/bottom_tab_bar.dart b/packages/flutter/lib/src/cupertino/bottom_tab_bar.dart index 62af9d46c5..c61c9e1a78 100644 --- a/packages/flutter/lib/src/cupertino/bottom_tab_bar.dart +++ b/packages/flutter/lib/src/cupertino/bottom_tab_bar.dart @@ -44,7 +44,7 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget { this.backgroundColor: _kDefaultTabBarBackgroundColor, this.activeColor: CupertinoColors.activeBlue, this.inactiveColor: CupertinoColors.inactiveGray, - this.iconSize: 24.0, + this.iconSize: 30.0, }) : assert(items != null), assert(items.length >= 2), assert(0 <= currentIndex && currentIndex < items.length), @@ -111,10 +111,12 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget { color: inactiveColor, size: iconSize, ), - child: DefaultTextStyle.merge( // Default with the inactive state. + child: new DefaultTextStyle( // Default with the inactive state. style: new TextStyle( + fontFamily: '.SF UI Text', fontSize: 10.0, - letterSpacing: 0.12, + letterSpacing: -0.24, + fontWeight: FontWeight.w500, color: inactiveColor, ), child: new Row( diff --git a/packages/flutter/lib/src/cupertino/icons.dart b/packages/flutter/lib/src/cupertino/icons.dart index b7048b6e91..c531a13447 100644 --- a/packages/flutter/lib/src/cupertino/icons.dart +++ b/packages/flutter/lib/src/cupertino/icons.dart @@ -70,14 +70,23 @@ class CupertinoIcons { static const IconData flag = const IconData(0xf42c, fontFamily: iconFont, fontPackage: iconFontPackage); /// A magnifier loop outline. - static const IconData search = const IconData(0xf4c6, fontFamily: iconFont, fontPackage: iconFontPackage); + static const IconData search = const IconData(0xf4a5, fontFamily: iconFont, fontPackage: iconFontPackage); /// A checkmark. - static const IconData check_mark = const IconData(0xf41e, fontFamily: iconFont, fontPackage: iconFontPackage); + static const IconData check_mark = const IconData(0xf3fd, fontFamily: iconFont, fontPackage: iconFontPackage); /// A checkmark in a circle. - static const IconData check_mark_circled = const IconData(0xf41f, fontFamily: iconFont, fontPackage: iconFontPackage); + static const IconData check_mark_circled = const IconData(0xf3fe, fontFamily: iconFont, fontPackage: iconFontPackage); /// A thicker left chevron used in iOS for the nav bar back button. - static const IconData back = const IconData(0xf3f0, fontFamily: iconFont, fontPackage: iconFontPackage); + static const IconData back = const IconData(0xf3cf, fontFamily: iconFont, fontPackage: iconFontPackage); + + /// Outline of a simple front-facing house. + static const IconData home = const IconData(0xf447, fontFamily: iconFont, fontPackage: iconFontPackage); + + /// A right facing shopping cart outline. + static const IconData shopping_cart = const IconData(0xf3f7, fontFamily: iconFont, fontPackage: iconFontPackage); + + /// 3 solid dots. + static const IconData ellipsis = const IconData(0xf46a, fontFamily: iconFont, fontPackage: iconFontPackage); } diff --git a/packages/flutter/lib/src/cupertino/nav_bar.dart b/packages/flutter/lib/src/cupertino/nav_bar.dart index 50935fed1e..4bc6353622 100644 --- a/packages/flutter/lib/src/cupertino/nav_bar.dart +++ b/packages/flutter/lib/src/cupertino/nav_bar.dart @@ -5,6 +5,7 @@ import 'dart:ui' show ImageFilter; import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'button.dart'; @@ -277,6 +278,10 @@ Widget _wrapWithBackground({Color backgroundColor, Widget child}) { child: child, ); + final bool darkBackground = backgroundColor.computeLuminance() < 0.179; + SystemChrome.setSystemUIOverlayStyle( + darkBackground ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark); + if (backgroundColor.alpha == 0xFF) return childWithBackground; @@ -410,8 +415,9 @@ class _CupertinoPersistentNavigationBar extends StatelessWidget implements Prefe } } -class _CupertinoLargeTitleNavigationBarSliverDelegate extends SliverPersistentHeaderDelegate { - const _CupertinoLargeTitleNavigationBarSliverDelegate({ +class _CupertinoLargeTitleNavigationBarSliverDelegate + extends SliverPersistentHeaderDelegate with DiagnosticableTreeMixin { + _CupertinoLargeTitleNavigationBarSliverDelegate({ @required this.persistentHeight, @required this.title, this.leading,