-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.dart
493 lines (424 loc) · 13.7 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
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
//these are comments on one line
/* <--
these are
multi
| line
v comments
*/
//Edit (/* */) the slash and astricks are used for multi-line comments.
//Yes we could just use the (//) on multiple lines but that is lame.
//That's for NOOBS, and we are not noobs. We are wiggles! But yes you will see both being use. 🐙
//-Justice K.
//this is where we ask the libraries
//for their books ;)
import "package:flutter/material.dart";
import "dart:async" show Future;
//this is where bring in the
//other pages of this main book
import "./volunteer.dart" as volunteer;
import "./resources.dart" as resources;
import "./youth.dart" as youth;
import "./coffee.dart" as coffee;
import "./you.dart" as you;
import "./give.dart" as give;
import "./about.dart" as about;
import "./blog.dart" as blog;
import "./store.dart" as store;
import "./pageNOT.dart" as not;
/*
TODO
questions that must be answered as input to an
automated folder creation tool how many views does
the server app have (can be none)
should be able to fire it back up on an already
created tree and change folder/file names
instead of page names use view names
saying that all programmers do is write code is
like saying all a barista does is speak english
create a rust wrapper for mac, linux, windows and web
this will allow us to be able to push views to all
those using the video game style opengl views :3
*/
//do not be afraid if you are lacking context dear
//reader, rush on and tackle this book with the app
//in hand
//0
//these are the helpers for
//the documentation below
//of the main() function
//vvvv <-- this is the type of inBOX0
String inBOX0 = "we can add some";
//vvvv <-- this is the function's output type
String yellow_out(inBOX0){
inBOX0 += " more words";
outBOX0 = inBOX0
return outBOX0;
}
void yellow(){
}
class Green{
//makes a new green nothing
Green();
}
/*
if you are not familiar with category logic,
classes are basically prescriptions of object attributes
importantly when viewed in this context, individual classes
may contain usage of other classes' attributes
classes are Green */Green colorBOX0 = new Green();/*
you usually take a copy of a specific class
and put it into a box to be used locally only
the box usually only fits a specific class of contents
boxes are white */String wordBOX0 = "this box is called word";
/* and are usually typed with a class
functions are class attributes also called methods
they prescribe several algorithms that allow the class
to express its usage, its workflow recipes if you will
functions are yellow */yellow()/*
they take inputs at the suspiciously hole shaped thing
where the user of the function puts boxes holding
ingredients
they drop their outputs into a box
*/String outBOX0 = yellow_out(inBOX0);/*
finally grey text behind two // characters
labels the end bracket depth by the class name
that is nearest to the matching start bracket
*/
void main() {
runApp(new MaterialApp(
home: new PageFrame0(),
//the following allows you to start each
//different view (the part after the ':')
//just by typing the brown string
//(saves alot of work)
routes: <String, WidgetBuilder> {
'/GiveView': (BuildContext context) => new give.GiveView(),
'/VolunteerView' : (BuildContext context) => new volunteer.VolunteerView(),
'/ResourcesView' : (BuildContext context) => new resources.ResourcesView(),
'/AboutView' : (BuildContext context) => new about.AboutView(),
'/BlogView' : (BuildContext context) => new blog.BlogView(),
'/StoreView' : (BuildContext context) => new store.StoreView(),
'/NotView' : (BuildContext context) => new not.View()
}
));
}
//the following two classes are actually one Widget
//the tree in the state class
//is the main page with tabs
//the default tab selected is 'youth'
class PageFrame0 extends StatefulWidget {
@override
PageFrame0State createState() => new PageFrame0State();
}
//This is the class that defines
//what the actual page frame will look like
class PageFrame0State extends State<PageFrame0>
with SingleTickerProviderStateMixin {
//this is the box for the tab controller
TabController controller;
//START
//this sets up a new tab controller
//everytime the app is started
@override
void initState(){
super.initState();
//puts it in the box we made
controller = new TabController(vsync: this, length: 3);
}
//this gets rid of it when
//it is not needed
void dispose() {
controller.dispose();
super.dispose();
}
//END
//START
//this allows you to press the back button
//and go to the 'youth' tab which is now default
Future<bool> _onWillPop() {
//if the index in the tab controller box
//is already set to the first index
if (controller.index == 0){
return new Future<bool>.value(true);
}
else {
//otherwise set the index to the first position
controller.index = 0;
return new Future<bool>.value(false);
}
}
//END
@override
Widget build(BuildContext context){
return new WillPopScope(
//this sets the function to run
//in the event of a back button press
onWillPop: _onWillPop,
//this is the skeleton of the view parts
//it carries a drawer
//and the app bar, tab bar
//and essentially the page views
child: new Scaffold(
drawer: new CustomDrawer(),
//this is the code bloat that has to be
//introduced by use of the animation
body: new NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
new SliverOverlapAbsorber(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
//this is where the actual parts
// of the app bar are defined
child: new SliverAppBar(
backgroundColor: const Color(0xff000000),
title: new Text("Coffee Oasis"),
pinned:true,
expandedHeight: 256.0,
forceElevated: innerBoxIsScrolled,
flexibleSpace: new FlexibleSpaceBar(
background: new Stack(
fit: StackFit.expand,
children: <Widget> [
//cover image
new Image.asset(
'assets/coffeeCover0.jpg',
fit: BoxFit.cover,
height: 256.0
)
]
)
),
bottom: new TabBar(
//this is the same controller
//in the box we set up earlier
controller: controller,
//these are three tabs with icons stacked on them
//in a box fitted for Tab objects
tabs: <Tab>[
new Tab(
icon: new ImageIcon(
new AssetImage("assets/sun.png"),
)
),
new Tab(
icon: new ImageIcon(
new AssetImage("assets/coffee.png"),
)
),
new Tab(
icon: new ImageIcon(
new AssetImage("assets/child.png"),
)
)
],
)
)
)
];
},
//this is where the page shows below the appbar,
//three tabs worth
body: new TabBarView(
controller: controller,
/*this kind of box has
been seen but probably
not yet understood*/
//this is a list box
//it is a partitioned box
//that is typed with a class
children: <Widget>[
//tab index 0 (a widget)
new youth.YouthView(),
//tab index 1 (a widget)
new coffee.CoffeeView(),
//tab index 2 (a widget)
new you.YouView()
],
)
)
)
);
}
}
//this class (also called object or widget)
//just going to butt in here, but its not the
//widget that you might have heard on android.
// this widget is the visual apsect of flutter,
//and my most favourite part.
//This will be where you add and change the style,
//font, and animations for the whole flutter UI.
//-Justice K.
//defines the transparent card elements
//with text on them
//that are used in the app drawer
//(accessed using the the three bar icon top left)
class DrawerInk extends StatelessWidget{
//these are the receiving boxes
//that are going to be used
//to sort the stuff the coder gives
//to the object when they use it
final String text;
final Icon icon;
//this is the box that the route
//is delivered in, it is a string type
//and the contents look like this "/ViewAddress"
final String route;
//this part collects all the neccisary boxes
//from a coder in order to display their contents
//and navigate to addresses within the app
DrawerInk(this.text, this.icon, this.route);
//this is where the navigation
//is defined using pieces from
//the app context (a collection
//of information about the parts
//of the app) --------------vvvvvvv this is the context box
void onPressed(BuildContext context){
Navigator.of(context).pushNamed(this.route);
}
@override
Widget build(BuildContext context){
//this is the start of the tree
//for the drawer buttons
return new FlatButton(
padding: new EdgeInsets.symmetric(vertical: 15.0),
//color: Colors.white,
child: new Row(children: <Widget>[
new Container(
padding: new EdgeInsets.symmetric(horizontal:10.0),
child: this.icon
),
new Flexible(
child: new Text(this.text,
softWrap: true)
)
]),
onPressed: (){onPressed(context);}
);
}
}
//this is the drawer object
//here we define the pieces in that
class CustomDrawer extends StatelessWidget{
@override
Widget build(BuildContext context){
//this is the start of the tree
//for the drawer
return new Drawer(
child: new Container(
color: const Color(0xffc9c3bb),
child: new ListView(
children: <Widget> [
new DrawerHeader(
decoration: new BoxDecoration(
image: new DecorationImage(
image: new AssetImage("assets/mainlogo.jpg"),
fit: BoxFit.cover
)
)
),
new DrawerInk(
"about us",
new Icon(Icons.assessment),
"/AboutView"
),
new DrawerInk(
"read our blog",
new Icon(Icons.book),
"/BlogView"
),
new DrawerInk(
"our store is full of goodies",
new Icon(Icons.explore),
"/StoreView"
),
new DrawerInk(
"cart",
new Icon(Icons.credit_card),
"/NotView"
)
]
),
)
);
}
}
//this describes the portions of the page
//that have no apparent card, just text
class ViewInk extends StatelessWidget{
final String text;
final String title;
ViewInk(this.title, this.text);
@override
Widget build(BuildContext context){
//this is teh start of the tree
//for the object used to display text
//without using a card underneath
return new Container(
padding: new EdgeInsets.all(25.0),
child: new Column(children: <Widget>[
new Center(
child: new Text(this.title,
style: new TextStyle(
fontWeight: FontWeight.bold,
fontFamily: "Open Sans",
fontSize: 17.4,
color: const Color(0xFFc2421f)
)),
),
new Text("\n"),
new Flexible(
child: new Center(
child: new Text(this.text,
softWrap: true,
style: new TextStyle(
fontFamily: "Open Sans"
))
)
)
],
mainAxisSize: MainAxisSize.min),
);
}
}
//this describes the cards
//within the main pages which
//have a background raised card
//with text content on top
//these almost always navigate
//to another view when tapped
class ViewCard extends StatelessWidget{
final String text;
final Icon icon;
final String route;
ViewCard(this.text, this.icon, this.route);
void onPressed(BuildContext context){
Navigator.of(context).pushNamed(this.route);
}
@override
Widget build(BuildContext context){
//this is the start of the tree
//for the viewcard object
return new Container(
padding: new EdgeInsets.symmetric(horizontal: 10.0),
child: new Card(
color: const Color(0xffc9c3bb),
child: new Ink(
child: new FlatButton(
padding: new EdgeInsets.symmetric(vertical: 30.0),
child: new Row(children: <Widget>[
new Container(
padding: new EdgeInsets.symmetric(horizontal: 55.0),
child: this.icon
),
new Flexible(
child: new Text(this.text,
softWrap: true)
)
]),
onPressed: (){onPressed(context);}
),
)
)
);
}
}