Skip to content

Commit ed7cb2e

Browse files
thamaraiselvamthamaraiselvam
authored andcommitted
code refactor
1 parent 20371f5 commit ed7cb2e

File tree

11 files changed

+276
-216
lines changed

11 files changed

+276
-216
lines changed

TODO

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,4 @@ Todo:
44
☐ Vibrate when wrong item selected
55
☐ Store recent scores in local storage
66
☐ Code refactor
7-
☐ Add constant file
87
☐ Write test cases
9-
10-
11-

lib/component/ScoreCard.dart

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:numbers/utils/constants.dart';
3+
import 'package:numbers/widgets/dashedLine.dart';
4+
5+
class ScoreBoard extends StatelessWidget {
6+
String title;
7+
ScoreBoard(this.title);
8+
9+
@override
10+
Widget build(BuildContext context) {
11+
return Container(
12+
padding: const EdgeInsets.only(top: 5, left: 10, right: 10, bottom: 5),
13+
child: Column(
14+
children: <Widget>[
15+
Card(
16+
color: Colors.white,
17+
child: Column(
18+
children: [
19+
ListTile(
20+
leading: Icon(
21+
Icons.show_chart,
22+
color: primaryColor,
23+
),
24+
title: Text(title,
25+
style: TextStyle(
26+
color: primaryColor, fontWeight: FontWeight.bold)),
27+
),
28+
dashedLineBreak(Colors.grey),
29+
Table(
30+
columnWidths: {
31+
0: FractionColumnWidth(0.2),
32+
1: FractionColumnWidth(0.6),
33+
2: FractionColumnWidth(0.2)
34+
},
35+
children: [
36+
_buildTableRow("Rank,Name,Score"),
37+
],
38+
),
39+
ListView.builder(
40+
itemCount: 5,
41+
shrinkWrap: true,
42+
// physics: const NeverScrollableScrollPhysics(),
43+
itemExtent: 35,
44+
itemBuilder: (BuildContext context, int index) {
45+
return ListTile(
46+
leading: Text(
47+
index.toString(),
48+
style: TextStyle(color: greyFontColor, fontSize: 13),
49+
),
50+
title: Text(
51+
'Thamaraiselvam',
52+
style: TextStyle(color: greyFontColor, fontSize: 13),
53+
),
54+
trailing: Text(index.toString() + ' days ago',
55+
style: TextStyle(color: greyFontColor, fontSize: 13)),
56+
);
57+
},
58+
),
59+
SizedBox(height: 15,)
60+
],
61+
),
62+
),
63+
],
64+
),
65+
);
66+
}
67+
68+
TableRow _buildTableRow(String listOfNames) {
69+
return TableRow(
70+
children: listOfNames.split(',').map((name) {
71+
return Container(
72+
child: Text(
73+
name,
74+
style: TextStyle(
75+
fontSize: 13.0,
76+
color: greyFontColor,
77+
fontWeight: FontWeight.bold),
78+
textAlign: TextAlign.left,
79+
),
80+
padding: EdgeInsets.only(top: 15.0, left: 10),
81+
);
82+
}).toList(),
83+
);
84+
}
85+
}

lib/main.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import 'package:flutter/services.dart';
2-
import 'package:numbers/screens/GameScreen.dart';
3-
import 'package:numbers/screens/HowToScreen.dart';
2+
import 'package:numbers/screens/GameScreen/GameScreen.dart';
3+
import 'package:numbers/screens/TurorialScreen.dart';
44
import 'package:numbers/screens/LoadingScreen.dart';
55
import 'package:flutter/material.dart';
66
import 'package:numbers/screens/SplashScreen.dart';
7-
import 'package:numbers/screens/homeScreen.dart';
7+
import 'package:numbers/screens/HomeScreen/HomeScreen.dart';
88

99
Future<void> main() async {
1010
SystemChrome.setPreferredOrientations([
@@ -19,7 +19,7 @@ Future<void> main() async {
1919
'/home': (BuildContext context) => HomeScreen(),
2020
'/loading': (BuildContext context) => LoadingScreen(),
2121
'/game': (BuildContext context) => GameScreen(),
22-
'/howTo': (BuildContext context) => HowToScreen(),
22+
'/tutorial': (BuildContext context) => TurorialScreen(),
2323
},
2424
));
2525
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class _GameScreenState extends State<GameScreen> {
5757
);
5858
}
5959

60-
void initTimer() {
60+
void initTimer() {
6161
this.gameTimerObject = Timer.periodic(Duration(seconds: 1), (timer) {
6262
setState(() {
6363
this.secCounter--;
@@ -211,7 +211,9 @@ class _GameScreenState extends State<GameScreen> {
211211
alignment: Alignment(0.0, 0.0),
212212
// color: Colors.grey,
213213
padding: const EdgeInsets.all(30),
214-
child: Wrap(spacing: 40, runSpacing: 40, children: _generateBlocks(6)),
214+
child: Center(
215+
child: Wrap(spacing: 40, runSpacing: 40, children: _generateBlocks(6)),
216+
),
215217
);
216218
}
217219

lib/screens/HomeScreen.dart

Lines changed: 0 additions & 204 deletions
This file was deleted.

0 commit comments

Comments
 (0)