import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/progress_indicator/app_loader_widget.dart';
import 'package:flutter/material.dart';

import '../../locator.dart';
import '../progress_indicator/app_loader_widget.dart';
import 'arrow_back.dart';
import 'network_base_view.dart';
import 'not_auh_page.dart';

class PharmacyAppScaffold extends StatelessWidget {
  final String appBarTitle;
  final Widget body;
  final Widget bottomSheet;
  final bool isLoading;
  final bool isShowAppBar;
  final bool hasAppBarParam;
  final BaseViewModel baseViewModel;
  final bool isBottomBar;
  final Widget floatingActionButton;
  final String title;
  final String description;
  final bool isShowDecPage;
  final Color backgroundColor;

  AuthenticatedUserObject authenticatedUserObject =
      locator<AuthenticatedUserObject>();

  PharmacyAppScaffold(
      {@required this.body,
      this.appBarTitle = '',
      this.isLoading = false,
      this.isShowAppBar = false,
      this.hasAppBarParam,
      this.bottomSheet,
      this.baseViewModel,
      this.floatingActionButton,
      this.title,
      this.description,
      this.isShowDecPage = true,
      this.isBottomBar,
      this.backgroundColor});

  @override
  Widget build(BuildContext context) {
    AppGlobal.context = context;

    return Scaffold(
      backgroundColor:
          backgroundColor ?? Theme.of(context).scaffoldBackgroundColor,
      appBar: isShowAppBar
          ? AppBar(
              elevation: 0,
              backgroundColor: Color(0xff5AB145),
              textTheme: TextTheme(
                headline6:
                    TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
              ),
              title: Text(authenticatedUserObject.isLogin
                  ? appBarTitle.toUpperCase()
                  : appBarTitle.toUpperCase()),
              leading: Builder(
                builder: (BuildContext context) {
                  return ArrowBack();
                },
              ),
              centerTitle: true,
              actions: <Widget>[],
            )
          : null,
      body: (!authenticatedUserObject.isLogin && isShowDecPage)
          ? NotAutPage(
              title: appBarTitle,
              description: description,
            )
          : baseViewModel != null
              ? NetworkBaseView(
                  child: buildBodyWidget(),
                  baseViewModel: baseViewModel,
                )
              : buildBodyWidget(),
      bottomSheet: bottomSheet,
      // floatingActionButton: floatingActionButton ?? floatingActionButton,
      // bottomNavigationBar:
      //     this.isBottomBar == true ? BottomBarSearch() : SizedBox()
      // floatingActionButton: FloatingSearchButton(),
    );
  }

  buildAppLoaderWidget(bool isLoading) {
    return isLoading ? AppLoaderWidget() : Container();
  }

  buildBodyWidget() {
    return body; //Stack(children: <Widget>[body, buildAppLoaderWidget(isLoading)]);
    //return Stack(children: <Widget>[body, FloatingSearchButton()]);
  }
}
