Skip to content

Commit

Permalink
tab inferior e tela de dividendos
Browse files Browse the repository at this point in the history
  • Loading branch information
flavio342 committed Jun 13, 2020
1 parent df68f4a commit 837b104
Show file tree
Hide file tree
Showing 13 changed files with 234 additions and 53 deletions.
8 changes: 4 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:app/login.dart';
import 'package:app/portfolio.dart';
import 'package:app/views/login.dart';
import 'package:app/views/home.dart';
import 'package:flutter/material.dart';

import 'splashScreen.dart';
import 'package:app/views/splashScreen.dart';

void main() async{

Expand All @@ -11,7 +11,7 @@ void main() async{
home: SplashScreen(),
routes: <String, WidgetBuilder>{
// Set routes for using the Navigator.
'/home': (BuildContext context) => new Portfolio(),
'/home': (BuildContext context) => new Home(),
'/login': (BuildContext context) => new Login()
},
)
Expand Down
File renamed without changes.
23 changes: 23 additions & 0 deletions lib/models/dividend.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:flutter/material.dart';

class Dividend {

final String _fantasyName;
final String _ticker;
final String _type;
final String _date;
final String currency;
final String _netIncome;

final Map<String, IconData> _assetTypeIcons= {
"share": Icons.library_books,
"reit": Icons.location_city
};

Dividend(this._fantasyName, this._ticker, this._type, this._date, this._netIncome, {this.currency="R\$"});

String get name => _fantasyName + " (" + _ticker + ")";
IconData get icon => _assetTypeIcons[this._type];
String get date => _date;
String get income => "$currency$_netIncome";
}
2 changes: 1 addition & 1 deletion lib/CEICredentials.dart → lib/utils/CEICredentials.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'dart:convert';
import 'package:app/storage.dart';
import 'package:app/utils/storage.dart';

class CEICredentials{
String _cpf;
Expand Down
2 changes: 1 addition & 1 deletion lib/appInitializer.dart → lib/utils/appInitializer.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:app/CEICredentials.dart';
import 'package:app/utils/CEICredentials.dart';

redirect(BuildContext context) async{
CEICredentials creds = CEICredentials.empty();
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions lib/utils/theme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import 'package:flutter/material.dart';

final biggerFont = const TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold);
final normalFont = const TextStyle(fontSize: 18.0);
final smallerFont = const TextStyle(fontSize: 14.0, color: Colors.grey);
final buttonFont = const TextStyle(fontSize: 18.0, color: Colors.white);
79 changes: 79 additions & 0 deletions lib/views/dividends.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import 'package:flutter/material.dart';
import 'package:app/utils/theme.dart';

import '../models/dividend.dart';

class DividendsState extends State<Dividends> {

final _provisioned = <Dividend>[
Dividend("Energias do Brasil", "ENBR3", "share", "28/06/2020", "31,30"),
Dividend("KINEA RENDA IMOBILIÁRIA FDO INV IMOB", "KNRI11", "reit", "20/06/2020", "25,10"),
Dividend("Sinqia", "SQIA3", "share", "17/06/2020", "08,60")
];

final _credited = <Dividend>[
Dividend("Itaúsa", "ITSA4", "share", "10/06/2020", "10,20"),
Dividend("Fleury", "FLRY3", "share", "08/06/2020", "4,20"),
Dividend("B3", "B3SA3", "share", "02/06/2020", "15,50"),
Dividend("HSI MALL FDO INV IMOB", "HSML11", "reit", "01/06/2020", "20,60")
];

@override
Widget build(BuildContext context) {
return _buildDividends();
}

Widget _buildDividends() {
return ListView.builder(
padding: const EdgeInsets.all(15),
itemBuilder: (context, i) {
if (i.isOdd) return Divider();
int index = i ~/ 2;

if (index == 0) return _buildTitle("Provisionado");
index -= 1;

if (index < _provisioned.length) return _buildRow(_provisioned[index]);
index -= _provisioned.length;

if (index == 0) return _buildTitle("Creditado");
index -= 1;

if (index < _credited.length) return _buildRow(_credited[index]);

return null;
});
}

Widget _buildTitle(text) {
return ListTile(
title: Text(
text,
style: biggerFont
)
);
}

Widget _buildRow(Dividend dividend) {
return ListTile(
title: Text(
dividend.name,
style: biggerFont,
),
subtitle: Text(
dividend.date,
style: smallerFont,
),
leading: Icon(dividend.icon),
trailing: Text(
dividend.income,
style: normalFont,
)
);
}
}

class Dividends extends StatefulWidget {
@override
DividendsState createState() => DividendsState();
}
49 changes: 49 additions & 0 deletions lib/views/home.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import 'package:flutter/material.dart';

import 'package:app/views/portfolio.dart';
import 'package:app/views/dividends.dart';

class HomeState extends State<Home> {
int _currentIndex = 0;
final List<Widget> _children = [
Portfolio(),
Dividends()
];

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Bezunca Investimentos'),
),
body: _children[_currentIndex],
bottomNavigationBar: BottomNavigationBar(
onTap: onTabTapped,
currentIndex: _currentIndex,
items: [
BottomNavigationBarItem(
icon: new Icon(Icons.account_balance_wallet),
title: new Text('Portfolio'),
),
BottomNavigationBarItem(
icon: new Icon(Icons.attach_money),
title: new Text('Proventos'),
)
],
),
);
}

void onTabTapped(int index) {
setState(() {
_currentIndex = index;
});
}
}

class Home extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return HomeState();
}
}
19 changes: 7 additions & 12 deletions lib/login.dart → lib/views/login.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import 'dart:convert';
import 'package:app/utils/theme.dart';

import 'package:app/CEICredentials.dart';
import 'package:app/utils/CEICredentials.dart';
import 'package:flutter/material.dart';

class LoginState extends State<Login> {

// Fonts
final _normalFont = const TextStyle(fontSize: 18.0);

final _buttonFont = const TextStyle(fontSize: 18.0, color: Colors.white);

final _cpf = TextEditingController();
final _password = TextEditingController();
Expand All @@ -27,22 +22,22 @@ class LoginState extends State<Login> {
TextFormField(
controller: _cpf,
keyboardType: TextInputType.text,
style: _normalFont,
decoration: InputDecoration(labelText: "CPF", labelStyle: _normalFont)
style: normalFont,
decoration: InputDecoration(labelText: "CPF", labelStyle: normalFont)
),
TextFormField(
controller: _password,
obscureText: true,
keyboardType: TextInputType.text,
style: _normalFont,
decoration: InputDecoration(labelText: "Senha", labelStyle: _normalFont)
style: normalFont,
decoration: InputDecoration(labelText: "Senha", labelStyle: normalFont)
),
Container(
height: 40.0,
margin: EdgeInsets.only(top: 30.0),
child: RaisedButton(
color: Colors.blue,
child: Text("LOGIN", style: _buttonFont),
child: Text("LOGIN", style: buttonFont),
onPressed: () { _onClickLogin(context); },
),
)
Expand Down
25 changes: 6 additions & 19 deletions lib/portfolio.dart → lib/views/portfolio.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'asset.dart';
import 'package:app/utils/theme.dart';
import '../models/asset.dart';

class PortfolioState extends State<Portfolio> {
final _portfolio = <Asset>[
Expand All @@ -16,23 +17,9 @@ class PortfolioState extends State<Portfolio> {
Asset("IShare SP500CI", "IVVB11", 11597, "etf")
];

// Fonts
final _biggerFont =
const TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold);
final _normalFont = const TextStyle(fontSize: 18.0);
final _smallerFont = const TextStyle(fontSize: 14.0, color: Colors.grey);

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Bezunca Investimentos"),
actions: <Widget>[
IconButton(icon: Icon(Icons.search), onPressed: () => {}),
],
),
body: _buildPortfolio(),
);
return _buildPortfolio();
}

Widget _buildPortfolio() {
Expand All @@ -50,16 +37,16 @@ class PortfolioState extends State<Portfolio> {
return ListTile(
title: Text(
asset.name,
style: _biggerFont,
style: biggerFont,
),
subtitle: Text(
asset.ticker,
style: _smallerFont,
style: smallerFont,
),
leading: Icon(asset.icon),
trailing: Text(
asset.price,
style: _normalFont,
style: normalFont,
));
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/splashScreen.dart → lib/views/splashScreen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import "appInitializer.dart";
import "../utils/appInitializer.dart";

class SplashScreen extends StatelessWidget{
@override
Expand Down
Loading

0 comments on commit 837b104

Please sign in to comment.