import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/landing/landing_page.dart';
import 'package:diplomaticquarterapp/routes.dart';
import 'package:diplomaticquarterapp/widgets/others/bottom_bar.dart';
import 'package:diplomaticquarterapp/widgets/progress_indicator/app_loader_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:diplomaticquarterapp/widgets/robo-search/robosearch.dart';
import 'package:diplomaticquarterapp/widgets/robo-search/search.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';

import 'floating_button_search.dart';
import '../progress_indicator/app_loader_widget.dart';
import 'arrow_back.dart';
import 'network_base_view.dart';

class AppScaffold extends StatelessWidget {
  final String appBarTitle;
  final Widget body;
  final Widget bottomSheet;
  final bool isLoading;
  final bool isShowAppBar;
  final bool hasAppBarParam;
  final BaseViewModel baseViewModel;
  final Widget floatingActionButton;

  AppScaffold(
      {@required this.body,
      this.appBarTitle = '',
      this.isLoading = false,
      this.isShowAppBar = false,
      this.hasAppBarParam,
      this.bottomSheet,
      this.baseViewModel, this.floatingActionButton});

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

    return Scaffold(
        backgroundColor: Theme.of(context).scaffoldBackgroundColor,
        appBar: isShowAppBar
            ? AppBar(
                elevation: 0,
                backgroundColor: Theme.of(context).appBarTheme.color,
                textTheme: TextTheme(
                  headline6: TextStyle(
                      color: Colors.white, fontWeight: FontWeight.bold),
                ),
                title: Text(appBarTitle.toUpperCase()),
                leading: Builder(
                  builder: (BuildContext context) {
                    return ArrowBack();
                  },
                ),
                centerTitle: true,
                actions: <Widget>[
                  IconButton(
                    icon: Icon(FontAwesomeIcons.home),
                    color: Colors.white,
                    onPressed: () {
                      Navigator.of(context).popUntil(ModalRoute.withName('/'));
                    },
                  ),
                ],
              )
            : null,
        body: baseViewModel != null
            ? NetworkBaseView(
                child: buildBodyWidget(),
                baseViewModel: baseViewModel,
              )
            : buildBodyWidget(),
        bottomSheet: bottomSheet,
       // bottomNavigationBar: BottomBarSearch()
        floatingActionButton: floatingActionButton??floatingActionButton,
        );
  }

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

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