Skip to content

Commit

Permalink
start page animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Erkan committed Dec 20, 2020
1 parent c097913 commit 2acbba7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 9,7 @@ void main() async{
await Firebase.initializeApp();
runApp(
ChangeNotifierProvider(
builder: (_) => ThemeProvider(isLightTheme: true),
builder: (_) => ThemeProvider(isLightTheme: false),
child: App(),
),
);
Expand Down
49 changes: 42 additions & 7 deletions lib/pages/start_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 18,21 @@ class StartPage extends StatefulWidget {
_StartPageState createState() => _StartPageState();
}

class _StartPageState extends State<StartPage> {
class _StartPageState extends State<StartPage>
with SingleTickerProviderStateMixin {
TextEditingController _textEditingController = TextEditingController();
bool isEnabled = false;
AnimationController _controller;
Animation _animation;

@override
Widget build(BuildContext context) {
if(_controller.isCompleted) _controller.reset();
_controller.forward();
final themeProvider = Provider.of<ThemeProvider>(context);
return Scaffold(
body: Center(
child: Container(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
Expand All @@ -37,6 42,26 @@ class _StartPageState extends State<StartPage> {
margin: EdgeInsets.only(right: 50, left: 50),
child: Column(
children: [
Center(
child: AnimatedBuilder(
animation: _animation,
builder: (context, child) {
String textR = "R";
String text = "Retrospective".substring(1,_animation.value);
return Row(
children: [
Text(
textR,
style: TextStyle(fontSize: 100),
),
Text(
text,
style: TextStyle(fontSize: 40),
),
],
);
},
)),
Center(
child: Switch(
value: themeProvider.isLightTheme,
Expand All @@ -49,7 74,9 @@ class _StartPageState extends State<StartPage> {
height: 60,
width: double.infinity,
child: RaisedButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10.0))),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.all(Radius.circular(10.0))),
onPressed: () {
Navigator.pushNamed(context, "/choose_template");
},
Expand Down Expand Up @@ -88,7 115,9 @@ class _StartPageState extends State<StartPage> {
height: 60,
width: double.infinity,
child: RaisedButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10.0))),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.all(Radius.circular(10.0))),
onPressed: isEnabled
? () {
Navigator.pushNamed(context, "/retro",
Expand All @@ -112,7 141,9 @@ class _StartPageState extends State<StartPage> {
height: 60,
width: double.infinity,
child: RaisedButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10.0))),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.all(Radius.circular(10.0))),
onPressed: () {
Navigator.pushNamed(context, "/saved_history");
},
Expand All @@ -135,14 166,18 @@ class _StartPageState extends State<StartPage> {
void dispose() {
// Clean up the controller when the widget is removed from the
// widget tree.
_textEditingController.dispose();
super.dispose();
_textEditingController.dispose();
_controller.dispose();
}

@override
void initState() {
super.initState();

_controller =
AnimationController(duration: const Duration(seconds: 1), vsync: this);
_animation = IntTween(begin: 1, end: 13).animate(_controller);
_controller.forward();
_textEditingController.addListener(_checkButtonEnable);
}

Expand Down

0 comments on commit 2acbba7

Please sign in to comment.