import 'dart:ui';

import 'package:diplomaticquarterapp/core/model/eye/AppoimentAllHistoryResult.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/EyeViewModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/weight_pressure_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'ClassesPage.dart';
import 'ContactLensPage.dart';

class EyeHomePage extends StatefulWidget {
  final AppoimentAllHistoryResultList appointmentAllHistoryResultList;

  const EyeHomePage({Key key, this.appointmentAllHistoryResultList})
      : super(key: key);

  @override
  _EyeHomePageState createState() => _EyeHomePageState();
}

class _EyeHomePageState extends State<EyeHomePage>
    with SingleTickerProviderStateMixin {
  TabController _tabController;

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

  @override
  void dispose() {
    super.dispose();
    _tabController.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return AppScaffold(
      isShowAppBar: true,
      appBarTitle: TranslationBase.of(context).measurements,
      body: Scaffold(
        extendBodyBehindAppBar: true,
        appBar: PreferredSize(
          preferredSize: Size.fromHeight(60.0),
          child: Stack(
            children: <Widget>[
              Positioned(
                bottom: 1,
                left: 0,
                right: 0,
                child: BackdropFilter(
                  filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
                  child: Container(
                    color: Theme.of(context)
                        .scaffoldBackgroundColor
                        .withOpacity(0.8),
                    height: 70.0,
                  ),
                ),
              ),
              Center(
                child: Container(
                  height: 55.0,
                  margin: EdgeInsets.only(left: 20,right: 20,top: 15),
                  color: Colors.white,
                  child: Center(
                    child: TabBar(
                      isScrollable: true,
                      controller: _tabController,
                      indicatorWeight: 5.0,
                      indicatorSize: TabBarIndicatorSize.label,
                      indicatorColor: Colors.red[800],
                      labelColor: Theme.of(context).primaryColor,
                      labelPadding:
                          EdgeInsets.only(top: 4.0, left: 5.0, right: 5.0),
                      unselectedLabelColor: Colors.grey[800],
                      tabs: [
                        Container(
                          width: MediaQuery.of(context).size.width * 0.27,
                          child: Center(
                            child: Texts(TranslationBase.of(context).classes),
                          ),
                        ),
                        Container(
                          width: MediaQuery.of(context).size.width * 0.27,
                          child: Center(
                            child: Texts(TranslationBase.of(context).contactLens),
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
        body: Column(
          children: <Widget>[
            Expanded(
              child: TabBarView(
                physics: BouncingScrollPhysics(),
                controller: _tabController,
                children: <Widget>[
                  ClassesPage(
                    glassPerscription: widget.appointmentAllHistoryResultList
                        .listHISGetGlassPerscription[0],
                  ),
                  ContactLensPage(
                    listHISGetContactLensPerscription: widget
                        .appointmentAllHistoryResultList
                        .listHISGetContactLensPerscription[0],
                  )
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
