Skip to content

Commit

Permalink
Fixed a bit of the layout, added ellipsis as per #1
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilhermeFreire committed Jun 13, 2020
1 parent 837b104 commit 10ef4b0
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 93 deletions.
16 changes: 9 additions & 7 deletions lib/models/dividend.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
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 int _netIncome;

final Map<String, IconData> _assetTypeIcons= {
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\$"});
Dividend(
this._fantasyName, this._ticker, this._type, this._date, this._netIncome,
{this.currency = "R\$"});

String get name => _fantasyName + " (" + _ticker + ")";
String get name => _fantasyName;
String get ticker => _ticker;
IconData get icon => _assetTypeIcons[this._type];
String get date => _date;
String get income => "$currency$_netIncome";
}
String get income => "$currency${(_netIncome/100.0).toStringAsFixed(2)}";
}
62 changes: 33 additions & 29 deletions lib/views/dividends.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ 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")
Dividend("Energias do Brasil", "ENBR3", "share", "28/06/2020", 3130),
Dividend("Kinea Renda Imobiliária Fundo de Investimentos Imobiliário", "KNRI11", "reit",
"20/06/2020", 2510),
Dividend("Sinqia", "SQIA3", "share", "17/06/2020", 860)
];

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")
Dividend("Itaúsa", "ITSA4", "share", "10/06/2020", 1020),
Dividend("Fleury", "FLRY3", "share", "08/06/2020", 420),
Dividend("B3", "B3SA3", "share", "02/06/2020", 1550),
Dividend("HSI MALL FDO INV IMOB", "HSML11", "reit", "01/06/2020", 2060)
];

@override
Expand All @@ -33,7 +33,8 @@ class DividendsState extends State<Dividends> {
if (index == 0) return _buildTitle("Provisionado");
index -= 1;

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

if (index == 0) return _buildTitle("Creditado");
Expand All @@ -46,30 +47,33 @@ class DividendsState extends State<Dividends> {
}

Widget _buildTitle(text) {
return ListTile(
title: Text(
text,
style: biggerFont
)
);
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,
)
);
title: Text(
dividend.name,
style: biggerFont,
overflow: TextOverflow.ellipsis
),
subtitle: Text(
dividend.ticker,
style: smallerFont,
),
leading: Icon(dividend.icon),
trailing: Column(
children: <Widget>[
Text(
dividend.income,
style: normalFont,
),
Text(
dividend.date,
style: smallerFont,
)
],
));
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/views/portfolio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class PortfolioState extends State<Portfolio> {
title: Text(
asset.name,
style: biggerFont,
overflow: TextOverflow.ellipsis,
),
subtitle: Text(
asset.ticker,
Expand Down
72 changes: 15 additions & 57 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.0"
async:
dependency: transitive
description:
Expand All @@ -36,27 +22,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.12"
convert:
clock:
dependency: transitive
description:
name: convert
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
version: "1.0.1"
collection:
dependency: transitive
description:
name: crypto
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
version: "1.14.12"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -71,6 +50,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.5"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
file:
dependency: transitive
description:
Expand All @@ -88,13 +74,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.12"
intl:
dependency: transitive
description:
Expand Down Expand Up @@ -122,7 +101,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
version: "1.7.0"
path_provider:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -151,13 +130,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
platform:
dependency: transitive
description:
Expand All @@ -179,13 +151,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.13"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -232,7 +197,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.15"
version: "0.2.16"
typed_data:
dependency: transitive
description:
Expand All @@ -254,13 +219,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.1"
sdks:
dart: ">=2.7.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"

0 comments on commit 10ef4b0

Please sign in to comment.