2019-08-07 12:15:15 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
import 'package:local_spend/common/apifunctions/find_organisations.dart';
|
|
|
|
|
2019-08-07 13:53:57 +00:00
|
|
|
class FindOrganisations extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_FindOrganisationsState createState() => _FindOrganisationsState();
|
|
|
|
}
|
2019-08-07 12:15:15 +00:00
|
|
|
|
2019-08-07 13:53:57 +00:00
|
|
|
class _FindOrganisationsState extends State<FindOrganisations> {
|
2019-08-07 13:02:36 +00:00
|
|
|
List<Text> getFavourites() {
|
2019-08-07 12:15:15 +00:00
|
|
|
var numItems = 200;
|
|
|
|
var itemsList = new List<Text>();
|
|
|
|
|
|
|
|
for (int i = 0; i < numItems; i++) {
|
|
|
|
itemsList.add(Text(
|
|
|
|
"Payee " + (i + 1).toString(),
|
|
|
|
style: new TextStyle(fontSize: 18),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
return itemsList;
|
|
|
|
}
|
|
|
|
|
2019-08-07 13:02:36 +00:00
|
|
|
// todo: get all organisations, favourites and all data from one 'organisations' class or similar
|
|
|
|
// eg items: organisations.getFavourites().orderBy(name),
|
|
|
|
|
2019-08-07 13:53:57 +00:00
|
|
|
// Future<Organisation> dialog(context) {
|
|
|
|
TextEditingController searchBarText = new TextEditingController();
|
|
|
|
var listTitle = "Favourites";
|
|
|
|
|
|
|
|
void _submitSearch(String search) {
|
|
|
|
listTitle = "Results for \'" + search + "\'";
|
|
|
|
debugPrint("Searched for \'" + search + "\'");
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget build(BuildContext context) {
|
2019-08-07 13:02:36 +00:00
|
|
|
var favourites = getFavourites();
|
2019-08-07 12:15:15 +00:00
|
|
|
|
2019-08-07 13:53:57 +00:00
|
|
|
return SimpleDialog(
|
|
|
|
children: <Widget>[
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
width: 200,
|
|
|
|
height: 50,
|
|
|
|
child: TextField(
|
|
|
|
controller: searchBarText,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
hintText: "Payee Name",
|
|
|
|
),
|
|
|
|
onSubmitted: (_) {
|
|
|
|
_submitSearch(searchBarText.text);
|
|
|
|
},
|
|
|
|
),
|
2019-08-07 12:22:14 +00:00
|
|
|
),
|
2019-08-07 13:53:57 +00:00
|
|
|
Container(
|
|
|
|
width: 80,
|
|
|
|
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
|
|
|
|
child: RaisedButton(
|
|
|
|
onPressed: () {
|
|
|
|
_submitSearch(searchBarText.text);
|
2019-08-07 12:15:15 +00:00
|
|
|
},
|
2019-08-07 13:53:57 +00:00
|
|
|
child: Icon(Icons.search, color: Colors.white),
|
|
|
|
color: Colors.blue,
|
|
|
|
// make inactive when search in progress as activity indicator
|
2019-08-07 12:15:15 +00:00
|
|
|
),
|
|
|
|
),
|
2019-08-07 13:53:57 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.fromLTRB(20, 20, 0, 0),
|
|
|
|
child: Text(
|
|
|
|
listTitle,
|
|
|
|
style: new TextStyle(
|
|
|
|
fontSize: 23, fontWeight: FontWeight.bold),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.fromLTRB(10, 10, 10, 0),
|
|
|
|
width: MediaQuery
|
|
|
|
.of(context)
|
|
|
|
.size
|
|
|
|
.width * 0.7,
|
|
|
|
height: MediaQuery
|
|
|
|
.of(context)
|
|
|
|
.size
|
|
|
|
.height * 0.67,
|
|
|
|
|
|
|
|
child: Material(
|
|
|
|
shadowColor: Colors.transparent,
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: ListView.builder(
|
|
|
|
itemCount: favourites.length,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
return Card(
|
|
|
|
child: ListTile(
|
|
|
|
leading: Icon(Icons.person),
|
|
|
|
title: favourites[index],
|
|
|
|
trailing: Icon(Icons.arrow_forward_ios),
|
|
|
|
onTap: () {},
|
|
|
|
)
|
|
|
|
);
|
|
|
|
},
|
2019-08-07 12:15:15 +00:00
|
|
|
),
|
2019-08-07 13:53:57 +00:00
|
|
|
),
|
|
|
|
),
|
2019-08-07 12:15:15 +00:00
|
|
|
|
|
|
|
|
2019-08-07 13:53:57 +00:00
|
|
|
// help button for if org not listed
|
|
|
|
// cancel and ok buttons
|
2019-08-07 12:15:15 +00:00
|
|
|
|
2019-08-07 13:53:57 +00:00
|
|
|
],
|
2019-08-07 12:15:15 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|