import 'dart:ui';

import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/H2O_view_model.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/h2o/month_page.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/h2o/today_page.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/h2o/week_page.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.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';

class H2OPage extends StatefulWidget {
  @override
  _H2OPageState createState() => _H2OPageState();
}

class _H2OPageState extends State<H2OPage>
    with SingleTickerProviderStateMixin {
  TabController _tabController;

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

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

  @override
  Widget build(BuildContext context) {
    return BaseView<H2OViewModel>(
      builder: (_, model, widget) => AppScaffold(
        isShowAppBar: true,
        appBarTitle: "Water Tracker",
        body: Scaffold(
          extendBodyBehindAppBar: true,
          appBar: PreferredSize(
            preferredSize: Size.fromHeight(65.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: 60.0,
                    margin: EdgeInsets.only(top: 10.0),
                    width: MediaQuery.of(context).size.width * 0.9,

                    child: Center(
                      child: TabBar(
                        isScrollable: false,
                        controller: _tabController,
                        indicatorWeight: 5.0,
                        indicatorSize: TabBarIndicatorSize.label,
                        indicatorColor: Colors.red[800],
                        labelColor: Theme.of(context).primaryColor,
                        labelPadding:
                            EdgeInsets.only(top: 4.0, left: 10.0, right: 13.0),
                        unselectedLabelColor: Colors.grey[800],
                        tabs: [
                          Container(
                            width: MediaQuery.of(context).size.width * 0.28,
                            child: Center(
                              child: Texts(
                                  "Today"),
                            ),
                          ),
                          Container(
                            width: MediaQuery.of(context).size.width * 0.28,
                            child: Center(
                              child: Texts("Week"),
                            ),
                          ),
                          Container(
                            width: MediaQuery.of(context).size.width * 0.28,
                            child: Center(
                              child: Texts("Month"),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
          body: Column(
            children: <Widget>[
              Expanded(
                child: TabBarView(
                  physics: BouncingScrollPhysics(),
                  controller: _tabController,
                  children: <Widget>[TodayPage(), WeekPage(), MonthPage()],
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
