-
Notifications
You must be signed in to change notification settings - Fork 9
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
Showing
11 changed files
with
492 additions
and
65 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
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,20 @@ | ||
import 'package:http/http.dart' as http; | ||
import 'dart:convert'; | ||
|
||
class GetContacts { | ||
static Future<String> getContactsDjangoApi(dynamic query) async { | ||
String queryString = query.toString(); | ||
String contactUrl = 'http:https://192.168.100.76:8000/contact/?search=$queryString'; | ||
|
||
http.Response response = await http.get(Uri.encodeFull(contactUrl)); | ||
|
||
return response.body; | ||
} | ||
|
||
static Future<List<dynamic>> searchDjangoContacts(dynamic value) async { | ||
return GetContacts.getContactsDjangoApi(value).then((responseBody) { | ||
List<dynamic> data = jsonDecode(responseBody); | ||
return data; | ||
}); | ||
} | ||
} |
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,133 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:fst_app_flutter/contact_screen/pages/contacts_page_general.dart'; | ||
|
||
class ContactDetailPage extends StatelessWidget { | ||
static const routeName = '/contactDetail'; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final dynamic contactDetails = ModalRoute.of(context).settings.arguments; | ||
final ContactCard contactMethods = _contactDetailList(contactDetails); | ||
final ContactCard contactInfo = _aboutContactList(contactDetails); | ||
|
||
|
||
return Scaffold( | ||
body: CustomScrollView( | ||
slivers: <Widget>[ | ||
SliverAppBar( | ||
//TODO: investigate: are these actions feasible? | ||
actions: <Widget>[ | ||
IconButton(icon: Icon(Icons.share), onPressed: null), | ||
IconButton(icon: Icon(Icons.save), onPressed: null) | ||
], | ||
floating: false, | ||
pinned: true, | ||
snap: false, | ||
expandedHeight: 200.0, | ||
flexibleSpace: FlexibleSpaceBar( | ||
/* background: SvgPicture.asset( | ||
'assets/images/person-white-48dp.svg', | ||
fit: BoxFit.contain, | ||
color: Colors.blue[800], | ||
alignment: Alignment.center, | ||
), */ | ||
title: Padding( | ||
padding: EdgeInsets.only(right: 50.0), | ||
child: Text( | ||
contactDetails['name'], | ||
maxLines: 1, | ||
overflow: TextOverflow.ellipsis, | ||
), | ||
))), | ||
SliverFillRemaining( | ||
child: Column( | ||
mainAxisSize: MainAxisSize.max, | ||
verticalDirection: VerticalDirection.down, | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: <Widget>[ | ||
Expanded( | ||
flex: 1, | ||
child: ListView( | ||
children: <Widget>[contactMethods, contactInfo])), | ||
])) | ||
], | ||
)); | ||
} | ||
|
||
ContactCard _contactDetailList(final dynamic data) { | ||
List<dynamic> phoneNums = | ||
List<dynamic>.generate(data['phone_contact_set'].length, (i) { | ||
Icon icon = | ||
i == 0 ? Icon(Icons.phone) : Icon(Icons.phone, color: Colors.white); | ||
return ListTile( | ||
leading: icon, title: Text(data['phone_contact_set'][i]['phone'])); | ||
}); | ||
|
||
List<dynamic> iconifiedList = [ | ||
...phoneNums, | ||
phoneNums.length > 0 ? Divider() : null, | ||
data['email'] != '' | ||
? ListTile( | ||
leading: Icon(Icons.email), | ||
title: Text(data['email']), | ||
) | ||
: null, | ||
data['fax'] != '' ? Divider() : null, | ||
data['fax'] != '' | ||
? ListTile( | ||
leading: Icon(Icons.print), | ||
title: Text(data['fax']), | ||
subtitle: Text('Fax'), | ||
) | ||
: null | ||
]; | ||
|
||
iconifiedList.removeWhere((element) => element == null); | ||
if (iconifiedList.length > 0) { | ||
if (iconifiedList.elementAt(iconifiedList.length - 1) is Divider) | ||
iconifiedList.removeAt(iconifiedList.length - 1); | ||
} | ||
|
||
return ContactCard( | ||
margin: EdgeInsets.symmetric(horizontal: 10.0), | ||
child: Column( | ||
children: <Widget>[...iconifiedList], | ||
)); | ||
} | ||
|
||
ContactCard _aboutContactList(final dynamic data) { | ||
List<dynamic> iconifiedList; | ||
if (data['website'] != '' || data['description'] != '') { | ||
iconifiedList = [ | ||
ListTile(title: Text('About')), | ||
data['website'] != '' ? Divider() : null, | ||
data['website'] != '' | ||
? ListTile( | ||
title: Text('Website'), | ||
subtitle: Text(data['website']), | ||
trailing: Icon(Icons.chevron_right), | ||
) | ||
: null, | ||
data['description'] != '' ? Divider() : null, | ||
data['description'] != '' | ||
? ListTile( | ||
title: Text('Description'), | ||
subtitle: Text(data['description']), | ||
isThreeLine: true, | ||
) | ||
: null, | ||
]; | ||
|
||
iconifiedList.removeWhere((element) => element == null); | ||
|
||
return ContactCard( | ||
margin: EdgeInsets.fromLTRB(10.0, 25.0, 10.0, 25.0), | ||
child: Column( | ||
children: <Widget>[...iconifiedList], | ||
)); | ||
} else { | ||
return ContactCard(child: Column()); | ||
} | ||
} | ||
} |
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,82 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:fst_app_flutter/contact_screen/django_requests/handle_contacts.dart'; | ||
import 'package:fst_app_flutter/contact_screen/pages/contacts_page_general.dart'; | ||
|
||
class ChemContactPage extends StatefulWidget { | ||
@override | ||
_ChemContactPageState createState() => _ChemContactPageState(); | ||
} | ||
|
||
class _ChemContactPageState extends State<ChemContactPage> { | ||
|
||
List<dynamic> contacts = []; | ||
|
||
_ChemContactPageState() { | ||
updateContactsList(''); | ||
} | ||
|
||
updateContactsList(value) async { | ||
GetContacts.searchDjangoContacts(value).then((data) { | ||
setState(() { | ||
contacts.addAll(data); | ||
}); | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text('Chemistry Contacts'), | ||
), | ||
body: Container( | ||
padding: EdgeInsets.all(30.0), | ||
child: Column( | ||
mainAxisSize: MainAxisSize.max, | ||
verticalDirection: VerticalDirection.down, | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: <Widget>[ | ||
TextField( | ||
onChanged: (value) { | ||
contacts.clear(); | ||
if (value.isNotEmpty) { | ||
updateContactsList(value); | ||
} else { | ||
updateContactsList(''); | ||
} | ||
}, | ||
decoration: InputDecoration( | ||
suffixIcon: Icon(Icons.search), | ||
contentPadding: EdgeInsets.fromLTRB(30.0, 15.0, 30.0, 15.0), | ||
hintText: 'Search', | ||
filled: true, | ||
fillColor: Colors.grey[200], | ||
border: OutlineInputBorder( | ||
borderRadius: BorderRadius.all(Radius.circular(40.0)), | ||
borderSide: BorderSide.none, | ||
)), | ||
), | ||
Flexible( | ||
flex: 3, | ||
child: Text( | ||
contacts.length.toString() + ' contacts', | ||
textAlign: TextAlign.left, | ||
)), | ||
Spacer( | ||
flex: 1, | ||
), | ||
Expanded( | ||
flex: 30, | ||
child: ListView.builder( | ||
shrinkWrap: true, | ||
itemCount: contacts.length, | ||
itemBuilder: (BuildContext context, int index) { | ||
return buildContactListView(contacts); | ||
}, | ||
)) | ||
], | ||
)), | ||
); | ||
} | ||
} |
Oops, something went wrong.