Reformats platform_design to match repo conventions, fixes missing icon (#89)

pull/90/head
Andrew Brogdon 6 years ago committed by GitHub
parent 325c5a5d2b
commit 938ef8682c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -46,7 +46,8 @@ class MyAdaptingApp extends StatelessWidget {
// depending on the app and content. // depending on the app and content.
class PlatformAdaptingHomePage extends StatefulWidget { class PlatformAdaptingHomePage extends StatefulWidget {
@override @override
_PlatformAdaptingHomePageState createState() => _PlatformAdaptingHomePageState(); _PlatformAdaptingHomePageState createState() =>
_PlatformAdaptingHomePageState();
} }
class _PlatformAdaptingHomePageState extends State<PlatformAdaptingHomePage> { class _PlatformAdaptingHomePageState extends State<PlatformAdaptingHomePage> {
@ -80,9 +81,12 @@ class _PlatformAdaptingHomePageState extends State<PlatformAdaptingHomePage> {
return CupertinoTabScaffold( return CupertinoTabScaffold(
tabBar: CupertinoTabBar( tabBar: CupertinoTabBar(
items: [ items: [
BottomNavigationBarItem(title: Text(SongsTab.title), icon: SongsTab.iosIcon), BottomNavigationBarItem(
BottomNavigationBarItem(title: Text(NewsTab.title), icon: NewsTab.iosIcon), title: Text(SongsTab.title), icon: SongsTab.iosIcon),
BottomNavigationBarItem(title: Text(ProfileTab.title), icon: ProfileTab.iosIcon), BottomNavigationBarItem(
title: Text(NewsTab.title), icon: NewsTab.iosIcon),
BottomNavigationBarItem(
title: Text(ProfileTab.title), icon: ProfileTab.iosIcon),
], ],
), ),
tabBuilder: (context, index) { tabBuilder: (context, index) {
@ -149,9 +153,8 @@ class _AndroidDrawer extends StatelessWidget {
title: Text(NewsTab.title), title: Text(NewsTab.title),
onTap: () { onTap: () {
Navigator.pop(context); Navigator.pop(context);
Navigator.push(context, MaterialPageRoute( Navigator.push(
builder: (context) => NewsTab() context, MaterialPageRoute(builder: (context) => NewsTab()));
));
}, },
), ),
ListTile( ListTile(
@ -159,9 +162,8 @@ class _AndroidDrawer extends StatelessWidget {
title: Text(ProfileTab.title), title: Text(ProfileTab.title),
onTap: () { onTap: () {
Navigator.pop(context); Navigator.pop(context);
Navigator.push(context, MaterialPageRoute( Navigator.push(context,
builder: (context) => ProfileTab() MaterialPageRoute(builder: (context) => ProfileTab()));
));
}, },
), ),
// Long drawer contents are often segmented. // Long drawer contents are often segmented.
@ -174,9 +176,8 @@ class _AndroidDrawer extends StatelessWidget {
title: Text(SettingsTab.title), title: Text(SettingsTab.title),
onTap: () { onTap: () {
Navigator.pop(context); Navigator.pop(context);
Navigator.push(context, MaterialPageRoute( Navigator.push(context,
builder: (context) => SettingsTab() MaterialPageRoute(builder: (context) => SettingsTab()));
));
}, },
), ),
], ],

@ -26,13 +26,13 @@ class _NewsTabState extends State<NewsTab> {
void initState() { void initState() {
colors = getRandomColors(_itemsLength); colors = getRandomColors(_itemsLength);
titles = List.generate(_itemsLength, (index) => generateRandomHeadline()); titles = List.generate(_itemsLength, (index) => generateRandomHeadline());
contents = List.generate(_itemsLength, (index) => lorem(paragraphs: 1, words: 24)); contents =
List.generate(_itemsLength, (index) => lorem(paragraphs: 1, words: 24));
super.initState(); super.initState();
} }
Widget _listBuilder(context, index) { Widget _listBuilder(context, index) {
if (index >= _itemsLength) if (index >= _itemsLength) return null;
return null;
return SafeArea( return SafeArea(
top: false, top: false,
@ -81,7 +81,7 @@ class _NewsTabState extends State<NewsTab> {
], ],
), ),
), ),
) ),
), ),
); );
} }

@ -18,10 +18,13 @@ class ProfileTab extends StatelessWidget {
Padding( Padding(
padding: EdgeInsets.all(8), padding: EdgeInsets.all(8),
child: Center( child: Center(
child: Text('😼', style: TextStyle( child: Text(
fontSize: 80, '😼',
decoration: TextDecoration.none, style: TextStyle(
)), fontSize: 80,
decoration: TextDecoration.none,
),
),
), ),
), ),
PreferenceCard( PreferenceCard(
@ -102,7 +105,7 @@ class ProfileTab extends StatelessWidget {
} }
class PreferenceCard extends StatelessWidget { class PreferenceCard extends StatelessWidget {
const PreferenceCard({ this.header, this.content, this.preferenceChoices }); const PreferenceCard({this.header, this.content, this.preferenceChoices});
final String header; final String header;
final String content; final String content;
@ -157,7 +160,8 @@ class PreferenceCard extends StatelessWidget {
} }
class LogOutButton extends StatelessWidget { class LogOutButton extends StatelessWidget {
static const _logoutMessage = Text('You may check out any time you like, but you can never leave'); static const _logoutMessage =
Text('You may check out any time you like, but you can never leave');
// =========================================================================== // ===========================================================================
// Non-shared code below because this tab shows different interfaces. On // Non-shared code below because this tab shows different interfaces. On
@ -183,7 +187,7 @@ class LogOutButton extends StatelessWidget {
actions: [ actions: [
FlatButton( FlatButton(
child: const Text('Go back'), child: const Text('Go back'),
onPressed: () => Navigator.pop(context) , onPressed: () => Navigator.pop(context),
), ),
FlatButton( FlatButton(
child: const Text('Cancel'), child: const Text('Cancel'),
@ -191,7 +195,7 @@ class LogOutButton extends StatelessWidget {
), ),
], ],
); );
} },
); );
}, },
); );

@ -13,8 +13,13 @@ class SettingsTab extends StatefulWidget {
} }
class _SettingsTabState extends State<SettingsTab> { class _SettingsTabState extends State<SettingsTab> {
var switch1 = false; var switch2 = true; var switch3 = true; var switch4 = true; var switch1 = false;
var switch5 = true; var switch6 = false; var switch7 = true; var switch2 = true;
var switch3 = true;
var switch4 = true;
var switch5 = true;
var switch6 = false;
var switch7 = true;
Widget _buildList() { Widget _buildList() {
return ListView( return ListView(

@ -8,7 +8,7 @@ import 'widgets.dart';
// On Android, this page sits at the top of your app. On iOS, this page is on // On Android, this page sits at the top of your app. On iOS, this page is on
// top of the songs tab's content but is below the tab bar itself. // top of the songs tab's content but is below the tab bar itself.
class SongDetailTab extends StatelessWidget { class SongDetailTab extends StatelessWidget {
const SongDetailTab({ this.id, this.song, this.color }); const SongDetailTab({this.id, this.song, this.color});
final int id; final int id;
final String song; final String song;
@ -33,7 +33,8 @@ class SongDetailTab extends StatelessWidget {
// to build while the hero transition is mid-flight. // to build while the hero transition is mid-flight.
// //
// It could either be specified here or in SongsTab. // It could either be specified here or in SongsTab.
flightShuttleBuilder: (context, animation, flightDirection, fromHeroContext, toHeroContext) { flightShuttleBuilder: (context, animation, flightDirection,
fromHeroContext, toHeroContext) {
return HeroAnimatingSongCard( return HeroAnimatingSongCard(
song: song, song: song,
color: color, color: color,
@ -51,11 +52,15 @@ class SongDetailTab extends StatelessWidget {
itemBuilder: (context, index) { itemBuilder: (context, index) {
if (index == 0) { if (index == 0) {
return Padding( return Padding(
padding: const EdgeInsets.only(left: 15, top: 16, bottom: 8), padding:
child: Text('You might also like:', style: TextStyle( const EdgeInsets.only(left: 15, top: 16, bottom: 8),
fontSize: 16, child: Text(
fontWeight: FontWeight.w500, 'You might also like:',
)), style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
); );
} }
// Just a bunch of boxes that simulates loading song choices. // Just a bunch of boxes that simulates loading song choices.

@ -11,7 +11,7 @@ class SongsTab extends StatefulWidget {
static const androidIcon = Icon(Icons.music_note); static const androidIcon = Icon(Icons.music_note);
static const iosIcon = Icon(CupertinoIcons.music_note); static const iosIcon = Icon(CupertinoIcons.music_note);
const SongsTab({ Key key, this.androidDrawer }) : super(key: key); const SongsTab({Key key, this.androidDrawer}) : super(key: key);
final Widget androidDrawer; final Widget androidDrawer;
@ -47,8 +47,7 @@ class _SongsTabState extends State<SongsTab> {
} }
Widget _listBuilder(context, index) { Widget _listBuilder(context, index) {
if (index >= _itemsLength) if (index >= _itemsLength) return null;
return null;
// Show a slightly different color palette. Show poppy-ier colors on iOS // Show a slightly different color palette. Show poppy-ier colors on iOS
// due to lighter contrasting bars and tone it down on Android. // due to lighter contrasting bars and tone it down on Android.
@ -65,13 +64,15 @@ class _SongsTabState extends State<SongsTab> {
song: songNames[index], song: songNames[index],
color: color, color: color,
heroAnimation: AlwaysStoppedAnimation(0), heroAnimation: AlwaysStoppedAnimation(0),
onPressed: () => Navigator.of(context).push(MaterialPageRoute( onPressed: () => Navigator.of(context).push(
builder: (context) => SongDetailTab( MaterialPageRoute(
id: index, builder: (context) => SongDetailTab(
song: songNames[index], id: index,
color: color, song: songNames[index],
), color: color,
)), ),
),
),
), ),
), ),
); );
@ -138,7 +139,9 @@ class _SongsTabState extends State<SongsTab> {
CupertinoSliverNavigationBar( CupertinoSliverNavigationBar(
trailing: CupertinoButton( trailing: CupertinoButton(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
child: Icon(CupertinoIcons.shuffle), // TODO(redbrogdon): Change this back to shuffle once the new icon
// makes it into Flutter's stable channel.
child: Icon(CupertinoIcons.shuffle_thick),
onPressed: _togglePlatform, onPressed: _togglePlatform,
), ),
), ),

@ -11,8 +11,16 @@ import 'package:flutter/material.dart';
// This file has a number of platform-agnostic non-Widget utility functions. // This file has a number of platform-agnostic non-Widget utility functions.
const _myListOfRandomColors = [ const _myListOfRandomColors = [
Colors.red, Colors.blue, Colors.teal, Colors.yellow, Colors.amber, Colors.red,
Colors.deepOrange, Colors.green, Colors.indigo, Colors.lime, Colors.pink, Colors.blue,
Colors.teal,
Colors.yellow,
Colors.amber,
Colors.deepOrange,
Colors.green,
Colors.indigo,
Colors.lime,
Colors.pink,
Colors.orange, Colors.orange,
]; ];
@ -32,8 +40,7 @@ Iterable<WordPair> generateWordPair() sync* {
} }
final suffix = pickRandom(nouns); final suffix = pickRandom(nouns);
if (filterWord(prefix) || filterWord(suffix)) if (filterWord(prefix) || filterWord(suffix)) continue;
continue;
final wordPair = WordPair(prefix, suffix); final wordPair = WordPair(prefix, suffix);
yield wordPair; yield wordPair;

@ -8,9 +8,9 @@ class PlatformWidget extends StatelessWidget {
Key key, Key key,
@required this.androidBuilder, @required this.androidBuilder,
@required this.iosBuilder, @required this.iosBuilder,
}) : assert(androidBuilder != null), }) : assert(androidBuilder != null),
assert(iosBuilder != null), assert(iosBuilder != null),
super(key: key); super(key: key);
final WidgetBuilder androidBuilder; final WidgetBuilder androidBuilder;
final WidgetBuilder iosBuilder; final WidgetBuilder iosBuilder;
@ -50,7 +50,8 @@ class PressableCard extends StatefulWidget {
State<StatefulWidget> createState() => new _PressableCardState(); State<StatefulWidget> createState() => new _PressableCardState();
} }
class _PressableCardState extends State<PressableCard> with SingleTickerProviderStateMixin { class _PressableCardState extends State<PressableCard>
with SingleTickerProviderStateMixin {
bool pressed = false; bool pressed = false;
AnimationController controller; AnimationController controller;
Animation<double> elevationAnimation; Animation<double> elevationAnimation;
@ -61,7 +62,8 @@ class _PressableCardState extends State<PressableCard> with SingleTickerProvider
vsync: this, vsync: this,
duration: const Duration(milliseconds: 40), duration: const Duration(milliseconds: 40),
); );
elevationAnimation = controller.drive(CurveTween(curve: Curves.easeInOutCubic)); elevationAnimation =
controller.drive(CurveTween(curve: Curves.easeInOutCubic));
super.initState(); super.initState();
} }
@ -76,8 +78,14 @@ class _PressableCardState extends State<PressableCard> with SingleTickerProvider
@override @override
Widget build(context) { Widget build(context) {
return Listener( return Listener(
onPointerDown: (details) { if (widget.onPressed != null) { controller.forward(); } }, onPointerDown: (details) {
onPointerUp: (details) { controller.reverse(); }, if (widget.onPressed != null) {
controller.forward();
}
},
onPointerUp: (details) {
controller.reverse();
},
child: GestureDetector( child: GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () { onTap: () {
@ -90,7 +98,8 @@ class _PressableCardState extends State<PressableCard> with SingleTickerProvider
// hero animation. You likely want to modularize them more in your own // hero animation. You likely want to modularize them more in your own
// app. // app.
child: AnimatedBuilder( child: AnimatedBuilder(
animation: Listenable.merge([elevationAnimation, widget.flattenAnimation]), animation:
Listenable.merge([elevationAnimation, widget.flattenAnimation]),
child: widget.child, child: widget.child,
builder: (context, child) { builder: (context, child) {
return Transform.scale( return Transform.scale(
@ -98,9 +107,11 @@ class _PressableCardState extends State<PressableCard> with SingleTickerProvider
// in your own app. // in your own app.
scale: 1 - elevationAnimation.value * 0.03, scale: 1 - elevationAnimation.value * 0.03,
child: Padding( child: Padding(
padding: EdgeInsets.symmetric(vertical: 16, horizontal: 16) * flatten, padding: EdgeInsets.symmetric(vertical: 16, horizontal: 16) *
flatten,
child: PhysicalModel( child: PhysicalModel(
elevation: ((1 - elevationAnimation.value) * 10 + 10) * flatten, elevation:
((1 - elevationAnimation.value) * 10 + 10) * flatten,
borderRadius: BorderRadius.circular(12 * flatten), borderRadius: BorderRadius.circular(12 * flatten),
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
color: widget.color, color: widget.color,
@ -123,7 +134,8 @@ class _PressableCardState extends State<PressableCard> with SingleTickerProvider
/// This is an example of a custom widget that an app developer might create for /// This is an example of a custom widget that an app developer might create for
/// use on both iOS and Android as part of their brand's unique design. /// use on both iOS and Android as part of their brand's unique design.
class HeroAnimatingSongCard extends StatelessWidget { class HeroAnimatingSongCard extends StatelessWidget {
HeroAnimatingSongCard({ this.song, this.color, this.heroAnimation, this.onPressed }); HeroAnimatingSongCard(
{this.song, this.color, this.heroAnimation, this.onPressed});
final String song; final String song;
final Color color; final Color color;
@ -154,7 +166,7 @@ class HeroAnimatingSongCard extends StatelessWidget {
children: [ children: [
// The song title banner slides off in the hero animation. // The song title banner slides off in the hero animation.
Positioned( Positioned(
bottom: - 80 * heroAnimation.value, bottom: -80 * heroAnimation.value,
left: 0, left: 0,
right: 0, right: 0,
child: Container( child: Container(
@ -173,7 +185,8 @@ class HeroAnimatingSongCard extends StatelessWidget {
), ),
// The play button grows in the hero animation. // The play button grows in the hero animation.
Padding( Padding(
padding: EdgeInsets.only(bottom: 45) * (1 - heroAnimation.value), padding:
EdgeInsets.only(bottom: 45) * (1 - heroAnimation.value),
child: Container( child: Container(
height: playButtonSize, height: playButtonSize,
width: playButtonSize, width: playButtonSize,
@ -182,7 +195,8 @@ class HeroAnimatingSongCard extends StatelessWidget {
color: Colors.black12, color: Colors.black12,
), ),
alignment: Alignment.center, alignment: Alignment.center,
child: Icon(Icons.play_arrow, size: playButtonSize, color: Colors.black38), child: Icon(Icons.play_arrow,
size: playButtonSize, color: Colors.black38),
), ),
), ),
], ],
@ -315,17 +329,19 @@ void showChoices(BuildContext context, List<String> choices) {
itemExtent: 40, itemExtent: 40,
scrollController: FixedExtentScrollController(initialItem: 1), scrollController: FixedExtentScrollController(initialItem: 1),
children: List<Widget>.generate(choices.length, (index) { children: List<Widget>.generate(choices.length, (index) {
return Center(child: Text( return Center(
choices[index], child: Text(
style: TextStyle( choices[index],
fontSize: 21, style: TextStyle(
fontSize: 21,
),
), ),
)); );
}), }),
onSelectedItemChanged: (value) {}, onSelectedItemChanged: (value) {},
), ),
); );
} },
); );
return; return;
default: default:

@ -0,0 +1,161 @@
# Generated by pub
# See https://www.dartlang.org/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
english_words:
dependency: "direct main"
description:
name: english_words
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.5"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_lorem:
dependency: "direct main"
description:
name: flutter_lorem
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.5"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.3"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.4"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
sdks:
dart: ">=2.2.0 <3.0.0"
flutter: ">=1.5.2"
Loading…
Cancel
Save