import 'package:diplomaticquarterapp/pages/BookAppointment/components/DocAvailableAppointments.dart';
import 'package:flutter/material.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:rating_bar/rating_bar.dart';
import 'Components/AppointmentActions.dart';

class AppointmentDetails extends StatefulWidget {
  @override
  _AppointmentDetailsState createState() => _AppointmentDetailsState();
}

class _AppointmentDetailsState extends State<AppointmentDetails>
    with SingleTickerProviderStateMixin {
  TabController _tabController;
  bool showFooterButton = false;

  @override
  void initState() {
    _tabController = new TabController(length: 2, vsync: this);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Eyad Ismail Abu-Jayab"),
      ),
      body: Container(
        color: new Color(0xFFf6f6f6),
        child: SingleChildScrollView(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Container(
                color: Colors.white,
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Container(
                      margin: EdgeInsets.only(top: 20.0),
                      alignment: Alignment.center,
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(100.0),
                        child: Image.network(
                            "https://hmgwebservices.com/Images/MobileImages/OALAY/2477.png",
                            fit: BoxFit.fill,
                            height: 120.0,
                            width: 120.0),
                      ),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 10.0),
                      alignment: Alignment.center,
                      child: Text("Dr. EYAD ISMAIL ABU-JAYAD",
                          style: TextStyle(
                              fontSize: 20.0,
                              color: Colors.grey[900],
                              letterSpacing: 1.0)),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 10.0),
                      alignment: Alignment.center,
                      child: Text("INTERNAL MEDICINE CLINIC",
                          style: TextStyle(
                              fontSize: 12.0,
                              color: Colors.grey[900],
                              letterSpacing: 1.0)),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 5.0),
                      alignment: Alignment.center,
                      child: RatingBar.readOnly(
                        initialRating: 3.5,
                        size: 35.0,
                        filledColor: Colors.yellow[700],
                        emptyColor: Colors.grey[500],
                        isHalfAllowed: true,
                        halfFilledIcon: Icons.star_half,
                        filledIcon: Icons.star,
                        emptyIcon: Icons.star,
                      ),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 5.0),
                      alignment: Alignment.center,
                      child: Text("(2322 Reviews)",
                          style: TextStyle(
                            fontSize: 14.0,
                            color: Colors.blue[800],
                            letterSpacing: 1.0,
                            decoration: TextDecoration.underline,
                          )),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 10.0),
                      child: Divider(
                        color: Colors.grey[500],
                      ),
                    ),
                    TabBar(
                      onTap: (index) {
                        setState(() {
                          index == 1
                              ? showFooterButton = true
                              : showFooterButton = false;
                          print(showFooterButton);
                        });
                      },
                      tabs: [
                        Tab(
                            child: Text(TranslationBase.of(context).appoActions,
                                style: TextStyle(color: Colors.black))),
                        Tab(
                          child: Text(TranslationBase.of(context).availableAppo,
                              style: TextStyle(color: Colors.black)),
                        )
                      ],
                      controller: _tabController,
                    ),
                  ],
                ),
              ),
              Container(
                height: MediaQuery.of(context).size.height * 0.8,
                child: TabBarView(
                  physics: NeverScrollableScrollPhysics(),
                  children: [AppointmentActions(), DocAvailableAppointments()],
                  controller: _tabController,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
