This repository has been archived by the owner on Feb 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rohan Dhesikan
authored and
Rohan Dhesikan
committed
Dec 2, 2018
1 parent
e5ca976
commit 1db04f1
Showing
5 changed files
with
239 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'global.dart'; | ||
import 'package:http/http.dart' as http; | ||
import 'dart:convert'; | ||
import 'global.dart'; | ||
|
||
class Checkout extends StatefulWidget { | ||
final List<dynamic> prices; | ||
final List<dynamic> items; | ||
final List<int> nums; | ||
final String title; | ||
final int total; | ||
|
||
Checkout({Key key, this.title, @required this.items, @required this.prices, @required this.nums, @required this.total}) : super(key: key); | ||
|
||
|
||
@override | ||
CheckoutState createState() => CheckoutState(); | ||
} | ||
|
||
class CheckoutState extends State<Checkout> { | ||
|
||
List<int> j = new List(); | ||
|
||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
title: 'Flutter Demo', | ||
theme: ThemeData( | ||
primarySwatch: Colors.blue, | ||
), | ||
home: new Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Basic AppBar')), | ||
body: new SafeArea( | ||
|
||
child: Column( | ||
|
||
mainAxisSize: MainAxisSize.max, | ||
children: <Widget>[ | ||
|
||
new ListView.builder( | ||
physics: const NeverScrollableScrollPhysics(), | ||
shrinkWrap: true, | ||
itemCount: widget.items.length, | ||
itemBuilder: (context, index) { | ||
return Card( | ||
child: | ||
new Container( | ||
height: 50.0, | ||
child: new Row( | ||
children: <Widget>[ | ||
Text(widget.nums[index].toString()+" "+ widget.items[index]+": "+widget.prices[index].toString()+" dollars each"), | ||
|
||
], | ||
) | ||
) | ||
); | ||
}, | ||
), | ||
new FlatButton( | ||
onPressed: (){ | ||
}, | ||
color: Colors.blue, | ||
child: Text( | ||
widget.total.toString())) | ||
], | ||
), | ||
),) | ||
, | ||
); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'global.dart'; | ||
import 'Checkout.dart'; | ||
import 'package:http/http.dart' as http; | ||
import 'dart:convert'; | ||
import 'global.dart'; | ||
|
||
class StoreDetails extends StatefulWidget { | ||
final Store ste; | ||
final String title; | ||
final int length; | ||
|
||
StoreDetails({Key key, this.title, @required this.ste, @required this.length}) : super(key: key); | ||
|
||
|
||
@override | ||
StoreDetailsState createState() => StoreDetailsState(); | ||
} | ||
|
||
class StoreDetailsState extends State<StoreDetails> { | ||
|
||
List<int> j = new List(); | ||
int total = 0; | ||
|
||
|
||
@override | ||
Widget build(BuildContext context) { | ||
while(j.length < widget.ste.menu.length){ | ||
j.add(0); | ||
} | ||
print(widget.ste); | ||
return MaterialApp( | ||
title: 'Flutter Demo', | ||
theme: ThemeData( | ||
primarySwatch: Colors.blue, | ||
), | ||
home: new Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Basic AppBar')), | ||
body: new SafeArea( | ||
|
||
child: Column( | ||
|
||
mainAxisSize: MainAxisSize.max, | ||
children: <Widget>[ | ||
|
||
new Card( | ||
child: Container( | ||
child: new Column( | ||
children: <Widget>[ | ||
new Text ((widget.ste.name), | ||
style: new TextStyle (fontWeight: FontWeight.bold),), | ||
new Text (widget.ste.type), | ||
new Text (widget.ste.price), | ||
new Text (widget.ste.location), | ||
], | ||
), | ||
width: 100.0, | ||
color: Colors.blue | ||
) | ||
), | ||
new ListView.builder( | ||
physics: const NeverScrollableScrollPhysics(), | ||
shrinkWrap: true, | ||
itemCount: widget.ste.menu.length, | ||
itemBuilder: (context, index) { | ||
return Card( | ||
child: new Row( | ||
children: <Widget>[ | ||
Text(widget.ste.menu[index]+": "+widget.ste.prices[index].toString()+" dollars"), | ||
|
||
|
||
IconButton( | ||
alignment: Alignment.centerRight, | ||
icon: Icon(Icons.remove_circle), | ||
onPressed: () { | ||
setState(() { | ||
if(j[index]==null || j[index] == 0){ | ||
j[index] = 0; | ||
|
||
} | ||
else { | ||
j[index] = j[index]-1; | ||
total = total - widget.ste.prices[index]; | ||
} | ||
}); | ||
setState(() { | ||
|
||
}); | ||
}, | ||
), | ||
Text(j[index].toString()), | ||
|
||
IconButton( | ||
alignment: Alignment.centerRight, | ||
icon: Icon(Icons.add_circle), | ||
onPressed: () { | ||
setState(() { | ||
print(j.length); | ||
if(j[index]==null){ | ||
j[index] = 1; | ||
total = total + widget.ste.prices[index]; | ||
} | ||
else { | ||
j[index] = j[index]+1; | ||
total = total + widget.ste.prices[index]; | ||
} | ||
}); | ||
}, | ||
), | ||
|
||
], | ||
) | ||
); | ||
}, | ||
), | ||
new FlatButton( | ||
onPressed: (){ | ||
Navigator.push( | ||
context, | ||
MaterialPageRoute(builder: (context) => Checkout(items: widget.ste.menu, nums: j, prices: widget.ste.prices, total:total)), | ||
); }, | ||
color: Colors.blue, | ||
child: Text( | ||
total.toString() | ||
)) | ||
], | ||
), | ||
),) | ||
, | ||
); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters