Skip to content

Commit 42ad519

Browse files
committed
contest rating graph added
1 parent 09d567b commit 42ad519

6 files changed

Lines changed: 724 additions & 276 deletions

File tree

lib/ui/compare.dart

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:cf_view/ui/home.dart';
12
import 'package:flutter/material.dart';
23
import 'dart:async';
34
import 'dart:convert';
@@ -12,6 +13,47 @@ class Compare extends StatelessWidget {
1213
this.handle2 = handle2;
1314
}
1415

16+
TextEditingController _handle1Controller = TextEditingController();
17+
TextEditingController _handle2Controller = TextEditingController();
18+
19+
_displayCompareDialog(BuildContext context) async {
20+
return showDialog(
21+
context: context,
22+
builder: (context) {
23+
return AlertDialog(
24+
title: new Column(
25+
children: <Widget>[
26+
new TextField(
27+
controller: _handle1Controller,
28+
decoration: InputDecoration(hintText: "Handle1"),
29+
),
30+
new TextField(
31+
controller: _handle2Controller,
32+
decoration: InputDecoration(hintText: "Handle2"),
33+
),
34+
],
35+
),
36+
actions: <Widget>[
37+
new FlatButton(
38+
child: new Text('Compare'),
39+
onPressed: () {
40+
Navigator.of(context).pop(context);
41+
Navigator.push(context, MaterialPageRoute(
42+
builder: (context) {
43+
String handle1 = _handle1Controller.text.toString();
44+
String handle2 = _handle2Controller.text.toString();
45+
_handle1Controller.clear();
46+
_handle2Controller.clear();
47+
return Compare(handle1, handle2);
48+
},
49+
));
50+
},
51+
),
52+
],
53+
);
54+
});
55+
}
56+
1557
@override
1658
Widget build(BuildContext context) {
1759
// TODO: implement build
@@ -49,13 +91,34 @@ class Compare extends StatelessWidget {
4991
],
5092
),
5193
floatingActionButton: FloatingActionButton(
52-
backgroundColor: Colors.deepPurple,
53-
child: Icon(
54-
Icons.arrow_back_ios,
94+
backgroundColor: Colors.deepPurple,
95+
child: Icon(
96+
Icons.compare,
97+
),
98+
onPressed: () => _displayCompareDialog(context)),
99+
bottomNavigationBar: Container(
100+
height: 60,
101+
color: Colors.black12,
102+
child: InkWell(
103+
onTap: () {
104+
Navigator.push(
105+
context,
106+
MaterialPageRoute(builder: (context) => Home()),
107+
);
108+
},
109+
child: Padding(
110+
padding: EdgeInsets.only(top: 8.0),
111+
child: Column(
112+
children: <Widget>[
113+
Icon(
114+
Icons.home,
115+
color: Theme.of(context).accentColor,
116+
),
117+
Text('Home')
118+
],
119+
),
120+
),
55121
),
56-
onPressed: () {
57-
Navigator.pop(context);
58-
},
59122
),
60123
);
61124
}

lib/ui/home.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class HomeState extends State {
140140
Navigator.push(context, MaterialPageRoute(
141141
builder: (context) {
142142
String handle = _textFieldController.text.toString();
143-
_textFieldController.clear();
143+
// _textFieldController.clear();
144144
return User(handle);
145145
},
146146
));
@@ -370,8 +370,14 @@ class HomeState extends State {
370370
bottomNavigationBar: BottomNavigationBar(
371371
items: const <BottomNavigationBarItem>[
372372
BottomNavigationBarItem(
373-
icon: Icon(Icons.new_releases),
374-
title: Text("UPCOMING"),
373+
icon: Icon(
374+
Icons.new_releases,
375+
color: Colors.blue,
376+
),
377+
title: Text(
378+
"UPCOMING",
379+
style: TextStyle(color: Colors.blue),
380+
),
375381
),
376382
BottomNavigationBarItem(
377383
icon: Icon(Icons.update),

lib/ui/previous_contests.dart

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ class PreviousContestsState extends State {
9696
builder: (context) {
9797
String handle1 = _handle1Controller.text.toString();
9898
String handle2 = _handle2Controller.text.toString();
99-
_handle1Controller.clear();
100-
_handle2Controller.clear();
99+
// _handle1Controller.clear();
100+
// _handle2Controller.clear();
101101
return Compare(handle1, handle2);
102102
},
103103
));
@@ -154,7 +154,7 @@ class PreviousContestsState extends State {
154154
itemCount: snapshot.data['result'].length,
155155
// ignore: missing_return
156156
itemBuilder: (context, index) {
157-
index += bal+1;
157+
index += bal + 1;
158158
print("bal : $bal");
159159
if (snapshot.data['result'][index]['phase'] == "FINISHED") {
160160
print("Index : $index");
@@ -276,7 +276,7 @@ class PreviousContestsState extends State {
276276
_launchURL(snapshot.data['result'][index]['id']),
277277
),
278278
);
279-
}
279+
}
280280
});
281281
}
282282
}),
@@ -289,12 +289,24 @@ class PreviousContestsState extends State {
289289
bottomNavigationBar: BottomNavigationBar(
290290
items: const <BottomNavigationBarItem>[
291291
BottomNavigationBarItem(
292-
icon: Icon(Icons.new_releases),
293-
title: Text("UPCOMING"),
292+
icon: Icon(
293+
Icons.new_releases,
294+
color: Colors.grey,
295+
),
296+
title: Text(
297+
"UPCOMING",
298+
style: TextStyle(color: Colors.grey),
299+
),
294300
backgroundColor: Colors.white),
295301
BottomNavigationBarItem(
296-
icon: Icon(Icons.cloud_done),
297-
title: Text("PREVIOUS"),
302+
icon: Icon(
303+
Icons.update,
304+
color: Colors.blue,
305+
),
306+
title: Text(
307+
"PREVIOUS",
308+
style: TextStyle(color: Colors.blue),
309+
),
298310
backgroundColor: Colors.blueGrey),
299311
BottomNavigationBarItem(
300312
icon: Icon(Icons.compare),

lib/ui/test.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[
2+
{
3+
status: OK,
4+
result:
5+
[
6+
{
7+
contribution: 0,
8+
lastOnlineTimeSeconds: 1592676640,
9+
rating: 1345,
10+
friendOfCount: 1,
11+
titlePhoto: //userpic.codeforces.com/1446253/title/2e8fd8c684026c8c.jpg,
12+
rank: pupil,
13+
handle: jspw,
14+
maxRating: 1429,
15+
avatar: //userpic.codeforces.com/1446253/avatar/f5b02ba30f9c8cb.jpg,
16+
registrationTimeSeconds: 1584970392,
17+
maxRank: specialist
18+
19+
}
20+
21+
]
22+
},
23+
24+
[
25+
{
26+
contestId: 1327,
27+
contestName: Educational Codeforces Round 84 (Rated for Div. 2),
28+
handle: jspw,
29+
rank: 8650,
30+
ratingUpdateTimeSeconds: 1584981300,
31+
oldRating: 0,
32+
newRating: 1429
33+
34+
},
35+
{
36+
contestId: 1342,
37+
contestName: Educational Codeforces Round 86 (Rated for Div. 2),
38+
handle: jspw,
39+
rank: 11585,
40+
ratingUpdateTimeSeconds: 1587918900,
41+
oldRating: 1429,
42+
newRating: 1345
43+
}
44+
45+
]
46+
]
47+
48+
49+

0 commit comments

Comments
 (0)