From c804cdec22e38cd7184df62b27d5717a271b8bcf Mon Sep 17 00:00:00 2001 From: rami-a <2364772+rami-a@users.noreply.github.com> Date: Wed, 8 Jan 2020 14:05:07 -0500 Subject: [PATCH] [Gallery] Implement cupertino navbar demo (#214) --- .../gallery/lib/codeviewer/code_segments.dart | 455 ++++++++++++++++++ gallery/gallery/lib/data/demos.dart | 51 +- .../cupertino_navigation_bar_demo.dart | 82 ++++ .../lib/l10n/gallery_localizations.dart | 22 + gallery/gallery/lib/l10n/intl_en_US.arb | 12 + gallery/gallery/lib/l10n/intl_en_US.xml | 12 + gallery/gallery/lib/l10n/messages_en_US.dart | 7 + 7 files changed, 625 insertions(+), 16 deletions(-) create mode 100644 gallery/gallery/lib/demos/cupertino/cupertino_navigation_bar_demo.dart diff --git a/gallery/gallery/lib/codeviewer/code_segments.dart b/gallery/gallery/lib/codeviewer/code_segments.dart index 17b15e37e..cfbc3abb3 100644 --- a/gallery/gallery/lib/codeviewer/code_segments.dart +++ b/gallery/gallery/lib/codeviewer/code_segments.dart @@ -9,6 +9,426 @@ import 'package:flutter/material.dart'; import 'package:gallery/codeviewer/code_style.dart'; class CodeSegments { + static TextSpan cupertinoNavigationBarDemo(BuildContext context) { + final CodeStyle codeStyle = CodeStyle.of(context); + return TextSpan(children: [ + TextSpan( + style: codeStyle.commentStyle, + text: '// Copyright 2019 The Flutter team. All rights reserved.'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan( + style: codeStyle.commentStyle, + text: + '// Use of this source code is governed by a BSD-style license that can be'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan( + style: codeStyle.commentStyle, text: '// found in the LICENSE file.'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: '\u0027package:flutter/cupertino.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: '\u0027package:flutter/material.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: '\u0027package:gallery/l10n/gallery_localizations.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'class'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'CupertinoNavigationBarDemo'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'extends'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'StatelessWidget'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: '@override'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'Widget'), + TextSpan(style: codeStyle.baseStyle, text: ' build'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.classStyle, text: 'BuildContext'), + TextSpan(style: codeStyle.baseStyle, text: ' context'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'return'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'Navigator'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'onGenerateRoute'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'settings'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'return'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.classStyle, text: '_NoAnimationCupertinoPageRoute'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a title'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'GalleryLocalizations'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'of'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'context'), + TextSpan(style: codeStyle.punctuationStyle, text: ').'), + TextSpan( + style: codeStyle.baseStyle, text: 'demoCupertinoNavigationBarTitle'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a builder'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'context'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '=>'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'CupertinoPageScaffold'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a child'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'CustomScrollView'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a slivers'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '['), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan( + style: codeStyle.classStyle, text: 'CupertinoSliverNavigationBar'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a automaticallyImplyLeading'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'false'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '),'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'SliverPadding'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a padding'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'MediaQuery'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'of'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'context'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'removePadding'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'removeTop'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'true'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'padding'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a sliver'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'SliverList'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a delegate'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'SliverChildBuilderDelegate'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'context'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' index'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' title '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'GalleryLocalizations'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'of'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'context'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'starterAppDrawerItem'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'index '), + TextSpan(style: codeStyle.punctuationStyle, text: '+'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.numberStyle, text: '1'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'return'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'ListTile'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a onTap'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '()'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'Navigator'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'of'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'context'), + TextSpan(style: codeStyle.punctuationStyle, text: ').'), + TextSpan(style: codeStyle.baseStyle, text: 'push'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.classStyle, text: 'CupertinoPageRoute'), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.keywordStyle, text: 'void'), + TextSpan(style: codeStyle.punctuationStyle, text: '>('), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a title'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' title'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a builder'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'context'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '=>'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: '_SecondPage'), + TextSpan(style: codeStyle.punctuationStyle, text: '(),'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '));'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '},'), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a title'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'Text'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'title'), + TextSpan(style: codeStyle.punctuationStyle, text: '),'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '},'), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a childCount'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.numberStyle, text: '20'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '),'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '),'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '),'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '],'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '),'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '),'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '});'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'class'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: '_SecondPage'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'extends'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'StatelessWidget'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: '@override'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'Widget'), + TextSpan(style: codeStyle.baseStyle, text: ' build'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.classStyle, text: 'BuildContext'), + TextSpan(style: codeStyle.baseStyle, text: ' context'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'return'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'CupertinoPageScaffold'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a navigationBar'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'const'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'CupertinoNavigationBar'), + TextSpan(style: codeStyle.punctuationStyle, text: '(),'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a child'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'Container'), + TextSpan(style: codeStyle.punctuationStyle, text: '(),'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), + TextSpan( + style: codeStyle.commentStyle, + text: '/// A CupertinoPageRoute without any transition animations.'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'class'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.classStyle, text: '_NoAnimationCupertinoPageRoute'), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.classStyle, text: 'T'), + TextSpan(style: codeStyle.punctuationStyle, text: '>'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'extends'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'CupertinoPageRoute'), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.classStyle, text: 'T'), + TextSpan(style: codeStyle.punctuationStyle, text: '>'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan( + style: codeStyle.classStyle, text: '_NoAnimationCupertinoPageRoute'), + TextSpan(style: codeStyle.punctuationStyle, text: '({'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: '@required'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'WidgetBuilder'), + TextSpan(style: codeStyle.baseStyle, text: ' builder'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'String'), + TextSpan(style: codeStyle.baseStyle, text: ' title'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '})'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'super'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'builder'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' builder'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' title'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' title'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: '@override'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'Widget'), + TextSpan(style: codeStyle.baseStyle, text: ' buildTransitions'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'BuildContext'), + TextSpan(style: codeStyle.baseStyle, text: ' context'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'Animation'), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.keywordStyle, text: 'double'), + TextSpan(style: codeStyle.punctuationStyle, text: '>'), + TextSpan(style: codeStyle.baseStyle, text: ' animation'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'Animation'), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.keywordStyle, text: 'double'), + TextSpan(style: codeStyle.punctuationStyle, text: '>'), + TextSpan(style: codeStyle.baseStyle, text: ' secondaryAnimation'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'Widget'), + TextSpan(style: codeStyle.baseStyle, text: ' child'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'return'), + TextSpan(style: codeStyle.baseStyle, text: ' child'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), + ]); + } + static TextSpan cupertinoSegmentedControlDemo(BuildContext context) { final CodeStyle codeStyle = CodeStyle.of(context); return TextSpan(children: [ @@ -881,6 +1301,13 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'CupertinoNavigationBar'), TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a automaticallyImplyLeading'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'false'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a middle'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -1024,6 +1451,13 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'CupertinoNavigationBar'), TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a automaticallyImplyLeading'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'false'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a middle'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -1448,6 +1882,13 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'CupertinoNavigationBar'), TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a automaticallyImplyLeading'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'false'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a middle'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -10395,6 +10836,13 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'AppBar'), TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a automaticallyImplyLeading'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'false'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a title'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -14477,6 +14925,13 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'AppBar'), TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a automaticallyImplyLeading'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'false'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a title'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), diff --git a/gallery/gallery/lib/data/demos.dart b/gallery/gallery/lib/data/demos.dart index b92322693..a590dfc2c 100644 --- a/gallery/gallery/lib/data/demos.dart +++ b/gallery/gallery/lib/data/demos.dart @@ -11,6 +11,7 @@ import 'package:gallery/data/icons.dart'; import 'package:gallery/demos/cupertino/cupertino_activity_indicator_demo.dart'; import 'package:gallery/demos/cupertino/cupertino_alert_demo.dart'; import 'package:gallery/demos/cupertino/cupertino_button_demo.dart'; +import 'package:gallery/demos/cupertino/cupertino_navigation_bar_demo.dart'; import 'package:gallery/demos/cupertino/cupertino_segmented_control_demo.dart'; import 'package:gallery/demos/cupertino/cupertino_slider_demo.dart'; import 'package:gallery/demos/cupertino/cupertino_switch_demo.dart'; @@ -480,22 +481,6 @@ List cupertinoDemos(BuildContext context) { ), ], ), - GalleryDemo( - title: GalleryLocalizations.of(context).demoCupertinoButtonsTitle, - icon: GalleryIcons.genericButtons, - subtitle: GalleryLocalizations.of(context).demoCupertinoButtonsSubtitle, - configurations: [ - GalleryDemoConfiguration( - title: GalleryLocalizations.of(context).demoCupertinoButtonsTitle, - description: - GalleryLocalizations.of(context).demoCupertinoButtonsDescription, - documentationUrl: - 'https://api.flutter.dev/flutter/cupertino/CupertinoButton-class.html', - buildRoute: (_) => CupertinoButtonDemo(), - code: CodeSegments.cupertinoButtonDemo, - ), - ], - ), GalleryDemo( title: GalleryLocalizations.of(context).demoCupertinoAlertsTitle, icon: GalleryIcons.dialogs, @@ -554,6 +539,40 @@ List cupertinoDemos(BuildContext context) { ), ], ), + GalleryDemo( + title: GalleryLocalizations.of(context).demoCupertinoButtonsTitle, + icon: GalleryIcons.genericButtons, + subtitle: GalleryLocalizations.of(context).demoCupertinoButtonsSubtitle, + configurations: [ + GalleryDemoConfiguration( + title: GalleryLocalizations.of(context).demoCupertinoButtonsTitle, + description: + GalleryLocalizations.of(context).demoCupertinoButtonsDescription, + documentationUrl: + 'https://api.flutter.dev/flutter/cupertino/CupertinoButton-class.html', + buildRoute: (_) => CupertinoButtonDemo(), + code: CodeSegments.cupertinoButtonDemo, + ), + ], + ), + GalleryDemo( + title: GalleryLocalizations.of(context).demoCupertinoNavigationBarTitle, + icon: GalleryIcons.bottomSheetPersistent, + subtitle: + GalleryLocalizations.of(context).demoCupertinoNavigationBarSubtitle, + configurations: [ + GalleryDemoConfiguration( + title: + GalleryLocalizations.of(context).demoCupertinoNavigationBarTitle, + description: GalleryLocalizations.of(context) + .demoCupertinoNavigationBarDescription, + documentationUrl: + 'https://api.flutter.dev/flutter/cupertino/CupertinoNavigationBar-class.html', + buildRoute: (_) => CupertinoNavigationBarDemo(), + code: CodeSegments.cupertinoNavigationBarDemo, + ), + ], + ), GalleryDemo( title: GalleryLocalizations.of(context).demoCupertinoSegmentedControlTitle, diff --git a/gallery/gallery/lib/demos/cupertino/cupertino_navigation_bar_demo.dart b/gallery/gallery/lib/demos/cupertino/cupertino_navigation_bar_demo.dart new file mode 100644 index 000000000..c93990ca7 --- /dev/null +++ b/gallery/gallery/lib/demos/cupertino/cupertino_navigation_bar_demo.dart @@ -0,0 +1,82 @@ +// 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/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:gallery/l10n/gallery_localizations.dart'; + +// BEGIN cupertinoNavigationBarDemo + +class CupertinoNavigationBarDemo extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Navigator(onGenerateRoute: (settings) { + return _NoAnimationCupertinoPageRoute( + title: GalleryLocalizations.of(context).demoCupertinoNavigationBarTitle, + builder: (context) => CupertinoPageScaffold( + child: CustomScrollView( + slivers: [ + CupertinoSliverNavigationBar( + automaticallyImplyLeading: false, + ), + SliverPadding( + padding: MediaQuery.of(context) + .removePadding(removeTop: true) + .padding, + sliver: SliverList( + delegate: SliverChildBuilderDelegate( + (context, index) { + final title = GalleryLocalizations.of(context) + .starterAppDrawerItem(index + 1); + return ListTile( + onTap: () { + Navigator.of(context).push(CupertinoPageRoute( + title: title, + builder: (context) => _SecondPage(), + )); + }, + title: Text(title), + ); + }, + childCount: 20, + ), + ), + ), + ], + ), + ), + ); + }); + } +} + +class _SecondPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + return CupertinoPageScaffold( + navigationBar: const CupertinoNavigationBar(), + child: Container(), + ); + } +} + +/// A CupertinoPageRoute without any transition animations. +class _NoAnimationCupertinoPageRoute extends CupertinoPageRoute { + _NoAnimationCupertinoPageRoute({ + @required WidgetBuilder builder, + String title, + }) : super(builder: builder, title: title); + + @override + Widget buildTransitions( + BuildContext context, + Animation animation, + Animation secondaryAnimation, + Widget child, + ) { + return child; + } +} + +// END diff --git a/gallery/gallery/lib/l10n/gallery_localizations.dart b/gallery/gallery/lib/l10n/gallery_localizations.dart index d29f933bc..98bf62649 100644 --- a/gallery/gallery/lib/l10n/gallery_localizations.dart +++ b/gallery/gallery/lib/l10n/gallery_localizations.dart @@ -1645,6 +1645,28 @@ class GalleryLocalizations { desc: r'Title for the cupertino buttons component demo.'); } + String get demoCupertinoNavigationBarDescription { + return Intl.message( + r'An iOS-styled navigation bar. The navigation bar is a toolbar that minimally consists of a page title, in the middle of the toolbar.', + locale: _localeName, + name: 'demoCupertinoNavigationBarDescription', + desc: r'Description for the cupertino navigation bar component demo.'); + } + + String get demoCupertinoNavigationBarSubtitle { + return Intl.message(r'iOS-style navigation bar', + locale: _localeName, + name: 'demoCupertinoNavigationBarSubtitle', + desc: r'Subtitle for the cupertino navigation bar component demo.'); + } + + String get demoCupertinoNavigationBarTitle { + return Intl.message(r'Navigation Bar', + locale: _localeName, + name: 'demoCupertinoNavigationBarTitle', + desc: r'Title for the cupertino navigation bar component demo.'); + } + String get demoCupertinoSegmentedControlDescription { return Intl.message( r'Used to select between a number of mutually exclusive options. When one option in the segmented control is selected, the other options in the segmented control cease to be selected.', diff --git a/gallery/gallery/lib/l10n/intl_en_US.arb b/gallery/gallery/lib/l10n/intl_en_US.arb index d29b17bc2..9b4d2550b 100644 --- a/gallery/gallery/lib/l10n/intl_en_US.arb +++ b/gallery/gallery/lib/l10n/intl_en_US.arb @@ -733,6 +733,18 @@ "@demoCupertinoActionSheetDescription": { "description": "Description for the cupertino action sheet component demo." }, + "demoCupertinoNavigationBarTitle": "Navigation Bar", + "@demoCupertinoNavigationBarTitle": { + "description": "Title for the cupertino navigation bar component demo." + }, + "demoCupertinoNavigationBarSubtitle": "iOS-style navigation bar", + "@demoCupertinoNavigationBarSubtitle": { + "description": "Subtitle for the cupertino navigation bar component demo." + }, + "demoCupertinoNavigationBarDescription": "An iOS-styled navigation bar. The navigation bar is a toolbar that minimally consists of a page title, in the middle of the toolbar.", + "@demoCupertinoNavigationBarDescription": { + "description": "Description for the cupertino navigation bar component demo." + }, "demoCupertinoSegmentedControlTitle": "Segmented Control", "@demoCupertinoSegmentedControlTitle": { "description": "Title for the cupertino segmented control component demo." diff --git a/gallery/gallery/lib/l10n/intl_en_US.xml b/gallery/gallery/lib/l10n/intl_en_US.xml index 748386da8..2f6748177 100644 --- a/gallery/gallery/lib/l10n/intl_en_US.xml +++ b/gallery/gallery/lib/l10n/intl_en_US.xml @@ -697,6 +697,18 @@ name="demoCupertinoActionSheetDescription" description="Description for the cupertino action sheet component demo." >An action sheet is a specific style of alert that presents the user with a set of two or more choices related to the current context. An action sheet can have a title, an additional message, and a list of actions. + Navigation Bar + iOS-style navigation bar + An iOS-styled navigation bar. The navigation bar is a toolbar that minimally consists of a page title, in the middle of the toolbar.