Add animations and details page screen
This commit is contained in:
+29
-7
@@ -1,15 +1,23 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:como_gasto/graph_widget.dart';
|
||||
import 'package:como_gasto/pages/details_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
|
||||
enum GraphType {
|
||||
LINES,
|
||||
PIE,
|
||||
}
|
||||
|
||||
class MonthWidget extends StatefulWidget {
|
||||
final List<DocumentSnapshot> documents;
|
||||
final double total;
|
||||
final List<double> perDay;
|
||||
final Map<String, double> categories;
|
||||
final GraphType graphType;
|
||||
final int month;
|
||||
|
||||
MonthWidget({Key key, this.documents, days})
|
||||
MonthWidget({Key key, @required this.month, this.graphType, this.documents, days})
|
||||
:
|
||||
total = documents.map((doc) => doc['value'])
|
||||
.fold(0.0, (a, b) => a + b),
|
||||
@@ -72,16 +80,30 @@ class _MonthWidgetState extends State<MonthWidget> {
|
||||
}
|
||||
|
||||
Widget _graph() {
|
||||
return Container(
|
||||
height: 250.0,
|
||||
child: GraphWidget(
|
||||
data: widget.perDay,
|
||||
),
|
||||
);
|
||||
if (widget.graphType == GraphType.LINES) {
|
||||
return Container(
|
||||
height: 250.0,
|
||||
child: LinesGraphWidget(
|
||||
data: widget.perDay,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
var perCategory = widget.categories.keys.map((name) => widget.categories[name] / widget.total).toList();
|
||||
return Container(
|
||||
height: 250.0,
|
||||
child: PieGraphWidget(
|
||||
data: perCategory,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _item(IconData icon, String name, int percent, double value) {
|
||||
return ListTile(
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed("/details",
|
||||
arguments: DetailsParams(name, widget.month));
|
||||
},
|
||||
leading: Icon(icon, size: 32.0,),
|
||||
title: Text(name,
|
||||
style: TextStyle(
|
||||
|
||||
Reference in New Issue
Block a user