import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'DoctorView.dart'; class BranchView extends StatefulWidget { final List doctorsList; final List result; final int num; const BranchView({Key key, this.doctorsList, this.result, this.num}) : super(key: key); @override _BranchViewState createState() => _BranchViewState(); } class _BranchViewState extends State { @override Widget build(BuildContext context) { return AppScaffold( appBarTitle: TranslationBase.of(context).bookAppo, isShowAppBar: true, body: new ListView.builder( itemBuilder: (BuildContext context, int index) { return new ExpandableListView( result2: widget.result, val: index, doctorsList2: widget.doctorsList); }, itemCount: widget.num, //5, ), ); } } class ExpandableListView extends StatefulWidget { final List result2; final List doctorsList2; final val; const ExpandableListView( {Key key, this.result2, this.val, this.doctorsList2}) : super(key: key); @override _ExpandableListViewState createState() => new _ExpandableListViewState(); } class _ExpandableListViewState extends State { bool expandFlag = false; @override Widget build(BuildContext context) { return new Container( // margin: new EdgeInsets.symmetric(vertical: 1.0), width: MediaQuery.of(context).size.width * 0.6, margin: EdgeInsets.fromLTRB(20.0, 10.0, 10.0, 0.0), child: Card( // margin: EdgeInsets.fromLTRB(20.0, 16.0, 20.0, 8.0), color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), child: Container( decoration: BoxDecoration(), padding: EdgeInsets.all(5.0), width: MediaQuery.of(context).size.width, child: new Column( children: [ new Container( color: Colors.white, // padding: new EdgeInsets.symmetric(horizontal: 5.0), child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ new Text( widget.result2[widget.val].toString()+" "+ "22 كم", style: new TextStyle( fontWeight: FontWeight.bold, color: Colors.black), ), new IconButton( icon: new Container( height: 30.0, width: 30.0, decoration: new BoxDecoration( color: Colors.red, shape: BoxShape.circle, ), child: new Center( child: new Icon( expandFlag ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down, color: Colors.white, size: 30.0, ), ), ), onPressed: () { setState(() { expandFlag = !expandFlag; }); }), ], ), ), // SizedBox(height: 15), new ExpandableContainer( expanded: expandFlag, child: ListView.builder( scrollDirection: Axis.vertical, shrinkWrap: true, physics: ScrollPhysics(), padding: EdgeInsets.all(0.0), itemCount: widget.doctorsList2.length, itemBuilder: (context, index) { return widget.result2[widget.val].toString() == widget.doctorsList2[index].projectName.toString()? DoctorView( //AJ note doctor: widget.doctorsList2[index] // widget.doctorsList2[index] ):Container(); }, ), ) ], ), ), ), ); } } class ExpandableContainer extends StatelessWidget { final bool expanded; final double collapsedHeight; final double expandedHeight; final Widget child; ExpandableContainer({ @required this.child, this.collapsedHeight = 0.0, this.expandedHeight = 300.0, this.expanded = true, }); @override Widget build(BuildContext context) { double screenWidth = MediaQuery.of(context).size.width; return new AnimatedContainer( duration: new Duration(milliseconds: 500), curve: Curves.easeInOut, width: screenWidth, height: expanded ? expandedHeight : collapsedHeight, child: new Container( child: child, decoration: new BoxDecoration( border: new Border.all(width: 1.0, color: Colors.white)), ), ); } }