Compare commits
1 commit
developmen
...
felix/brok
Author | SHA1 | Date | |
---|---|---|---|
|
c634b3ab88 |
3 changed files with 92 additions and 67 deletions
|
@ -3,18 +3,12 @@ import 'dart:async';
|
||||||
|
|
||||||
import 'package:local_spend/common/apifunctions/find_organisations.dart';
|
import 'package:local_spend/common/apifunctions/find_organisations.dart';
|
||||||
|
|
||||||
class FindOrganisations {
|
class FindOrganisations extends StatefulWidget {
|
||||||
|
@override
|
||||||
TextField getSearchBar(TextEditingController controller, String hintText) {
|
_FindOrganisationsState createState() => _FindOrganisationsState();
|
||||||
return TextField(
|
}
|
||||||
controller: controller,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
hintText: hintText,
|
|
||||||
icon: Icon(Icons.search),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
class _FindOrganisationsState extends State<FindOrganisations> {
|
||||||
List<Text> getFavourites() {
|
List<Text> getFavourites() {
|
||||||
var numItems = 200;
|
var numItems = 200;
|
||||||
var itemsList = new List<Text>();
|
var itemsList = new List<Text>();
|
||||||
|
@ -32,60 +26,97 @@ class FindOrganisations {
|
||||||
// todo: get all organisations, favourites and all data from one 'organisations' class or similar
|
// todo: get all organisations, favourites and all data from one 'organisations' class or similar
|
||||||
// eg items: organisations.getFavourites().orderBy(name),
|
// eg items: organisations.getFavourites().orderBy(name),
|
||||||
|
|
||||||
Future<Organisation> dialog(context) {
|
// Future<Organisation> dialog(context) {
|
||||||
var searchBar = getSearchBar(null, "Payee Name");
|
TextEditingController searchBarText = new TextEditingController();
|
||||||
|
var listTitle = "Favourites";
|
||||||
|
|
||||||
|
void _submitSearch(String search) {
|
||||||
|
listTitle = "Results for \'" + search + "\'";
|
||||||
|
debugPrint("Searched for \'" + search + "\'");
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget build(BuildContext context) {
|
||||||
var favourites = getFavourites();
|
var favourites = getFavourites();
|
||||||
return showDialog<Organisation>(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: true,
|
|
||||||
|
|
||||||
builder: (BuildContext context) {
|
return SimpleDialog(
|
||||||
return SimpleDialog(
|
children: <Widget>[
|
||||||
children: <Widget>[
|
Padding(
|
||||||
Padding(
|
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
|
||||||
padding: EdgeInsets.symmetric(horizontal: 10),
|
child: Row(
|
||||||
child: searchBar,
|
children: <Widget>[
|
||||||
),
|
Container(
|
||||||
|
width: 200,
|
||||||
Container(
|
height: 50,
|
||||||
padding: EdgeInsets.fromLTRB(20, 20, 0, 0),
|
child: TextField(
|
||||||
child: Text(
|
controller: searchBarText,
|
||||||
"Favourites",
|
decoration: InputDecoration(
|
||||||
style: new TextStyle(fontSize: 23, fontWeight: FontWeight.bold),
|
hintText: "Payee Name",
|
||||||
),
|
),
|
||||||
),
|
onSubmitted: (_) {
|
||||||
|
_submitSearch(searchBarText.text);
|
||||||
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: () {},
|
|
||||||
)
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Container(
|
||||||
|
width: 80,
|
||||||
|
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
|
||||||
|
child: RaisedButton(
|
||||||
|
onPressed: () {
|
||||||
|
_submitSearch(searchBarText.text);
|
||||||
|
},
|
||||||
|
child: Icon(Icons.search, color: Colors.white),
|
||||||
|
color: Colors.blue,
|
||||||
|
// make inactive when search in progress as activity indicator
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
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: () {},
|
||||||
|
)
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
// help button for if org not listed
|
// help button for if org not listed
|
||||||
// cancel and ok buttons
|
// cancel and ok buttons
|
||||||
|
|
||||||
],
|
],
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,14 +1,11 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:local_spend/pages/home_page.dart';
|
import 'package:local_spend/pages/home_page.dart';
|
||||||
import 'package:local_spend/pages/login_page.dart';
|
import 'package:local_spend/pages/login_page.dart';
|
||||||
import 'package:local_spend/pages/receipt_page.dart';
|
|
||||||
import 'package:local_spend/pages/receipt_page_2.dart';
|
import 'package:local_spend/pages/receipt_page_2.dart';
|
||||||
import 'package:local_spend/pages/spash_screen.dart';
|
import 'package:local_spend/pages/spash_screen.dart';
|
||||||
import 'package:local_spend/pages/more_page.dart';
|
import 'package:local_spend/pages/more_page.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
|
|
||||||
import 'package:local_spend/common/apifunctions/get_graph_data.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(MyApp());
|
runApp(MyApp());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:local_spend/common/platform/platform_scaffold.dart';
|
import 'package:local_spend/common/platform/platform_scaffold.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:local_spend/common/apifunctions/find_organisations.dart';
|
import 'package:local_spend/common/apifunctions/find_organisations.dart';
|
||||||
import 'package:local_spend/common/widgets/organisations_dialog.dart';
|
import 'package:local_spend/common/widgets/organisations_dialog.dart';
|
||||||
|
@ -39,6 +40,9 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
var dialog = new Dialog(
|
||||||
|
child: FindOrganisations(),
|
||||||
|
);
|
||||||
|
|
||||||
return PlatformScaffold(
|
return PlatformScaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
@ -151,14 +155,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
||||||
height: 32.0,
|
height: 32.0,
|
||||||
child: RaisedButton(
|
child: RaisedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// var popupListView = new PopupListView();
|
dialog.then((org) {});
|
||||||
// var dialog = popupListView.dialog(context, optionsList, "Choose Organization");
|
|
||||||
var organisations = new FindOrganisations();
|
|
||||||
var orgDialog = organisations.dialog(context);
|
|
||||||
|
|
||||||
orgDialog.then((organisation) {
|
|
||||||
debugPrint(organisation.name);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
transaction.organisation.name == null
|
transaction.organisation.name == null
|
||||||
|
|
Reference in a new issue