From d276a19e02d106dc139ace7cbd9e44f7511cc786 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 9 Mar 2020 16:37:20 +0200 Subject: [PATCH] first step from patient search --- lib/routes.dart | 7 +- lib/screens/QR_reader_screen.dart | 0 lib/screens/home_screen.dart | 42 +++- lib/screens/my_schedule_screen.dart | 2 + lib/screens/patient_search_screen.dart | 333 +++++++++++++++++++++++++ lib/widgets/home/home_item.dart | 43 ++++ lib/widgets/shared/app.drawer.dart | 3 + 7 files changed, 427 insertions(+), 3 deletions(-) create mode 100644 lib/screens/QR_reader_screen.dart create mode 100644 lib/screens/patient_search_screen.dart create mode 100644 lib/widgets/home/home_item.dart diff --git a/lib/routes.dart b/lib/routes.dart index 36d1791e..9387e331 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -1,3 +1,5 @@ +import './screens/patient_search_screen.dart'; + import './screens/my_schedule_screen.dart'; import './screens/auth/login_screen.dart'; @@ -6,10 +8,13 @@ import './screens/home_screen.dart'; const String INIT_ROUTE = 'login'; const String HOME = '/'; const String MY_SCHEDULE = 'my-schedule'; +const String QR_READER = 'my-schedule'; +const String PATIENT_SEARCH = 'patient-search'; var routes = { HOME:(_)=>HomeScreen(), INIT_ROUTE:(_)=>Loginsreen(), - MY_SCHEDULE:(_)=>MyScheduleScreen() + MY_SCHEDULE:(_)=>MyScheduleScreen(), + PATIENT_SEARCH:(_)=>PatientSearch(), }; diff --git a/lib/screens/QR_reader_screen.dart b/lib/screens/QR_reader_screen.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index c79f9ec9..d82cfcaf 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -1,11 +1,49 @@ +import 'package:doctor_app_flutter/widgets/home/home_item.dart'; import 'package:doctor_app_flutter/widgets/shared/app.drawer.dart'; import 'package:flutter/material.dart'; + +class Category { + final String id; + final String title; + final String image; + + const Category({ + @required this.id, + @required this.title, + this.image, + }); +} + class HomeScreen extends StatelessWidget { @override Widget build(BuildContext context) { + const DUMMY_CATEGORIES = const [ + Category( + id: 'c1', + title: 'My Schedule', + image: 'assets/images/user_id_icon.png', + ), + Category( + id: 'c2', + title: 'Patient Search', + image: 'assets/images/user_id_icon.png', + ), + ]; return Scaffold( - appBar: AppBar(title: Text('Home'),), + appBar: AppBar( + title: Text('Home'), + ), drawer: AppDrawer(), + body: GridView( + padding: EdgeInsets.all(25), + children: DUMMY_CATEGORIES + .map((data) => HomeItem(data.id, data.title, data.image)) + .toList(), + gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( + maxCrossAxisExtent: 200, + childAspectRatio: 3 / 2, + crossAxisSpacing: 20, + mainAxisSpacing: 20)), ); } -} \ No newline at end of file +} diff --git a/lib/screens/my_schedule_screen.dart b/lib/screens/my_schedule_screen.dart index c7775c10..6ef83634 100644 --- a/lib/screens/my_schedule_screen.dart +++ b/lib/screens/my_schedule_screen.dart @@ -1,9 +1,11 @@ +import 'package:doctor_app_flutter/widgets/shared/app.drawer.dart'; import 'package:flutter/material.dart'; class MyScheduleScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text("My Schedule"),), + drawer: AppDrawer(), ); } } \ No newline at end of file diff --git a/lib/screens/patient_search_screen.dart b/lib/screens/patient_search_screen.dart new file mode 100644 index 00000000..76b78bed --- /dev/null +++ b/lib/screens/patient_search_screen.dart @@ -0,0 +1,333 @@ +import 'package:doctor_app_flutter/routes.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; + +class PatientSearch extends StatefulWidget { + @override + _PatientSearchState createState() => _PatientSearchState(); +} + +class _PatientSearchState extends State { + final List> _items = [ + {"text": "outPatiant1", "val": "1"}, + {"text": "outPatiant3", "val": "3"}, + {"text": "outPatiant2", "val": "2"}, + ]; + String _selectedItem = '2'; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text("Search Patient"), + ), + body: SingleChildScrollView( + child: LayoutBuilder(builder: (ctx, constraints) { + var smallScreenSize = 660; + bool isSmallScreen = constraints.maxWidth <= smallScreenSize; + return Container( + padding: EdgeInsets.all(15), + width: constraints.maxWidth * 0.9, + child: Form( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Patiant Type', + style: TextStyle(fontSize: 20), + ), + SizedBox( + height: 15, + ), + Container( + width: double.infinity, + child: DropdownButton( + value: _selectedItem, + iconSize: 24, + elevation: 16, + selectedItemBuilder: (BuildContext context) { + return _items.map((item) { + return Text(item['text']); + }).toList(); + }, + onChanged: (String newValue) => { + setState(() { + _selectedItem = newValue; + }) + }, + items: _items.map((item) { + return DropdownMenuItem( + child: Text('${item['text']}'), + value: item['val'], + ); + }).toList(), + ), + ), + SizedBox( + height: 15, + ), + Text( + 'First Name', + style: TextStyle(fontSize: 20), + ), + SizedBox( + height: 15, + ), + TextFormField( + decoration: InputDecoration( + hintText: 'First Name', + hintStyle: TextStyle( + fontSize: isSmallScreen + ? 14 + : constraints.maxWidth * 0.024), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(20)), + borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + ), + focusedBorder: OutlineInputBorder( + borderRadius: + BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide( + color: Theme.of(context).primaryColor), + ) + //BorderRadius.all(Radius.circular(20)); + ), + validator: (value) { + if (value.isEmpty) { + return 'Please enter some text'; + } + return null; + }, + ), + SizedBox( + height: 20, + ), + Text( + 'Middle Name', + style: TextStyle(fontSize: 20), + ), + SizedBox( + height: 15, + ), + TextFormField( + decoration: InputDecoration( + hintText: 'Middle Name', + hintStyle: TextStyle( + fontSize: isSmallScreen + ? 14 + : constraints.maxWidth * 0.024), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(20)), + borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + ), + focusedBorder: OutlineInputBorder( + borderRadius: + BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide( + color: Theme.of(context).primaryColor), + ) + //BorderRadius.all(Radius.circular(20)); + ), + validator: (value) { + if (value.isEmpty) { + return 'Please enter some text'; + } + return null; + }, + ), + SizedBox( + height: 20, + ), + Text( + 'Last Name', + style: TextStyle(fontSize: 20), + ), + SizedBox( + height: 15, + ), + TextFormField( + decoration: InputDecoration( + hintText: 'Last Name', + hintStyle: TextStyle( + fontSize: isSmallScreen + ? 14 + : constraints.maxWidth * 0.024), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(20)), + borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + ), + focusedBorder: OutlineInputBorder( + borderRadius: + BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide( + color: Theme.of(context).primaryColor), + ) + //BorderRadius.all(Radius.circular(20)); + ), + validator: (value) { + if (value.isEmpty) { + return 'Please enter some text'; + } + return null; + }, + ), + SizedBox( + height: 20, + ), + Text( + 'Phone Number', + style: TextStyle(fontSize: 20), + ), + SizedBox( + height: 15, + ), + TextFormField( + decoration: InputDecoration( + hintText: 'Phone Number', + hintStyle: TextStyle( + fontSize: isSmallScreen + ? 14 + : constraints.maxWidth * 0.024), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(20)), + borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + ), + focusedBorder: OutlineInputBorder( + borderRadius: + BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide( + color: Theme.of(context).primaryColor), + ) + //BorderRadius.all(Radius.circular(20)); + ), + validator: (value) { + if (value.isEmpty) { + return 'Please enter some text'; + } + return null; + }, + ), + SizedBox( + height: 20, + ), + // Container(child: GridView(gridDelegate: null,),) + + SizedBox( + height: 20, + ), + Text( + 'Patiant Type', + style: TextStyle(fontSize: 20), + ), + SizedBox( + height: 15, + ), + TextFormField( + decoration: InputDecoration( + hintText: 'Enter ID', + hintStyle: TextStyle( + fontSize: isSmallScreen + ? 14 + : constraints.maxWidth * 0.024), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(20)), + borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + ), + focusedBorder: OutlineInputBorder( + borderRadius: + BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide( + color: Theme.of(context).primaryColor), + ) + //BorderRadius.all(Radius.circular(20)); + ), + validator: (value) { + if (value.isEmpty) { + return 'Please enter some text'; + } + return null; + }, + ), + SizedBox( + height: 20, + ), + Text( + 'Patiant Type', + style: TextStyle(fontSize: 20), + ), + SizedBox( + height: 15, + ), + TextFormField( + decoration: InputDecoration( + hintText: 'Enter ID', + hintStyle: TextStyle( + fontSize: isSmallScreen + ? 14 + : constraints.maxWidth * 0.024), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(20)), + borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + ), + focusedBorder: OutlineInputBorder( + borderRadius: + BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide( + color: Theme.of(context).primaryColor), + ) + //BorderRadius.all(Radius.circular(20)); + ), + validator: (value) { + if (value.isEmpty) { + return 'Please enter some text'; + } + return null; + }, + ), + SizedBox( + height: 20, + ), + Text( + 'Patiant Type', + style: TextStyle(fontSize: 20), + ), + SizedBox( + height: 15, + ), + TextFormField( + decoration: InputDecoration( + hintText: 'Enter ID', + hintStyle: TextStyle( + fontSize: isSmallScreen + ? 14 + : constraints.maxWidth * 0.024), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(20)), + borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + ), + focusedBorder: OutlineInputBorder( + borderRadius: + BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide( + color: Theme.of(context).primaryColor), + ) + //BorderRadius.all(Radius.circular(20)); + ), + validator: (value) { + if (value.isEmpty) { + return 'Please enter some text'; + } + return null; + }, + ), + SizedBox( + height: 20, + ) + ], + ), + ), + ); + }), + )); + } +} diff --git a/lib/widgets/home/home_item.dart b/lib/widgets/home/home_item.dart new file mode 100644 index 00000000..8223f733 --- /dev/null +++ b/lib/widgets/home/home_item.dart @@ -0,0 +1,43 @@ +import 'package:doctor_app_flutter/routes.dart'; +import 'package:flutter/material.dart'; + +class HomeItem extends StatelessWidget { + final String id; + final String title; + final String image; + HomeItem(this.id, this.title, this.image); + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () => selectItem(context,id), + splashColor: Colors.red, + child: Container( + child: Column( + children: [ + Container( + child: CircleAvatar( + backgroundColor: Colors.white, + child: Image.asset( + + image, + color: Theme.of(context).primaryColor, + ), + )), + Text(title,style: TextStyle(fontSize: 20),) + ], + ), + ), + ); + } + + void selectItem(BuildContext ctx, id ) { + String route; + if (id =='c2') { + route = PATIENT_SEARCH; + } + Navigator.of(ctx).pushNamed(route, arguments: { + 'id': id, + 'title': title, + }); + } +} diff --git a/lib/widgets/shared/app.drawer.dart b/lib/widgets/shared/app.drawer.dart index ad84d34c..3582e6fc 100644 --- a/lib/widgets/shared/app.drawer.dart +++ b/lib/widgets/shared/app.drawer.dart @@ -27,6 +27,9 @@ class AppDrawer extends StatelessWidget { ListTile( title: Text('QR Reader'), leading: Icon(Icons.photo), + onTap: () { + drawerNavigator(context, QR_READER); + }, ), Divider(), ListTile(