-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f29771
commit ed60323
Showing
9 changed files
with
110 additions
and
36 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import 'package:Bitalarm/entities/coin.entity.dart'; | ||
import 'package:Bitalarm/entities/orderbook.entity.dart'; | ||
import 'package:Bitalarm/services/coin.service.dart'; | ||
import 'package:Bitalarm/shared/styles.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class OrderBook extends StatefulWidget { | ||
final Coin coin; | ||
|
||
OrderBook({this.coin}); | ||
|
||
@override | ||
State<StatefulWidget> createState() => OrderBookState(); | ||
} | ||
|
||
class OrderBookState extends State<OrderBook> { | ||
var coinService = CoinService(); | ||
OrderBookModel model = OrderBookModel(asks: [], bids: []); | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
_getOrderBook(); | ||
} | ||
|
||
_getOrderBook() async { | ||
model = await coinService.getOrderBook(widget.coin.symbol); | ||
setState(() {}); | ||
} | ||
|
||
_makeRows(List<dynamic> bidOrAsk, {Color color = Colors.red}) { | ||
var list = bidOrAsk; | ||
var style = TextStyle(color: color, fontSize: 11); | ||
|
||
return list | ||
.map((boa) => DataRow(cells: [ | ||
DataCell(Text( | ||
boa[0].toString(), | ||
style: style, | ||
)), | ||
DataCell(Text(boa[1].toStringAsFixed(4), style: style)), | ||
])) | ||
.toList(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
var askRows = _makeRows(model.asks, color: COLOR_SOFT_BLUE); | ||
var bidRows = _makeRows(model.bids, color: COLOR_SOFT_RED); | ||
|
||
return Row( | ||
mainAxisAlignment: MainAxisAlignment.start, | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Expanded( | ||
child: DataTable(columns: [ | ||
DataColumn(label: Text("USD")), | ||
DataColumn(label: Text(widget.coin.symbol)) | ||
], rows: askRows)), | ||
Expanded( | ||
child: DataTable(columns: [ | ||
DataColumn(label: Text("USD")), | ||
DataColumn(label: Text(widget.coin.symbol)) | ||
], rows: bidRows)) | ||
], | ||
); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
class OrderBook { | ||
List<List<double>> asks; | ||
List<List<double>> bids; | ||
class OrderBookModel { | ||
final List<dynamic> asks; | ||
final List<dynamic> bids; | ||
|
||
OrderBook({this.asks, this.bids}); | ||
OrderBookModel({this.asks = const [], this.bids = const []}); | ||
} |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
const COLOR_HEADLINE = const Color(0x252525); | ||
|
||
const COLOR_SOFT_RED = const Color.fromRGBO(255, 104, 104, 1); | ||
const COLOR_SOFT_BLUE = const Color.fromRGBO(155, 99, 239, 1); |