2019-08-07 13:15:15 +01:00
import ' package:flutter/material.dart ' ;
import ' dart:async ' ;
import ' package:local_spend/common/apifunctions/find_organisations.dart ' ;
class FindOrganisations {
TextField getSearchBar ( TextEditingController controller , String hintText ) {
return TextField (
controller: controller ,
decoration: InputDecoration (
hintText: hintText ,
icon: Icon ( Icons . search ) ,
) ,
) ;
}
2019-08-07 14:02:36 +01:00
List < Text > getFavourites ( ) {
2019-08-07 13:15:15 +01: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 14:02:36 +01: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:15:15 +01:00
Future < Organisation > dialog ( context ) {
var searchBar = getSearchBar ( null , " Payee Name " ) ;
2019-08-07 14:02:36 +01:00
var favourites = getFavourites ( ) ;
2019-08-07 13:15:15 +01:00
return showDialog < Organisation > (
context: context ,
barrierDismissible: true ,
builder: ( BuildContext context ) {
return SimpleDialog (
children: < Widget > [
Padding (
padding: EdgeInsets . symmetric ( horizontal: 10 ) ,
child: searchBar ,
) ,
2019-08-07 13:22:14 +01:00
Container (
padding: EdgeInsets . fromLTRB ( 20 , 20 , 0 , 0 ) ,
child: Text (
" Favourites " ,
style: new TextStyle ( fontSize: 23 , fontWeight: FontWeight . bold ) ,
) ,
) ,
2019-08-07 13:15:15 +01:00
Container (
2019-08-07 14:02:36 +01:00
padding: EdgeInsets . fromLTRB ( 10 , 10 , 10 , 0 ) ,
2019-08-07 13:15:15 +01:00
width: MediaQuery . of ( context ) . size . width * 0.7 ,
2019-08-07 14:02:36 +01:00
height: MediaQuery . of ( context ) . size . height * 0.67 ,
2019-08-07 13:15:15 +01:00
child: Material (
shadowColor: Colors . transparent ,
color: Colors . transparent ,
child: ListView . builder (
2019-08-07 14:02:36 +01:00
itemCount: favourites . length ,
2019-08-07 13:15:15 +01:00
itemBuilder: ( context , index ) {
return Card (
child: ListTile (
leading: Icon ( Icons . person ) ,
2019-08-07 14:02:36 +01:00
title: favourites [ index ] ,
2019-08-07 13:15:15 +01:00
trailing: Icon ( Icons . arrow_forward_ios ) ,
2019-08-07 14:02:36 +01:00
onTap: ( ) { } ,
2019-08-07 13:15:15 +01:00
)
) ;
} ,
) ,
) ,
) ,
// help button for if org not listed
// cancel and ok buttons
] ,
) ;
} ,
) ;
}
}