diff --git a/gallery/gallery/lib/codeviewer/code_segments.dart b/gallery/gallery/lib/codeviewer/code_segments.dart index f6b1162ab..5fb6b04be 100644 --- a/gallery/gallery/lib/codeviewer/code_segments.dart +++ b/gallery/gallery/lib/codeviewer/code_segments.dart @@ -413,6 +413,551 @@ class CodeSegments { ]); } + static TextSpan cupertinoNavigationDemo(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\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: '_TabInfo'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'const'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: '_TabInfo'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.keywordStyle, text: 'this'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'title'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'this'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'icon'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + 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.keywordStyle, text: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'IconData'), + TextSpan(style: codeStyle.baseStyle, text: ' icon'), + 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: 'CupertinoNavigationDemo'), + 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: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' _tabInfo '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.classStyle, text: '_TabInfo'), + TextSpan(style: codeStyle.punctuationStyle, text: '>['), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: '_TabInfo'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + 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: 'cupertinoNavigationHomeTab'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'CupertinoIcons'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'home'), + 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: '_TabInfo'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + 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: 'cupertinoNavigationChatTab'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'CupertinoIcons'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'conversation_bubble'), + 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: '_TabInfo'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + 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: 'cupertinoNavigationProfileTab'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'CupertinoIcons'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'profile_circled'), + 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: 'return'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'DefaultTextStyle'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a style'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'CupertinoTheme'), + 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: 'textTheme'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'textStyle'), + 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: 'CupertinoTabScaffold'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a tabBar'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'CupertinoTabBar'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a items'), + 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: 'for'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.keywordStyle, text: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' tabInfo '), + TextSpan(style: codeStyle.keywordStyle, text: 'in'), + TextSpan(style: codeStyle.baseStyle, text: ' _tabInfo'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'BottomNavigationBarItem'), + 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: 'tabInfo'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'title'), + TextSpan(style: codeStyle.punctuationStyle, text: '),'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a icon'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'Icon'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'tabInfo'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'icon'), + 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 tabBuilder'), + 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: ' 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: 'switch'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + 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: 'case'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.numberStyle, text: '0'), + 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: 'CupertinoTabView'), + 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: '_CupertinoDemoTab'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a title'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' _tabInfo'), + TextSpan(style: codeStyle.punctuationStyle, text: '['), + TextSpan(style: codeStyle.numberStyle, text: '0'), + TextSpan(style: codeStyle.punctuationStyle, text: '].'), + TextSpan(style: codeStyle.baseStyle, text: 'title'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a icon'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' _tabInfo'), + TextSpan(style: codeStyle.punctuationStyle, text: '['), + TextSpan(style: codeStyle.numberStyle, text: '0'), + TextSpan(style: codeStyle.punctuationStyle, text: '].'), + TextSpan(style: codeStyle.baseStyle, text: 'icon'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '),'), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a defaultTitle'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' _tabInfo'), + TextSpan(style: codeStyle.punctuationStyle, text: '['), + TextSpan(style: codeStyle.numberStyle, text: '0'), + 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.keywordStyle, text: 'break'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'case'), + 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: 'CupertinoTabView'), + 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: '_CupertinoDemoTab'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a title'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' _tabInfo'), + TextSpan(style: codeStyle.punctuationStyle, text: '['), + TextSpan(style: codeStyle.numberStyle, text: '1'), + TextSpan(style: codeStyle.punctuationStyle, text: '].'), + TextSpan(style: codeStyle.baseStyle, text: 'title'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a icon'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' _tabInfo'), + TextSpan(style: codeStyle.punctuationStyle, text: '['), + TextSpan(style: codeStyle.numberStyle, text: '1'), + TextSpan(style: codeStyle.punctuationStyle, text: '].'), + TextSpan(style: codeStyle.baseStyle, text: 'icon'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '),'), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a defaultTitle'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' _tabInfo'), + TextSpan(style: codeStyle.punctuationStyle, text: '['), + TextSpan(style: codeStyle.numberStyle, text: '1'), + 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.keywordStyle, text: 'break'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'case'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.numberStyle, text: '2'), + 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: 'CupertinoTabView'), + 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: '_CupertinoDemoTab'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a title'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' _tabInfo'), + TextSpan(style: codeStyle.punctuationStyle, text: '['), + TextSpan(style: codeStyle.numberStyle, text: '2'), + TextSpan(style: codeStyle.punctuationStyle, text: '].'), + TextSpan(style: codeStyle.baseStyle, text: 'title'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a icon'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' _tabInfo'), + TextSpan(style: codeStyle.punctuationStyle, text: '['), + TextSpan(style: codeStyle.numberStyle, text: '2'), + TextSpan(style: codeStyle.punctuationStyle, text: '].'), + TextSpan(style: codeStyle.baseStyle, text: 'icon'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '),'), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a defaultTitle'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' _tabInfo'), + TextSpan(style: codeStyle.punctuationStyle, text: '['), + TextSpan(style: codeStyle.numberStyle, text: '2'), + 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.keywordStyle, text: 'break'), + 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.keywordStyle, text: 'return'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'null'), + 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: '_CupertinoDemoTab'), + 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: 'const'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: '_CupertinoDemoTab'), + TextSpan(style: codeStyle.punctuationStyle, text: '({'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'Key'), + TextSpan(style: codeStyle.baseStyle, text: ' key'), + 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.keywordStyle, text: 'this'), + 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.keywordStyle, text: '@required'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'this'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'icon'), + 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: 'key'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' key'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + 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.keywordStyle, text: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'IconData'), + TextSpan(style: codeStyle.baseStyle, text: ' icon'), + 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: ' 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.classStyle, text: 'CupertinoNavigationBar'), + TextSpan(style: codeStyle.punctuationStyle, text: '(),'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a backgroundColor'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'CupertinoColors'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'systemBackground'), + 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: 'Center'), + 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: 'Icon'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a icon'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a semanticLabel'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' title'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a size'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.numberStyle, text: '100'), + 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'), + ]); + } + static TextSpan cupertinoAlertDemo(BuildContext context) { final CodeStyle codeStyle = CodeStyle.of(context); return TextSpan(children: [ diff --git a/gallery/gallery/lib/data/demos.dart b/gallery/gallery/lib/data/demos.dart index 2f645f957..9e7c068ca 100644 --- a/gallery/gallery/lib/data/demos.dart +++ b/gallery/gallery/lib/data/demos.dart @@ -10,6 +10,7 @@ import 'package:gallery/data/gallery_options.dart'; import 'package:gallery/data/icons.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_tab_bar_demo.dart'; import 'package:gallery/demos/cupertino/cupertino_segmented_control_demo.dart'; import 'package:gallery/demos/material/bottom_navigation_demo.dart'; import 'package:gallery/demos/material/bottom_sheet_demo.dart'; @@ -466,6 +467,22 @@ List cupertinoDemos(BuildContext context) { ), ], ), + GalleryDemo( + title: GalleryLocalizations.of(context).demoCupertinoTabBarTitle, + icon: GalleryIcons.bottomNavigation, + subtitle: GalleryLocalizations.of(context).demoCupertinoTabBarSubtitle, + configurations: [ + GalleryDemoConfiguration( + title: GalleryLocalizations.of(context).demoCupertinoTabBarTitle, + description: + GalleryLocalizations.of(context).demoCupertinoTabBarDescription, + documentationUrl: + 'https://api.flutter.dev/flutter/cupertino/CupertinoTabBar-class.html', + buildRoute: (_) => CupertinoTabBarDemo(), + code: CodeSegments.cupertinoNavigationDemo, + ), + ], + ), ]; } diff --git a/gallery/gallery/lib/demos/cupertino/cupertino_tab_bar_demo.dart b/gallery/gallery/lib/demos/cupertino/cupertino_tab_bar_demo.dart new file mode 100644 index 000000000..7eff3d190 --- /dev/null +++ b/gallery/gallery/lib/demos/cupertino/cupertino_tab_bar_demo.dart @@ -0,0 +1,88 @@ +// 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:gallery/l10n/gallery_localizations.dart'; + +// BEGIN cupertinoNavigationDemo + +class _TabInfo { + const _TabInfo(this.title, this.icon); + + final String title; + final IconData icon; +} + +class CupertinoTabBarDemo extends StatelessWidget { + @override + Widget build(BuildContext context) { + final _tabInfo = [ + _TabInfo( + GalleryLocalizations.of(context).cupertinoTabBarHomeTab, + CupertinoIcons.home, + ), + _TabInfo( + GalleryLocalizations.of(context).cupertinoTabBarChatTab, + CupertinoIcons.conversation_bubble, + ), + _TabInfo( + GalleryLocalizations.of(context).cupertinoTabBarProfileTab, + CupertinoIcons.profile_circled, + ), + ]; + + return DefaultTextStyle( + style: CupertinoTheme.of(context).textTheme.textStyle, + child: CupertinoTabScaffold( + tabBar: CupertinoTabBar( + items: [ + for (final tabInfo in _tabInfo) + BottomNavigationBarItem( + title: Text(tabInfo.title), + icon: Icon(tabInfo.icon), + ), + ], + ), + tabBuilder: (context, index) { + return CupertinoTabView( + builder: (context) => _CupertinoDemoTab( + title: _tabInfo[index].title, + icon: _tabInfo[index].icon, + ), + defaultTitle: _tabInfo[index].title, + ); + }, + ), + ); + } +} + +class _CupertinoDemoTab extends StatelessWidget { + const _CupertinoDemoTab({ + Key key, + @required this.title, + @required this.icon, + }) : super(key: key); + + final String title; + final IconData icon; + + @override + Widget build(BuildContext context) { + return CupertinoPageScaffold( + navigationBar: CupertinoNavigationBar(), + backgroundColor: CupertinoColors.systemBackground, + child: Center( + child: Icon( + icon, + semanticLabel: title, + size: 100, + ), + ), + ); + } +} + +// END diff --git a/gallery/gallery/lib/l10n/gallery_localizations.dart b/gallery/gallery/lib/l10n/gallery_localizations.dart index d32c99d34..01b1e91a6 100644 --- a/gallery/gallery/lib/l10n/gallery_localizations.dart +++ b/gallery/gallery/lib/l10n/gallery_localizations.dart @@ -1174,6 +1174,27 @@ class GalleryLocalizations { desc: r'Button text to show iOS-style alert.'); } + String get cupertinoTabBarChatTab { + return Intl.message(r'Chat', + locale: _localeName, + name: 'cupertinoTabBarChatTab', + desc: r'Title for the chat tab in the bottom tab bar demo.'); + } + + String get cupertinoTabBarHomeTab { + return Intl.message(r'Home', + locale: _localeName, + name: 'cupertinoTabBarHomeTab', + desc: r'Title for the home tab in the bottom tab bar demo.'); + } + + String get cupertinoTabBarProfileTab { + return Intl.message(r'Profile', + locale: _localeName, + name: 'cupertinoTabBarProfileTab', + desc: r'Title for the profile tab in the bottom tab bar demo.'); + } + String get demoActionChipDescription { return Intl.message( r'Action chips are a set of options which trigger an action related to primary content. Action chips should appear dynamically and contextually in a UI.', @@ -1539,6 +1560,28 @@ class GalleryLocalizations { desc: r'Title for the cupertino segmented control component demo.'); } + String get demoCupertinoTabBarDescription { + return Intl.message( + r'An iOS-style bottom navigation tab bar. Displays multiple tabs with one tab being active, the first tab by default.', + locale: _localeName, + name: 'demoCupertinoTabBarDescription', + desc: r'Description for the cupertino bottom tab bar demo.'); + } + + String get demoCupertinoTabBarSubtitle { + return Intl.message(r'iOS-style bottom tab bar', + locale: _localeName, + name: 'demoCupertinoTabBarSubtitle', + desc: r'Subtitle for the cupertino bottom tab bar demo.'); + } + + String get demoCupertinoTabBarTitle { + return Intl.message(r'Tab Bar', + locale: _localeName, + name: 'demoCupertinoTabBarTitle', + desc: r'Title for the cupertino bottom tab bar demo.'); + } + String get demoDialogSubtitle { return Intl.message(r'Simple, alert, and fullscreen', locale: _localeName, diff --git a/gallery/gallery/lib/l10n/intl_en_US.arb b/gallery/gallery/lib/l10n/intl_en_US.arb index 6d1d603f4..1e7dc39ff 100644 --- a/gallery/gallery/lib/l10n/intl_en_US.arb +++ b/gallery/gallery/lib/l10n/intl_en_US.arb @@ -645,6 +645,30 @@ "@demoCupertinoSegmentedControlDescription": { "description": "Description for the cupertino segmented control component demo." }, + "demoCupertinoTabBarTitle": "Tab Bar", + "@demoCupertinoTabBarTitle": { + "description": "Title for the cupertino bottom tab bar demo." + }, + "demoCupertinoTabBarSubtitle": "iOS-style bottom tab bar", + "@demoCupertinoTabBarSubtitle": { + "description": "Subtitle for the cupertino bottom tab bar demo." + }, + "demoCupertinoTabBarDescription": "An iOS-style bottom navigation tab bar. Displays multiple tabs with one tab being active, the first tab by default.", + "@demoCupertinoTabBarDescription": { + "description": "Description for the cupertino bottom tab bar demo." + }, + "cupertinoTabBarHomeTab": "Home", + "@cupertinoTabBarHomeTab": { + "description": "Title for the home tab in the bottom tab bar demo." + }, + "cupertinoTabBarChatTab": "Chat", + "@cupertinoTabBarChatTab": { + "description": "Title for the chat tab in the bottom tab bar demo." + }, + "cupertinoTabBarProfileTab": "Profile", + "@cupertinoTabBarProfileTab": { + "description": "Title for the profile tab in the bottom tab bar demo." + }, "demoColorsTitle": "Colors", "@demoColorsTitle": { "description": "Title for the colors demo." diff --git a/gallery/gallery/lib/l10n/intl_en_US.xml b/gallery/gallery/lib/l10n/intl_en_US.xml index de0d99eaf..7ed170da1 100644 --- a/gallery/gallery/lib/l10n/intl_en_US.xml +++ b/gallery/gallery/lib/l10n/intl_en_US.xml @@ -609,6 +609,30 @@ name="demoCupertinoSegmentedControlDescription" description="Description for the cupertino segmented control component demo." >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. + Tab Bar + iOS-style bottom tab bar + An iOS-style bottom navigation tab bar. Displays multiple tabs with one tab being active, the first tab by default. + Home + Chat + Profile