-
Notifications
You must be signed in to change notification settings - Fork 13
/
static_page.dart
238 lines (222 loc) · 7.34 KB
/
static_page.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
import 'dart:convert';
import 'dart:math';
import 'package:auto_animated/auto_animated.dart';
import 'package:crypto_wallet_app/widget/asset_card.dart';
import 'package:crypto_wallet_app/widget/button.dart';
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:iconly/iconly.dart';
class StaticPage extends StatefulWidget {
const StaticPage({ Key? key }) : super(key: key);
@override
State<StaticPage> createState() => _StaticPageState();
}
class _StaticPageState extends State<StaticPage> {
List _currency = [];
Future<void> readJson() async {
final String response = await rootBundle.loadString('assets/json/currency.json');
final data = await json.decode(response);
setState(() {
_currency = data['currency'];
});
}
@override
void initState() {
// TODO: implement initState
super.initState();
readJson();
}
final List<FlSpot> dummyData3 = List.generate(30, (index) {
return FlSpot(index.toDouble(), index * Random().nextDouble());
});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
leading: IconButton(
icon: const Icon(IconlyBroken.arrow_left),
onPressed:(){Navigator.pop(context);}
),
backgroundColor: Colors.black,
title: const Text('Statics'),
actions: [
IconButton(
onPressed: () {},
icon: const Icon(IconlyBroken.more_circle))
],
elevation: 0,
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
children: [
SizedBox(
height: 100,
child: Image.asset('assets/images/eth.png'),
),
const SizedBox(height: 15,),
const Text('Ethereum(ETH)', style: TextStyle(color: Colors.grey, fontWeight: FontWeight.bold),),
Text('\$2,920', style: TextStyle(color: Colors.grey[100], fontSize: 25, fontWeight: FontWeight.bold),),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Icon(IconlyBold.arrow_up_2, size: 25, color: Colors.greenAccent,),
Text('3.79%(+1.43%)', style: TextStyle(color: Colors.greenAccent, fontSize: 11),)
],
),
const SizedBox(height: 20,),
Container(
width: double.infinity,
padding: const EdgeInsets.all(32),
height: 300,
decoration: BoxDecoration(
color: Colors.grey[900],
borderRadius: const BorderRadius.all(Radius.circular(20))
),
child: LineChart(
LineChartData(
borderData: FlBorderData(show: false),
backgroundColor: Colors.grey[900],
gridData: FlGridData(show: false),
titlesData: titlesData1,
minX: 0,
maxX: 30,
maxY: 25,
minY: 0,
lineBarsData: [
LineChartBarData(
preventCurveOvershootingThreshold: 0,
preventCurveOverShooting: true,
isStrokeCapRound: true,
aboveBarData: BarAreaData(show: true, color: Colors.transparent),
spots: dummyData3,
isCurved: true,
barWidth: 1,
shadow: const Shadow(
color: Colors.black,
blurRadius: 4,
offset: Offset(0, 5)
),
dotData: FlDotData(
show: false
),
color: Colors.yellowAccent[700],
),
],
),
swapAnimationDuration: const Duration(milliseconds: 500),
swapAnimationCurve: Curves.easeInOut,
)
),
const SizedBox(height: 20,),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Button.primaryButton(
child: const Text('BUY', style: TextStyle(color: Colors.grey),),
onPressed: () {}
),
),
const SizedBox(width: 16,),
Expanded(
child: Button.secondaryButton(
child: const Text('SELL', style: TextStyle(color: Colors.black),),
onPressed: () {}
),
),
],
),
LiveList(
showItemInterval: const Duration(milliseconds: 500),
showItemDuration: const Duration(seconds: 1),
padding: const EdgeInsets.only(top: 16, bottom: 16),
physics: const BouncingScrollPhysics(),
shrinkWrap: true,
itemCount: _currency.length,
itemBuilder: _buildAnimatedItem,
),
]),
)
);
}
Widget _buildAnimatedItem(BuildContext context, int index, Animation<double> animation,) =>
FadeTransition(
opacity: Tween<double>(
begin: 0,
end: 1,
).animate(animation),
child: SlideTransition(
position: Tween<Offset>(
begin: const Offset(0, -0.1),
end: Offset.zero,
).animate(animation),
child: Padding(
padding: const EdgeInsets.all(5),
child: AssetsCard(
title: _currency[index]['name'] + ' ' + '('+_currency[index]["symbol"] + ')',
price: _currency[index]['symbol'],
logo: _currency[index]['logo'],
chart: 'chart',
rise: '\$5,017',
percent: '3.75%',
),
),
),
);
FlTitlesData get titlesData1 => FlTitlesData(
bottomTitles: AxisTitles(
sideTitles: bottomTitles,
),
rightTitles: AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
topTitles: AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
leftTitles: AxisTitles(
sideTitles: SideTitles(showTitles: false)
)
);
SideTitles get bottomTitles => SideTitles(
showTitles: true,
reservedSize: 32,
interval: 1,
getTitlesWidget: bottomTitleWidgets,
);
Widget bottomTitleWidgets(double value, TitleMeta meta) {
const style = TextStyle(
color: Color.fromARGB(255, 114, 106, 69),
fontWeight: FontWeight.bold,
fontSize: 16,
);
Widget text;
switch (value.toInt()) {
case 0:
text = const Text('1H', style: style);
break;
case 6:
text = const Text('1D', style: style);
break;
case 12:
text = const Text('1W', style: style);
break;
case 18:
text = const Text('1M', style: style);
break;
case 24:
text = const Text('1Y', style: style);
break;
case 29:
text = const Text('ALL', style: style);
break;
default:
text = const Text('');
break;
}
return Padding(child: text, padding: const EdgeInsets.only(top: 10.0));
}
}