import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:unit2/bloc/offline/offline_passo/land/land_property_owner_bloc/land_property_owner_bloc.dart';
import 'package:unit2/model/offline/offline_profile.dart';

import 'package:unit2/screens/offline/passo/building_home_offline.dart';
import 'package:unit2/screens/offline/passo/land_home_offline.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/widgets/empty_data.dart';

import '../../../bloc/offline/offline_passo/building/owner_info_bloc/crud_bloc.dart';

class PassoOfflineDashBoard extends StatefulWidget {
  final OfflineProfile offlineProfile;

  const PassoOfflineDashBoard(this.offlineProfile, {super.key});

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

class _PassoOfflineDashBoard extends State<PassoOfflineDashBoard> {
  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 3,
      child: Scaffold(
          body: NestedScrollView(
        headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
          return <Widget>[
            const SliverAppBar(
              backgroundColor: primary,
              title: Text('Faas Dashboard'),
              centerTitle: true,
              pinned: true,
              floating: true,
              bottom: TabBar(
                isScrollable: true,
                tabs: [
                  Tab(child: Text('Building')),
                  Tab(child: Text('Land')),
                  Tab(child: Text('Machineries')),
                ],
              ),
            ),
          ];
        },
        body: TabBarView(
          children: <Widget>[
            BlocProvider(
              create: (context) => CrudBloc()..add(FetchTodos()),
              child: BuildingHomeOffline(widget.offlineProfile),
            ),
            BlocProvider(
              create: (context) =>
                  LandPropertyOwnerBloc()..add(LoadLandPropertyOwner()),
              child: LandHomeOffline(widget.offlineProfile),
            ),
            EmptyData(
              message: "Sorry, this page is under construction.",
            )
          ],
        ),
      )),
    );
  }
}
