Created
March 16, 2019 18:09
-
-
Save felangel/0549465a4087ac5672076ac30ad1bf53 to your computer and use it in GitHub Desktop.
[flutter_todos] stats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter/foundation.dart'; | |
import 'package:flutter/widgets.dart'; | |
import 'package:flutter_bloc/flutter_bloc.dart'; | |
import 'package:todos_app_core/todos_app_core.dart'; | |
import 'package:flutter_todos/blocs/stats/stats.dart'; | |
import 'package:flutter_todos/widgets/widgets.dart'; | |
import 'package:flutter_todos/flutter_todos_keys.dart'; | |
class Stats extends StatelessWidget { | |
Stats({Key key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
final StatsBloc statsBloc = BlocProvider.of<StatsBloc>(context); | |
return BlocBuilder( | |
bloc: statsBloc, | |
builder: (BuildContext context, StatsState state) { | |
if (state is StatsLoading) { | |
return LoadingIndicator(key: FlutterTodosKeys.statsLoadingIndicator); | |
} else if (state is StatsLoaded) { | |
return Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: [ | |
Padding( | |
padding: EdgeInsets.only(bottom: 8.0), | |
child: Text( | |
ArchSampleLocalizations.of(context).completedTodos, | |
style: Theme.of(context).textTheme.title, | |
), | |
), | |
Padding( | |
padding: EdgeInsets.only(bottom: 24.0), | |
child: Text( | |
'${state.numCompleted}', | |
key: ArchSampleKeys.statsNumCompleted, | |
style: Theme.of(context).textTheme.subhead, | |
), | |
), | |
Padding( | |
padding: EdgeInsets.only(bottom: 8.0), | |
child: Text( | |
ArchSampleLocalizations.of(context).activeTodos, | |
style: Theme.of(context).textTheme.title, | |
), | |
), | |
Padding( | |
padding: EdgeInsets.only(bottom: 24.0), | |
child: Text( | |
"${state.numActive}", | |
key: ArchSampleKeys.statsNumActive, | |
style: Theme.of(context).textTheme.subhead, | |
), | |
) | |
], | |
), | |
); | |
} else { | |
return Container(key: FlutterTodosKeys.emptyStatsContainer); | |
} | |
}, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment