Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
trentpiercy authored Aug 9, 2020
2 parents 7948e40 + a617fba commit 59af12c
Show file tree
Hide file tree
Showing 19 changed files with 169 additions and 136 deletions.
1 change: 1 addition & 0 deletions .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"package_info","path":"C:\\\\Users\\\\TJ\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\package_info-0.3.2+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\Users\\\\TJ\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-0.4.1\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\Users\\\\TJ\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.4.3\\\\","dependencies":[]},{"name":"url_launcher","path":"C:\\\\Users\\\\TJ\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher-3.0.3\\\\","dependencies":[]}],"android":[{"name":"package_info","path":"C:\\\\Users\\\\TJ\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\package_info-0.3.2+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\Users\\\\TJ\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-0.4.1\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\Users\\\\TJ\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.4.3\\\\","dependencies":[]},{"name":"url_launcher","path":"C:\\\\Users\\\\TJ\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher-3.0.3\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"package_info","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"shared_preferences","dependencies":[]},{"name":"url_launcher","dependencies":[]}],"date_created":"2020-08-09 00:30:24.358227","version":"1.21.0-8.0.pre.47"}
8 changes: 4 additions & 4 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if (keystorePropertiesFile.exists()) {
}

android {
compileSdkVersion 28
compileSdkVersion 29

lintOptions {
disable 'InvalidPackage'
Expand All @@ -30,9 +30,9 @@ android {
defaultConfig {
applicationId "com.trentpiercy.trace"
minSdkVersion 21
targetSdkVersion 28
versionCode 9
versionName "1.0.8"
targetSdkVersion 29
versionCode 10
versionName "1.0.9"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand Down
1 change: 1 addition & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
Binary file added assets/images/ampl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/bze.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/klown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/leo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/matic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/sin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=C:\Code\flutter"
export "FLUTTER_APPLICATION_PATH=C:\Code\trace"
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build\ios"
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
export "FLUTTER_FRAMEWORK_DIR=C:\Code\flutter\bin\cache\artifacts\engine\ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=false"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.packages"
36 changes: 21 additions & 15 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,47 @@ String upArrow = "⬆";
String downArrow = "⬇";

int lastUpdate;

Future<Null> getMarketData() async {
int numberOfCoins = 1500;
int pages = 5;
List tempMarketListData = [];

Future<Null> _pullData(start, limit) async {
Future<Null> _pullData(page) async {
var response = await http.get(
Uri.encodeFull("https://api.coinmarketcap.com/v2/ticker/" +
"?start=" +
start.toString() +
"&limit=" +
limit.toString()),
Uri.encodeFull("https://min-api.cryptocompare.com/data/top/mktcapfull?tsym=USD&limit=100" +
"&page=" +
page.toString()),
headers: {"Accept": "application/json"});

Map rawMarketListData = new JsonDecoder().convert(response.body)["data"];
tempMarketListData.addAll(rawMarketListData.values);
List rawMarketListData = new JsonDecoder().convert(response.body)["Data"];
tempMarketListData.addAll(rawMarketListData);
}

List<Future> futures = [];
for (int i = 0; i <= numberOfCoins / 100 - 1; i++) {
int start = i * 100 + 1;
int limit = i * 100 + 100;
futures.add(_pullData(start, limit));
for (int i = 0; i < pages; i++) {
futures.add(_pullData(i));
}
await Future.wait(futures);

marketListData = tempMarketListData;
marketListData = [];
// Filter out lack of financial data
for (Map coin in tempMarketListData) {
if (coin.containsKey("RAW") && coin.containsKey("CoinInfo")) {
marketListData.add(coin);
}
}

getApplicationDocumentsDirectory().then((Directory directory) async {
File jsonFile = new File(directory.path + "/marketData.json");
jsonFile.writeAsStringSync(json.encode(marketListData));
});
print("Got new market data.");

lastUpdate = DateTime.now().millisecondsSinceEpoch;
}

void main() async {
WidgetsFlutterBinding.ensureInitialized();

await getApplicationDocumentsDirectory().then((Directory directory) async {
File jsonFile = new File(directory.path + "/portfolio.json");
if (jsonFile.existsSync()) {
Expand All @@ -80,6 +85,7 @@ void main() async {
jsonFile.createSync();
jsonFile.writeAsStringSync("[]");
marketListData = [];
// getMarketData(); ?does this work?
}
});

Expand Down
55 changes: 28 additions & 27 deletions lib/market/change_bar.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import '../main.dart';

final Map ohlcvWidthOptions = {
"1h": [
Expand Down Expand Up @@ -83,11 +84,11 @@ class QuickPercentChangeBar extends StatelessWidget {
.apply(color: Theme.of(context).hintColor)),
new Padding(padding: const EdgeInsets.only(right: 3.0)),
new Text(
snapshot["percent_change_1h"] >= 0
? "+" + snapshot["percent_change_1h"].toString() + "%"
: snapshot["percent_change_1h"].toString() + "%",
snapshot["CHANGEPCTHOUR"] >= 0
? "+" + snapshot["CHANGEPCTHOUR"].toStringAsFixed(2) + "%"
: snapshot["CHANGEPCTHOUR"].toStringAsFixed(2) + "%",
style: Theme.of(context).primaryTextTheme.body2.apply(
color: snapshot["percent_change_1h"] >= 0
color: snapshot["CHANGEPCTHOUR"] >= 0
? Colors.green
: Colors.red))
],
Expand All @@ -102,34 +103,34 @@ class QuickPercentChangeBar extends StatelessWidget {
.apply(color: Theme.of(context).hintColor)),
new Padding(padding: const EdgeInsets.only(right: 3.0)),
new Text(
snapshot["percent_change_24h"] >= 0
? "+" + snapshot["percent_change_24h"].toString() + "%"
: snapshot["percent_change_24h"].toString() + "%",
snapshot["CHANGEPCT24HOUR"] >= 0
? "+" + snapshot["CHANGEPCT24HOUR"].toStringAsFixed(2) + "%"
: snapshot["CHANGEPCT24HOUR"].toStringAsFixed(2) + "%",
style: Theme.of(context).primaryTextTheme.body2.apply(
color: snapshot["percent_change_24h"] >= 0
color: snapshot["CHANGEPCT24HOUR"] >= 0
? Colors.green
: Colors.red))
],
),
new Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new Text("7D",
style: Theme.of(context)
.textTheme
.body1
.apply(color: Theme.of(context).hintColor)),
new Padding(padding: const EdgeInsets.only(right: 3.0)),
new Text(
snapshot["percent_change_7d"] >= 0
? "+" + snapshot["percent_change_7d"].toString() + "%"
: snapshot["percent_change_7d"].toString() + "%",
style: Theme.of(context).primaryTextTheme.body2.apply(
color: snapshot["percent_change_7d"] >= 0
? Colors.green
: Colors.red)),
],
)
// new Row(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// new Text("7D",
// style: Theme.of(context)
// .textTheme
// .body1
// .apply(color: Theme.of(context).hintColor)),
// new Padding(padding: const EdgeInsets.only(right: 3.0)),
// new Text(
// snapshot["percent_change_7d"] >= 0
// ? "+" + snapshot["percent_change_7d"].toString() + "%"
// : snapshot["percent_change_7d"].toString() + "%",
// style: Theme.of(context).primaryTextTheme.body2.apply(
// color: snapshot["percent_change_7d"] >= 0
// ? Colors.green
// : Colors.red)),
// ],
// )
],
),
);
Expand Down
20 changes: 10 additions & 10 deletions lib/market/coin_tabs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class CoinDetailsState extends State<CoinDetails>
_makeTabs();
_tabController = new TabController(length: _tabAmt, vsync: this);

symbol = widget.snapshot["symbol"];
symbol = widget.snapshot["CoinInfo"]["Name"];

_makeGeneralStats();
if (historyOHLCV == null) {
Expand All @@ -79,7 +79,7 @@ class CoinDetailsState extends State<CoinDetails>
backgroundColor: Theme.of(context).primaryColor,
titleSpacing: 2.0,
elevation: appBarElevation,
title: new Text(widget.snapshot["name"],
title: new Text(widget.snapshot["CoinInfo"]["FullName"],
style: Theme.of(context).textTheme.title),
bottom: new PreferredSize(
preferredSize: const Size.fromHeight(25.0),
Expand Down Expand Up @@ -137,16 +137,16 @@ class CoinDetailsState extends State<CoinDetails>

_getGeneralStats() async {
const int fifteenMin = 15*60*1000;
if (DateTime.now().millisecondsSinceEpoch - lastUpdate >= fifteenMin) {
if (lastUpdate != null && fifteenMin != null && DateTime.now().millisecondsSinceEpoch - lastUpdate >= fifteenMin) {
await getMarketData();
}
_makeGeneralStats();
}

_makeGeneralStats() {
for (Map coin in marketListData) {
if (coin["symbol"] == symbol) {
generalStats = coin["quotes"]["USD"];
if (coin["CoinInfo"]["Name"] == symbol) {
generalStats = coin["RAW"]["USD"];
break;
}
}
Expand Down Expand Up @@ -237,7 +237,7 @@ class CoinDetailsState extends State<CoinDetails>
"\$" +
(generalStats != null
? normalizeNumNoCommas(
generalStats["price"])
generalStats["PRICE"])
: "0"),
style: Theme.of(context)
.textTheme
Expand Down Expand Up @@ -279,7 +279,7 @@ class CoinDetailsState extends State<CoinDetails>
generalStats != null
? "\$" +
normalizeNum(
generalStats["market_cap"])
generalStats["MKTCAP"])
: "0",
style: Theme.of(context)
.textTheme
Expand All @@ -291,7 +291,7 @@ class CoinDetailsState extends State<CoinDetails>
generalStats != null
? "\$" +
normalizeNum(
generalStats["volume_24h"])
generalStats["TOTALVOLUME24H"])
: "0",
style: Theme.of(context)
.textTheme
Expand Down Expand Up @@ -827,7 +827,7 @@ class CoinDetailsState extends State<CoinDetails>

for (Map transaction in transactionList) {
cost += transaction["quantity"] * transaction["price_usd"];
value += transaction["quantity"] * generalStats["price"];
value += transaction["quantity"] * generalStats["PRICE"];
holdings += transaction["quantity"];
}

Expand Down Expand Up @@ -917,7 +917,7 @@ class CoinDetailsState extends State<CoinDetails>
delegate: new SliverChildBuilderDelegate(
(context, index) => new TransactionItem(
snapshot: transactionList[index],
currentPrice: generalStats["price"],
currentPrice: generalStats["PRICE"],
symbol: symbol,
refreshPage: () {
setState(() {
Expand Down
Loading

0 comments on commit 59af12c

Please sign in to comment.