-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.dart
175 lines (163 loc) · 4.38 KB
/
main.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
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
void main() {
runApp(AlgIO());
}
class AlgIO extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
backgroundColor: Color.fromARGB(100, 56, 99, 168),
textTheme: TextTheme(
headline: GoogleFonts.ubuntu(
textStyle: Theme.of(context).textTheme.display1,
fontSize: 60,
color: Colors.white,
),
body1: GoogleFonts.ubuntu(
textStyle: Theme.of(context).textTheme.display1,
fontSize: 20,
color: Colors.white,
),
),
),
routes: {
'/': (context) => WelcomeScreen(),
'/home': (context) => HomeScreen(),
'/sorting': (context) => SortingAlgScreen(),
},
);
}
}
// The App will start as a stateful widget
class WelcomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).backgroundColor,
body: Center(
child: Column(children: [
Divider(
height: 250,
),
Text(
'AlgIO',
style: Theme.of(context).textTheme.headline,
),
Divider(height: 20),
// A button which will progress the app when pressed
ClipRRect(
borderRadius: BorderRadius.circular(20.0),
child: FlatButton(
color: Colors.white24,
onPressed: () => displayHomeScreen(context),
child: Container(
child: Text(
'Continue to App',
style: Theme.of(context).textTheme.body1,
),
),
),
),
]),
),
);
}
// Takes the app to the home screen
void displayHomeScreen(BuildContext context) {
Navigator.of(context).pushNamed('/home');
}
}
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
final _topics = [
'Sorting Algorithms',
'Time Complexities',
'Graphs and Trees',
'Abstract Data Structures',
'Design Patterns',
'More'
];
@override
Widget build(BuildContext context) {
TextStyle titleFont = GoogleFonts.ubuntu(
textStyle: Theme.of(context).textTheme.display1,
fontSize: 20,
color: Colors.white,
);
return Scaffold(
backgroundColor: Theme.of(context).backgroundColor,
appBar: AppBar(
elevation: 10,
backgroundColor: Theme.of(context).backgroundColor,
title: Text(
'AlgIO',
style: titleFont,
)),
body: _buildTopics(),
);
}
Widget _buildTopics() {
return ListView.builder(
padding: const EdgeInsets.all(16),
itemBuilder: (BuildContext _context, int i) {
if (i.isOdd) {
return Divider();
}
final int index = i ~/ 2;
if (index < _topics.length) {
return _buildRow(_topics[index]);
} else {
return _buildRow('');
}
});
}
Widget _buildRow(String topic) {
final bool isEmpty = topic.isEmpty;
return ListTile(
title: Text(
topic,
style: GoogleFonts.ubuntu(
textStyle: Theme.of(context).textTheme.display1,
fontSize: 20,
color: Colors.white,
),
),
trailing: isEmpty
? null
: Icon(
Icons.send,
color: Colors.white.withOpacity(0.5),
size: 20,
),
onTap: () => visitPage(context, topic),
);
}
void visitPage(BuildContext context, String directory) {
if (directory == 'Sorting Algorithms') {
Navigator.pushNamed(context, '/sorting');
}
}
}
class SortingAlgScreen extends StatefulWidget {
@override
_SortingAlgScreenState createState() => _SortingAlgScreenState();
}
class _SortingAlgScreenState extends State<SortingAlgScreen> {
@override
Widget build(BuildContext context) {
return Container(
color: Theme.of(context).backgroundColor,
child: Center(
child: Text(
'Sorting Algorithms coming soon',
style: Theme.of(context).textTheme.headline,
),
),
);
}
}