Visitar URL original
Shared Axis Transition Demo App by shihaohong · Pull Request #61 · flutter/packages · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
WIP - sign in page
  • Loading branch information
Shi Hao Hong
Shi Hao Hong committed Jan 15, 2020
commit 8ebe83c51893d6ec249f7c2b5f2b0154f2af87d1
206 changes: 205 additions & 1 deletion packages/animations/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,207 @@
import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: license header


void main() => runApp(const Placeholder());
import 'package:animations/animations.dart';

void main() => runApp(MaterialApp(
theme: ThemeData(
pageTransitionsTheme: const PageTransitionsTheme(
builders: <TargetPlatform, PageTransitionsBuilder>{
TargetPlatform.android: ZoomPageTransitionsBuilder(),
},
),
),
home: _TransitionsHomePage(),
));

class _TransitionsHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Material Transitions')),
body: Column(
children: <Widget>[
ListTile(
contentPadding: const EdgeInsets.symmetric(
vertical: 10.0,
horizontal: 15.0,
),
leading: Container(
width: 40.0,
height: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
border: Border.all(
color: Colors.black54,
),
),
child: Icon(
Icons.play_arrow,
size: 35,
),
),
onTap: () {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) => _SharedAxisTransitionDemo(),
),
);
},
title: const Text('Shared Axis'),
subtitle: const Text('Page transition where outgoing and incoming elements share a fade transition'),
),
],
),
);
}
}

class _SharedAxisTransitionDemo extends StatefulWidget {
@override
__SharedAxisTransitionDemoState createState() => __SharedAxisTransitionDemoState();
}

class __SharedAxisTransitionDemoState extends State<_SharedAxisTransitionDemo> {
SharedAxisTransitionType transitionType = SharedAxisTransitionType.horizontal;

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Shared Axis Transition')),
body: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return Column(
children: <Widget>[
SizedBox(
height: constraints.maxHeight - 120,
child: _SignInPage(),
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 15.0,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
const FlatButton(
onPressed: null,
child: Text('BACK'),
),
RaisedButton(
onPressed: () {},
child: const Text('NEXT'),
),
],
),
),
const Divider(thickness: 2.0),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Radio<SharedAxisTransitionType>(
value: SharedAxisTransitionType.horizontal,
groupValue: transitionType,
onChanged: (SharedAxisTransitionType newValue) {
setState(() {
transitionType = newValue;
});
},
),
const Text('X'),
Radio<SharedAxisTransitionType>(
value: SharedAxisTransitionType.vertical,
groupValue: transitionType,
onChanged: (SharedAxisTransitionType newValue) {
setState(() {
transitionType = newValue;
});
},
),
const Text('Y'),
Radio<SharedAxisTransitionType>(
value: SharedAxisTransitionType.scaled,
groupValue: transitionType,
onChanged: (SharedAxisTransitionType newValue) {
setState(() {
transitionType = newValue;
});
},
),
const Text('Z'),
],
),
],
);
},
),
);
}
}

class _SignInPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
const Padding(padding: EdgeInsets.symmetric(vertical: 35.0)),
CircleAvatar(
radius: 28.0,
backgroundColor: Colors.black54,
child: Text(
'DP',
style: TextStyle(
fontSize: 20.0,
color: Colors.white,
),
),
),
const Padding(padding: EdgeInsets.symmetric(vertical: 8.0)),
Text(
'Hi David Park',
style: Theme.of(context).textTheme.headline,
),
const Padding(padding: EdgeInsets.symmetric(vertical: 8.0)),
Text(
'Sign in with your account',
style: TextStyle(
fontSize: 12.0,
color: Colors.grey,
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const Padding(
padding: EdgeInsets.only(
top: 40.0,
left: 15.0,
right: 15.0,
bottom: 10.0,
),
child: TextField(
decoration: InputDecoration(
labelText: 'Email or phone number',
border: OutlineInputBorder(),
),
),
),
Padding(
padding: const EdgeInsets.only(left: 10.0),
child: FlatButton(
onPressed: () {},
child: const Text('FORGOT EMAIL?'),
),
),
Padding(
padding: const EdgeInsets.only(left: 10.0),
child: FlatButton(
onPressed: () {},
child: const Text('CREATE ACCOUNT'),
),
),
],
),
],
);
}
}
2 changes: 2 additions & 0 deletions packages/animations/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
animations:
path: ../../animations

dev_dependencies:
flutter_test:
Expand Down