-
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.
Merge pull request #13 from imranhashmi/listview
- Loading branch information
Showing
7 changed files
with
262 additions
and
16 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,15 @@ | ||
class Manager { | ||
final String name; | ||
final String description; | ||
|
||
Manager(this.name, this.description) { | ||
if (name == null) { | ||
throw new ArgumentError("name of Manager cannot be null. " | ||
"Received: '$name'"); | ||
} | ||
if (description == null) { | ||
throw new ArgumentError("description of Manager cannot be null. " | ||
"Received: '$description'"); | ||
} | ||
} | ||
} |
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,15 @@ | ||
class Store { | ||
final String name; | ||
final String description; | ||
|
||
Store(this.name, this.description) { | ||
if (name == null) { | ||
throw new ArgumentError("name of Store cannot be null. " | ||
"Received: '$name'"); | ||
} | ||
if (description == null) { | ||
throw new ArgumentError("description of Store cannot be null. " | ||
"Received: '$description'"); | ||
} | ||
} | ||
} |
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,15 @@ | ||
class Survey { | ||
final String name; | ||
final String description; | ||
|
||
Survey(this.name, this.description) { | ||
if (name == null) { | ||
throw new ArgumentError("name of Survey cannot be null. " | ||
"Received: '$name'"); | ||
} | ||
if (description == null) { | ||
throw new ArgumentError("description of Survey cannot be null. " | ||
"Received: '$description'"); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,78 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'dart:convert'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
import 'package:dukandaar/datamodel/manager.dart'; | ||
|
||
class ManagersPageState extends State<ManagersPage> { | ||
var _stores = <Manager>[]; | ||
|
||
final _biggerFont = const TextStyle(fontSize: 18.0); | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
|
||
// NOT USED for now | ||
//_loadData(); | ||
} | ||
|
||
class ManagersPage extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
// TODO: implement build | ||
return new Center( | ||
child: new Text("Managers"), | ||
return new Scaffold ( | ||
floatingActionButton: new FloatingActionButton( | ||
onPressed: _addData, | ||
tooltip: 'Add', | ||
child: new Icon(Icons.add) | ||
), | ||
body: new ListView.builder( | ||
itemCount: _stores.length * 2, | ||
itemBuilder: (BuildContext context, int position) { | ||
if (position.isOdd) return new Divider(); | ||
|
||
final index = position ~/ 2; | ||
|
||
return _buildRow(index); | ||
} | ||
), | ||
); | ||
} | ||
|
||
Widget _buildRow(int i) { | ||
return new Padding( | ||
padding: const EdgeInsets.all(16.0), | ||
child: new ListTile( | ||
title: new Text(_stores[i].name, style: _biggerFont), | ||
subtitle: new Text(_stores[i].description, style: _biggerFont), | ||
) | ||
); | ||
} | ||
|
||
_addData(){ | ||
setState((){ | ||
// add new store here, | ||
final member = new Manager("dummy" + "${_stores.length}","description"); | ||
_stores.add(member); | ||
}); | ||
} | ||
|
||
// NOT USED for now | ||
_loadData() async { | ||
String dataURL = "https://api.github.com/orgs/raywenderlich/members"; | ||
http.Response response = await http.get(dataURL); | ||
setState(() { | ||
final membersJSON = JSON.decode(response.body); | ||
|
||
for (var memberJSON in membersJSON) { | ||
final member = new Manager(memberJSON["login"], memberJSON["avatar_url"]); | ||
_stores.add(member); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
class ManagersPage extends StatefulWidget { | ||
@override | ||
createState() => new ManagersPageState(); | ||
} |
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 |
---|---|---|
@@ -1,11 +1,78 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'dart:convert'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
import 'package:dukandaar/datamodel/store.dart'; | ||
|
||
class StoresPageState extends State<StoresPage> { | ||
var _stores = <Store>[]; | ||
|
||
final _biggerFont = const TextStyle(fontSize: 18.0); | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
|
||
// NOT USED for now | ||
//_loadData(); | ||
} | ||
|
||
class StoresPage extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
// TODO: implement build | ||
return new Center( | ||
child: new Text("Stores"), | ||
return new Scaffold ( | ||
floatingActionButton: new FloatingActionButton( | ||
onPressed: _addData, | ||
tooltip: 'Add', | ||
child: new Icon(Icons.add) | ||
), | ||
body: new ListView.builder( | ||
itemCount: _stores.length * 2, | ||
itemBuilder: (BuildContext context, int position) { | ||
if (position.isOdd) return new Divider(); | ||
|
||
final index = position ~/ 2; | ||
|
||
return _buildRow(index); | ||
} | ||
), | ||
); | ||
} | ||
|
||
Widget _buildRow(int i) { | ||
return new Padding( | ||
padding: const EdgeInsets.all(16.0), | ||
child: new ListTile( | ||
title: new Text(_stores[i].name, style: _biggerFont), | ||
subtitle: new Text(_stores[i].description, style: _biggerFont), | ||
) | ||
); | ||
} | ||
|
||
_addData(){ | ||
setState((){ | ||
// add new store here, | ||
final member = new Store("dummy" + "${_stores.length}","description"); | ||
_stores.add(member); | ||
}); | ||
} | ||
|
||
// NOT USED for now | ||
_loadData() async { | ||
String dataURL = "https://api.github.com/orgs/raywenderlich/members"; | ||
http.Response response = await http.get(dataURL); | ||
setState(() { | ||
final membersJSON = JSON.decode(response.body); | ||
|
||
for (var memberJSON in membersJSON) { | ||
final member = new Store(memberJSON["login"], memberJSON["avatar_url"]); | ||
_stores.add(member); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
class StoresPage extends StatefulWidget { | ||
@override | ||
createState() => new StoresPageState(); | ||
} |
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 |
---|---|---|
@@ -1,11 +1,78 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'dart:convert'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
import 'package:dukandaar/datamodel/survey.dart'; | ||
|
||
class SurveysPageState extends State<SurveysPage> { | ||
var _stores = <Survey>[]; | ||
|
||
final _biggerFont = const TextStyle(fontSize: 18.0); | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
|
||
// NOT USED for now | ||
//_loadData(); | ||
} | ||
|
||
class SurveysPage extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
// TODO: implement build | ||
return new Center( | ||
child: new Text("Surveys"), | ||
return new Scaffold ( | ||
floatingActionButton: new FloatingActionButton( | ||
onPressed: _addData, | ||
tooltip: 'Add', | ||
child: new Icon(Icons.add) | ||
), | ||
body: new ListView.builder( | ||
itemCount: _stores.length * 2, | ||
itemBuilder: (BuildContext context, int position) { | ||
if (position.isOdd) return new Divider(); | ||
|
||
final index = position ~/ 2; | ||
|
||
return _buildRow(index); | ||
} | ||
), | ||
); | ||
} | ||
|
||
Widget _buildRow(int i) { | ||
return new Padding( | ||
padding: const EdgeInsets.all(16.0), | ||
child: new ListTile( | ||
title: new Text(_stores[i].name, style: _biggerFont), | ||
subtitle: new Text(_stores[i].description, style: _biggerFont), | ||
) | ||
); | ||
} | ||
|
||
_addData(){ | ||
setState((){ | ||
// add new store here, | ||
final member = new Survey("dummy" + "${_stores.length}","description"); | ||
_stores.add(member); | ||
}); | ||
} | ||
|
||
// NOT USED for now | ||
_loadData() async { | ||
String dataURL = "https://api.github.com/orgs/raywenderlich/members"; | ||
http.Response response = await http.get(dataURL); | ||
setState(() { | ||
final membersJSON = JSON.decode(response.body); | ||
|
||
for (var memberJSON in membersJSON) { | ||
final member = new Survey(memberJSON["login"], memberJSON["avatar_url"]); | ||
_stores.add(member); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
class SurveysPage extends StatefulWidget { | ||
@override | ||
createState() => new SurveysPageState(); | ||
} |